]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/MakeAOD.C
Enable use iof GDB in PROOF sessions, and some updates to QA scripts
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeAOD.C
CommitLineData
ffca499d 1/**
2 * @defgroup pwg2_forward_scripts_makers Maker scripts
3 * @ingroup pwg2_forward_scripts
4 */
56236b95 5//====================================================================
7c1a1f1d 6/**
ffca499d 7 * @file MakeAOD.C
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 09:40:10 2011
7c1a1f1d 10 *
ffca499d 11 * @brief Run first pass of the analysis - AOD generation
12 *
13 * @ingroup pwg2_forward_scripts_makers
7c1a1f1d 14 */
56236b95 15//====================================================================
c389303e 16/**
17 * Run first pass of the analysis - that is read in ESD and produce AOD
18 *
0be6c8cd 19 * If the ROOT AliEn interface library (libRAliEn) can be loaded,
20 * and the parameter @a name is not empty, then use the plugin to do
21 * the analysis. Note that in this case, the output is placed
22 * in a sub-directory named by @a name after escaping spaces and special
23 * characters
24 *
25 * If PROOF mode is selected, then Terminate will be run on the master node
26 * in any case.
27 *
ffca499d 28 * @param esddir ESD input directory. Any file matching the pattern
29 * *AliESDs*.root are added to the chain
30 * @param nEvents Number of events to process. If 0 or less, then
31 * all events are analysed
32 * @param proof If larger then 1, run in PROOF-Lite mode with this
33 * many number of workers.
34 * @param mc Data is assumed to be from simulations
35 * @param centrality Whether to use centrality or not
0be6c8cd 36 * @param name Name of train - free form. This will be the name
37 * of the output directory if the plug-in is used
7e4038b5 38 *
ffca499d 39 * @ingroup pwg2_forward_aod
7e4038b5 40 */
0171f148 41void MakeAOD(const char* esddir,
0be6c8cd 42 Int_t nEvents = -1,
43 Int_t proof = 0,
44 Bool_t mc = false,
45 Bool_t centrality = true,
871a9ac1 46 const char* name = 0,
47 bool debug = false)
7e4038b5 48{
0be6c8cd 49 // --- Possibly use plug-in for this -------------------------------
50 if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
56236b95 51 const char* builder =
52 "$(ALICE_ROOT)/PWG2/FORWARD/analysis2/trains/BuildTrain.C"
53 gROOT->LoadMacro(builder);
54
55 BuildTrain("MakeAODTrain");
56
0be6c8cd 57 MakeAODTrain t(name, 0, 0, 0, centrality, false);
58 t.SetDataDir(esddir);
59 t.SetDataSet("");
60 t.SetProofServer(Form("workers=%d",proof));
871a9ac1 61 t.SetUseGDB(debug);
0be6c8cd 62 t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
63 return;
64 }
65
da60d315 66 // --- Libraries to load -------------------------------------------
0bd4b00f 67 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
2d68d438 68
da60d315 69 // --- Check for proof mode, and possibly upload pars --------------
1174780f 70 if (proof> 0) {
71 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
01caf91f 72 if (!LoadPars(proof)) {
73 Error("MakeAOD", "Failed to load PARs");
74 return;
75 }
1174780f 76 }
7e4038b5 77
da60d315 78 // --- Our data chain ----------------------------------------------
b2e7f2d6 79 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
80 TChain* chain = MakeChain("ESD", esddir,true);
c389303e 81 // If 0 or less events is select, choose all
82 if (nEvents <= 0) nEvents = chain->GetEntries();
e1f47419 83
84 // --- Set the macro path ------------------------------------------
85 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
86 "$ALICE_ROOT/ANALYSIS/macros",
87 gROOT->GetMacroPath()));
da60d315 88
89 // --- Creating the manager and handlers ---------------------------
9453b19e 90 AliAnalysisManager *mgr = new AliAnalysisManager(name,
91 "Forward multiplicity");
0f84fefb 92 AliAnalysisManager::SetCommonFileName("forward.root");
fea27ee0 93
0171f148 94 // --- ESD input handler -------------------------------------------
7e4038b5 95 AliESDInputHandler *esdHandler = new AliESDInputHandler();
7e4038b5 96 mgr->SetInputEventHandler(esdHandler);
97
0171f148 98 // --- Monte Carlo handler -----------------------------------------
99 if (mc) {
c389303e 100 AliMCEventHandler* mcHandler = new AliMCEventHandler();
101 mgr->SetMCtruthEventHandler(mcHandler);
0171f148 102 mcHandler->SetReadTR(true);
c389303e 103 }
0171f148 104
105 // --- AOD output handler ------------------------------------------
7e4038b5 106 AliAODHandler* aodHandler = new AliAODHandler();
107 mgr->SetOutputEventHandler(aodHandler);
e308a636 108 aodHandler->SetNeedsHeaderReplication();
9d05ffeb 109 aodHandler->SetOutputFileName("AliAOD.root");
da60d315 110
111 // --- Add tasks ---------------------------------------------------
1174780f 112 // Physics selection
e1f47419 113 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
ffca499d 114 AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
0be6c8cd 115 // --- Fix up physics selection to give proper A,C, and E triggers -
116 AliInputEventHandler* ih =
117 static_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
118 AliPhysicsSelection* ps =
119 static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
120 // Ignore trigger class when selecting events. This mean that we
121 // get offline+(A,C,E) events too
f7cfc454 122 // ps->SetSkipTriggerClassSelection(true);
0be6c8cd 123
1174780f 124 // Centrality
e28f5fc5 125 if(centrality) {
e1f47419 126 gROOT->LoadMacro("AddTaskCentrality.C");
f2171361 127 AliCentralitySelectionTask* centTask = AddTaskCentrality();
128 centTask->SetPass(1);
962863eb 129 if(mc)centTask->SetMCInput();
e28f5fc5 130 }
962863eb 131
132 // Copy header information
133 gROOT->LoadMacro("AddTaskCopyHeader.C");
134 AddTaskCopyHeader();
135
1174780f 136 // FMD
ffca499d 137 gROOT->LoadMacro("AddTaskForwardMult.C");
138 AddTaskForwardMult(mc);
1174780f 139
1f52daed 140 // Central
0be6c8cd 141 gROOT->LoadMacro("AddTaskCentralMult.C");
8e400b14 142 AddTaskCentralMult(mc);
7e4038b5 143
da60d315 144 // --- Run the analysis --------------------------------------------
7e4038b5 145 TStopwatch t;
9d99b0dd 146 if (!mgr->InitAnalysis()) {
0171f148 147 Error("MakeAOD", "Failed to initialize analysis train!");
9d99b0dd 148 return;
149 }
c389303e 150 // Skip terminate if we're so requested and not in Proof or full mode
0171f148 151 mgr->SetSkipTerminate(false);
9d99b0dd 152 // Some informative output
153 mgr->PrintStatus();
e308a636 154 if (proof) mgr->SetDebugLevel(3);
0171f148 155 if (mgr->GetDebugLevel() < 1 && !proof)
bad9a3c1 156 mgr->SetUseProgressBar(kTRUE,100);
2d68d438 157
9d99b0dd 158 // Run the train
159 t.Start();
01caf91f 160 Printf("=== RUNNING ANALYSIS on %9d events ==========================",
161 nEvents);
0171f148 162 mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);
9d99b0dd 163 t.Stop();
164 t.Print();
7e4038b5 165}
166//
167// EOF
168//