f251c08b86ca80093fed42db9f1833a2c8c0647c
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeAOD.C
1 /**
2  * @file 
3  * 
4  * @ingroup pwg2_forward_scripts
5  */
6
7 /** 
8  * Run first pass of the analysis - that is read in ESD and produce AOD
9  * 
10  * @param esddir    ESD input directory. Any file matching the pattern 
11  *                  *AliESDs*.root are added to the chain 
12  * @param nEvents   Number of events to process.  If 0 or less, then 
13  *                  all events are analysed
14  * @param proof     Run in proof mode 
15  * @param mc        Run over MC data
16  *
17  * If PROOF mode is selected, then Terminate will be run on the master node 
18  * in any case. 
19  * 
20  *
21  * @ingroup pwg2_forward_scripts
22  */
23 void MakeAOD(const char* esddir, 
24              Int_t       nEvents=-1, 
25              Int_t       proof=0,
26              Bool_t      mc=false,
27              Bool_t      centrality=true )
28 {
29   // --- Libraries to load -------------------------------------------
30   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
31
32   // --- Check for proof mode, and possibly upload pars --------------
33   if (proof> 0) { 
34     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
35     if (!LoadPars(proof)) { 
36       Error("MakeAOD", "Failed to load PARs");
37       return;
38     }
39   }
40   
41   // --- Our data chain ----------------------------------------------
42   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
43   TChain* chain = MakeChain("ESD", esddir,true);
44   // If 0 or less events is select, choose all 
45   if (nEvents <= 0) nEvents = chain->GetEntries();
46   
47   // --- Set the macro path ------------------------------------------
48   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
49                            "$ALICE_ROOT/ANALYSIS/macros",
50                            gROOT->GetMacroPath()));
51
52   // --- Creating the manager and handlers ---------------------------
53   AliAnalysisManager *mgr  = new AliAnalysisManager("Forward Train", 
54                                                     "Forward multiplicity");
55   AliAnalysisManager::SetCommonFileName("forward.root");
56
57   // --- ESD input handler -------------------------------------------
58   AliESDInputHandler *esdHandler = new AliESDInputHandler();
59   esdHandler->SetInactiveBranches(// "AliESDRun " 
60                                   // "AliESDHeader "
61                                   // "AliESDZDC "
62                                   // "AliESDFMD "
63                                   // "AliESDVZERO " 
64                                   "AliESDTZERO " 
65                                   "TPCVertex " 
66                                   // "SPDVertex "
67                                   // "PrimaryVertex "
68                                   // "AliMultiplicity "
69                                   "PHOSTrigger "
70                                   "EMCALTrigger "
71                                   "SPDPileupVertices " 
72                                   "TrkPileupVertices " 
73                                   // "Tracks "
74                                   "MuonTracks " 
75                                   "PmdTracks "
76                                   "TrdTracks "
77                                   "V0s " 
78                                   "Cascades " 
79                                   "Kinks " 
80                                   "CaloClusters "
81                                   "EMCALLCells "
82                                   "PHOSCells "
83                                   "AliRawDataErrorLogs "
84                                   "ALIESDCACORDE " 
85                                   "HLTGlobalTrigger");
86   mgr->SetInputEventHandler(esdHandler);      
87        
88   // --- Monte Carlo handler -----------------------------------------
89   if (mc) {
90     AliMCEventHandler* mcHandler = new AliMCEventHandler();
91     mgr->SetMCtruthEventHandler(mcHandler);
92     mcHandler->SetReadTR(true);    
93   }
94
95   // --- AOD output handler ------------------------------------------
96   AliAODHandler* aodHandler   = new AliAODHandler();
97   mgr->SetOutputEventHandler(aodHandler);
98   aodHandler->SetOutputFileName("AliAOD.root");
99
100   // --- Add tasks ---------------------------------------------------
101   // Physics selection 
102   gROOT->LoadMacro("AddTaskPhysicsSelection.C");
103   // test HHD
104   AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
105
106 #if 0
107   // Centrality 
108   if (!proof) {
109     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/Compile.C");
110     Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCopyHeader.C","");
111     AddTaskCopyHeader();
112   }
113 #endif
114   if(centrality) {
115     gROOT->LoadMacro("AddTaskCentrality.C");
116     AddTaskCentrality();
117   }
118   // FMD 
119   gROOT->LoadMacro("AddTaskFMD.C");
120   AddTaskFMD(mc);
121
122   // Central 
123   gROOT->LoadMacro("AddTaskCentral.C");
124   AddTaskCentral();
125   
126   // --- Run the analysis --------------------------------------------
127   TStopwatch t;
128   if (!mgr->InitAnalysis()) {
129     Error("MakeAOD", "Failed to initialize analysis train!");
130     return;
131   }
132   // Skip terminate if we're so requested and not in Proof or full mode
133   mgr->SetSkipTerminate(false);
134   // Some informative output 
135   mgr->PrintStatus();
136   // mgr->SetDebugLevel(3);
137   if (mgr->GetDebugLevel() < 1 && !proof) 
138     mgr->SetUseProgressBar(kTRUE,100);
139
140   // Run the train 
141   t.Start();
142   Printf("=== RUNNING ANALYSIS on %9d events ==========================",
143          nEvents);
144   mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);
145   t.Stop();
146   t.Print();
147 }
148 //
149 // EOF
150 //