AliPhysics  64a5cfc (64a5cfc)
 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  fOptions.Add("hit-threshold", "CUT", "Threshold for hits", 0.9);
50 
51  // Other options
52  fOptions.Add("copy", "LIST", "',' separated list to copy","cent");
53  fOptions.Add("mc-tracks", "Enable MC track filter", false);
54  fOptions.Add("tpc-ep", "Use TPC event plane");
55 
56  // SPD tracklet options
57  fOptions.Add("max-delta", "X","Cut on weighted distance",25.);
58  fOptions.Add("scale-dtheta", "Scale dTheta" , true);
59  fOptions.Add("dphi-window", "X","dPhi window", 0.06);
60  fOptions.Add("dtheta-window", "X","dTheta window", 0.025);
61  fOptions.Add("dphi-shift", "X","Bending shift", 0.0045);
62  fOptions.Add("phi-overlap-cut", "X","Phi overlap cut", 0.005);
63  fOptions.Add("z-eta-overlap-cut","X","Z-Eta overlap cut", 0.05);
64  fOptions.Add("filter-str", "X","Filter strange tracks", 0);
65  fOptions.Add("need-clusters", "If set, insist on RecPoints",false);
66  fOptions.Set("type", "ESD");
67  }
68 protected:
79  AliVEventHandler* CreateInputHandler(UShort_t type, Bool_t needRec=false)
80  {
81  Bool_t needRP = fOptions.AsBool("need-clusters");
82  return TrainSetup::CreateInputHandler(type, needRP);
83  }
93  AliVEventHandler* CreateMCHandler(UShort_t type, bool mc)
94  {
95  AliMCEventHandler* ret =
96  static_cast<AliMCEventHandler*>(TrainSetup::CreateMCHandler(type,mc));
97  if (ret) ret->SetPreReadMode(AliMCEventHandler::kLmPreRead);
98  return ret;
99  }
100 
109  {
110  // --- Add TPC eventplane task
111  if (fOptions.Has("tpc-ep")) CoupleSECar("AddTaskEventplane.C","", mask);
112 
113  // --- Task to copy header information ---------------------------
114  TString cpy = fOptions.Get("copy");
115  Info("", "What to copy: %s", cpy.Data());
116  CoupleSECar("AddTaskCopyHeader.C", Form("\"%s\"", cpy.Data()), mask);
117  }
126  const TString& call,
127  const TString& arg)
128  {
129  TString cmd;
130  cmd.Form("((AliForwardMultiplicityBase*)%p)->%s(%s)",
131  tsk, call.Data(), arg.Data())
132  gROOT->ProcessLine(cmd);
133  }
142  const TString& call,
143  const TString& arg)
144  {
145  TString cmd;
146  cmd.Form("((AliForwardMCMultiplicityTask*)%p)->%s(%s)",
147  tsk, call.Data(), arg.Data())
148  gROOT->ProcessLine(cmd);
149  }
158  {
159  // --- Output file name ------------------------------------------
160  AliAnalysisManager::SetCommonFileName("forward.root");
161 
162  // --- Get options -----------------------------------------------
163  ULong_t run = fOptions.AsInt("run", 0);
164  UShort_t sys = fOptions.AsInt("sys", 0);
165  UShort_t sNN = fOptions.AsInt("snn", 0);
166  UShort_t fld = fOptions.AsInt("field", 0);
167  UShort_t mSt = fOptions.AsInt("max-strips", 2);
168  Double_t thr = fOptions.AsDouble("hit-threshold". .9);
169  Bool_t sec = fOptions.Has("secmap");
170  TString corr = "";
171  TString dead = "";
172  if (fOptions.Has("corr")) corr = fOptions.Get("corr");
173  if (fOptions.Has("dead")) dead = fOptions.Get("dead");
174 
175  // --- Add the task ----------------------------------------------
176  TString fwdConfig = fOptions.Get("forward-config");
178  CoupleSECar("AddTaskForwardMult.C",
179  Form("%d,%ld,%d,%d,%d,\"%s\",\"%s\",\"%s\"",
180  mc, run, sys, sNN, fld,
181  fwdConfig.Data(), corr.Data(),
182  dead.Data()), mask);
183  if (!fwd)
184  Fatal("CoupleForwardCar", "Failed to add forward task");
185 
186  SetOnFwd(fwd, "GetCorrections().SetUseSecondaryMap", Form("%d",sec));
187  //SetOnFwd(fwd, "GetDensityCalculator()->SetHitThreshold", Form("%f", thr));
188  if (mc)
189  SetOnMCFwd(fwd, "GetTrackDensity().SetMaxConsequtiveStrips",
190  Form("%d",mSt));
191  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(), fwdConfig), true);
192  if (!corr.IsNull())
193  fRailway->LoadAux(Form("%s/fmd_corrections.root",corr.Data()), true);
194  if (!dead.IsNull())
195  fRailway->LoadAux(Form("%s",dead.Data()), true);
196  }
205  {
206  Bool_t noCentral = fOptions.Has("no-central");
207  if (noCentral) return;
208 
209  // --- Get options -----------------------------------------------
210  ULong_t run = fOptions.AsInt("run", 0);
211  UShort_t sys = fOptions.AsInt("sys", 0);
212  UShort_t sNN = fOptions.AsInt("snn", 0);
213  UShort_t fld = fOptions.AsInt("field", 0);
214  UShort_t mSt = fOptions.AsInt("max-strips", 2);
215  Bool_t sec = fOptions.Has("secmap");
216  TString corr = "";
217  if (fOptions.Has("corr")) corr = fOptions.Get("corr");
218 
219  // --- Add the task ----------------------------------------------
220  TString cenConfig = fOptions.Get("central-config");
221  AliAnalysisTask* cen = CoupleSECar("AddTaskCentralMult.C",
222  Form("%d,%ld,%d,%d,%d,\"%s\",\"%s\"",
223  mc, run, sys, sNN, fld,
224  cenConfig.Data(), corr.Data()),
225  mask);
226  if (!cen)
227  Fatal("CoupleClusterCar", "Failed to add central (cluster) task");
228  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(),cenConfig),true);
229  if (!corr.IsNull())
230  fRailway->LoadAux(Form("%s/spd_corrections.root",corr.Data()), true);
231  gROOT->ProcessLine(Form("((AliCentralMultiplicityTask*)%p)"
232  "->SetUseSecondary(%d)",
233  cen, sec));
234  }
243  {
244  // --- Output file name ------------------------------------------
245  AliAnalysisManager::SetCommonFileName("tracklet.root");
246 
247  // Load our sources
248  fRailway->LoadSource("FixPaths.C");
249  fRailway->LoadSource("AliAODSimpleHeader.C");
250  fRailway->LoadSource("AliSimpleHeaderTask.C");
251  fRailway->LoadSource("AliAODTracklet.C");
252  fRailway->LoadSource("AliTrackletAODTask.C");
253 
254  // --- Task to create simple header ------------------------------
255  if (!gROOT->ProcessLine("AliSimpleHeaderTask::Create()"))
256  Fatal("CoupleTrackletTask", "Failed to make simple header task");
257 
258  // --- Create the task using interpreter -------------------------
259  Long_t ret =
260  gROOT->ProcessLine("AliTrackletAODTask::Create()");
261  AliAnalysisTaskSE* task = reinterpret_cast<AliAnalysisTaskSE*>(ret);
262  if (!task)
263  Fatal("CoupleTrackletCar", "Failed to make tracklet task");
264 
265  // --- Set various options on task -------------------------------
266  FromOption(task, "MaxDelta", "max-delta", 25.);
267  FromOption(task, "ScaleDTheta", "scale-dtheta", true);
268  FromOption(task, "DPhiWindow", "dphi-window", 0.06);
269  FromOption(task, "DThetaWindow", "dtheta-window", 0.025);
270  FromOption(task, "DPhiShift", "dphi-shift", 0.0045);
271  FromOption(task, "PhiOverlapCut", "phi-overlap-cut" , 0.005);
272  FromOption(task, "ZEtaOverlapCut", "z-eta-overlap-cut", 0.05);
273  FromOption(task, "FilterStrange", "filter-str", 0);
274  }
283  {
284  // --- Output file name ------------------------------------------
285  AliAnalysisManager::SetCommonFileName("AnalysisResults.root");
286  // --- Add MC particle task --------------------------------------
287  if (!mc || !fOptions.Has("mc-tracks")) return;
288  CoupleSECar("AddTaskMCParticleFilter.C","", mask);
289  }
296  {
297  // --- Load libraries/pars ---------------------------------------
298  fRailway->LoadLibrary("PWGLFforward2");
299 
300  // --- Set load path ---------------------------------------------
301  TString mp(gROOT->GetMacroPath());
302  mp.Append(":$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2");
303  mp.Append(":$(ALICE_ROOT)/ANALYSIS/macros");
304  mp.Append(":$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2/dndeta/tracklets3");
305  gROOT->SetMacroPath(mp);
306 
307  // --- Check if this is MC ---------------------------------------
308  Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
309  UInt_t mask = AliVEvent::kAny;
310 
311  // --- Couple our tasks ------------------------------------------
312  CouplePreCars (mgr, mc, mask);
313  CoupleForwardCar (mgr, mc, mask);
314  CoupleClusterCar (mgr, mc, mask);
315  CoupleTrackletCar(mgr, mc, mask);
316  CouplePostCars (mgr, mc, mask);
317  }
318  //__________________________________________________________________
325  {
326  if (!fOptions.Has("cent")) return;
328  }
329  //__________________________________________________________________
330  const char* ClassName() const { return "BothAODTrain"; }
331  //__________________________________________________________________
338  void SaveSetup(Bool_t asShellScript)
339  {
340  TrainSetup::SaveSetup(asShellScript);
341  SaveSummarize();
342  SavedNdeta(asShellScript);
343  }
349  void SavedNdeta(Bool_t asShellScript)
350  {
351  if (!fRailway) {
352  Warning("BothAODTrain::SaveSetup",
353  "Cannot make dNdeta.C script without helper");
354  return;
355  }
356 
357  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
358  Bool_t mc = mgr && (mgr->GetMCtruthEventHandler() != 0);
359  OptionList uopts(fRailway->Options());
360  OptionList opts(fOptions);
361  TString cls("BothdNdetaTrain");
362  TString name(fName);
363  Int_t sys = fOptions.AsInt("sys", 0);
364  if (name.Contains("aod")) name.ReplaceAll("aod", "dndeta");
365  else name.Append("_dndeta");
366  opts.Remove("run");
367  opts.Remove("sys");
368  opts.Remove("snn");
369  opts.Remove("field");
370  opts.Remove("tpc-ep");
371  opts.Remove("corr");
372  opts.Remove("max-strips");
373  opts.Remove("mc-tracks");
374  opts.Remove("secmap");
375  opts.Remove("copy");
376  opts.Remove("scale-dtheta");
377  opts.Remove("dphi-window");
378  opts.Remove("dtheta-window");
379  opts.Remove("phi-overlap-cut");
380  opts.Remove("z-eta-overlap-cut");
381  opts.Remove("filter-k0s");
382  // Various
383  opts.Add("cent-bins", "BINS", "Centrality bins", "");
384  opts.Add("ipz-bins", "BINS", "IPz bins", "u15");
385  opts.Add("satellite", "Restrict analysis to satellite events",false);
386  opts.Add("trig", "TRIGGER", "Trigger type", "INEL");
387  opts.Add("filter", "FILTER", "Filter type", "OUTLIER|PILEUP-BIN");
388  opts.Add("mc", "Also analyse MC truth", fRailway->IsMC());
389  opts.Add("multsel", "Enable MultSelection", false);
390  opts.Add("abs-min-cent", "PERCENT", "Absolute least cent.", -1);
391  // For forward
392  opts.Add("scheme", "FLAGS", "Normalization scheme","TRIGGER,EVENT");
393  opts.Add("trigEff", "EFFICIENCY","Trigger efficiency", 1.);
394  opts.Add("trigEff0", "EFFICIENCY","0-bin trigger efficiency",1.);
395  opts.Add("truth-config", "FILE", "MC-Truth configuration", "");
396  opts.Add("mean-ipz", "MU", "Mean of IPz dist.", 0);
397  opts.Add("var-ipz", "SIGMA", "Variance of IPz dist.", -1);
398  // For tracklets
399  opts.Add("eta-bins", "BINS", "Eta bins", "r16:-2:+2");
400  opts.Add("tail-delta", "X", "Tail cut on distance", 5.);
401  opts.Add("tail-max", "X", "Tail cut on distance", -1.);
402  opts.Add("delta-cut", "X", "Cut on weighted distance",1.5);
403  opts.Add("shifted-dphi-cut","RADIANS","Cut on dPhi-phiBent", -1.);
404  opts.Add("reweigh", "FILE", "File with weights", "");
405  opts.Add("reweigh-calc", "MODE", "prod,square,sum", "prod");
406  opts.Add("reweigh-mask", "MASK", "Tracklet mask for weighing", 0xFF);
407  opts.Add("reweigh-veto", "VETO", "Tracklet veto for weighing", 0x0);
408  opts.Add("reweigh-inv", "W -> 1/W", false);
409 
410  // Rewrite our URL
411  TString outString = fRailway->OutputLocation();
412  if (outString.IsNull()) outString = fEscapedName;
413  TUrl outUrl(outString);
414 
415  if (uopts.Find("pattern")) // && outString.EndsWith("AliAOD.root"))
416  uopts.Set("pattern", "*/AliAOD.root");
417  // if (uopts.Find("concat")) uopts.Set("concat", true);
418  if (uopts.Find("par")) uopts.Set("par", "task");
419 
420  std::stringstream s;
421  uopts.Store(s, "", "&", false, true);
422  outUrl.SetOptions(s.str().c_str());
423 
424  const char* defConfig=
425  "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dNdetaConfig.C";
426  opts.Set("url", outUrl.GetUrl());
427  opts.Set("type", "AOD");
428  opts.Set("forward-config",defConfig);
429  opts.Set("central-config",defConfig);
430  opts.Set("truth-config",defConfig);
431  if (!fDatimeString.IsNull()) opts.Set("date", fDatimeString);
432 
433  if (sys != 1) {
434  opts.Set("cent", "default");
435  opts.Set("trig", "V0AND");
436  opts.Set("scheme", "default");
437  opts.Set("cent-bins", "default");
438  SaveSetupROOT("dNdeta", cls, name, opts, &uopts);
439  if (asShellScript)
440  SaveSetupShell("dndeta", cls, name, opts, &uopts);
441  }
442  else {
443  name.ReplaceAll("dndeta", "dndeta_inel");
444  SaveSetupROOT("dNdetaINEL", cls, name, opts, &uopts);
445  if (asShellScript)
446  SaveSetupShell("dndeta_inel", cls, name, opts, &uopts);
447 
448  name.ReplaceAll("inel", "nsd");
449  opts.Set("trig", "V0AND");
450  SaveSetupROOT("dNdetaNSD", cls, name, opts, &uopts);
451  if (asShellScript)
452  SaveSetupShell("dndeta_nsd", cls, name, opts, &uopts);
453 
454  name.ReplaceAll("nsd", "inelgt0");
455  opts.Set("trig", "INELGT0");
456  SaveSetupROOT("dNdetaINELGt0", cls, name, opts, &uopts);
457  if (asShellScript)
458  SaveSetupShell("dndeta_inelgt0", cls, name, opts, &uopts);
459  }
460  }
466  {
467  std::ofstream f("Summarize.C");
468  if (!f) {
469  Error("SaveSummarize", "Failed to open Summarize.C script");
470  return;
471  }
472  f << "// Generated by " << ClassName() << "\n"
473  << "// WHAT is a bit mask of\n"
474  << "// 0x001 Event inspector\n"
475  << "// 0x002 Sharing filter\n"
476  << "// 0x004 Density calculator\n"
477  << "// 0x008 Corrector\n"
478  << "// 0x010 Histogram collector\n"
479  << "// 0x020 Analysis step cartoon\n"
480  << "// 0x040 Results\n"
481  << "// 0x080 Central\n"
482  << "// 0x100 Landscape\n"
483  << "// 0x200 Pause\n"
484  << "//\n"
485  << "void Summarize(const char* filename=\"forward.root\",\n"
486  << " UShort_t what=0x1FF)\n"
487  << "{\n"
488  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
489  << " gROOT->LoadMacro(Form(\"%s/DrawAODSummary.C\",fwd));\n"
490  << " DrawAODSummary(filename,what);\n"
491  << "}\n"
492  << "// EOF" << std::endl;
493  f.close();
494  }
500  void PostShellCode(std::ostream& f)
501  {
502  f << " echo \"=== Summarizing results ...\"\n"
503  << " aliroot -l -b -q ${prefix}Summarize.C\n"
504  << std::endl;
505  }
506 };
507 //
508 // EOF
509 //
Double_t AsDouble(const TString &name, Double_t def=0) const
Definition: Option.C:673
void CoupleTrackletCar(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:242
virtual void CreateCentralitySelection(Bool_t mc)
Definition: TrainSetup.C:759
virtual AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t esdRecPoints=false)
Definition: TrainSetup.C:539
double Double_t
Definition: External.C:58
TString fDatimeString
Definition: TrainSetup.C:1664
Railway * fRailway
Definition: TrainSetup.C:1666
TString fName
Definition: TrainSetup.C:1662
void CoupleClusterCar(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:204
void PostShellCode(std::ostream &f)
Definition: BothAODTrain.C:500
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
TSystem * gSystem
virtual AliVEventHandler * CreateMCHandler(UShort_t, bool mc)
Definition: TrainSetup.C:582
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:1495
Definition: External.C:92
void CreateTasks(AliAnalysisManager *mgr)
Definition: BothAODTrain.C:295
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:93
BothAODTrain(const TString &name)
Definition: BothAODTrain.C:29
void CoupleForwardCar(AliAnalysisManager *mgr, Bool_t mc, UInt_t mask)
Definition: BothAODTrain.C:157
const OptionList & Options() const
Definition: Railway.C:454
void SaveSummarize()
Definition: BothAODTrain.C:465
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:282
void SaveSetup(Bool_t asShellScript)
Definition: BothAODTrain.C:338
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1471
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:108
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Double_t defval)
Definition: TrainSetup.C:1228
OptionList fOptions
Definition: TrainSetup.C:1665
unsigned short UShort_t
Definition: External.C:28
void SetOnFwd(AliAnalysisTask *task, const TString &call, const TString &arg)
Definition: BothAODTrain.C:125
AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t needRec=false)
Definition: BothAODTrain.C:79
bool Bool_t
Definition: External.C:53
void SetOnMCFwd(AliAnalysisTask *task, const TString &call, const TString &arg)
Definition: BothAODTrain.C:141
TString fEscapedName
Definition: TrainSetup.C:1663
void CreateCentralitySelection(Bool_t mc)
Definition: BothAODTrain.C:324
virtual AliAnalysisTaskSE * CoupleSECar(const TString &macro, const TString &args, UInt_t mask=0)
Definition: TrainSetup.C:875
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
const char * ClassName() const
Definition: BothAODTrain.C:330
static void SaveSetupROOT(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1536
virtual Bool_t LoadSource(const TString &name, bool copy=false)
Definition: Railway.C:231
void SavedNdeta(Bool_t asShellScript)
Definition: BothAODTrain.C:349