]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/MakeELossFits.C
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / MakeELossFits.C
CommitLineData
7c1a1f1d 1/**
ffca499d 2 * @file MakeELossFits.C
3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Wed Mar 23 14:08:14 2011
7c1a1f1d 5 *
56236b95 6 * @brief Generate energy loss fits
ffca499d 7 *
bd6f5206 8 * @ingroup pwglf_forward_scripts_makers
0bd4b00f 9 */
10/**
11 * Run a pass on ESD data to produce the energ loss fits
12 *
56236b95 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
17 * characters
18 *
19 * If PROOF mode is selected, then Terminate will be run on the master node
20 * in any case.
21 *
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
0bd4b00f 32 *
bd6f5206 33 * @ingroup pwglf_forward_eloss
0bd4b00f 34 */
9e59fb95 35void MakeELossFits(const char* esddir,
9453b19e 36 Int_t nEvents = 1000,
37 Int_t proof = 0,
38 Bool_t mc = false,
39 Bool_t cent = false,
40 const char* name = 0)
0bd4b00f 41{
9453b19e 42 // --- Possibly use plug-in for this -------------------------------
43 if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
56236b95 44 const char* builder =
bd6f5206 45 "$(ALICE_ROOT)/PWGLF/FORWARD/analysis2/trains/BuildTrain.C"
56236b95 46 gROOT->LoadMacro(builder);
e2213ed5 47 BuildTrain("MakeFMDELossTrain");
56236b95 48
e2213ed5 49 MakeFMDELossTrain t(name, cent, false);
9453b19e 50 t.SetDataDir(esddir);
51 t.SetDataSet("");
52 t.SetProofServer(Form("workers=%d",proof));
53 t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
54 return;
55 }
56
0bd4b00f 57 // --- Libraries to load -------------------------------------------
bd6f5206 58 gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
0bd4b00f 59
60 // --- Check for proof mode, and possibly upload pars --------------
1c762251 61 if (proof > 0) {
bd6f5206 62 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadPars.C");
1c762251 63 LoadPars(proof);
64 }
0bd4b00f 65
66 // --- Our data chain ----------------------------------------------
bd6f5206 67 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/MakeChain.C");
5e64cabf 68 TChain* chain = MakeChain("ESD",esddir, true);
e2213ed5 69 chain->GetListOfFiles()->ls();
0bd4b00f 70 // If 0 or less events is select, choose all
71 if (nEvents <= 0) nEvents = chain->GetEntries();
9e59fb95 72 Info("MakeELossFits", "Will analyse %d events", nEvents);
0bd4b00f 73
e1f47419 74 // --- Set the macro path ------------------------------------------
bd6f5206 75 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2:"
e1f47419 76 "$ALICE_ROOT/ANALYSIS/macros",
77 gROOT->GetMacroPath()));
78
0bd4b00f 79 // --- Creating the manager and handlers ---------------------------
0f84fefb 80 AliAnalysisManager *mgr = new AliAnalysisManager("Forward ELoss Train",
81 "Forward energy loss");
82 AliAnalysisManager::SetCommonFileName("forward_eloss.root");
0bd4b00f 83
9453b19e 84 // --- ESD input handler -------------------------------------------
0bd4b00f 85 AliESDInputHandler *esdHandler = new AliESDInputHandler();
0bd4b00f 86 mgr->SetInputEventHandler(esdHandler);
9453b19e 87
88 // --- Monte Carlo handler -----------------------------------------
89 if (mc) {
90 AliMCEventHandler* mcHandler = new AliMCEventHandler();
91 mgr->SetMCtruthEventHandler(mcHandler);
92 mcHandler->SetReadTR(true);
93 }
0bd4b00f 94
95 // --- Add tasks ---------------------------------------------------
e1f47419 96 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
e28f5fc5 97 AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
98
9453b19e 99 // Centrality
100 if(cent) {
101 gROOT->LoadMacro("AddTaskCentrality.C");
102 AddTaskCentrality();
103 }
e28f5fc5 104
9453b19e 105 // FMD ELoss fitter
106 gROOT->LoadMacro("AddTaskFMDELoss.C");
107 AddTaskFMDELoss(mc, cent);
0bd4b00f 108
0bd4b00f 109 // --- Run the analysis --------------------------------------------
110 TStopwatch t;
111 if (!mgr->InitAnalysis()) {
112 Error("RunManager", "Failed to initialize analysis train!");
113 return;
114 }
115 // Some informative output
116 mgr->PrintStatus();
117 // mgr->SetDebugLevel(3);
9453b19e 118 if (mgr->GetDebugLevel() < 1 && proof <= 0)
119 mgr->SetUseProgressBar(kTRUE,100);
0bd4b00f 120
121 // Run the train
122 t.Start();
37079f20 123 Printf("=== RUNNING ANALYSIS on %9d events ========================",nEvents);
1c762251 124 mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);
0bd4b00f 125 t.Stop();
126 t.Print();
127}
128//
129// EOF
130//