]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/RunManager.C
Doc fixes
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / RunManager.C
CommitLineData
7c1a1f1d 1/**
2 * @file
3 *
4 * @ingroup pwg2_forward_scripts
5 */
7e4038b5 6/**
c389303e 7 * Flags for the analysis
8 *
7c1a1f1d 9 * @ingroup pwg2_forward_scripts
c389303e 10 */
11enum {
12 kMC = 0x01, // MC input
13 kProof = 0x02, // Run in proof mode
14 kFull = 0x04, // Do full analysis - including terminate
15 kAnalyse = 0x08, // Run the analysis
16 kTerminate = 0x10 // Run only terminate
17};
18
19/**
20 * Run first pass of the analysis - that is read in ESD and produce AOD
21 *
22 * @param esddir ESD input directory. Any file matching the pattern
23 * *AliESDs*.root are added to the chain
24 * @param nEvents Number of events to process. If 0 or less, then
25 * all events are analysed
26 * @param flags Job flags. A bit mask of
27 * - 0x01 (MC) Monte-Carlo truth handler installed
28 * - 0x02 (PROOF) Proof mode
29 * - 0x04 (FULL) Run full analysis - including terminate
30 * - 0x08 (ANALYSE) Run only analysis - not terminate
31 * - 0x10 (TERMINATE) Run no analysis - just terminate.
32 *
33 * of these, PROOF, FULL, ANALYSE, and TERMINATE are mutually exclusive.
34 *
35 * If PROOF mode is selected, then Terminate will be run on the master node
36 * in any case.
37 *
38 * If FULL is selected, then the full analysis is done. Note that
39 * this can be combined with PROOF but with no effect.
40 *
41 * ANALYSE cannot be combined with FULL, PROOF, or TERMINATE. In a
42 * local job, the output AnalysisResults.root will still be made, but
43 * terminate is not called.
44 *
45 * In TERMINATE, the file AnalysisResults.root is opened and all
46 * containers found are connected to the tasks. The terminate member
47 * function is then called
7e4038b5 48 *
7e4038b5 49 *
7c1a1f1d 50 * @ingroup pwg2_forward_scripts
7e4038b5 51 */
c389303e 52void RunManager(const char* esddir,
53 Int_t nEvents=1000,
54 UShort_t flags=kFull)
7e4038b5 55{
da60d315 56 // --- Libraries to load -------------------------------------------
0bd4b00f 57 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
2d68d438 58
da60d315 59 // --- Check for proof mode, and possibly upload pars --------------
0bd4b00f 60 if (flags & kProof)
61 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
7e4038b5 62
da60d315 63 // --- Our data chain ----------------------------------------------
0bd4b00f 64 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeESDChain.C");
65 TChain* chain = MakeESDChain(esddir);
c389303e 66 // If 0 or less events is select, choose all
67 if (nEvents <= 0) nEvents = chain->GetEntries();
da60d315 68
69 // --- Creating the manager and handlers ---------------------------
7e4038b5 70 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train",
71 "FMD analysis train");
fea27ee0 72
7e4038b5 73 AliESDInputHandler *esdHandler = new AliESDInputHandler();
74 esdHandler->SetInactiveBranches("AliESDACORDE "
75 "AliRawDataErrorLogs "
76 "CaloClusters "
77 "Cascades "
78 "EMCALCells "
79 "EMCALTrigger "
80 "Kinks "
81 "Cascades "
82 "MuonTracks "
83 "TrdTracks "
2d68d438 84 "CaloClusters "
85 "HLTGlobalTrigger");
7e4038b5 86 mgr->SetInputEventHandler(esdHandler);
87
7e4038b5 88 // Monte Carlo handler
c389303e 89 if (flags & kMC) {
90 AliMCEventHandler* mcHandler = new AliMCEventHandler();
91 mgr->SetMCtruthEventHandler(mcHandler);
92 mcHandler->SetReadTR(readTR);
93 }
7e4038b5 94
95 // AOD output handler
96 AliAODHandler* aodHandler = new AliAODHandler();
97 mgr->SetOutputEventHandler(aodHandler);
fea27ee0 98 aodHandler->SetOutputFileName("AliAODs.root");
da60d315 99
100 // --- Add tasks ---------------------------------------------------
7e4038b5 101 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMD.C");
102 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
c389303e 103 AliAnalysisTask* task = AddTaskFMD();
0bd4b00f 104 // mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
2d68d438 105
c389303e 106 task = AddTaskPhysicsSelection((flags & kMC), kTRUE, kTRUE);
0bd4b00f 107 // mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
7e4038b5 108
da60d315 109 // --- Run the analysis --------------------------------------------
7e4038b5 110 TStopwatch t;
9d99b0dd 111 if (!mgr->InitAnalysis()) {
112 Error("RunManager", "Failed to initialize analysis train!");
113 return;
114 }
c389303e 115 // Skip terminate if we're so requested and not in Proof or full mode
116 mgr->SetSkipTerminate(!(flags & kProof) &&
117 !(flags & kFull) &&
118 (flags & kAnalyse));
9d99b0dd 119 // Some informative output
120 mgr->PrintStatus();
da60d315 121 // mgr->SetDebugLevel(3);
c389303e 122 if (mgr->GetDebugLevel() < 1 && !(flags & kProof))
da60d315 123 mgr->SetUseProgressBar(kTRUE);
2d68d438 124
9d99b0dd 125 // Run the train
126 t.Start();
0bd4b00f 127 if (!(flags & kTerminate)) {
128 Printf("=== RUNNING ANALYSIS ==================================");
c389303e 129 mgr->StartAnalysis((flags & kProof) ? "proof" : "local", chain, nEvents);
0bd4b00f 130 }
c389303e 131 else {
0bd4b00f 132 Printf("=== RUNNING TERMINATE =================================");
133 // mgr->ImportWrappers(0);
c389303e 134 mgr->Terminate();
135 }
9d99b0dd 136 t.Stop();
137 t.Print();
7e4038b5 138}
139//
140// EOF
141//