AliPhysics  e34b7ac (e34b7ac)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BothAODTrain.C
Go to the documentation of this file.
1 
10 #include "TrainSetup.C"
11 #include <sstream>
12 
13 //====================================================================
21 class BothAODTrain : public TrainSetup
22 {
23 public:
29  BothAODTrain(const TString& name)
30  : TrainSetup(name)
31  {
32  // Forward options
33  fOptions.Add("run", "NUMBER", "Run number for corrs", 0);
34  fOptions.Add("sys", "SYSTEM", "1:pp, 2:PbPb, 3:pPb", 0);
35  fOptions.Add("snn", "ENERGY", "Center of mass energy in GeV", 0);
36  fOptions.Add("field","STRENGTH","L3 field strength in kG", 0);
37  fOptions.Add("corr", "DIR", "Corrections dir", "");
38  fOptions.Add("dead", "FILE", "Additional dead-map script", "");
39  fOptions.Add("max-strips", "NUMBER",
40  "Maximum consequtive strips (MC)", 2);
41  fOptions.Add("forward-config", "FILE", "Forward configuration",
42  "ForwardAODConfig.C");
43  fOptions.Add("central-config", "FILE", "Central configuration",
44  "CentralAODConfig.C");
45  fOptions.Add("no-central","Do not at SPD cluster task",false);
46  fOptions.Add("cent", "Use centrality");
47  fOptions.Add("satelitte", "Use satelitte interactions");
48  fOptions.Add("secmap", "Use secondary maps to correct", false);
49 
50  // Other options
51  fOptions.Add("copy", "LIST", "',' separated list to copy","cent");
52  fOptions.Add("mc-tracks", "Enable MC track filter", false);
53  fOptions.Add("tpc-ep", "Use TPC event plane");
54 
55  // SPD tracklet options
56  fOptions.Add("max-delta", "X","Cut on weighted distance",25.);
57  fOptions.Add("scale-dtheta", "Scale dTheta" , true);
58  fOptions.Add("dphi-window", "X","dPhi window", 0.06);
59  fOptions.Add("dtheta-window", "X","dTheta window", 0.025);
60  fOptions.Add("dphi-shift", "X","Bending shift", 0.0045);
61  fOptions.Add("phi-overlap-cut", "X","Phi overlap cut", 0.005);
62  fOptions.Add("z-eta-overlap-cut","X","Z-Eta overlap cut", 0.05);
63  fOptions.Add("filter-k0s", "Filter K0s clusters", false);
64  fOptions.Add("need-clusters", "If set, insist on RecPoints",false);
65  fOptions.Set("type", "ESD");
66  }
67 protected:
78  AliVEventHandler* CreateInputHandler(UShort_t type, Bool_t needRec=false)
79  {
80  Bool_t needRP = fOptions.AsBool("need-clusters");
81  return TrainSetup::CreateInputHandler(type, needRP);
82  }
92  AliVEventHandler* CreateMCHandler(UShort_t type, bool mc)
93  {
94  AliMCEventHandler* ret =
95  static_cast<AliMCEventHandler*>(TrainSetup::CreateMCHandler(type,mc));
96  if (ret) ret->SetPreReadMode(AliMCEventHandler::kLmPreRead);
97  return ret;
98  }
99 
108  {
109  // --- Add TPC eventplane task
110  if (fOptions.Has("tpc-ep")) CoupleSECar("AddTaskEventplane.C","", mask);
111 
112  // --- Task to copy header information ---------------------------
113  TString cpy = fOptions.Get("copy");
114  Info("", "What to copy: %s", cpy.Data());
115  CoupleSECar("AddTaskCopyHeader.C", Form("\"%s\"", cpy.Data()), mask);
116  }
125  {
126  // --- Output file name ------------------------------------------
127  AliAnalysisManager::SetCommonFileName("forward.root");
128 
129  // --- Get options -----------------------------------------------
130  ULong_t run = fOptions.AsInt("run", 0);
131  UShort_t sys = fOptions.AsInt("sys", 0);
132  UShort_t sNN = fOptions.AsInt("snn", 0);
133  UShort_t fld = fOptions.AsInt("field", 0);
134  UShort_t mSt = fOptions.AsInt("max-strips", 2);
135  Bool_t sec = fOptions.Has("secmap");
136  TString corr = "";
137  TString dead = "";
138  if (fOptions.Has("corr")) corr = fOptions.Get("corr");
139  if (fOptions.Has("dead")) dead = fOptions.Get("dead");
140 
141  // --- Add the task ----------------------------------------------
142  TString fwdConfig = fOptions.Get("forward-config");
144  CoupleSECar("AddTaskForwardMult.C",
145  Form("%d,%ld,%d,%d,%d,\"%s\",\"%s\",\"%s\"",
146  mc, run, sys, sNN, fld,
147  fwdConfig.Data(), corr.Data(),
148  dead.Data()), mask);
149  if (!fwd)
150  Fatal("CoupleForwardCar", "Failed to add forward task");
151 
152  gROOT->ProcessLine(Form("((AliForwardMultiplicityBase*)%p)"
153  "->GetCorrections().SetUseSecondaryMap(%d)",
154  fwd, sec));
155  if (mc) {
156  gROOT->ProcessLine(Form("((AliForwardMCMultiplicityTask*)%p)"
157  "->GetTrackDensity()"
158  ".SetMaxConsequtiveStrips(%d)",
159  fwd, mSt));
160  }
161  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(), fwdConfig), true);
162  if (!corr.IsNull())
163  fRailway->LoadAux(Form("%s/fmd_corrections.root",corr.Data()), true);
164  if (!dead.IsNull())
165  fRailway->LoadAux(Form("%s",dead.Data()), true);
166  }
175  {
176  Bool_t noCentral = fOptions.Has("no-central");
177  if (noCentral) return;
178 
179  // --- Get options -----------------------------------------------
180  ULong_t run = fOptions.AsInt("run", 0);
181  UShort_t sys = fOptions.AsInt("sys", 0);
182  UShort_t sNN = fOptions.AsInt("snn", 0);
183  UShort_t fld = fOptions.AsInt("field", 0);
184  UShort_t mSt = fOptions.AsInt("max-strips", 2);
185  Bool_t sec = fOptions.Has("secmap");
186  TString corr = "";
187  if (fOptions.Has("corr")) corr = fOptions.Get("corr");
188 
189  // --- Add the task ----------------------------------------------
190  TString cenConfig = fOptions.Get("central-config");
191  AliAnalysisTask* cen = CoupleSECar("AddTaskCentralMult.C",
192  Form("%d,%ld,%d,%d,%d,\"%s\",\"%s\"",
193  mc, run, sys, sNN, fld,
194  cenConfig.Data(), corr.Data()),
195  mask);
196  if (!cen)
197  Fatal("CoupleClusterCar", "Failed to add central (cluster) task");
198  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(),cenConfig),true);
199  if (!corr.IsNull())
200  fRailway->LoadAux(Form("%s/spd_corrections.root",corr.Data()), true);
201  gROOT->ProcessLine(Form("((AliCentralMultiplicityTask*)%p)"
202  "->SetUseSecondary(%d)",
203  cen, sec));
204  }
213  {
214  // --- Output file name ------------------------------------------
215  AliAnalysisManager::SetCommonFileName("tracklet.root");
216 
217  // Load our sources
218  fRailway->LoadSource("FixPaths.C");
219  fRailway->LoadSource("AliAODSimpleHeader.C");
220  fRailway->LoadSource("AliSimpleHeaderTask.C");
221  fRailway->LoadSource("AliAODTracklet.C");
222  fRailway->LoadSource("AliTrackletAODTask.C");
223 
224  // --- Task to create simple header ------------------------------
225  if (!gROOT->ProcessLine("AliSimpleHeaderTask::Create()"))
226  Fatal("CoupleTrackletTask", "Failed to make simple header task");
227 
228  // --- Create the task using interpreter -------------------------
229  Long_t ret =
230  gROOT->ProcessLine("AliTrackletAODTask::Create()");
231  AliAnalysisTaskSE* task = reinterpret_cast<AliAnalysisTaskSE*>(ret);
232  if (!task)
233  Fatal("CoupleTrackletCar", "Failed to make tracklet task");
234 
235  // --- Set various options on task -------------------------------
236  FromOption(task, "MaxDelta", "max-delta", 25.);
237  FromOption(task, "ScaleDTheta", "scale-dtheta", true);
238  FromOption(task, "DPhiWindow", "dphi-window", 0.06);
239  FromOption(task, "DThetaWindow", "dtheta-window", 0.025);
240  FromOption(task, "DPhiShift", "dphi-shift", 0.0045);
241  FromOption(task, "PhiOverlapCut", "phi-overlap-cut" , 0.005);
242  FromOption(task, "ZEtaOverlapCut", "z-eta-overlap-cut", 0.05);
243  FromOption(task, "FilterK0S", "filter-k0s", false);
244  }
253  {
254  // --- Output file name ------------------------------------------
255  AliAnalysisManager::SetCommonFileName("AnalysisResults.root");
256  // --- Add MC particle task --------------------------------------
257  if (!mc || !fOptions.Has("mc-tracks")) return;
258  CoupleSECar("AddTaskMCParticleFilter.C","", mask);
259  }
266  {
267  // --- Load libraries/pars ---------------------------------------
268  fRailway->LoadLibrary("PWGLFforward2");
269 
270  // --- Set load path ---------------------------------------------
271  TString mp(gROOT->GetMacroPath());
272  mp.Append(":$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2");
273  mp.Append(":$(ALICE_ROOT)/ANALYSIS/macros");
274  mp.Append(":$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2/dndeta/tracklets3");
275  gROOT->SetMacroPath(mp);
276 
277  // --- Check if this is MC ---------------------------------------
278  Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
279  UInt_t mask = AliVEvent::kAny;
280 
281  // --- Couple our tasks ------------------------------------------
282  CouplePreCars (mgr, mc, mask);
283  CoupleForwardCar (mgr, mc, mask);
284  CoupleClusterCar (mgr, mc, mask);
285  CoupleTrackletCar(mgr, mc, mask);
286  CouplePostCars (mgr, mc, mask);
287  }
288  //__________________________________________________________________
295  {
296  if (!fOptions.Has("cent")) return;
298  }
299  //__________________________________________________________________
300  const char* ClassName() const { return "BothAODTrain"; }
301  //__________________________________________________________________
308  void SaveSetup(Bool_t asShellScript)
309  {
310  TrainSetup::SaveSetup(asShellScript);
311  SaveSummarize();
312  SavedNdeta(asShellScript);
313  }
319  void SavedNdeta(Bool_t asShellScript)
320  {
321  if (!fRailway) {
322  Warning("BothAODTrain::SaveSetup",
323  "Cannot make dNdeta.C script without helper");
324  return;
325  }
326 
327  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
328  Bool_t mc = mgr && (mgr->GetMCtruthEventHandler() != 0);
329  OptionList uopts(fRailway->Options());
330  OptionList opts(fOptions);
331  TString cls("BothdNdetaTrain");
332  TString name(fName);
333  Int_t sys = fOptions.AsInt("sys", 0);
334  if (name.Contains("aod")) name.ReplaceAll("aod", "dndeta");
335  else name.Append("_dndeta");
336  opts.Remove("run");
337  opts.Remove("sys");
338  opts.Remove("snn");
339  opts.Remove("field");
340  opts.Remove("tpc-ep");
341  opts.Remove("corr");
342  opts.Remove("max-strips");
343  opts.Remove("mc-tracks");
344  opts.Remove("secmap");
345  opts.Remove("copy");
346  opts.Remove("scale-dtheta");
347  opts.Remove("dphi-window");
348  opts.Remove("dtheta-window");
349  opts.Remove("phi-overlap-cut");
350  opts.Remove("z-eta-overlap-cut");
351  opts.Remove("filter-k0s");
352  // Various
353  opts.Add("cent-bins", "BINS", "Centrality bins", "");
354  opts.Add("ipz-bins", "BINS", "IPz bins", "u15");
355  opts.Add("satellite", "Restrict analysis to satellite events",false);
356  opts.Add("trig", "TRIGGER", "Trigger type", "INEL");
357  opts.Add("filter", "FILTER", "Filter type", "OUTLIER|PILEUP-BIN");
358  opts.Add("mc", "Also analyse MC truth", fRailway->IsMC());
359  opts.Add("multsel", "Enable MultSelection", false);
360  opts.Add("abs-min-cent", "PERCENT", "Absolute least cent.", -1);
361  // For forward
362  opts.Add("scheme", "FLAGS", "Normalization scheme","TRIGGER,EVENT");
363  opts.Add("trigEff", "EFFICIENCY","Trigger efficiency", 1.);
364  opts.Add("trigEff0", "EFFICIENCY","0-bin trigger efficiency",1.);
365  opts.Add("truth-config", "FILE", "MC-Truth configuration", "");
366  opts.Add("mean-ipz", "MU", "Mean of IPz dist.", 0);
367  opts.Add("var-ipz", "SIGMA", "Variance of IPz dist.", -1);
368  // For tracklets
369  opts.Add("eta-bins", "BINS", "Eta bins", "r16:-2:+2");
370  opts.Add("tail-delta", "X", "Tail cut on distance", 5.);
371  opts.Add("tail-max", "X", "Tail cut on distance", -1.);
372  opts.Add("delta-cut", "X", "Cut on weighted distance",1.5);
373  opts.Add("shifted-dphi-cut","RADIANS","Cut on dPhi-phiBent", -1.);
374  opts.Add("reweigh", "FILE", "File with weights", "");
375  opts.Add("reweigh-calc", "MODE", "prod,square,sum", "prod");
376  opts.Add("reweigh-mask", "MASK", "Tracklet mask for weighing", 0xFF);
377  opts.Add("reweigh-veto", "VETO", "Tracklet veto for weighing", 0x0);
378  opts.Add("reweigh-inv", "W -> 1/W", false);
379 
380  // Rewrite our URL
381  TString outString = fRailway->OutputLocation();
382  if (outString.IsNull()) outString = fEscapedName;
383  TUrl outUrl(outString);
384 
385  if (uopts.Find("pattern")) // && outString.EndsWith("AliAOD.root"))
386  uopts.Set("pattern", "*/AliAOD.root");
387  // if (uopts.Find("concat")) uopts.Set("concat", true);
388  if (uopts.Find("par")) uopts.Set("par", "task");
389 
390  std::stringstream s;
391  uopts.Store(s, "", "&", false, true);
392  outUrl.SetOptions(s.str().c_str());
393 
394  const char* defConfig=
395  "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dNdetaConfig.C";
396  opts.Set("url", outUrl.GetUrl());
397  opts.Set("type", "AOD");
398  opts.Set("forward-config",defConfig);
399  opts.Set("central-config",defConfig);
400  opts.Set("truth-config",defConfig);
401  if (!fDatimeString.IsNull()) opts.Set("date", fDatimeString);
402 
403  if (sys != 1) {
404  opts.Set("cent", "default");
405  opts.Set("trig", "V0AND");
406  opts.Set("scheme", "default");
407  opts.Set("cent-bins", "default");
408  SaveSetupROOT("dNdeta", cls, name, opts, &uopts);
409  if (asShellScript)
410  SaveSetupShell("dndeta", cls, name, opts, &uopts);
411  }
412  else {
413  name.ReplaceAll("dndeta", "dndeta_inel");
414  SaveSetupROOT("dNdetaINEL", cls, name, opts, &uopts);
415  if (asShellScript)
416  SaveSetupShell("dndeta_inel", cls, name, opts, &uopts);
417 
418  name.ReplaceAll("inel", "nsd");
419  opts.Set("trig", "V0AND");
420  SaveSetupROOT("dNdetaNSD", cls, name, opts, &uopts);
421  if (asShellScript)
422  SaveSetupShell("dndeta_nsd", cls, name, opts, &uopts);
423 
424  name.ReplaceAll("nsd", "inelgt0");
425  opts.Set("trig", "INELGT0");
426  SaveSetupROOT("dNdetaINELGt0", cls, name, opts, &uopts);
427  if (asShellScript)
428  SaveSetupShell("dndeta_inelgt0", cls, name, opts, &uopts);
429  }
430  }
436  {
437  std::ofstream f("Summarize.C");
438  if (!f) {
439  Error("SaveSummarize", "Failed to open Summarize.C script");
440  return;
441  }
442  f << "// Generated by " << ClassName() << "\n"
443  << "// WHAT is a bit mask of\n"
444  << "// 0x001 Event inspector\n"
445  << "// 0x002 Sharing filter\n"
446  << "// 0x004 Density calculator\n"
447  << "// 0x008 Corrector\n"
448  << "// 0x010 Histogram collector\n"
449  << "// 0x020 Analysis step cartoon\n"
450  << "// 0x040 Results\n"
451  << "// 0x080 Central\n"
452  << "// 0x100 Landscape\n"
453  << "// 0x200 Pause\n"
454  << "//\n"
455  << "void Summarize(const char* filename=\"forward.root\",\n"
456  << " UShort_t what=0x1FF)\n"
457  << "{\n"
458  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
459  << " gROOT->LoadMacro(Form(\"%s/DrawAODSummary.C\",fwd));\n"
460  << " DrawAODSummary(filename,what);\n"
461  << "}\n"
462  << "// EOF" << std::endl;
463  f.close();
464  }
470  void PostShellCode(std::ostream& f)
471  {
472  f << " echo \"=== Summarizing results ...\"\n"
473  << " aliroot -l -b -q ${prefix}Summarize.C\n"
474  << std::endl;
475  }
476 };
477 //
478 // EOF
479 //
void CoupleTrackletCar(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:212
virtual void CreateCentralitySelection(Bool_t mc)
Definition: TrainSetup.C:758
virtual AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t esdRecPoints=false)
Definition: TrainSetup.C:538
TString fDatimeString
Definition: TrainSetup.C:1662
Railway * fRailway
Definition: TrainSetup.C:1664
TString fName
Definition: TrainSetup.C:1660
void CoupleClusterCar(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:174
void PostShellCode(std::ostream &f)
Definition: BothAODTrain.C:470
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
TSystem * gSystem
virtual AliVEventHandler * CreateMCHandler(UShort_t, bool mc)
Definition: TrainSetup.C:581
Int_t AsInt(const TString &name, Int_t def=0) const
Definition: Option.C:645
static void SaveSetupShell(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1493
Definition: External.C:92
void CreateTasks(AliAnalysisManager *mgr)
Definition: BothAODTrain.C:265
const TString & Get(const TString &name) const
Definition: Option.C:596
Bool_t Has(const TString &name) const
Definition: Option.C:584
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
AliVEventHandler * CreateMCHandler(UShort_t type, bool mc)
Definition: BothAODTrain.C:92
BothAODTrain(const TString &name)
Definition: BothAODTrain.C:29
void CoupleForwardCar(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:124
const OptionList & Options() const
Definition: Railway.C:454
void SaveSummarize()
Definition: BothAODTrain.C:435
void Set(const TString &name, const TString &value)
Definition: Option.C:736
virtual Bool_t IsMC() const
Definition: Railway.C:354
unsigned long ULong_t
Definition: External.C:38
Base classs for train specifications.
Option * Add(const TString &name, const TString &arg, const TString &desc, const TString &val="")
Definition: Option.C:421
const char * fwd
virtual TString OutputLocation() const
Definition: Railway.C:369
void CouplePostCars(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:252
void SaveSetup(Bool_t asShellScript)
Definition: BothAODTrain.C:308
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1469
virtual Bool_t LoadAux(const TString &name, Bool_t copy=false)
Definition: Railway.C:255
void CouplePreCars(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:107
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Double_t defval)
Definition: TrainSetup.C:1226
OptionList fOptions
Definition: TrainSetup.C:1663
unsigned short UShort_t
Definition: External.C:28
AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t needRec=false)
Definition: BothAODTrain.C:78
bool Bool_t
Definition: External.C:53
TString fEscapedName
Definition: TrainSetup.C:1661
void CreateCentralitySelection(Bool_t mc)
Definition: BothAODTrain.C:294
virtual AliAnalysisTaskSE * CoupleSECar(const TString &macro, const TString &args, UInt_t mask=0)
Definition: TrainSetup.C:873
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
const char * ClassName() const
Definition: BothAODTrain.C:300
static void SaveSetupROOT(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1534
virtual Bool_t LoadSource(const TString &name, bool copy=false)
Definition: Railway.C:231
void SavedNdeta(Bool_t asShellScript)
Definition: BothAODTrain.C:319