2 * @file MakeELossFits.C
3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Wed Mar 23 14:08:14 2011
6 * @brief Generate energy loss fits
8 * @ingroup pwg2_forward_scripts_makers
11 * Run a pass on ESD data to produce the energ loss fits
13 * If the ROOT AliEn interface library (libRAliEn) can be loaded,
14 * and the parameter @a name is not empty, then use the plugin to do
15 * the analysis. Note that in this case, the output is placed
16 * in a sub-directory named by @a name after escaping spaces and special
19 * If PROOF mode is selected, then Terminate will be run on the master node
22 * @param esddir ESD input directory. Any file matching the pattern
23 * *AliESDs*.root are added to the chain
24 * @param nEvents Number of events to process. If 0 or less, then
25 * all events are analysed
26 * @param proof If larger then 1, run in PROOF-Lite mode with this
27 * many number of workers.
28 * @param mc Data is assumed to be from simulations
29 * @param cent Whether to use centrality or not
30 * @param name Name of train - free form. This will be the name
31 * of the output directory if the plug-in is used
33 * @ingroup pwg2_forward_eloss
35 void MakeELossFits(const char* esddir,
42 // --- Possibly use plug-in for this -------------------------------
43 if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
45 "$(ALICE_ROOT)/PWG2/FORWARD/analysis2/trains/BuildTrain.C"
46 gROOT->LoadMacro(builder);
47 BuildTrain("FMDELossTrain");
49 FMDELossTrain t(name, cent, false);
52 t.SetProofServer(Form("workers=%d",proof));
53 t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
57 // --- Libraries to load -------------------------------------------
58 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
60 // --- Check for proof mode, and possibly upload pars --------------
62 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
66 // --- Our data chain ----------------------------------------------
67 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
68 TChain* chain = MakeChain("ESD",esddir, true);
69 // If 0 or less events is select, choose all
70 if (nEvents <= 0) nEvents = chain->GetEntries();
71 Info("MakeELossFits", "Will analyse %d events", nEvents);
73 // --- Set the macro path ------------------------------------------
74 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
75 "$ALICE_ROOT/ANALYSIS/macros",
76 gROOT->GetMacroPath()));
78 // --- Creating the manager and handlers ---------------------------
79 AliAnalysisManager *mgr = new AliAnalysisManager("Forward ELoss Train",
80 "Forward energy loss");
81 AliAnalysisManager::SetCommonFileName("forward_eloss.root");
83 // --- ESD input handler -------------------------------------------
84 AliESDInputHandler *esdHandler = new AliESDInputHandler();
85 mgr->SetInputEventHandler(esdHandler);
87 // --- Monte Carlo handler -----------------------------------------
89 AliMCEventHandler* mcHandler = new AliMCEventHandler();
90 mgr->SetMCtruthEventHandler(mcHandler);
91 mcHandler->SetReadTR(true);
94 // --- Add tasks ---------------------------------------------------
95 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
96 AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
100 gROOT->LoadMacro("AddTaskCentrality.C");
105 gROOT->LoadMacro("AddTaskFMDELoss.C");
106 AddTaskFMDELoss(mc, cent);
108 // --- Run the analysis --------------------------------------------
110 if (!mgr->InitAnalysis()) {
111 Error("RunManager", "Failed to initialize analysis train!");
114 // Some informative output
116 // mgr->SetDebugLevel(3);
117 if (mgr->GetDebugLevel() < 1 && proof <= 0)
118 mgr->SetUseProgressBar(kTRUE,100);
122 Printf("=== RUNNING ANALYSIS on %9d events ========================",nEvents);
123 mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);