2 * @defgroup pwg2_forward_scripts_makers Maker scripts
3 * @ingroup pwg2_forward_scripts
7 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
8 * @date Wed Mar 23 09:40:10 2011
10 * @brief Run first pass of the analysis - AOD generation
12 * @ingroup pwg2_forward_scripts_makers
15 * Run first pass of the analysis - that is read in ESD and produce AOD
17 * If the ROOT AliEn interface library (libRAliEn) can be loaded,
18 * and the parameter @a name is not empty, then use the plugin to do
19 * the analysis. Note that in this case, the output is placed
20 * in a sub-directory named by @a name after escaping spaces and special
23 * If PROOF mode is selected, then Terminate will be run on the master node
26 * @param esddir ESD input directory. Any file matching the pattern
27 * *AliESDs*.root are added to the chain
28 * @param nEvents Number of events to process. If 0 or less, then
29 * all events are analysed
30 * @param proof If larger then 1, run in PROOF-Lite mode with this
31 * many number of workers.
32 * @param mc Data is assumed to be from simulations
33 * @param centrality Whether to use centrality or not
34 * @param name Name of train - free form. This will be the name
35 * of the output directory if the plug-in is used
37 * @ingroup pwg2_forward_aod
39 void MakeAOD(const char* esddir,
43 Bool_t centrality = true,
46 // --- Possibly use plug-in for this -------------------------------
47 if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
48 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
49 "$ALICE_ROOT/ANALYSIS/macros",
50 gROOT->GetMacroPath()));
51 gSystem->AddIncludePath("-I${ALICE_ROOT}/include");
52 gSystem->Load("libANALYSIS");
53 gSystem->Load("libANALYSISalice");
54 gROOT->LoadMacro("TrainSetup.C+g");
55 MakeAODTrain t(name, 0, 0, 0, centrality, false);
58 t.SetProofServer(Form("workers=%d",proof));
59 t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
63 // --- Libraries to load -------------------------------------------
64 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
66 // --- Check for proof mode, and possibly upload pars --------------
68 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
69 if (!LoadPars(proof)) {
70 Error("MakeAOD", "Failed to load PARs");
75 // --- Our data chain ----------------------------------------------
76 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
77 TChain* chain = MakeChain("ESD", esddir,true);
78 // If 0 or less events is select, choose all
79 if (nEvents <= 0) nEvents = chain->GetEntries();
81 // --- Set the macro path ------------------------------------------
82 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
83 "$ALICE_ROOT/ANALYSIS/macros",
84 gROOT->GetMacroPath()));
86 // --- Creating the manager and handlers ---------------------------
87 AliAnalysisManager *mgr = new AliAnalysisManager(name,
88 "Forward multiplicity");
89 AliAnalysisManager::SetCommonFileName("forward.root");
91 // --- ESD input handler -------------------------------------------
92 AliESDInputHandler *esdHandler = new AliESDInputHandler();
93 mgr->SetInputEventHandler(esdHandler);
95 // --- Monte Carlo handler -----------------------------------------
97 AliMCEventHandler* mcHandler = new AliMCEventHandler();
98 mgr->SetMCtruthEventHandler(mcHandler);
99 mcHandler->SetReadTR(true);
102 // --- AOD output handler ------------------------------------------
103 AliAODHandler* aodHandler = new AliAODHandler();
104 mgr->SetOutputEventHandler(aodHandler);
105 aodHandler->SetNeedsHeaderReplication();
106 aodHandler->SetOutputFileName("AliAOD.root");
108 // --- Add tasks ---------------------------------------------------
110 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
111 AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
112 // --- Fix up physics selection to give proper A,C, and E triggers -
113 AliInputEventHandler* ih =
114 static_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
115 AliPhysicsSelection* ps =
116 static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
117 // Ignore trigger class when selecting events. This mean that we
118 // get offline+(A,C,E) events too
119 ps->SetSkipTriggerClassSelection(true);
125 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/Compile.C");
126 Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCopyHeader.C","");
131 gROOT->LoadMacro("AddTaskCentrality.C");
135 gROOT->LoadMacro("AddTaskForwardMult.C");
136 AddTaskForwardMult(mc);
139 gROOT->LoadMacro("AddTaskCentralMult.C");
140 AddTaskCentralMult(mc);
142 // --- Run the analysis --------------------------------------------
144 if (!mgr->InitAnalysis()) {
145 Error("MakeAOD", "Failed to initialize analysis train!");
148 // Skip terminate if we're so requested and not in Proof or full mode
149 mgr->SetSkipTerminate(false);
150 // Some informative output
152 if (proof) mgr->SetDebugLevel(3);
153 if (mgr->GetDebugLevel() < 1 && !proof)
154 mgr->SetUseProgressBar(kTRUE,100);
158 Printf("=== RUNNING ANALYSIS on %9d events ==========================",
160 mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);