void SetupAnalysis(TString mode, TString analysisMode="full", Bool_t useMC = kFALSE, Int_t nEvents=1.0*1e9, Int_t nEventsSkip=0, TString format="esd") { // ILC stuff IlcAnalysisManager *mgr = IlcAnalysisManager::GetAnalysisManager(); if (!mgr) mgr = new IlcAnalysisManager("CAF train"); // Create and configure the alien handler plugin gROOT->LoadMacro("CreateAnalysisPlugin.C"); IlcAnalysisGrid *alienHandler = CreateAnalysisPlugin(analysisMode); if (!alienHandler) return; mgr->SetGridHandler(alienHandler); // input handler for esd or AOD, real or MC data InputHandlerSetup(format,useMC); // physics selection if(!format.CompareTo("esd")){ gROOT->LoadMacro("$ILC_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); IlcPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE); if(useMC) physSelTask->GetPhysicsSelection()->SetAnalyzeMC(); IlcPhysicsSelection* physSel = physSelTask->GetPhysicsSelection(); physSel->AddBackgroundIdentification(new IlcBackgroundSelection()); } gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ILC_ROOT"))); gROOT->LoadMacro("IlcAnalysisTaskEfficiency.cxx+g"); // load and run AddTask macro gROOT->LoadMacro("AddTaskEfficiency.C"); IlcAnalysisTaskSE* task1 = AddTaskEfficiency(-1); if(!task1){ Printf("AddTask could not be run."); } // Run analysis mgr->InitAnalysis(); if ((!mode.CompareTo("proof")) ||(!mode.CompareTo("local"))) { mgr->StartAnalysis(mode.Data(),nEvents,nEventsSkip); } else { mgr->StartAnalysis(mode.Data()); } }
void QAmerge(const char *suffix, const char *dir, Int_t stage) { // Merging method TStopwatch timer; timer.Start(); TString outputDir = dir; TString outputFiles = Form("QAresults%s.root,EventStat_temp%s.root,RecoQAresults%s.root",suffix,suffix,suffix); TString mergeExcludes = ""; TObjArray *list = outputFiles.Tokenize(","); TIter *iter = new TIter(list); TObjString *str; TString outputFile; Bool_t merged = kTRUE; while((str=(TObjString*)iter->Next())) { outputFile = str->GetString(); // Skip already merged outputs if (!gSystem->AccessPathName(outputFile)) { printf("Output file <%s> found. Not merging again.",outputFile.Data()); continue; } if (mergeExcludes.Contains(outputFile.Data())) continue; merged = IlcAnalysisAlien::MergeOutput(outputFile, outputDir, 10, stage); if (!merged && !outputFile.Contains("RecoQAresults")) { printf("ERROR: Cannot merge %s\n", outputFile.Data()); return; } } // read the analysis manager from file if (!outputDir.Contains("Stage")) { ofstream out; out.open("outputs_valid", ios::out); out.close(); return; } IlcAnalysisManager *mgr = IlcAnalysisManager::GetAnalysisManager(); mgr->SetRunFromPath(mgr->GetRunFromAlienPath(dir)); mgr->SetSkipTerminate(kFALSE); if (!mgr->InitAnalysis()) return; mgr->PrintStatus(); IlcLog::SetGlobalLogLevel(IlcLog::kError); TTree *tree = NULL; mgr->StartAnalysis("gridterminate", tree); if (strlen(suffix)) { if (gSystem->Exec(Form("mv trending.root trending%s.root", suffix))) ::Error("QAmerge", "File trending.root was not produced"); if (gSystem->Exec(Form("mv event_stat.root event_stat%s.root", suffix))) ::Error("QAmerge", "File trending.root was not produced"); } ofstream out; out.open("outputs_valid", ios::out); out.close(); timer.Print(); }
void QAtrain(Int_t run = 0, const char *xmlfile = "wn.xml", Int_t stage = 0) /*0 = QA train, 1...n - merging stage*/ { run_number = run; TGrid::Connect("alien://"); if (!gGrid || !gGrid->IsConnected()) { ::Error("QAtrain", "No grid connection"); return; } // Set temporary merging directory to current one gSystem->Setenv("TMPDIR", gSystem->pwd()); // Set temporary compilation directory to current one gSystem->SetBuildDir(gSystem->pwd(), kTRUE); // Load libraries LoadLibraries(); printf("Include path: %s\n", gSystem->GetIncludePath()); // Create manager IlcAnalysisManager *mgr = new IlcAnalysisManager("PilotAnalysis_sim", "Production train"); mgr->SetRunFromPath(run_number); // Input handler IlcESDInputHandlerRP *esdHandler = new IlcESDInputHandlerRP(); esdHandler->SetReadFriends(kTRUE); esdHandler->SetActiveBranches("ESDfriend"); mgr->SetInputEventHandler(esdHandler); mgr->SetDebugLevel(debug_level); // Monte Carlo handler IlcMCEventHandler* mcHandler = new IlcMCEventHandler(); mgr->SetMCtruthEventHandler(mcHandler); mcHandler->SetPreReadMode(1); mcHandler->SetReadTR(kTRUE); // AnalysisTasks AddAnalysisTasks(); if (stage>0) { QAmerge(xmlfile, stage); return; } // Input chain TChain *chain = new TChain("esdTree"); chain->Add("IlcESDs.root"); TStopwatch timer; timer.Start(); if (mgr->InitAnalysis()) { mgr->PrintStatus(); mgr->SetSkipTerminate(kTRUE); // mgr->SetNSysInfo(1); mgr->StartAnalysis("local", chain); } timer.Print(); }
void DphiAnalysis() { gSystem->Load("libTree.so"); gSystem->Load("libPhysics.so"); gSystem->Load("libGeom.so"); gSystem->Load("libVMC.so"); gSystem->Load("libANALYSIS.so"); gSystem->Load("libSTEERBase.so"); gSystem->Load("libAOD.so"); gSystem->Load("libESD.so"); gSystem->Load("libANALYSISilc.so"); // if (gApplication) gApplication->InitializeGraphics(); // Create the chain // //TString path("/afs/cern.ch/user/m/morsch/public/"); TString path("./"); TChain* chain = new TChain("aodTree"); chain->Add(Form("%s/%s",path.Data(),"IlcAOD.root")); /////////////////////////////////////////////////////////////////////////////////// // Create the analysis manager // // Input IlcMultiEventInputHandler* inpHandler = new IlcMultiEventInputHandler(2, 1); // Pool IlcEventPoolOTF* pool = new IlcEventPoolOTF("event pool", "AOD"); pool->SetTagDirectory(path.Data()); pool->SetMultiplicityBin(0, 100, 100); pool->Init(); IlcAnalysisManager *mgr = new IlcAnalysisManager("Jet Manager", "Jet Manager"); mgr->SetInputEventHandler (inpHandler); mgr->SetEventPool(pool); inpHandler->SetEventPool(pool); mgr->SetDebugLevel(10); /////////////////////////////////////////////////////////////////////////////////// gROOT->LoadMacro("IlcAnalysisTaskPhiCorr.cxx++g"); IlcAnalysisTaskPhiCorr *dphiana = new IlcAnalysisTaskPhiCorr("Phi Correlation Analysis"); dphiana->SetDebugLevel(10); mgr->AddTask(dphiana); // // Create containers for input/output IlcAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(), IlcAnalysisManager::kInputContainer); IlcAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(), IlcAnalysisManager::kExchangeContainer, "default"); IlcAnalysisDataContainer *coutput2 = mgr->CreateContainer("histos", TList::Class(), IlcAnalysisManager::kOutputContainer, "histos.root"); mgr->ConnectInput (dphiana, 0, mgr->GetCommonInputContainer()); mgr->ConnectOutput (dphiana, 0, coutput1 ); mgr->ConnectOutput (dphiana, 1, coutput2 ); // // Run the analysis // mgr->InitAnalysis(); mgr->PrintStatus(); mgr->StartAnalysis("mix",chain, 1000); }
void runCentralitySelection(const char *mode="local") { // Load common libraries gSystem->Load("libCore.so"); gSystem->Load("libTree.so"); gSystem->Load("libGeom.so"); gSystem->Load("libVMC.so"); gSystem->Load("libPhysics.so"); gSystem->Load("libSTEERBase"); gSystem->Load("libESD"); gSystem->Load("libAOD"); gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISilc"); gSystem->Load("libCORRFW"); gSystem->Load("libPWGHFbase"); gSystem->Load("libPWGmuon"); // Use IlcRoot includes to compile our task gROOT->ProcessLine(".include $ILC_ROOT/include"); // filename TChain* chain = new TChain("esdTree"); chain->AddFile("/home/alberica/analysis/centrality/data/ilc/sim/LHC10a12/104157/998/root_archive.zip#IlcESDs.root"); // Create the analysis manager IlcAnalysisManager *mgr = new IlcAnalysisManager("AnalysisManager"); mgr->SetDebugLevel(10); // My task gROOT->LoadMacro("IlcCentralitySelectionTask.cxx++g"); IlcCentralitySelectionTask *task = new IlcCentralitySelectionTask("CentralitySelection"); task->SetPercentileFile("test_IlcCentralityBy1D.root"); task->SetCentralityMethod("V0"); mgr->AddTask(task); // My dummy task gROOT->LoadMacro("IlcDummy.cxx++g"); IlcDummy *dummytask = new IlcDummy("Dummy"); mgr->AddTask(dummytask); IlcMCEventHandler* mcHandler = new IlcMCEventHandler(); mgr->SetMCtruthEventHandler(mcHandler); IlcESDInputHandler* esdH = new IlcESDInputHandler(); mgr->SetInputEventHandler(esdH); // Create containers for input/output mgr->ConnectInput (task,0, mgr->GetCommonInputContainer()); mgr->ConnectInput (dummytask,0, mgr->GetCommonInputContainer()); // mgr->ConnectOutput(task,0, mgr->GetCommonOutputContainer()); // Enable debug printouts mgr->SetDebugLevel(2); if(!mgr->InitAnalysis()) return; mgr->PrintStatus(); // Start analysis in grid. mgr->StartAnalysis(mode, chain); };
void JetAnalysisManagerKine() { gSystem->Load("libTree.so"); gSystem->Load("libPhysics.so"); gSystem->Load("libGeom.so"); gSystem->Load("libVMC.so"); gSystem->Load("libANALYSIS.so"); gSystem->Load("libSTEERBase.so"); gSystem->Load("libAOD.so"); gSystem->Load("libESD.so"); gSystem->Load("libANALYSISilc.so"); gSystem->Load("libJETAN.so"); // if (gApplication) gApplication->InitializeGraphics(); // Create the chain // gROOT->LoadMacro("CreateESDChain.C"); TChain* chain = new TChain("TE"); chain->Add("/Users/kleinb/ilc/sim/PDC_08/LHC08v/280039/999/gilc.root"); /////////////////////////////////////////////////////////////////////////////////// // Create the analysis manager // // Output IlcAODHandler* aodHandler = new IlcAODHandler(); aodHandler->SetOutputFileName("aod.root"); // MC Truth IlcMCEventHandler* mcHandler = new IlcMCEventHandler(); IlcAnalysisManager *mgr = new IlcAnalysisManager("Jet Manager", "Jet Manager"); mgr->SetOutputEventHandler (aodHandler); mgr->SetMCtruthEventHandler(mcHandler); mgr->SetDebugLevel(10); IlcAnalysisTaskKineFilter *kinefilter = new IlcAnalysisTaskKineFilter("Kine Filter"); mgr->AddTask(kinefilter); IlcAnalysisTaskJets *jetana = new IlcAnalysisTaskJets("JetAnalysis"); jetana->SetConfigFile("ConfigJetAnalysisMC.C"); jetana->SetDebugLevel(10); mgr->AddTask(jetana); // // Create containers for input/output IlcAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(), IlcAnalysisManager::kInputContainer); IlcAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(), IlcAnalysisManager::kOutputContainer, "default"); IlcAnalysisDataContainer *coutput2 = mgr->CreateContainer("histos", TList::Class(), IlcAnalysisManager::kOutputContainer, "histos.root"); mgr->ConnectInput (kinefilter, 0, cinput1 ); mgr->ConnectOutput (kinefilter, 0, coutput1 ); mgr->ConnectInput (jetana, 0, cinput1 ); mgr->ConnectOutput (jetana, 0, coutput1 ); mgr->ConnectOutput (jetana, 1, coutput2 ); // // Run the analysis // mgr->InitAnalysis(); mgr->PrintStatus(); mgr->StartAnalysis("local",chain); }
//______________________________________________________________________________ void AODtrain(Int_t merge=0) { // Main analysis train macro. if (merge) { TGrid::Connect("alien://"); if (!gGrid || !gGrid->IsConnected()) { ::Error("QAtrain", "No grid connection"); return; } } // Set temporary merging directory to current one gSystem->Setenv("TMPDIR", gSystem->pwd()); // Set temporary compilation directory to current one gSystem->SetBuildDir(gSystem->pwd(), kTRUE); printf("==================================================================\n"); printf("=========== RUNNING FILTERING TRAIN ==========\n"); printf("==================================================================\n"); printf("= Configuring analysis train for: =\n"); if (usePhysicsSelection) printf("= Physics selection =\n"); if (useTender) printf("= TENDER =\n"); if (iESDfilter) printf("= ESD filter =\n"); if (iMUONcopyAOD) printf("= MUON copy AOD =\n"); if (iJETAN) printf("= Jet analysis =\n"); if (iJETANdelta) printf("= Jet delta AODs =\n"); if (iPWGHFvertexing) printf("= PWGHF vertexing =\n"); if (iPWGDQJPSIfilter) printf("= PWGDQ j/psi filter =\n"); if (iPWGHFd2h) printf("= PWGHF D0->2 hadrons QA =\n"); // Load common libraries and set include path if (!LoadCommonLibraries()) { ::Error("AnalysisTrain", "Could not load common libraries"); return; } // Make the analysis manager and connect event handlers IlcAnalysisManager *mgr = new IlcAnalysisManager("Analysis Train", "Production train"); if (useSysInfo) mgr->SetNSysInfo(100); // Load analysis specific libraries if (!LoadAnalysisLibraries()) { ::Error("AnalysisTrain", "Could not load analysis libraries"); return; } // Create input handler (input container created automatically) // ESD input handler IlcESDInputHandler *esdHandler = new IlcESDInputHandler(); mgr->SetInputEventHandler(esdHandler); // Monte Carlo handler if (useMC) { IlcMCEventHandler* mcHandler = new IlcMCEventHandler(); mgr->SetMCtruthEventHandler(mcHandler); mcHandler->SetReadTR(useTR); } // AOD output container, created automatically when setting an AOD handler if (iAODhandler) { // AOD output handler IlcAODHandler* aodHandler = new IlcAODHandler(); aodHandler->SetOutputFileName("IlcAOD.root"); mgr->SetOutputEventHandler(aodHandler); } // Debugging if needed if (useDBG) mgr->SetDebugLevel(3); AddAnalysisTasks(); if (merge) { AODmerge(); mgr->InitAnalysis(); mgr->SetGridHandler(new IlcAnalysisAlien); mgr->StartAnalysis("gridterminate",0); return; } // Run the analysis // TChain *chain = CreateChain(); if (!chain) return; TStopwatch timer; timer.Start(); mgr->SetSkipTerminate(kTRUE); if (mgr->InitAnalysis()) { mgr->PrintStatus(); mgr->StartAnalysis("local", chain); } timer.Print(); }