std::string Ntp1Analyzer_HWWlvjj::getHLTPathForRun(int runN, std::string fullname) { TString fullName = TString(fullname.c_str()); TObjArray* selectionTokens = fullName.Tokenize(":"); if (selectionTokens->GetEntries()!=2) { std::cout << "Wrong trigger strings " << selectionTokens->GetEntries() << std::endl; return std::string("NOPATH"); } TString RunRange =((TObjString*)(*selectionTokens)[0])->GetString(); TString HLTPathName =((TObjString*)(*selectionTokens)[1])->GetString(); TObjArray* runs = RunRange.Tokenize("-"); if (runs->GetEntries()!=2) { std::cout << "Wrong trigger run range strings " << runs->GetEntries() << std::endl; return std::string("NOPATH"); } const char *minStr = (((TObjString*)(*runs)[0])->GetString()).Data(); const char *maxStr = (((TObjString*)(*runs)[1])->GetString()).Data(); int min = atoi(minStr); int max = atoi(maxStr); if(runN>=min && runN<=max) return std::string(HLTPathName.Data()); else return std::string("NOPATH"); }
int main() { TGeoNode *node = NULL; TGeoVolume *vol = NULL; LMCgeomN *g = new LMCgeomN("Telescope"); TObjArray *oa = g->GetGeoManager()->GetListOfNodes(); for (int i=0; i<oa->GetEntries(); i++) { node = (TGeoNode*)oa->At(i); vol = node->GetVolume(); cout << "= " << node->GetName() << " " << vol->GetName() <<endl; TObjArray *vnodes = vol->GetNodes(); cout << vnodes->GetEntries() << endl; for (int j=0; j<vnodes->GetEntries(); j++) { node = (TGeoNode*)vnodes->At(j); cout << "== " << node->GetName() << endl; vol = node->GetVolume(); TObjArray *vnodes1 = vol->GetNodes(); for (int k=0; k<vnodes1->GetEntries(); k++) { node = (TGeoNode*)vnodes1->At(k); cout << "=== " << node->GetName() << endl; vol = node->GetVolume(); TObjArray *vnodes2 = vol->GetNodes(); if(!vnodes2) continue; for (int q=0; q<vnodes2->GetEntries(); q++) { node = (TGeoNode*)vnodes2->At(q); cout << "==== " << node->GetName() << endl; } } } } return 0; }
void getlist(ostream& out, TBranch* branch, int depth=0) { TObjArray* array = branch->GetListOfBranches(); if ( ! array ) return; if ( depth > 10 ) return; string name; int nitems = array->GetEntries(); for (int i = 0; i < nitems; i++) { TBranch* b = (TBranch*)((*array)[i]); if ( ! b ) continue; string branchname(b->GetName()); out << SPACE.substr(0,4*depth) << branchname << endl; TObjArray* a = b->GetListOfLeaves(); if ( a ) { int n = a->GetEntries(); { for (int j = 0; j < n; j++) { TLeaf* leaf = (TLeaf*)((*a)[j]); int count = 0; int ndata = 0; TLeaf* leafc = leaf->GetLeafCounter(count); if ( ! leafc) ndata = leaf->GetLen(); else ndata = leafc->GetMaximum(); string leafname(leaf->GetName()); out << SPACE.substr(0,4*(depth+1)) << ndata << " " << leafname << endl; } } // else if ( n == 1 ) // { // TBranch* bc = (TBranch*)((*a)[j]); // string leafname(bc->GetName()); // if ( leafname != branchname ) // out << SPACE.substr(0,4*(depth+1)) << leafname << endl; // } } getlist(out, b, depth+1); } }
Bool_t KVDatime::IsGANACQFormat(const Char_t* date) { // Static method, returns kTRUE if 'date' is in format of GANIL acquisition // e.g. 29-SEP-2005 09:42:17.00 KVString tmp(date); TObjArray *toks = tmp.Tokenize("-:. "); if( toks->GetEntries() < 6 || toks->GetEntries() > 7 ) { // if format is correct, there should be 6 or 7 elements in toks delete toks; return kFALSE; } delete toks; return kTRUE; }
TObjArray* findClassesForAlias(THashList &list, const char* aliasName) { TObjArray* matchingTrClasses = new TObjArray(2); TIter iter(&list); TNamed *n = 0; iter.Reset(); while((n = dynamic_cast<TNamed*>(iter.Next()))){ TString aliasList(n->GetTitle()); if(aliasList.Contains(aliasName)){ TObjArray* arrAliases = aliasList.Tokenize(','); Int_t nAliases = arrAliases->GetEntries(); for(Int_t i=0; i<nAliases; i++){ TObjString *alias = (TObjString*) arrAliases->At(i); alias->Print(0); if(alias->String()==TString(aliasName)){ TObjString *trClass = new TObjString(n->GetName()); matchingTrClasses->Add(trClass); } } } } return matchingTrClasses; }
void GetTreeSize(TString FileName, TString TreeName) { TFile *inf = TFile::Open(FileName); TTree *tr = (TTree*)inf->Get(TreeName); TObjArray *branches = (TObjArray*)tr->GetListOfBranches(); int size(0); cout.setf(ios::right); int N(branches->GetEntries()); TH1F *hSize = new TH1F("size","size",N,0,N); for(int ib=0;ib<N;ib++) { TString name(branches->At(ib)->GetName()); TBranch *br = (TBranch*)tr->GetBranch(name); hSize->Fill(name,br->GetZipBytes()/1e+3); size += br->GetZipBytes(); } cout<<"Total size: "<<size<<endl; for(int ib=0;ib<N;ib++) { TString name(branches->At(ib)->GetName()); TBranch *br = (TBranch*)tr->GetBranch(name); float percent = TMath::Ceil(1000*float(br->GetZipBytes())/float(size))/10; cout<<ib<<setw(20)<<name<<setw(15)<<br->GetZipBytes()<<" "<<percent<<"%"<<endl; } TCanvas *can = new TCanvas("TreeSize","TreeSize",1000,400); hSize->GetXaxis()->SetTitle("Branch Name"); hSize->GetXaxis()->SetLabelSize(0.04); hSize->GetYaxis()->SetTitle("Size (KB)"); hSize->SetFillColor(kGray); hSize->Draw(); }
void formatForCmsPublic(TPad * c, TLegend *leg, TString title, int nsamp, float legx, float legy, float legw, float legh, TString legopt) { if(title.Length()!=0) { TPaveText *pave = new TPaveText(0.5,0.96,0.94,0.99,"NDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); TObjArray * tokens = title.Tokenize("\\\\"); int nt = tokens->GetEntries(); for(int it=0; it<nt; ++it) { TObjString * t = (TObjString *)tokens->At(it); pave->AddText(t->GetString()); } pave->Draw("same"); } float legx1=legx, legx2=legx+legw; float legy1 = legy, legy2 = legy-legh*(float)(nsamp); if(leg==0) leg = ((TPad *)c)->BuildLegend(legx1,legy1,legx2,legy2); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetLineWidth(1); leg->SetTextFont(42); leg->SetEntryOption(legopt); leg->SetX1NDC(legx1); leg->SetY1NDC(legy1);//-nsamp*legh); leg->SetX2NDC(legx2); leg->SetY2NDC(legy2); }
TLegend* legend(THStack* stack, Option_t* option = "lp", Bool_t addColor = kFALSE, Int_t token = -1, Float_t xmin = 0.50, Float_t ymin = 0.51, Float_t xmax = 0.85, Float_t ymax = 0.92) { if(! stack) return 0; TLegend* leg = new TLegend(xmin, ymin, xmax, ymax); TList* list = stack->GetHists(); TIterator* iter = list->MakeIterator(); TObject* obj = 0; //Hist color iterator Int_t colorIt = 1; while (obj = iter->Next()) { if (! obj->InheritsFrom(TH1::Class())) continue; if (addColor) { hist::color(obj->GetName(), colorIt); ++colorIt; } if (token == -1) leg->AddEntry(obj, obj->GetTitle(), option); else { TString name(obj->GetName()); TObjArray* a = name.Tokenize("_"); if (a->GetEntries() <= token) leg->AddEntry(obj, obj->GetName(), option); else leg->AddEntry(obj, a->At(token)->GetName(), option); } } return leg; }
void TBDataParser::OnCharacters(const char *characters) { if(_currentElement != NULL && !strcmp(_currentElement->Data(),"vector")) { TString *string = new TString(characters); TObjArray *values = string->Tokenize(", "); for(Int_t i = 0; i < values->GetEntries(); i++) { TObjString *object = (TObjString *) values->At(i); TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", ""); if(value.IsFloat()) { _vector->Fill(value.Atof()); } } if(_vectorsStack->GetEntries() == 1) { _motherVecEntries = _vector->GetEntries(); } else if(_currentMethod != NULL && !strcmp(_currentMethod->Data(),"all")) { for(Int_t i = 1; i < _motherVecEntries; i++) { TObjString *object = (TObjString *) values->First(); TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", ""); if(value.IsFloat()) _vector->Fill(value.Atof()); } } values->Delete(); } }
TString KVNumberList::GetLogical(const Char_t *observable) { // Get logical expression of 'this' list in the TTree:Draw condition format // observable is one of the leaf of the TTree // 12-15 20 --> ( 12<=observable&&observable<=15 || observable==20 ) // return "" if 'this' list is empty if (IsEmpty()) return ""; GetList(); TString tmp = fString; tmp.ReplaceAll(" ","||"); TObjArray *toks = tmp.Tokenize("||"); TString cond="( "; Int_t nt = toks->GetEntries(); for (Int_t ii=0; ii<nt; ii+=1) { TString line = ((TObjString*)(*toks)[ii])->GetString(); if ( line.Contains("-") ) { line.ReplaceAll("-",Form("<=%s&&%s<=",observable,observable)); cond+=line; } else { cond+=Form("%s==",observable)+line; } if (ii!=nt-1) cond+="||"; } cond += " )"; delete toks; return cond; }
void OCDBDefault(Int_t mode) { Int_t run = atoi(gSystem->Getenv("CONFIG_RUN")); AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage("raw://"); if(gSystem->Getenv("CONFIG_OCDBTIMESTAMP")) { TString t = gSystem->Getenv("CONFIG_OCDBTIMESTAMP"); TObjArray* list =t.Tokenize("_"); UInt_t tU[6]; for(Int_t i=0; i<list->GetEntries(); i++) { TString st = ((TObjString*)list->At(i))->GetString(); tU[i] =(UInt_t)atoi(st.Data()); } man->SetMaxDate(TTimeStamp(tU[0], tU[1], tU[2], tU[3], tU[4], tU[5])); printf("*** Setting custom OCDB time stamp %s ***\n", t.Data()); } man->SetRun(run); // set detector specific paths DefaultSpecificStorage(man, mode); }
KVUniqueNameList* KVDMS::GetFullListing(const Char_t* directory) { // Create and fill TList with info (name, size, modification date) // on all files & containers in current directory // (default) or in given directory. // TList is filled with DMSFile_t objects which belong to the list, list must be deleted after use. longlist(directory); if (fout == "") { Error("GetListing", "Unknown directory %s", directory); return 0; } TObjArray* toks = fout.Tokenize("\n"); KVUniqueNameList* list = new KVUniqueNameList(kTRUE); list->SetOwner(kTRUE); list->SetName(((TObjString*)(*toks)[0])->String().Remove(TString::kBoth, ' ').Data()); for (int i = 1; i < toks->GetEntries(); i++) { TString tmp = ((TObjString*)(*toks)[i])->String().Remove(TString::kBoth, ' '); DMSFile_t* f = new DMSFile_t; if (IsContainer(tmp)) { // container f->SetName(gSystem->BaseName(tmp.Data())); f->SetIsContainer(); } else { ExtractFileInfos(tmp, f); } list->Add(f); } delete toks; return list; }
void KVAvailableRunsFile::GetRunInfos(Int_t run, KVList * dates, KVList * files) { //Look for a given run number in the file, and read the file's modification date/time and filename //These informations are stored in the two TList as TObjString objects (these objects belong to the //lists and will be deleted by them). //We do not stop at the first run found, but continue until the end of the file, adding //informations for every occurence of the run in the file. //If available runs file does not exist, Update() is called to create it. //does runlist exist ? if (!OpenAvailableRunsFile()) { Error("GetRunInfos", "Error opening available runs file"); return; } //clear lists - delete objects dates->Delete(); files->Delete(); //loop over lines in fRunlist file //look for line beginning with 'run|' TString line; line.ReadLine(fRunlist); while (fRunlist.good()) { if (line.BeginsWith(Form("%d|", run))) { //found it TObjArray *toks = line.Tokenize('|'); // split into fields // check date is not identical to a previous entry // i.e. there are spurious duplicate entries TObjString* rundate = (TObjString*)toks->At(1)->Clone(); if(dates->FindObject(rundate->GetName())){ delete toks; delete rundate; line.ReadLine(fRunlist); continue; } //add date string dates->Add(toks->At(1)->Clone()); //backwards compatibility //an old available_runs file will not have the filename field //in this case we assume that the name of the file is given by the //dataset's base file name (i.e. with no date/time suffix) if (toks->GetEntries() > 2) { files->Add(toks->At(2)->Clone()); } else { files-> Add(new TObjString(fDataSet-> GetBaseFileName(GetDataType(), run))); } delete toks; } line.ReadLine(fRunlist); } CloseAvailableRunsFile(); }
void transferxSecFromTextToROOT(std::string inputStr="xSec_T3G.txt"){ ifstream fin(inputStr.c_str()); char line[200]; TFile *xSecProspinoFile =0; TH1D *xSecProspino =0; int minMom = 1000000, maxMom = 0; int nBins = 0; std::vector<int> momVec; std::vector<double> xSecVec, xSecErrVec; while( fin.getline(line, 200) ){ TString lineT(line); if( lineT.Contains("Interactions") ) continue; TObjArray *vlist = lineT.Tokenize(" "); int nEntries = vlist->GetEntries(); int mMom; double xSec =0, xSecRelErr =0; for(int ie=0; ie<nEntries; ie++){ TObjString* perObj = dynamic_cast<TObjString*>(vlist->At(ie)); TString perStr = perObj->GetString(); if( ie==0 ){ mMom = perStr.Atoi(); if( minMom > mMom ) minMom = mMom; if( maxMom < mMom ) maxMom = mMom; } if( ie==1 ) xSec = perStr.Atof(); if( ie==2 ) xSecRelErr = perStr.Atof(); } nBins ++; momVec.push_back(mMom); xSecVec.push_back(xSec); xSecErrVec.push_back(xSec*xSecRelErr/100.); // std::cout<<"mMom : "<<mMom<<" xSec : "<<xSec<<" xSecRelErr : "<<xSecRelErr<<std::endl; } double divBin = 1.0*(maxMom - minMom)/(nBins-1); double lowMom = minMom-divBin/2.0, highMom = maxMom+divBin/2.0; std::cout<<"nBins : "<<nBins<<" minMom : "<<minMom<<" maxMom : "<<maxMom<<" divBin : "<<divBin<<" lowMom : "<<lowMom<<" highMom : "<<highMom<<std::endl; TString rootStrT(inputStr); rootStrT.ReplaceAll("txt", "root"); std::cout<<"root file : "<<rootStrT<<std::endl; xSecProspinoFile = new TFile(rootStrT, "RECREATE"); if( rootStrT.Contains("T1") ) xSecProspino = new TH1D("gluino_xsection", "gluino_xsection", nBins, lowMom, highMom); if( rootStrT.Contains("T2") ) xSecProspino = new TH1D("squark_xsection", "squark_xsection", nBins, lowMom, highMom); if( rootStrT.Contains("T3G") ) xSecProspino = new TH1D("stop_xsection", "stop_xsection", nBins, lowMom, highMom); for(int iv=0; iv<(int)momVec.size(); iv++){ double mMom = (double)momVec[iv]; int ib = xSecProspino->FindFixBin(mMom); xSecProspino->SetBinContent(ib, xSecVec[iv]); xSecProspino->SetBinError(ib, xSecErrVec[iv]); } // xSecProspino->Write(); xSecProspinoFile->Write(); xSecProspinoFile->Close(); }
vector<int> tokenize(TString s) { TObjArray *t = s.Tokenize(","); const int n = t->GetEntries(); vector<int> CATVETO; CATVETO.clear(); for (int i=0; i<n; i++) { CATVETO.push_back(((TObjString*)t->At(i))->String().Atoi()); } return CATVETO; }
TString tag(TString s) { TObjArray *t = s.Tokenize(","); const int n = t->GetEntries(); TString tCATVETO = ""; for (int i=0; i<n; i++) { tCATVETO += TString::Format("%d",((TObjString*)t->At(i))->String().Atoi()); } if (n>0): tCATVETO = "_CATveto"+tCATVETO; return tCATVETO; }
//_______________________________________ TObjArray* GetTerminateOptions ( TString taskOpt, Bool_t isMC ) { TObjArray* terminateList = 0x0; if ( ! taskOpt.IsNull() ) { TObjArray* optList = taskOpt.Tokenize(";"); for ( Int_t iopt=0; iopt<optList->GetEntries(); iopt++ ) { TString currOpt = (static_cast<TObjString*>(optList->At(iopt)))->GetString(); if ( ! currOpt.Contains("@") ) continue; TObjArray* tmpList = currOpt.Tokenize("@"); if ( tmpList->GetEntries() == 4 ) { terminateList = tmpList; break; } delete tmpList; } delete optList; } else { terminateList = new TObjArray(4); terminateList->SetOwner(); TString physSel = "", trigClasses = "", centr = "", furtherOpt = ""; if ( isMC ) { physSel = "PhysSelPass,PhysSelReject"; trigClasses = "ANY"; centr = "-5_105"; furtherOpt = "MC verbose"; } //TString GetPeriod(opt); terminateList->AddAt(new TObjString(physSel),0); terminateList->AddAt(new TObjString(trigClasses),1); terminateList->AddAt(new TObjString(centr),2); terminateList->AddAt(new TObjString(furtherOpt),3); } // if ( terminateList ) { // printf("Printing terminate list\n"); // REMEMBER TO CUT // PrintNames("Terminate options", terminateList); // printf(" ***************:\n"); // } return terminateList; }
void DeleteROOTVoxels() { std::cout << " IN DELETE VOXEL METHOD \n"; int counter=0; TObjArray * volist = gGeoManager->GetListOfVolumes(); std::cout << " entries " << volist->GetEntries() << "\n"; for(int i=0;i<volist->GetEntries();++i) { TGeoVolume *vol = (TGeoVolume *) volist->At(i); if ( vol!=NULL && vol->GetVoxels()!=0 ) { counter++; delete vol->GetVoxels(); vol->SetVoxelFinder(0); } } std::cout << " deleted " << counter << " Voxels \n"; }
TString get_var_name(TString name) { TObjArray* arr = name.Tokenize("."); TString out = ((TObjString*)arr->At(arr->GetEntries()-2))->GetString(); TString res; if (out.Contains("up")) res = "plus"; if (out.Contains("down")) res = "minus"; return res; }
void PetiteMacroDeNuit() { Int_t evt = 0 ; RecAna * t = new RecAna("junk.root"); t->GetEvent(evt); TObjArray * lp = t->PVBARPpsdRP ; cout << "Tree macro = " << lp << endl ; for (int i = 0 ; i < lp->GetEntries() ; i++ ) { IlcPVBARPpsdRecPoint * rpp = (IlcPVBARPpsdRecPoint *)lp->At(i) ; rpp.Print(); } TObjArray * le = t->PVBAREmcRP ; for (int i = 0 ; i < le->GetEntries() ; i++ ) { IlcPVBAREmcRecPoint * rp = (IlcPVBAREmcRecPoint *)le->At(i) ; rp->Print(); } IlcPVBARIndexToObject * please = IlcPVBARIndexToObject::GetInstance() ; for (int i = 0 ; i < (t->PVBARTS_-1) ; i++) { cout << "TrackSegment # " << i << endl << "====================" << endl ; int index = t->PVBARTS_fEmcRecPoint[i] ; IlcPVBAREmcRecPoint * emrp = (IlcPVBAREmcRecPoint *) ( please->GimeRecPoint(index, TString("emc") ) ) ; emrp->Print() ; index = t->PVBARTS_fPpsdLowRecPoint[i] ; IlcPVBARPpsdRecPoint * ppsdl = (IlcPVBARPpsdRecPoint *) ( please->GimeRecPoint(index, TString("ppsd") ) ) ; if (ppsdl) ppsdl->Print() ; index = t->PVBARTS_fPpsdUpRecPoint[i] ; IlcPVBARPpsdRecPoint * ppsdu = (IlcPVBARPpsdRecPoint *) ( please->GimeRecPoint(index, TString("ppsd") ) ) ; if (ppsdu) ppsdu->Print() ; } for (int i = 0 ; i < (t->PVBARRP_-1) ; i++) { cout << "RecParticles # " << i << endl << "====================" << endl ; cout << "type = " << t->PVBARRP_fType[i] << " energy = " << t->PVBARRP_fE[i] << endl ; } delete t ; }
void KVDatime::SetGanacqDate(const Char_t * GanacqDateString) { //Decodes GANIL acquisition (INDRA) run-sheet format date into a TDatime //Format of date string is: // 29-SEP-2005 09:42:17.00 // or 29-SEP-2005 09:42:17 // or 29-SEP-05 09:42:17.00 // or 29-SEP-05 09:42:17 // //If format is not respected, we set to current time & date KVString tmp(GanacqDateString); TObjArray *toks = tmp.Tokenize("-:. "); if( toks->GetEntries() < 6 || toks->GetEntries() > 7 ) { // if format is correct, there should be 6 or 7 elements in toks delete toks; Error("SetGanacqDate", "Format is incorrect: %s (should be like \"29-SEP-2005 09:42:17.00\" or \"29-SEP-05 09:42:17\")", GanacqDateString); Set(); return; } KV__TOBJSTRING_TO_INT(toks,0,day) TObject *mm = fmonths->FindObject(((TObjString *) toks->At(1))->String().Data()); Int_t month = 0; if (mm) month = fmonths->IndexOf(mm) + 1; KV__TOBJSTRING_TO_INT(toks,2,year) // year may be written in shortened form: 97 instead of 1997 if(year<100){ Warning("SetGanacqDate", "Ambiguous value for year: %d. Assuming this means: %d", year, (year<82?year+2000:year+1900)); (year<82?year+=2000:year+=1900); } KV__TOBJSTRING_TO_INT(toks,3,hour) KV__TOBJSTRING_TO_INT(toks,4,min) KV__TOBJSTRING_TO_INT(toks,5,sec) delete toks; Set(year, month, day, hour, min, sec); }
UpdateRecoParam(const Int_t runNumber) { // Read the array of PHOS recoparam objects from OCDB and update // EMC fitter version to "v4". // Write the updated object to OCDB. // Yuri Kharlov. 9.12.2011 // /* $Id$ */ AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(runNumber); AliCDBEntry* cdbEntry = AliCDBManager::Instance()->Get("PHOS/Calib/RecoParam"); AliCDBMetaData *md = cdbEntry->GetMetaData(); cout << "Responsible: " << md->GetResponsible() << endl; cout << "MD Comment : " << md->GetComment() << endl; TObjArray* arrayRecoParam = (TObjArray*)cdbEntry->GetObject(); cout << "N recoparam = " << arrayRecoParam->GetEntries() << endl; AliPHOSRecoParam *rp = 0; for (Int_t i=0; i<arrayRecoParam->GetEntries(); i++) { rp = (AliPHOSRecoParam*)arrayRecoParam->At(i); printf("RP %d: event specie = %d, fitter version = %s\n", i,rp->GetEventSpecie(),rp->EMCFitterVersion()); rp->SetEMCFitterVersion("v4"); } // Writing new recoparam to OCDB AliCDBManager* cdb = AliCDBManager::Instance(); cdb->SetDefaultStorage("local://OCDB"); AliCDBMetaData *md= new AliCDBMetaData(); md->SetResponsible("Yuri Kharlov"); md->SetComment("PHOS recoparameters: EMC fitter version is updated to v4"); AliCDBId id("PHOS/Calib/RecoParam",167690,AliCDBRunRange::Infinity()); cdb->Put(arrayRecoParam,id, md); }
TString get_sample_name(TString name) { TObjArray* arr = name.Tokenize("."); TString out = ((TObjString*)arr->At(arr->GetEntries()-2))->GetString(); out.ReplaceAll("_JER_up", ""); out.ReplaceAll("_JER_down", ""); out.ReplaceAll("_JEC_up", ""); out.ReplaceAll("_JEC_down", ""); out.ReplaceAll("_PU_down", ""); out.ReplaceAll("_PU_up", ""); out.ReplaceAll("_LJets_up", ""); out.ReplaceAll("_LJets_down", ""); out.ReplaceAll("_BJets_up", ""); out.ReplaceAll("_BJets_down", ""); out.ReplaceAll("_MuonSF_down", ""); out.ReplaceAll("_MuonSF_up", ""); out.ReplaceAll("_BJets_down", ""); out.ReplaceAll("_BJets_down", ""); out.ReplaceAll("_matching_down", ""); out.ReplaceAll("_matching_up", ""); out.ReplaceAll("_scale_down", ""); out.ReplaceAll("_scale_up", ""); out.ToLower(); out.ReplaceAll("dyjets_50toinf", "zlight"); out.ReplaceAll("dyjets", "zlight"); out.ReplaceAll("dy", "zlight"); out.ReplaceAll("wjets_bflavor", "wb"); out.ReplaceAll("wjets_cflavor", "wc"); out.ReplaceAll("wjets_lflavor", "wlight"); //out.ReplaceAll("tt", "ttbar"); if (out.Contains("zp")){ TString temp = out; temp.ReplaceAll("zp",""); temp.ReplaceAll("p", "."); TObjArray* arr2 = temp.Tokenize("w"); TString nom = ((TObjString*)arr2->At(1))->GetString(); TString denom = ((TObjString*)arr2->At(0))->GetString(); cout << "nom = " << nom << " denom = " << denom << endl; Int_t p = (100*nom.Atof())/denom.Atof(); cout << "p = " << p << endl; out = TString::Format("zp %d w %d p",denom.Atoi(), p); out.ReplaceAll(" ", ""); } return out; }
void run_basicLoop_data() { //the problem with this structure is that it doesn't parallelize //parallelization would work well on dellcmscornell TString computername = gSystem->Getenv("HOST"); TString dir = "/cu1/joshmt/"; //default is dellcmscornell if (computername =="JoshPC") { dir="~/data/"; } dir += "BasicNtuples/"; dir += version; dir+="/"; TChain dummy("dummy"); TString dirs = dir; dirs+="*"; dummy.Add(dirs); TObjArray* dirlist = dummy.GetListOfFiles(); int nfiles=dirlist->GetEntries(); unsigned int currentfileindex=1; for (int ifile=0; ifile<nfiles; ifile++) { TString samplefiles = dirlist->At(ifile)->GetTitle(); samplefiles+="/*.root"; cout<<"About to start on files: "<<samplefiles<<endl; // if (!samplefiles.Contains("LM13")) continue; //hack to skip some samples TChain ch("BasicTreeMaker/tree"); TChain info("BasicTreeMaker/infotree"); ch.Add(samplefiles); info.Add(samplefiles); basicLoop looper(&ch,&info); //important! this is where cuts are defined looper.setCutScheme(basicLoop::kBaseline0); looper.setMETType(basicLoop::kpfMET); looper.setMETRange(basicLoop::kWide); //get more events for plotting looper.setJetType(basicLoop::kPF); looper.setLeptonType(basicLoop::kPFLeptons); looper.setDPType(basicLoop::kminDP); //apply the CU minDeltaPhi cut looper.setIgnoredCut("cut3Jets"); //N-1 looper.setBCut(0); //no b tagging cut so that plots can apply it selectively looper.Loop(currentfileindex); //go! currentfileindex++; } }
void run_cutflowPlotter() { //TString libname="basicLoop_C.so"; TString computername = gSystem->Getenv("HOST"); TString dir = "/cu1/joshmt/"; if (computername =="JoshPC") { dir="~/data/"; } //could also add CASTOR dir += "BasicNtuples/"; if (extrapath!="") { dir += extrapath; dir += "/";} dir += version; dir+="/"; TChain dummy("dummy"); TString dirs = dir; dirs+="*"; dummy.Add(dirs); TObjArray* dirlist = dummy.GetListOfFiles(); int nfiles=dirlist->GetEntries(); for (int ifile=0; ifile<nfiles; ifile++) { TString samplefiles = dirlist->At(ifile)->GetTitle(); samplefiles+="/*.root"; cout<<"About to start on files: "<<samplefiles<<endl; if (samplefiles.Contains("DATA")) continue; //skip data (use run_cutflowPlotter_data.C) if (!(samplefiles.Contains("TTbarJ") )) continue; //hack to skip some samples TChain ch("BasicTreeMaker/tree"); TChain info("BasicTreeMaker/infotree"); ch.Add(samplefiles); info.Add(samplefiles); basicLoop looper(&ch,&info); looper.setCutScheme(basicLoop::kBaseline0); looper.setMETType(basicLoop::kpfMET); looper.setMETRange(basicLoop::kHigh); //signal region looper.setJetType(basicLoop::kPF); looper.setLeptonType(basicLoop::kPFLeptons); looper.setDPType(basicLoop::kminDP); looper.setCleaningType(basicLoop::kMuonCleaning); looper.setBCut(3); //require 3 b tags so that we run the full cut flow table looper.cutflowPlotter(); } }
void MakeQAThresholdsEntry(const char* storageUri="local://$ALICE_ROOT/../AliRoot/OCDB", Int_t firstRun=0, Int_t lastRun=999999999) { AliCDBManager *cdb = AliCDBManager::Instance(); cdb->SetDefaultStorage(storageUri); // QAThresholds TObjArray* qaThrArray = new TObjArray(); for (Int_t idet = 0; idet < AliDAQ::kNDetectors; idet++){ TString detName = AliDAQ::OnlineName(idet); if (detName == "TRI" || detName == "HLT" || detName == "TST") continue; // skipping TRI, HLT, TST since they do not produce QAThresholds Printf("Processing QAThreshold for detector %s",detName.Data()); TString inFile(gSystem->ExpandPathName("$ALICE_ROOT/../AliRoot/GRP/ShuttleInput/")); inFile += "run000168322_"; inFile += detName; inFile += "_DQM_QAThresholds"; Printf("Opening QAThreshold file %s", inFile.Data()); TFile dqmFile(inFile.Data(),"READ"); if (dqmFile.IsOpen()) { AliQAThresholds* qaThr = dynamic_cast<AliQAThresholds*>(dqmFile.Get(detName.Data())); if (qaThr){ Int_t qaThrId = qaThr->GetDetectorId(); if (qaThrId != idet){ Printf("ERROR: Expecting QA threshold for detector %s, but found that for detector %s, skipping",detName.Data(), AliDAQ::OnlineName(qaThrId)); continue; } else{ qaThrArray->AddAtAndExpand(qaThr, qaThrId); } } else { Printf("ERROR: No QAThresholds object found in the file for detector %s, skipping",detName.Data()); continue; } } else { Printf("ERROR: Can't open QAThreshold file for detector %s, skipping",detName.Data()); continue; } } if (qaThrArray->GetEntries() > 0){ AliCDBMetaData md; md.SetResponsible("Barthélémy von Haller"); md.SetComment("QA Threshold TObjArray"); AliCDBId id("GRP/Calib/QAThresholds", firstRun, lastRun); cdb->Put(qaThrArray, id, &md); } else{ Printf("No valid QAThresholds entries found, storing nothing in the OCDB"); } }
//_____________________________________// GetProductionInfo(TString &fPeriod, TString &fPass, TString &fName) { const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR"); TString fS = turl; TObjArray *fDirs = fS.Tokenize("/"); for (int iter=0; iter<fDirs->GetEntries(); iter++) { TString fDir = ((TObjString *) fDirs->At(iter))->String(); if (fDir.Contains("LHC")) fPeriod = fDir; if (fDir.Contains("pass")) fPass = fDir; } fName = fPeriod+"."+fPass; }
void initweights(TChain *chain, float *xsecs, float lumi) { TObjArray *files = chain->GetListOfFiles(); for (int i=0; i<files->GetEntries(); ++i) { TFile *file = TFile::Open(files->At(i)->GetTitle(),"READ"); xsecweights[i] = getweight(file,lumi*xsecs[i]); file->Close(); } chain->SetAlias("procidx","This->GetTreeNumber()"); }
/// \brief Cache MC production trees, store summary information in formated text files -> root trees /// \param dataType - /// \param fileList void CacheTestMCProductions(TString dataType, const char *fileList=NULL){ AliExternalInfo info; info.fLoadMetadata=kFALSE; TObjArray* periodList = NULL; TArrayI nRuns; if (fileList!=NULL) { periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n"); nRuns.Set(periodList->GetEntries()); }else{ TTree * tree = info.GetTree("MonALISA.ProductionMC","",""); Int_t nProd=tree->GetEntries(); periodList = new TObjArray(nProd); nRuns.Set(nProd); TLeaf *leaf = tree->GetLeaf("Tag"); TLeaf *leafRuns = tree->GetLeaf("Number_of_runs"); for (Int_t iProd=0; iProd<nProd; iProd++){ tree->GetEntry(iProd); TString prodName=((char*)leaf->GetValuePointer()); if (prodName.Contains("LHC")==0) continue; periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd); nRuns[iProd]=leafRuns->GetValue(); } delete tree; } for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){ TObjString * pName= (TObjString*)periodList->At(iPeriod); if (pName==NULL) continue; TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC"); if (tree){ Int_t entries=tree->Draw("run","1","goff"); TString sInfo=periodList->At(iPeriod)->GetName(); sInfo+="\t"; sInfo+=dataType; sInfo+="\t"; sInfo+=TString::Format("%d\t",entries); sInfo+=TString::Format("%d\t",nRuns[iPeriod]); for (Int_t j=0; j<entries; j++) { sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]); ::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]); } sInfo+="0"; ::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data()); delete tree; }else{ ::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]); } } }
void ilceve_init_import_macros() { // Put macros in the list of browsables, add a macro browser to // top-level GUI. TString macdir("$(ILC_ROOT)/EVE/ilc-macros"); gSystem->ExpandPathName(macdir); TFolder* f = gEve->GetMacroFolder(); void* dirhandle = gSystem->OpenDirectory(macdir.Data()); if (dirhandle != 0) { char* filename; TPMERegexp re("\\.C$"); TObjArray names; while ((filename = gSystem->GetDirEntry(dirhandle)) != 0) { if (re.Match(filename)) names.AddLast(new TObjString(filename)); } names.Sort(); for (Int_t ii=0; ii<names.GetEntries(); ++ii) { TObjString * si = (TObjString*) names.At(ii); f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data()))); } } gSystem->FreeDirectory(dirhandle); gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data())); { TEveBrowser *br = gEve->GetBrowser(); TGFileBrowser *fb = 0; fb = br->GetFileBrowser(); fb->GotoDir(macdir); { br->StartEmbedding(0); fb = br->MakeFileBrowser(); fb->BrowseObj(f); fb->Show(); br->StopEmbedding(); br->SetTabTitle("Macros", 0); br->SetTab(0, 0); } } }