/*Get_Kin_Name{{{*/ TString gGet_Kin_Name(const TString& aKin){ TString aKin_Name="MM"; if(aKin.Contains("3.1")) aKin_Name="3.1"; else if(aKin.Contains("3.2")) aKin_Name="3.2"; else if(aKin.Contains("4.1")) aKin_Name="4.1"; else if(aKin.Contains("4.2")) aKin_Name="4.2"; else if(aKin.Contains("5.0")&&!aKin.Contains("5.05")) aKin_Name="5.0"; else if(aKin.Contains("5.05")) aKin_Name="5.05"; else if(aKin.Contains("5.1")) aKin_Name="5.1"; else if(aKin.Contains("5.2")) aKin_Name="5.2"; else if(aKin.Contains("6.5")) aKin_Name="6.5"; else cerr<<"*** I don't know the kinematics name!!!"<<endl; return aKin_Name; }
void drawLKT(TString& type, TString& ytitle, TString& xtitle, TString& head, TString &leg1, TString& leg2, TString& leg3, double miny = 0.85, double maxy = 1.02){ TCanvas *c = new TCanvas(Form("%s",type.Data()), Form("%s",type.Data()) ,5,49,400,400); SetStyleCanvas(c); TGraphErrors *grae1 = new TGraphErrors(); TGraphErrors *grae2 = new TGraphErrors(); TGraphErrors *grae3 = new TGraphErrors(); if( type.Contains("cEffLKTETA")){ SetEffLKTETA(grae1, grae2, grae3); clearXErrorBar(grae1); clearXErrorBar(grae2); clearXErrorBar(grae3); }else if (type.Contains("cEffLKTNCal")){ SetEffLKTNCal(grae1, grae2, grae3); } SetStyleGraphErrors(grae1, 2, 20, 0, 0.81, ytitle, xtitle, miny, maxy); SetStyleGraphErrors(grae2, 1, 21, 0, 0.81, ytitle, xtitle, miny, maxy); SetStyleGraphErrors(grae3, 4, 22, 0, 0.81, ytitle, xtitle, miny, maxy); grae1->Draw("AP"); grae2->Draw("PSame"); grae3->Draw("PSame"); if( type.Contains("cEffLKTETA")){ SetLegend(grae1, grae2, grae3, head, leg1, leg2, leg3,"P","P","P", 0.6,0.20,0.9,0.40); SetLabel(0.6,0.48,36); }else if( type.Contains("cEffLKTNCal")){ SetLegend(grae1, grae2, grae3, head, leg1, leg2, leg3,"PL","PL","PL", 0.6,0.58,0.9,0.81); SetLabel(0.6,0.88,36); } c->Print(Form("%s.eps",type.Data())); }
TString round(double n, int e, double d){ if(d==0) return " - "; double neg = 1; if(n*d<0) neg = -1; double b = (int)(neg*n/d*pow(10.,(double)e)+0.5); b /= pow(10.,(double)e)*neg; TString result; result+= b; result.ReplaceAll(" ",""); if(!result.Contains(".") && e != 0) result += "."; TString afterdot = result; afterdot.Remove(0,afterdot.First(".")+1); for(int i=0; i<e-afterdot.Length(); i++) result += "0"; return result; }
void FSRBinByBin(const char* MODE,TString datasetName, char* chunk, TString Alt) { // directory with data TString protocol = "file://"; //TString dirname = "/mnt/hadoop/store/user/asvyatko/DYstudy/dataAnalysis13/rootfiles/"; TString dirnameEE = "/scratch/scratch95/a/asvyatko/DY2013/rootfiles_Purdue/"; TString dirnameMuMu = "/scratch/lustreC/a/asvyatko/DY2013/rootfiles_Purdue/"; TString dirname = dirnameMuMu; if (datasetName.Contains("EE")) dirname = dirnameEE; TString ncores = "30"; //if (!datasetName.Contains("samp") && (chunk.Contains("_") || datasetName.Contains("00"))) ncores = "1"; if (!(datasetName.Contains("1020") || datasetName.Contains("samp"))) ncores = "3"; if (datasetName.Contains("1020")) ncores = "10"; TString beautiful = beautifulDataset(datasetName); TFileCollection* c = loadChunks(chunk[0],protocol,dirname,datasetName,beautiful); gSystem->Load("Muon_cc.so"); gSystem->Load("Electron_cc.so"); gSystem->Load("Dimuon_cc.so"); gSystem->Load("Dielectron_cc.so"); gEnv->SetValue("ProofLite.Sandbox", "/home/asvyatko/DYStudy/CMSSW_5_3_3_patch2/src/Analysis/DYPackage/test/FSRunfold_Purdue/proofbox/"); TProof* p = TProof::Open("workers="+ncores); p->RegisterDataSet(datasetName+chunk, c,"OV"); p->ShowDataSets(); TObjString* mode = new TObjString(MODE); p->AddInput(new TNamed("mode",MODE)); gROOT->Time(); p->SetParameter("PROOF_LookupOpt", "all"); p->Process(datasetName+chunk+"#/recoTree/DiLeptonTree","EventSelector_FSRUnfBBB.C+"); }
//______________________________________________________________________________ HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields, Bool_t exp, Option_t *option) { // Add a new table in our list of tables. TString opt = option; opt.ToLower(); HtmlObjTable *table = new HtmlObjTable(name, nfields, exp); fNTables++; if (opt.Contains("first")) fObjTables->AddFirst(table); else fObjTables->Add(table); return table; }
TString round(double n, int e, double d){ if(d==0) return " - "; double b = (int)(n/d*pow(10,e)+0.5); b /= pow(10,e); TString result; result+= b; result.ReplaceAll(" ",""); if(b<10 && e==2){ if(result.Length() == 1) result += ".00"; if(result.Length() == 3) result += "0"; } if(e==1 && !result.Contains(".")) result += ".0"; return result; }
TString HiggsPlot::RoundNumber(double n, int e, double d){ if(d==0) return " - "; double neg = 1; if(n*d<0) neg = -1; double b = static_cast<int>(neg*n/d*pow(10.,static_cast<double>(e))+0.5); b /= pow(10.,static_cast<double>(e))*neg; TString result; result+= b; result.ReplaceAll(" ",""); if(!result.Contains(".") && e != 0) result += "."; TString afterdot = result; afterdot.Remove(0,afterdot.First(".")+1); for(int i=0; i<e-afterdot.Length(); i++) result += "0"; return result; }
HistoTransform::Region* HistoTransform::getRegion(SubDirectory* subDir, string histName) { KFold* kFold = getKFold(subDir, histName); if (!kFold) return 0; if (kFold -> regions.size() == 1) return kFold -> regions[0]; TString name = histName; for (unsigned int iRegion = 0; iRegion < kFold -> regions.size(); iRegion++) { TString stringIofK = TString::Format("_%iof%i", iRegion, (int) kFold -> regions.size()); if (name.Contains(stringIofK)) return kFold -> regions[iRegion]; } // cout << "WARNING: region for histo '" << histName << "' not found!" << endl; return 0; }
AliAnalysisKinkESDat* AddTaskKink(TString lCustomName="") { //pp settings AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); if (!mgr) { ::Error("AddKinkTask", "No analysis manager to connect to."); return NULL; } // Check the analysis type using the event handlers connected to the analysis manager. //============================================================================== if (!mgr->GetInputEventHandler()) { ::Error("AddKinkTask", "This task requires an input event handler"); return NULL; } TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD" if(type.Contains("AOD")) { ::Error("AddKinkTask", "This task requires to run on ESD"); return NULL; } //TString outputFileName = AliAnalysisManager::GetCommonFileName(); //outputFileName += ":PWG2SpectraTOF"; AliAnalysisKinkESDat* task = new AliAnalysisKinkESDat("AliAnalysisKinkESDat"); //task->SetMC("kFALSE"); // 26/11/12 task->SetMulCut(0,1002); mgr->AddTask(task); //Attach input AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); // mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); mgr->ConnectInput(task,0,cinput); TString lContainerName="PWGLFKinks"; lContainerName.Append(lCustomName); AliAnalysisDataContainer *coutput1= mgr->CreateContainer(lContainerName.Data(),TList::Class(), AliAnalysisManager::kOutputContainer,"AnalysisResults.root"); mgr->ConnectOutput(task, 1, coutput1); return task; }
void bcut::parseWeight(TString wgt){ cutTypes_.push_back(kFloat); fWeights_.push_back(NULL); fvWeights_.push_back(NULL); indWeights_.push_back(-1); constWeights_.push_back(1.); if(wgt=="weight") fWeights_.back() = &baby_base::weight; else if(wgt=="w_lumi") fWeights_.back() = &baby_base::w_lumi; else if(wgt=="w_pu") fWeights_.back() = &baby_base::w_pu; else if(wgt=="w_lep") fWeights_.back() = &baby_base::w_lep; else if(wgt=="w_fs_lep") fWeights_.back() = &baby_base::w_fs_lep; else if(wgt=="w_toppt") fWeights_.back() = &baby_base::w_toppt; else if(wgt=="w_btag") fWeights_.back() = &baby_base::w_btag; else if(wgt=="eff_trig") fWeights_.back() = &baby_base::eff_trig; else if(wgt.Contains("[")){ // if weight is a vector element TString index_s(wgt); wgt.Remove(wgt.Index("["), wgt.Length()); index_s.Remove(0, index_s.Index("[")+1); index_s.Remove(index_s.Index("]"), index_s.Length()); indWeights_.back() = index_s.Atoi(); cutTypes_.back() = kvFloat; if(wgt=="w_pdf") fvWeights_.back() = &baby_base::w_pdf; else if(wgt=="sys_pdf") fvWeights_.back() = &baby_base::sys_pdf; else if(wgt=="sys_isr") fvWeights_.back() = &baby_base::sys_isr; else if(wgt=="sys_mur") fvWeights_.back() = &baby_base::sys_mur; else if(wgt=="sys_muf") fvWeights_.back() = &baby_base::sys_muf; else if(wgt=="sys_murf") fvWeights_.back() = &baby_base::sys_murf; else if(wgt=="sys_trig") fvWeights_.back() = &baby_base::sys_trig; else if(wgt=="sys_lep") fvWeights_.back() = &baby_base::sys_lep; else if(wgt=="sys_fs_lep") fvWeights_.back() = &baby_base::sys_fs_lep; else if(wgt=="sys_bctag") fvWeights_.back() = &baby_base::sys_bctag; else if(wgt=="sys_fs_bctag") fvWeights_.back() = &baby_base::sys_fs_bctag; else if(wgt=="sys_udsgtag") fvWeights_.back() = &baby_base::sys_udsgtag; else if(wgt=="sys_fs_udsgtag") fvWeights_.back() = &baby_base::sys_fs_udsgtag; else { cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl; exit(0); } }else if(wgt.Atof()>0) { constWeights_.back() = wgt.Atof(); cutTypes_.back() = kConst; } else { cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl; exit(0); } }
void UATAna(TString Cfg = "Config.cfg" , TString Steps = "R"){ Steps.ToUpper(); UATAnaConfig Config; Config.ReadCfg(Cfg); Config.Print(); if ( Steps.Contains ('R') || Steps.Contains ('T') ) { bool bWTree = false ; if ( Steps.Contains ('T') ) bWTree = true ; UATAnaReader Reader; Reader.Init (Config , bWTree ); Reader.Analyze(Config , bWTree ); Reader.End (Config , bWTree ); } if ( Steps.Contains ('F') || Steps.Contains ('Y') || Steps.Contains ('L') || Steps.Contains ('C') ) { UATAnaDisplay Display; Display.Init (Config); if ( Steps.Contains ('D') ) { Config.SetDrawRatio(true); Config.SetDrawBgError(true); } if ( Steps.Contains ('E') ) Config.SetDrawBgError(true); if ( Steps.Contains ('F') ) Display.Yields(Config,1); if ( Steps.Contains ('Y') ) Display.Yields(Config,0,0); if ( Steps.Contains ('C') ) { if ( Steps.Contains ('S') ) Display.CPlot (Config,1); else Display.CPlot (Config,0); } if ( Steps.Contains ('L') ) Display.LimitCard (Config); } }
void PlotEff(TString dataFileName = "DataEE_eleEndcap", TString mcFileName = "DYJetsToEE_M-50_eleEndcap", TString histBaseName = "ZMassEndcap") { SetStyle(); TFile * fileData = new TFile(dataFileName+".root"); TFile * fileMC = new TFile(mcFileName+".root"); TGraphAsymmErrors * effData = (TGraphAsymmErrors*)fileData->Get(histBaseName); TGraphAsymmErrors * effMC = (TGraphAsymmErrors*)fileMC->Get(histBaseName); effData->SetLineColor(2); effData->SetMarkerColor(2); effData->SetMarkerSize(1.2); effData->SetMarkerStyle(20); effMC->SetLineColor(4); effMC->SetMarkerColor(4); effMC->SetMarkerStyle(21); effMC->GetXaxis()->SetTitleOffset(1.1); effMC->GetXaxis()->SetTitleSize(0.05); effMC->GetYaxis()->SetTitleOffset(1.1); effMC->GetYaxis()->SetTitleSize(0.05); effMC->GetYaxis()->SetRangeUser(0.0,1.001); TString EtaRegion("Endcap"); if (histBaseName.Contains("Barrel")) EtaRegion = "Barrel"; TCanvas * canv = new TCanvas("canv","",700,600); effMC->Draw("APE"); effData->Draw("PESame"); TLegend * leg = new TLegend(0.69,0.17,0.94,0.40); leg->SetFillColor(0); leg->SetHeader(EtaRegion); leg->SetTextSize(0.06); leg->AddEntry(effData,"Data","lp"); leg->AddEntry(effMC,"MC","lp"); leg->Draw(); canv->SetGridx(); canv->SetGridy(); canv->Print(histBaseName+"_eff.png"); canv->Update(); }
Graph *GetJESGraph(double E) { Graph *g = new Graph(); int Np=0; for (int i=-45;i<45;++i) { double eta=0.05+0.1*i; double JES=GetJES(E,eta); //JES+=GetJES(E,-eta); JES/=2; double pT=E/cosh(eta); if (pT/JES<10) continue; if ( _jesFile.Contains("FatJet") && pT/JES<40 ) continue; //if (E==30) // printf("eta = %.2f, JES: %.2f, E = %.2f, Eem: %.2f\n",eta,JES,E,E/JES); //abort(); g->SetPoint(Np++,eta,1.0/JES); } return g; }
/** * Get the size of a given run * * @param in Input stream * @param runNo Run number to search for * @param mc True for simulations * @param minSize Least size * * @return true on success */ Bool_t GetSize(std::istream& in, ULong_t runNo, Bool_t mc, ULong_t minSize=100000) { TString line; TString tgt2(mc ? "table_row_right" : "ESDs size"); Int_t cnt = 0; do { line.ReadLine(in); if (!line.Contains(tgt2)) continue; cnt++; if (mc && cnt < 3) continue; if (!mc) line.ReadLine(in); if (fDebug) Info("", line); TString ssiz; if (mc) { Int_t first = line.Index(">"); Int_t last = line.Index("<",first+1); if (first == kNPOS || last == kNPOS) { Error("GetDir", "Failed to get directory from %s", line.Data()); return false; } ssiz = line(first+1, last-first-1); } else { for (Int_t i = 0; i < line.Length(); i++) { if (line[i] == '<') break; if (line[i] == ' ' || line[i] == '\t' || line[i] == ',') continue; ssiz.Append(line[i]); } } Long_t size = ssiz.Atoll(); if (fDebug) Info("", "Got run %lu %lu" , runNo, size); if (size < 0) { Error("GetSize", "Failed to extract size for run %lu", runNo); return false; } if (ULong_t(size) < minSize) { Warning("GetSize","Run %lu does not have enough events %lu",runNo,size); return false; } break; } while (!in.eof()); return true; }
Int_t KVRTGIDManager::WriteAsciiFile ( const Char_t * filename, const TCollection *selection, Bool_t update ) { // Write identification functions in file 'filename'. // If selection=0 (default), write all grids. // If update=true, call UpdateListFromIDGridManager() before writing // If selection!=0, write only grids in list. // Returns number of functions written in file. if( update ) UpdateListFromIDGridManager(); if( !fIDGlobalList ){ Warning("KVRTGIDManager::WriteAsciiFile","No listed identification functions to write"); return 0; } ofstream tgidfile ( filename ); if( !tgidfile.is_open() ){ Error("KVRTGIDManager::WriteAsciiFile","No write permission for file %s", filename); return 0; } const TCollection *list_tgid = ( selection ? selection : fIDGlobalList ); TIter next ( list_tgid ); KVTGID *tgid = NULL; Int_t n_saved = 0; while ( ( tgid = (KVTGID *)next() ) ) { // Not write a KVTGID copy TString tmp = tgid->GetTitle(); if(tmp.Contains("COPY")){ tmp.Remove(0, tmp.Index("0x")); KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof()); Warning("KVRTGIDManager::WriteAsciiFile","The function %s (%s, %p) is not written because it is a copy of %s (%s, %p)" , tgid->GetName(), tgid->ClassName(), tgid , tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid); continue; } tgid->WriteToAsciiFile ( tgidfile ); Info( "KVRTGIDManager::WriteAsciiFile", "%s (%s, %p) saved", tgid->GetName(), tgid->ClassName(), tgid ); n_saved++; } tgidfile.close(); return n_saved; }
/** * Get list of runs associated with production * * @param url The production URL * @param mc True of MC * @param minSize Least size of runs to use * * @return true on success */ Bool_t GetRuns(const TString& url, Bool_t mc, ULong_t minSize) { TString index("job"); if (!Download(Form("%s%s", (mc ? "" : "raw/"), url.Data()), index)) return false; std::ifstream in(index.Data()); TString tgt1(mc ? "window.open" : "runDetails"); TString line = ""; do { line.ReadLine(in); if (!line.Contains(tgt1)) continue; Int_t first = -1; Int_t last = -1; if (!mc) { first = line.Index(tgt1); last = line.Index(")", first+tgt1.Length()+1); } else { Int_t tmp = line.Index(">"); first = line.Index(">", tmp+1); last = line.Index("<", first); } if (first == kNPOS || last == kNPOS) { Error("GetDir", "Failed to get directory from %s", line.Data()); return false; } first += (mc ? 1 : tgt1.Length()+1); last -= first; TString srun = line(first, last); ULong_t runNo = srun.Atoll(); if (fDebug) Info("", "Got run %lu (%s)", runNo, srun.Data()); if (!GetSize(in, runNo, mc, minSize)) continue; if (!GetDir(in, runNo, mc)) continue; if (!fRuns.IsNull()) fRuns.Append(","); fRuns.Append(Form("%lu", runNo)); } while (!in.eof()); in.close(); if (fRuns.IsNull()) return false; return true; }
HistoTransform::SubDirectory* HistoTransform::findSubDirs(string subDirName, bool identical) { if (identical && subDirName == "") { SubDirectory* subDir = new SubDirectory(); subDir -> dir = m_inFile; m_subDirs.push_back(subDir); return subDir; } TKey* key; TIter nextkey(m_inFile -> GetListOfKeys()); while ((key = (TKey*) nextkey())) { TClass* cl = gROOT -> GetClass(key -> GetClassName()); if (!cl) continue; if (cl -> InheritsFrom(TDirectory::Class())) { TString name = key -> GetName(); if ((name.Contains(subDirName) && !identical) || name.EqualTo(subDirName)) { cout << "INFO: found subdirectory '" << name.Data() << "'" << endl; SubDirectory* subDir = new SubDirectory(); m_inFile -> cd(name); subDir -> dir = gDirectory; m_subDirs.push_back(subDir); if (identical) return subDir; else addBackground(subDir, "bkg"); } } } if (m_subDirs.size() == 0 && !identical) { cout << "INFO: no subdirectory found, using root directory" << endl; SubDirectory* subDir = new SubDirectory(); subDir -> dir = m_inFile; m_subDirs.push_back(subDir); addBackground(subDir, "bkg"); return subDir; } if (identical) { cout << "WARNING: subdirectory '" << subDirName << "' not found!" << endl; } return 0; }
Int_t getsipm( Char_t *start_datetime, Char_t *end_datetime ) { TSQLServer *serv = TSQLServer::Connect("pgsql://phnxdb1.phenix.bnl.gov/daq", "phnxrc", ""); // Create the sql query TString sql = "SELECT EXTRACT(EPOCH FROM read_datetime)::INT AS read_timestamp,current FROM sipm WHERE read_datetime >= \'"; sql += start_datetime; sql += "\' AND read_datetime < \'"; sql += end_datetime; sql += "\'"; std::cout << "sql query: " << sql << std::endl; TSQLResult *res; res = serv->Query(sql); // Extract the result of the query into vectors Int_t nrows = res->GetRowCount(); Int_t nfields = res->GetFieldCount(); std::cout << "rows: " << nrows << " columns: " << nfields << std::endl; TString fieldname; TString field; TSQLRow *row; // std::vector<double> read_timestamp; // std::vector<double> read_current; for (Int_t i = 0; i < nrows; i++) { row = res->Next(); for (Int_t j = 0; j < nfields; j++) { fieldname = TString( res->GetFieldName(j) ); field = TString( row->GetField(j) ); // std::cout << "fieldname: " << fieldname << " field: " << field << std::endl; if ( fieldname == "read_timestamp" ) read_time_sipm[0].push_back( field.Atof() ); if ( fieldname.Contains( "current" ) ) sipm_current[0].push_back( field.Atof() ); } } return nrows; }
/** * Get a directory * * @param in Input stream * @param runNo The run number * @param mc True for MC * * @return true on success */ Bool_t GetDir(std::istream& in, ULong_t runNo, Bool_t mc) { TString line; TString tgt3("/catalogue/index.jsp"); do { line.ReadLine(in); // Info("", "line=%s", line.Data()); if (!line.Contains(tgt3)) continue; if (fDebug) Info("", line); Int_t tmp = mc ? line.Index(">")+1 : 0; Int_t first = line.Index(">", tmp); Int_t last = line.Index("<",first+1); if (first == kNPOS || last == kNPOS) { Error("GetDir", "Failed to get directory from %s", line.Data()); return false; } TString dir = line(first+1,last-first-1); if (fDebug) Info("", "Got run %lu %s", runNo, dir.Data()); TString path, pass; if (!GetPathPass(dir, runNo, path, pass)) return false; if (fDebug) Info("", "Got run %lu %s %s", runNo,path.Data(),pass.Data()); if (fPath.IsNull()) fPath = path; else if (!fPath.EqualTo(path)) { Warning("GetDir", "Run %lu location %s not %s", runNo, path.Data(), fPath.Data()); return false; } if (fPass.IsNull()) fPass = pass; else if (!fPass.EqualTo(pass)) { Warning("GetDir", "Run %lu pass %s not %s", runNo, pass.Data(), fPass.Data()); return false; } break; } while (!in.eof()); return true; }
//_______________________________________ 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 KVNameValueList::ClearSelection(TRegexp& sel) { // Remove from list all parameters whose name matches the regular expression // Examples: // remove all parameters starting with "toto": TRegexp sel("^toto") // remove all parameters with "toto" in name: TRegexp sel("toto") TList toBeRemoved; Int_t np1 = GetNpar(); for (Int_t ii = 0; ii < np1; ii += 1) { TString name = GetParameter(ii)->GetName(); if (name.Contains(sel)) toBeRemoved.Add(new TNamed(name.Data(), "")); } if (toBeRemoved.GetEntries()) { TIter next(&toBeRemoved); TNamed* tbr; while ((tbr = (TNamed*)next())) RemoveParameter(tbr->GetName()); toBeRemoved.Delete(); } }
vector<TString> list_files(const char *dirname, const char *exp=".*HiForestAOD.*\\.root") { vector<TString> names; TSystemDirectory dir(dirname, dirname); TList *files = dir.GetListOfFiles(); if (files) { TSystemFile *file; TString fname; TIter next(files); while ((file=(TSystemFile*)next())) { fname = file->GetName(); if (!file->IsDirectory() && fname.Contains(TRegexp(exp))) { names.push_back(TString(dirname)+"/"+fname); } } } if (names.size()==0) return {dirname}; return names; }
//________________________________________________________ TObjArray GFOverlay::FindAllBetween(const TString &text, const char *startStr, const char *endStr) const { TObjArray result; // TObjStrings... if (text.Contains(startStr, TString::kIgnoreCase)) { Ssiz_t start = text.Index(startStr); while (start != kNPOS && start < text.Length()) { TString name = this->FindNextBetween(text, start, startStr, endStr); if (!name.IsNull()) { result.Add(new TObjString(name)); start = text.Index(startStr, start + name.Length() + TString(endStr).Length()); } else { break; } } } return result; }
void dumpTrees(TString dir = "zz4lTree", const char *cut="", int maxEvents = 200, const char *process=0) { TTree *Events = (TTree *) gFile->Get(dir+"/probe_tree"); if (Events == 0) { std::cerr << "Didn't find " << dir << " in file " << gFile->GetName() << std::endl; return; } Events->SetScanField(0); if (dir.Contains("4l") || dir.Contains("4L")) { Events->Scan("event:mass:m4l:z1mass:z2mass:l1pdgId:l1pt:l1eta:l2pt:l2eta:l3pdgId:l3pt:l3eta:l4pt:l4eta:massErr:melaLD:pho1pt:pho1eta:pho2pt:pho2eta:jet1pt:jet1eta:jet2pt:jet2eta:mjj:njets30",cut,"",maxEvents); //} else if (dir.Contains("anyZllTree")) { // Events->Scan("event:zmass:l1pdgId:l1pt:l1eta:l2pt:l2eta:l1pfIsoComb04EACorr/l1pt:l2pfIsoComb04EACorr/l2pt:l1sip:l2sip",cut,"",maxEvents); } else if (dir.Contains("muonTree")) { Events->Scan("event:pt:eta:phi:looseID:newID:prlID:mvaISO:sip:pfIsoComb04EACorr:bdtIso:mvaISO:pfIsoChHad04:pfIsoNHad04_NoEA:pfIsoPhot04_NoEA:pfIsoEAtot:rho:rhoAA",cut,"",maxEvents); } else if (dir.Contains("electronTree")) { Events->Scan("event:pt:eta:phi:looseID:newID:prlID:sip:pfIsoComb04EACorr:bdtIso:bdtID:mvaISO:mvaID:pfIsoChHad04:pfIsoNHad04_NoEA:pfIsoPhot04_NoEA:pfIsoEAtot:rho:rhoAA",cut,"",maxEvents); } else if (dir.Contains("jetTree")) { Events->Scan("event:pt:eta:phi:passID:passPUID:puJetIDMask:jetIDMVA",cut,"",maxEvents); } else if (dir.Contains("photonTree")) { Events->Scan("event:pt:eta:phi:deltaR:eleMatch:lepMatchNoIso:lepMatch:pfIsoChHad03pt02:pfIsoNHad03:pfIsoPhot03:pfIsoChHadPU03pt02",cut,"",maxEvents); } else if (dir.Contains("zeetree")) { Events->Scan("event:zmass:zmll:l1pt:l1eta:l1phi:l2pt:l2eta:l2phi:fsr:phopt:phoeta:phophi",cut,"",maxEvents); } else if (dir.Contains("zmmtree")) { Events->Scan("event:zmass:zmll:l1pt:l1eta:l1phi:l2pt:l2eta:l2phi:fsr:phopt:phoeta:phophi",cut,"",maxEvents); } }
Bool_t ExistMethodName( TString name, TDirectory *dir=0 ) { // find the key for a method if (dir==0) dir = gDirectory; TIter mnext(dir->GetListOfKeys()); TKey *mkey; Bool_t loop=kTRUE; while (loop) { mkey = (TKey*)mnext(); if (mkey==0) { loop = kFALSE; } else { TString clname = mkey->GetClassName(); TString keyname = mkey->GetName(); TClass *cl = gROOT->GetClass(clname); if (keyname.Contains("Method") && cl->InheritsFrom("TDirectory")) { TDirectory* d_ = (TDirectory*)dir->Get( keyname ); if (!d_) { cout << "HUUUGE TROUBLES IN TMVAGlob::ExistMethodName() --> contact authors" << endl; return kFALSE; } TIter mnext_(d_->GetListOfKeys()); TKey *mkey_; while ((mkey_ = (TKey*)mnext_())) { TString clname_ = mkey_->GetClassName(); TClass *cl_ = gROOT->GetClass(clname_); if (cl_->InheritsFrom("TDirectory")) { TString mname = mkey_->GetName(); // method name if (mname==name) { // target found! return kTRUE; } } } } } } return kFALSE; }
//------------------------------------------------------------------------------ // MakeElectronFR //------------------------------------------------------------------------------ void MakeElectronFR(TString filename) { TString jetpt = "jet35"; if (filename.Contains("jet15")) jetpt = "jet15"; if (filename.Contains("jet50")) jetpt = "jet50"; TH2F* fakeElH2 = new TH2F("fakeElH2_" + jetpt, "fakeElH2_" + jetpt, ptBinsSizeElFake, ptBinsElFake, etaBinsSizeElFake, etaBinsElFake); TFile* input = new TFile(path + filename + ".root", "read"); TH1F* histoFR_B1 = (TH1F*)input->Get("TrgElenewWPHWWPtBarrel1"); TH1F* histoFR_B2 = (TH1F*)input->Get("TrgElenewWPHWWPtBarrel2"); TH1F* histoFR_E1 = (TH1F*)input->Get("TrgElenewWPHWWPtEndcap1"); TH1F* histoFR_E2 = (TH1F*)input->Get("TrgElenewWPHWWPtEndcap2"); for (UInt_t ptBin=4; ptBin<4+ptBinsSizeElFake; ptBin++) { Float_t valueB1 = histoFR_B1->GetBinContent(ptBin); Float_t valueB2 = histoFR_B2->GetBinContent(ptBin); Float_t valueE1 = histoFR_E1->GetBinContent(ptBin); Float_t valueE2 = histoFR_E2->GetBinContent(ptBin); fakeElH2->SetBinContent(ptBin-3, 1, valueB1); fakeElH2->SetBinContent(ptBin-3, 2, valueB2); fakeElH2->SetBinContent(ptBin-3, 3, valueE1); fakeElH2->SetBinContent(ptBin-3, 4, valueE2); } TFile* output = new TFile(path + "EleFR_Moriond13_" + jetpt + "_EWKcorr.root", "recreate"); fakeElH2->Write("fakeElH2"); output->Close(); input->Close(); }
AliAnalysisTaskTRDmon* AddTaskTRDmon(const Char_t* triggerName = "", Bool_t isCollisionTrigger = kTRUE) { // // Configures an AliAnalysisTRDmon task and adds it to the analysis train // // check the analysis manager AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); if(!mgr) { Error("AddTaskTRDmon", "The analysis manager is not initialized"); return 0x0; } // check the ESD input handler TString type = mgr->GetInputEventHandler()->GetDataType(); if(!type.Contains("ESD")) { Error("AddTaskTRDmon", "AliAnalysisTaskTRDmon task needs the manager to have an ESD input handler."); return 0x0; } // configure task AliAnalysisTaskTRDmon *task = new AliAnalysisTaskTRDmon("TRDmon"); task->SetTriggerName(triggerName.Data()); task->SetIsCollisionEvent(isCollisionTrigger); mgr->AddTask(task); // connect input mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); // connect output AliAnalysisDataContainer *output = mgr->CreateContainer("TRDmon", TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("%s.root", task->GetName())); mgr->ConnectOutput(task, 0, output); return task; }
/** * Function to run a train. * * @param name Name of the train. * @param cls class name of train setup * @param uri Exection URI * @param opts Optons * * @return true on success * * @ingroup pwglf_forward_trains */ Bool_t RunTrain(const TString& name, const TString& cls, const TUrl& uri, const TString& opts) { // Check for help if (name.IsNull() || name.EqualTo("help", TString::kIgnoreCase) || cls.IsNull() || cls.EqualTo("help", TString::kIgnoreCase) || !uri.IsValid()) { PlainUsage(); return true; } Bool_t verb = opts.Contains("verbose"); // Build our helpers if (!BuildRailways(verb, false, true)) return false; // Tokenize options if (!opts.EndsWith(",")) opts.Append(","); opts.Append("url="); opts.Append(uri.GetUrl()); TObjArray* optList = opts.Tokenize(","); return TrainSetup::Main(name, cls, optList, false); }
bool dolog(TString hname, int axs) { _DEBUG("bool dolog(TString hname, int axs)"); if(hname.Contains("pT") && axs==1) return false; if(hname.Contains("pT") && axs==2) return true; if(hname.Contains("pT") && axs==3) return false; if(hname.Contains("QT") && axs==1) return true; if(hname.Contains("QT") && axs==2) return true; if(hname.Contains("Mass") && axs==1) return true; if(hname.Contains("Mass") && axs==2) { if(!hname.Contains("AFB") && !hname.Contains("CosTheta")) return true; } if(hname.Contains("Mass") && axs==3) return true; return false; }
void h1analysis::SlaveBegin(TTree *tree) { // function called before starting the event loop // -it performs some cleanup // -it creates histograms // -it sets some initialisation for the entry list //initialize the Tree branch addresses Init(tree); //print the option specified in the Process function. TString option = GetOption(); Info("SlaveBegin", "starting h1analysis with process option: %s (tree: %p)", option.Data(), tree); //create histograms hdmd = new TH1F("hdmd","dm_d",40,0.13,0.17); h2 = new TH2F("h2","ptD0 vs dm_d",30,0.135,0.165,30,-3,6); fOutput->Add(hdmd); fOutput->Add(h2); // Entry list stuff (re-parse option because on PROOF only SlaveBegin is called) if (option.Contains("fillList")) { fillList = kTRUE; // Get the list if (fInput) { if ((elist = (TEntryList *) fInput->FindObject("elist"))) // Need to clone to avoid problems when destroying the selector elist = (TEntryList *) elist->Clone(); if (elist) fOutput->Add(elist); else fillList = kFALSE; } } if (fillList) Info("SlaveBegin", "creating an entry-list"); }