]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/MakeAOD.C
small fix to the merging efficiency on or off
[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=1000, 
25              Bool_t      proof=false,
26              Bool_t      mc=false)
27 {
28   // --- Libraries to load -------------------------------------------
29   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
30
31   // --- Check for proof mode, and possibly upload pars --------------
32   if (proof) 
33     gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
34   
35   // --- Our data chain ----------------------------------------------
36   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeESDChain.C");
37   TChain* chain = MakeESDChain(esddir,mc);
38   // If 0 or less events is select, choose all 
39   if (nEvents <= 0) nEvents = chain->GetEntries();
40
41   // --- Creating the manager and handlers ---------------------------
42   AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", 
43                                                     "FMD analysis train");
44
45   // --- ESD input handler -------------------------------------------
46   AliESDInputHandler *esdHandler = new AliESDInputHandler();
47   esdHandler->SetInactiveBranches("AliESDACORDE "
48                                   "AliRawDataErrorLogs "
49                                   "CaloClusters "
50                                   "Cascades "
51                                   "EMCALCells "
52                                   "EMCALTrigger "
53                                   "Kinks "
54                                   "Cascades "
55                                   "MuonTracks "
56                                   "TrdTracks "
57                                   "CaloClusters "
58                                   "HLTGlobalTrigger");
59   mgr->SetInputEventHandler(esdHandler);      
60        
61   // --- Monte Carlo handler -----------------------------------------
62   if (mc) {
63     AliMCEventHandler* mcHandler = new AliMCEventHandler();
64     mgr->SetMCtruthEventHandler(mcHandler);
65     mcHandler->SetReadTR(true);    
66   }
67
68   // --- AOD output handler ------------------------------------------
69   AliAODHandler* aodHandler   = new AliAODHandler();
70   mgr->SetOutputEventHandler(aodHandler);
71   aodHandler->SetOutputFileName("AliAODs.root");
72
73   // --- Add tasks ---------------------------------------------------
74   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMD.C");
75   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
76   AddTaskFMD(mc);
77   AddTaskPhysicsSelection(mc, kTRUE, kTRUE);
78   
79   // --- Run the analysis --------------------------------------------
80   TStopwatch t;
81   if (!mgr->InitAnalysis()) {
82     Error("MakeAOD", "Failed to initialize analysis train!");
83     return;
84   }
85   // Skip terminate if we're so requested and not in Proof or full mode
86   mgr->SetSkipTerminate(false);
87   // Some informative output 
88   mgr->PrintStatus();
89   // mgr->SetDebugLevel(3);
90   if (mgr->GetDebugLevel() < 1 && !proof) 
91     mgr->SetUseProgressBar(kTRUE);
92
93   // Run the train 
94   t.Start();
95   Printf("=== RUNNING ANALYSIS ==================================");
96   mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);
97   t.Stop();
98   t.Print();
99 }
100 //
101 // EOF
102 //