]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/trains/MakeFullTrain.C
Refactoring for AliFMDEnergyFitter to allow sub-classing
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / trains / MakeFullTrain.C
1 #include "TrainSetup.C"
2 /**
3  * @file   MakeFullTrain.C
4  * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
5  * @date   Fri Jun  1 13:53:43 2012
6  * 
7  * @brief  
8  * 
9  * 
10  * @ingroup pwglf_forward_trains_specific
11  */
12
13 //====================================================================
14 /**
15  * Analysis train to make Forward and Central multiplicity, @f$
16  * dN/d\eta@f$, flow and @f$\Psi_R@f$ in one loop over the ESDs 
17  *
18  * @ingroup pwglf_forward_aod
19  * @ingroup pwglf_forward_dndete
20  * @ingroup pwglf_forward_flow
21  * @ingroup pwglf_forward_trains_specific
22  */
23 class MakeFullTrain : public TrainSetup
24 {
25 public:
26   /** 
27    * Constructor.  Date and time must be specified when running this
28    * in Termiante mode on Grid
29    * 
30    * @param name     Name of train (free form)
31    */
32   MakeFullTrain(const  char* name) 
33     : TrainSetup(name)
34   {
35     // General
36     fOptions.Add("dNdeta", "Add dN/deta tasks");
37     fOptions.Add("flow", "Add flow tasks");
38     fOptions.Add("cent",  "Use centrality");
39     // ESD settings
40     fOptions.Add("run",   "NUMBER",  "Run number", 0);
41     fOptions.Add("sys",   "SYSTEM",  "1:pp, 2:PbPb, 3:pPb", "");
42     fOptions.Add("snn",   "ENERGY",  "Center of mass energy in GeV", "");
43     fOptions.Add("field", "STRENGTH","L3 field strength in kG", "");
44     fOptions.Add("tpc-ep", "Use TPC event plane");
45     fOptions.Add("forward-config", "FILE", "Forward configuration", 
46                  "ForwardAODConfig.C");
47     fOptions.Add("central-config", "FILE", "Forward configuration", 
48                  "CentralAODConfig.C");
49     fOptions.Add("satelitte", "Use satelitte interactions");
50     fOptions.Add("corr", "DIR", "Corrections dir", "");
51     // dNdeta AOD settings
52     fOptions.Add("trig",     "TYPE", "Trigger type", "INEL");
53     fOptions.Add("vzMin",    "CENTIMETER", "Min Ip Z", "-10");
54     fOptions.Add("vzMax",    "CENTIMETER", "Max Ip Z", "+10");
55     fOptions.Add("scheme",   "SCHEME", "Normalization scheme", "");
56     fOptions.Add("trigEff",  "EFFICENCY", "Trigger effeciency", "1");
57     fOptions.Add("trigEff0", "EFFICENCY", "0-bin trigger effeciency", "1");
58     fOptions.Add("cut-edges", "Cut acceptance edges");
59     // Flow AOD settings
60     fOptions.Add("mom", "Flow moments to analyse", "234", "234");
61     fOptions.Add("eta-gap", "Whether to use an eta-gap", "[no,yes,both]", 
62                  "both");
63     fOptions.Add("eg-value", "Set value in |eta| of the eta gap", "2.0");
64     fOptions.Add("b-cent","Whether to use the impact parameter for centrality");
65     fOptions.Add("afterburner", "What to afterburn", "[eta,phi,b,pid]", "");
66     fOptions.Add("ab-type", "Type of afterburner", "1|2|3|4", "");
67     fOptions.Add("ab-order", "Order of afterburner", "2|3|4|5|6", "");
68     fOptions.Add("sat-vtx", "Whether to use satellite interactions");
69     fOptions.Add("outlier-fmd", "Outlier cut for FMD", "NSIGMA", "4.0");
70     fOptions.Add("outlier-spd", "Outlier cut for SPD", "NSIGMA", "0.0");
71
72     fOptions.Set("type", "ESD"); 
73     fOptions.Show(std::cout);
74
75   }
76 protected:
77   /** 
78    * Create the tasks 
79    * 
80    * @param mgr  Analysis manager 
81    */
82   void CreateTasks(AliAnalysisManager* mgr)
83   {
84     // --- Output file name ------------------------------------------
85     AliAnalysisManager::SetCommonFileName("forward.root");
86
87     // --- Load libraries/pars ---------------------------------------
88     fHelper->LoadLibrary("PWGLFforward2");
89     
90     // --- Set load path ---------------------------------------------
91     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
92                              gROOT->GetMacroPath()));
93     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/ANALYSIS/macros",
94                              gROOT->GetMacroPath()));
95
96     // --- Check if this is MC ---------------------------------------
97     Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
98    
99     // --- Add TPC eventplane task -----------------------------------
100     if (fOptions.Has("tpc-ep")) gROOT->Macro("AddTaskEventplane.C");
101
102     // --- Task to copy header information ---------------------------
103     gROOT->Macro("AddTaskCopyHeader.C");
104
105     // --- Get options -----------------------------------------------
106     ULong_t  run = fOptions.AsInt("run", 0);
107     UShort_t sys = fOptions.AsInt("sys", 0);
108     UShort_t sNN = fOptions.AsInt("snn", 0);
109     UShort_t fld = fOptions.AsInt("field", 0);
110     Bool_t  cent = fOptions.Has("cent");
111     TString  cor = "";
112     if (fOptions.Has("corr")) cor = fOptions.Get("corr");
113     
114     // --- Add the task ----------------------------------------------
115     TString fwdConfig = fOptions.Get("forward-config");
116     gROOT->Macro(Form("AddTaskForwardMult.C(%d,%d,%d,%d,%d,\"%s\")", 
117                       mc, runNo, sys, sNN, fld, fwdConfig.Data()));
118     fHelper->LoadAux(gSystem->Which(gROOT->GetMacroPath(), fwdConfig));
119
120     // --- Add the task ----------------------------------------------
121     TString cenConfig = fOptions.Get("central-config");
122     gROOT->Macro(Form("AddTaskCentralMult.C(%d,%d,%d,%d,%d,\"%s\")", 
123                       mc, runNo, sys, sNN, fld, cenConfig.Data()));
124     fHelper->LoadAux(gSystem->Which(gROOT->GetMacroPath(), cenConfig));
125
126     // --- Add MC particle task --------------------------------------
127     if (mc) gROOT->Macro("AddTaskMCParticleFilter.C");
128
129     
130     // --- Add dN/deta tasks -----------------------------------------
131     if (fOptions.Has("dNdeta")) {
132       // --- Get parameters --------------------------------------------
133       TString  trig   = fOptions.Get("trig");
134       TString  scheme = fOptions.Get("scheme");
135       Double_t vzMin  = fOptions.AsDouble("vzmin", -10);
136       Double_t vzMax  = fOptions.AsDouble("vzmax", +10);
137       Double_t effT   = fOptions.AsDouble("trigEff", 1);
138       Double_t effT0  = fOptions.AsDouble("trigEff0", 1);
139       Bool_t   edges  = fOptions.Has("cut-edges");
140       Bool_t   corrEm = fOptions.Has("corr-empty");
141
142       // --- Form arguments --------------------------------------------
143       TString args;
144       args.Form("\"%s\",%f,%f,%d,\"%s\",%d,%g,%g,%d",
145                 trig.Data(), vzMin, vzMax, cent, scheme.Data(),
146                 edges, effT, effT0, corrEm);
147       // --- Add the task ----------------------------------------------
148       gROOT->Macro(Form("AddTaskForwarddNdeta.C(%s);", args.Data()));
149       gROOT->Macro(Form("AddTaskCentraldNdeta.C(%s);", args.Data()));
150       gROOT->Macro(Form("AddTaskMCTruthdNdeta.C(%s);", args.Data()));
151     }
152     
153     // --- Add the flow task -----------------------------------------
154     if (fOptions.Has("flow")) {
155       // --- Get the parameters ----------------------------------------
156       TString  type    = fOptions.Get("mom");
157       TString  etaGap  = fOptions.Get("eta-gap");
158       Double_t egValue = fOptions.AsDouble("eg-value");
159       Bool_t   useCent = fOptions.AsBool("b-cent");
160       TString  addFlow = fOptions.Get("afterburner");
161       Int_t    abType  = fOptions.AsInt("ab-type");
162       Int_t    abOrder = fOptions.AsInt("ab-order");
163       Bool_t   satVtx  = fOptions.AsBool("sat-vtx");
164       Double_t fmdCut  = fOptions.AsDouble("outlier-fmd");
165       Double_t spdCut  = fOptions.AsDouble("outlier-spd");
166
167       // --- Add the task ----------------------------------------------
168       // Notice the '%%d' for second argument.  We substitute that later
169       TString arg(Form("AddTaskForwardFlow.C(\"%s\",%%d,%d,%f,%f,%f,%d,%d,\"%s\",%d,%d)",
170                        type.Data(),
171                        mc, 
172                        fmdCut, 
173                        spdCut,
174                        egValue,
175                        useCent,
176                        satVtx, 
177                        addFlow.Data(), 
178                        abType, 
179                        abOrder));
180       
181       if (etaGap.Contains("no") || etaGap.Contains("false") ||
182           etaGap.Contains("both"))
183         gROOT->Macro(Form(arg.Data(), false));
184       
185       if (etaGap.Contains("yes") || etaGap.Contains("true") ||
186           etaGap.Contains("both"))
187         gROOT->Macro(Form(arg.Data(), true));
188     }
189   }
190   //__________________________________________________________________
191   /** 
192    * Create physics selection , and add to manager
193    * 
194    * @param mc Whether this is for MC 
195    * @param mgr Manager 
196    */
197   void CreatePhysicsSelection(Bool_t mc,
198                               AliAnalysisManager* mgr)
199   {
200     TrainSetup::CreatePhysicsSelection(mc, mgr);
201
202     // --- Get input event handler -----------------------------------
203     AliInputEventHandler* ih =
204       dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
205     if (!ih) 
206       Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
207     
208     // --- Get Physics selection -------------------------------------
209     AliPhysicsSelection* ps = 
210       dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
211     if (!ps) 
212       Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)",ps);
213
214     // --- Special for pPb pilot run Sep. 2012 -----------------------
215     UShort_t sys = fOptions.AsInt("sys", 0);
216     if (sys == 3) { 
217       Warning("CreatePhysicsSelection", 
218               "Special setup for pPb pilot run September, 2012");
219       gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/ANALYSIS/macros",
220                                gROOT->GetMacroPath()));
221       gROOT->LoadMacro("PhysicsSelectionOADB_CINT5_pA.C");
222       gROOT->ProcessLine(Form("((AliPhysicsSelection*)%p)"
223                               "->SetCustomOADBObjects("
224                               "OADBSelection_CINT5_V0A(),0);", ps));
225       ps->SetSkipTriggerClassSelection(true);
226     }
227     // --- Ignore trigger class when selecting events.  This means ---
228     // --- that we get offline+(A,C,E) events too --------------------
229     // ps->SetSkipTriggerClassSelection(true);
230   }
231   //__________________________________________________________________
232   /** 
233    * Create the centrality selection only if requested
234    * 
235    * @param mc  Monte-Carlo truth flag 
236    * @param mgr Manager
237    */
238   void CreateCentralitySelection(Bool_t mc, AliAnalysisManager* mgr)
239   {
240     if (!fOptions.Has("cent")) return;
241     TrainSetup::CreateCentralitySelection(mc, mgr);
242   }
243   //__________________________________________________________________
244   const char* ClassName() const { return "MakeFullTrain"; }
245 };
246 //
247 // EOF
248 //