]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/RunManager.C
Improved eloss fitting - see NIM B1, 16
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / RunManager.C
CommitLineData
7e4038b5 1/**
c389303e 2 * Flags for the analysis
3 *
4 * @ingroup pwg2_forward_analysis_scripts
5 */
6enum {
7 kMC = 0x01, // MC input
8 kProof = 0x02, // Run in proof mode
9 kFull = 0x04, // Do full analysis - including terminate
10 kAnalyse = 0x08, // Run the analysis
11 kTerminate = 0x10 // Run only terminate
12};
13
14/**
15 * Run first pass of the analysis - that is read in ESD and produce AOD
16 *
17 * @param esddir ESD input directory. Any file matching the pattern
18 * *AliESDs*.root are added to the chain
19 * @param nEvents Number of events to process. If 0 or less, then
20 * all events are analysed
21 * @param flags Job flags. A bit mask of
22 * - 0x01 (MC) Monte-Carlo truth handler installed
23 * - 0x02 (PROOF) Proof mode
24 * - 0x04 (FULL) Run full analysis - including terminate
25 * - 0x08 (ANALYSE) Run only analysis - not terminate
26 * - 0x10 (TERMINATE) Run no analysis - just terminate.
27 *
28 * of these, PROOF, FULL, ANALYSE, and TERMINATE are mutually exclusive.
29 *
30 * If PROOF mode is selected, then Terminate will be run on the master node
31 * in any case.
32 *
33 * If FULL is selected, then the full analysis is done. Note that
34 * this can be combined with PROOF but with no effect.
35 *
36 * ANALYSE cannot be combined with FULL, PROOF, or TERMINATE. In a
37 * local job, the output AnalysisResults.root will still be made, but
38 * terminate is not called.
39 *
40 * In TERMINATE, the file AnalysisResults.root is opened and all
41 * containers found are connected to the tasks. The terminate member
42 * function is then called
7e4038b5 43 *
7e4038b5 44 *
45 * @ingroup pwg2_forward_analysis_scripts
46 */
c389303e 47void RunManager(const char* esddir,
48 Int_t nEvents=1000,
49 UShort_t flags=kFull)
7e4038b5 50{
da60d315 51 // --- Libraries to load -------------------------------------------
7e4038b5 52 gSystem->Load("libVMC");
53 gSystem->Load("libTree");
54
55 gSystem->Load("libSTEERBase");
56
57 gSystem->Load("libESD") ;
58 gSystem->Load("libAOD") ;
59 gSystem->Load("libANALYSIS");
60 gSystem->Load("libANALYSISalice");
61
62 gSystem->Load("libPhysics");
63 gSystem->Load("libPWG0base");
64 gSystem->Load("libPWG0dep");
65 gSystem->Load("libPWG2forward");
66 gSystem->Load("libPWG2forward2");
2d68d438 67
da60d315 68 // --- Check for proof mode, and possibly upload pars --------------
c389303e 69 if (flags & kProof) {
fea27ee0 70 TProof::Open("workers=2");
2d68d438 71 const char* pkgs[] = { "STEERBase", "ESD", "AOD", "ANALYSIS",
72 "ANALYSISalice", "PWG2forward", "PWG2forward2", 0};
73 const char** pkg = pkgs;
74 while (*pkg) {
75 gProof->UploadPackage(Form("${ALICE_ROOT}/%s.par",*pkg));
76 gProof->EnablePackage(*pkg);
77 pkg++;
78 }
2d68d438 79 }
7e4038b5 80
da60d315 81 // --- Our data chain ----------------------------------------------
7e4038b5 82 TChain* chain = new TChain("esdTree");
da60d315 83
84 // --- Get list of ESDs --------------------------------------------
85 // Open source directory, and make sure we go back to were we were
86 TString oldDir(gSystem->WorkingDirectory());
87 TSystemDirectory d(esddir, esddir);
88 TList* files = d.GetListOfFiles();
89 gSystem->ChangeDirectory(oldDir);
90
91 // Sort list of files and check if we should add it
92 files->Sort();
93 TIter next(files);
94 TSystemFile* file = 0;
95 while ((file = static_cast<TSystemFile*>(next()))) {
96 if (file->IsDirectory()) continue;
97 TString name(file->GetName());
98 if (!name.EndsWith(".root")) continue;
99 if (!name.Contains("AliESDs")) continue;
100 TString esd(Form("%s/%s", file->GetTitle(), name.Data()));
101 Info("RunManager", "Adding %s to chain", esd.Data());
102 chain->Add(esd);
103 }
c389303e 104 // If 0 or less events is select, choose all
105 if (nEvents <= 0) nEvents = chain->GetEntries();
106
da60d315 107
108 // --- Creating the manager and handlers ---------------------------
7e4038b5 109 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train",
110 "FMD analysis train");
fea27ee0 111
7e4038b5 112 AliESDInputHandler *esdHandler = new AliESDInputHandler();
113 esdHandler->SetInactiveBranches("AliESDACORDE "
114 "AliRawDataErrorLogs "
115 "CaloClusters "
116 "Cascades "
117 "EMCALCells "
118 "EMCALTrigger "
119 "Kinks "
120 "Cascades "
121 "MuonTracks "
122 "TrdTracks "
2d68d438 123 "CaloClusters "
124 "HLTGlobalTrigger");
7e4038b5 125 mgr->SetInputEventHandler(esdHandler);
126
7e4038b5 127 // Monte Carlo handler
c389303e 128 if (flags & kMC) {
129 AliMCEventHandler* mcHandler = new AliMCEventHandler();
130 mgr->SetMCtruthEventHandler(mcHandler);
131 mcHandler->SetReadTR(readTR);
132 }
7e4038b5 133
134 // AOD output handler
135 AliAODHandler* aodHandler = new AliAODHandler();
136 mgr->SetOutputEventHandler(aodHandler);
fea27ee0 137 aodHandler->SetOutputFileName("AliAODs.root");
da60d315 138
139 // --- Add tasks ---------------------------------------------------
7e4038b5 140 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMD.C");
141 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
c389303e 142 AliAnalysisTask* task = AddTaskFMD();
2d68d438 143 mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
144
c389303e 145 task = AddTaskPhysicsSelection((flags & kMC), kTRUE, kTRUE);
2d68d438 146 mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
7e4038b5 147
da60d315 148 // --- Run the analysis --------------------------------------------
7e4038b5 149 TStopwatch t;
9d99b0dd 150 if (!mgr->InitAnalysis()) {
151 Error("RunManager", "Failed to initialize analysis train!");
152 return;
153 }
c389303e 154 // Skip terminate if we're so requested and not in Proof or full mode
155 mgr->SetSkipTerminate(!(flags & kProof) &&
156 !(flags & kFull) &&
157 (flags & kAnalyse));
9d99b0dd 158 // Some informative output
159 mgr->PrintStatus();
da60d315 160 // mgr->SetDebugLevel(3);
c389303e 161 if (mgr->GetDebugLevel() < 1 && !(flags & kProof))
da60d315 162 mgr->SetUseProgressBar(kTRUE);
2d68d438 163
9d99b0dd 164 // Run the train
165 t.Start();
c389303e 166 if (!(flags & kTerminate))
167 mgr->StartAnalysis((flags & kProof) ? "proof" : "local", chain, nEvents);
168 else {
169 mgr->ImportWrappers();
170 mgr->Terminate();
171 }
9d99b0dd 172 t.Stop();
173 t.Print();
7e4038b5 174}
175//
176// EOF
177//