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 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(); }