]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/MakeELossFits.C
Updates to scripts. Mostly documentation and some new functionalities
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeELossFits.C
1 /**
2  * @file   MakeELossFits.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Wed Mar 23 14:08:14 2011
5  * 
6  * @brief  Generate energy loss fits 
7  * 
8  * @ingroup pwg2_forward_scripts_makers
9  */
10 /** 
11  * Run a pass on ESD data to produce the energ loss fits 
12  * 
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 
32  *
33  * @ingroup pwg2_forward_eloss
34  */
35 void MakeELossFits(const char* esddir, 
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)
41 {
42   // --- Possibly use plug-in for this -------------------------------
43   if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
44     const char* builder = 
45       "$(ALICE_ROOT)/PWG2/FORWARD/analysis2/trains/BuildTrain.C" 
46     gROOT->LoadMacro(builder);
47     BuildTrain("FMDELossTrain");
48
49     FMDELossTrain t(name, cent, false);
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
57   // --- Libraries to load -------------------------------------------
58   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
59
60   // --- Check for proof mode, and possibly upload pars --------------
61   if (proof > 0) {
62     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
63     LoadPars(proof);
64   }
65   
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);
72
73   // --- Set the macro path ------------------------------------------
74   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
75                            "$ALICE_ROOT/ANALYSIS/macros",
76                            gROOT->GetMacroPath()));
77
78   // --- Creating the manager and handlers ---------------------------
79   AliAnalysisManager *mgr  = new AliAnalysisManager("Forward ELoss Train", 
80                                                     "Forward energy loss");
81   AliAnalysisManager::SetCommonFileName("forward_eloss.root");
82
83   // --- ESD input handler -------------------------------------------
84   AliESDInputHandler *esdHandler = new AliESDInputHandler();
85   mgr->SetInputEventHandler(esdHandler);      
86        
87   // --- Monte Carlo handler -----------------------------------------
88   if (mc) {
89     AliMCEventHandler* mcHandler = new AliMCEventHandler();
90     mgr->SetMCtruthEventHandler(mcHandler);
91     mcHandler->SetReadTR(true);    
92   }
93
94   // --- Add tasks ---------------------------------------------------
95   gROOT->LoadMacro("AddTaskPhysicsSelection.C");
96   AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
97   
98   // Centrality 
99   if(cent) {
100     gROOT->LoadMacro("AddTaskCentrality.C");
101     AddTaskCentrality();
102   }
103   
104   // FMD ELoss fitter 
105   gROOT->LoadMacro("AddTaskFMDELoss.C");
106   AddTaskFMDELoss(mc, cent);
107
108   // --- Run the analysis --------------------------------------------
109   TStopwatch t;
110   if (!mgr->InitAnalysis()) {
111     Error("RunManager", "Failed to initialize analysis train!");
112     return;
113   }
114   // Some informative output 
115   mgr->PrintStatus();
116   // mgr->SetDebugLevel(3);
117   if (mgr->GetDebugLevel() < 1 && proof <= 0) 
118     mgr->SetUseProgressBar(kTRUE,100);
119
120   // Run the train 
121   t.Start();
122   Printf("=== RUNNING ANALYSIS on %9d events ========================",nEvents);
123   mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);
124   t.Stop();
125   t.Print();
126 }
127 //
128 // EOF
129 //