2 * @defgroup pwg2_forward_scripts_makers Maker scripts
3 * @ingroup pwg2_forward_scripts
5 //====================================================================
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 09:40:10 2011
11 * @brief Run first pass of the analysis - AOD generation
13 * @ingroup pwg2_forward_scripts_makers
15 //====================================================================
17 * Run first pass of the analysis - that is read in ESD and produce AOD
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
25 * If PROOF mode is selected, then Terminate will be run on the master node
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
36 * @param name Name of train - free form. This will be the name
37 * of the output directory if the plug-in is used
39 * @ingroup pwg2_forward_aod
41 void MakeAOD(const char* esddir,
45 Bool_t centrality = true,
49 // --- Possibly use plug-in for this -------------------------------
50 if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
52 "$(ALICE_ROOT)/PWG2/FORWARD/analysis2/trains/BuildTrain.C";
53 gROOT->LoadMacro(builder);
55 BuildTrain("MakeAODTrain");
57 MakeAODTrain t(name, 0, 0, 0, centrality, false);
60 t.SetProofServer(Form("workers=%d",proof));
62 t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
66 // --- Libraries to load -------------------------------------------
67 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
69 // --- Check for proof mode, and possibly upload pars --------------
71 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
72 if (!LoadPars(proof)) {
73 Error("MakeAOD", "Failed to load PARs");
78 // --- Our data chain ----------------------------------------------
79 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
80 TChain* chain = MakeChain("ESD", esddir,true);
81 // If 0 or less events is select, choose all
82 if (nEvents <= 0) nEvents = chain->GetEntries();
84 // --- Set the macro path ------------------------------------------
85 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
86 "$ALICE_ROOT/ANALYSIS/macros",
87 gROOT->GetMacroPath()));
89 // --- Creating the manager and handlers ---------------------------
90 AliAnalysisManager *mgr = new AliAnalysisManager(name,
91 "Forward multiplicity");
92 AliAnalysisManager::SetCommonFileName("forward.root");
94 // --- ESD input handler -------------------------------------------
95 AliESDInputHandler *esdHandler = new AliESDInputHandler();
96 mgr->SetInputEventHandler(esdHandler);
98 // --- Monte Carlo handler -----------------------------------------
100 AliMCEventHandler* mcHandler = new AliMCEventHandler();
101 mgr->SetMCtruthEventHandler(mcHandler);
102 mcHandler->SetReadTR(true);
105 // --- AOD output handler ------------------------------------------
106 AliAODHandler* aodHandler = new AliAODHandler();
107 mgr->SetOutputEventHandler(aodHandler);
108 aodHandler->SetNeedsHeaderReplication();
109 aodHandler->SetOutputFileName("AliAOD.root");
111 // --- Add tasks ---------------------------------------------------
113 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
114 AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
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
122 // ps->SetSkipTriggerClassSelection(true);
126 gROOT->LoadMacro("AddTaskCentrality.C");
127 AliCentralitySelectionTask* centTask = AddTaskCentrality();
128 centTask->SetPass(1);
129 if(mc)centTask->SetMCInput();
132 // Copy header information
133 gROOT->LoadMacro("AddTaskCopyHeader.C");
137 gROOT->LoadMacro("AddTaskForwardMult.C");
138 AddTaskForwardMult(mc);
141 gROOT->LoadMacro("AddTaskCentralMult.C");
142 AddTaskCentralMult(mc);
144 // --- Run the analysis --------------------------------------------
146 if (!mgr->InitAnalysis()) {
147 Error("MakeAOD", "Failed to initialize analysis train!");
150 // Skip terminate if we're so requested and not in Proof or full mode
151 mgr->SetSkipTerminate(false);
152 // Some informative output
154 if (proof) mgr->SetDebugLevel(3);
155 if (mgr->GetDebugLevel() < 1 && !proof)
156 mgr->SetUseProgressBar(kTRUE,100);
160 Printf("=== RUNNING ANALYSIS on %9d events ==========================",
162 mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);