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