AliPhysics  5eaf189 (5eaf189)
TrackletdNdetaTrain.C
Go to the documentation of this file.
1 
12 #include "TrainSetup.C"
13 #include <TF1.h>
14 
15 //====================================================================
23 class TrackletdNdetaTrain : public TrainSetup
24 {
25 public:
31  TrackletdNdetaTrain(const char* name)
32  : TrainSetup(name)
33  {
34  fOptions.Add("trig", "TYPE", "Trigger type", "INEL");
35  fOptions.Add("trigEff", "EFFICIENCY","Trigger efficiency", 1.);
36  fOptions.Add("filter", "TYPE", "Filter type","OUTLIER|PILEUP-BIN");
37  fOptions.Add("cent", "ESTIMATOR", "Use centrality", "none");
38  fOptions.Add("cent-bins", "BINS", "Centrality bins", "default");
39  fOptions.Add("abs-min-cent", "PERCENT", "Absolute least centrality", -1.);
40  fOptions.Add("ipz-bins", "BINS", "IPz bins", "u15");
41  fOptions.Add("eta-bins", "BINS", "Eta bins", "r16:-2:+2");
42  // For simulations
43  fOptions.Add("mc", "Also make dN/deta for MC truth", false);
44  // For SPD tracklets
45  fOptions.Add("max-delta", "X", "Cut on weighted distance",25.);
46  fOptions.Add("tail-delta", "X", "Tail cut on distance", 5.);
47  fOptions.Add("tail-max", "X", "Tail cut on distance", -1.);
48  fOptions.Add("delta-cut", "X", "Cut on weighted distance",1.5);
49  fOptions.Add("dphi-shift", "RADIANS","Bending shift", 0.0045);
50  fOptions.Add("shifted-dphi-cut", "RADIANS", "Cut on dPhi-phiBent", -1.);
51  fOptions.Add("reweigh", "FILE", "File with weights", "");
52  fOptions.Add("reweigh-calc", "MODE", "prod,square,sum", "prod");
53  fOptions.Add("reweigh-mask", "MASK", "Tracklet mask for weighing", 0xFF);
54  fOptions.Add("reweigh-veto", "VETO", "Tracklet veto for weighing", 0x0);
55  fOptions.Add("reweigh-inv", "W -> 1/W", false);
56 
57  }
58 protected:
65  {
66  AliAnalysisManager::SetCommonFileName("tracklet_dndeta.root");
67  TString fwd(gSystem->Getenv("ANA_SRC"));
68  if (fwd.IsNull()) fwd = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
69  gROOT->SetMacroPath(Form("%s:%s/dndeta/tracklets3",
70  gROOT->GetMacroPath(), fwd.Data()));
71  gSystem->AddIncludePath(Form("-I%s/dndeta/tracklets3", fwd.Data()));
72 
73  Info("CreateTasks", "Loading code");
74  fRailway->LoadSource("FixPaths.C");
75  fRailway->LoadSource("AliAODSimpleHeader.C");
76  fRailway->LoadSource("AliAODTracklet.C");
77  fRailway->LoadSource("AliTrackletWeights.C");
78  fRailway->LoadSource("AliTrackletAODUtils.C");
79  fRailway->LoadSource("AliTrackletAODdNdeta.C");
80 
81  // --- Create the task using interpreter -------------------------
82  Bool_t mc = fOptions.Has("mc");
83  if (!mc) mc = fRailway->IsMC();
84  Long_t ret =
85  gROOT->ProcessLine(Form("AliTrackletAODdNdeta::Create(%d,\"%s\")",mc,
86  fOptions.AsString("reweigh")));
87  AliAnalysisTaskSE* task = reinterpret_cast<AliAnalysisTaskSE*>(ret);
88  if (!task) return;
89 
90  // --- Figure out the trigger options ----------------------------
91  TString trg = fOptions.Get("trig"); trg.ToUpper();
92  UInt_t sel = AliVEvent::kINT7;
93  UInt_t mb = AliVEvent::kINT1; // AliVEvent::kMB;
94  if (trg.EqualTo("MB")) sel = mb;
95  else if (trg.EqualTo("MBOR")) sel = mb;
96  else if (trg.EqualTo("INEL")) sel = mb;
97  else if (trg.EqualTo("INELGT0")) sel = mb;
98  else if (trg.EqualTo("V0AND")) sel = AliVEvent::kINT7;
99  else if (trg.EqualTo("NSD")) sel = AliVEvent::kINT7;
100  else if (trg.EqualTo("V0OR")) sel = AliVEvent::kCINT5;
101  else if (trg.EqualTo("ANY")) sel = AliVEvent::kAny;
102  else if (trg.EqualTo("NONE")) sel = 0;
103  task->SelectCollisionCandidates(sel);
104  Int_t minTrk = trg.EqualTo("INELGT0") ? 1 : 0;
105 
106  // --- Figure out calculation mode -------------------------------
107  TString calc = fOptions.Get("reweigh-calc"); calc.ToUpper();
108  UChar_t mcal = 0;
109  if (calc.BeginsWith("PROD")) mcal = 0;
110  else if (calc.BeginsWith("SQ")) mcal = 1;
111  else if (calc.BeginsWith("SUM")) mcal = 2;
112  else if (calc.BeginsWith("AV")) mcal = 3;
113 
114  // --- Set various options on task -------------------------------
115  const char* defCent = "0-5-10-20-30-40-50-60-70-80-90";
116  FromOption(task, "CentralityMethod", "cent", "V0M");
117  FromOption(task, "CentralityAxis", "cent-bins", defCent);
118  FromOption(task, "EtaAxis", "eta-bins", "r16:2");
119  FromOption(task, "IPzAxis", "ipz-bins", "u15");
120  FromOption(task, "DeltaCut", "delta-cut", 1.5);
121  FromOption(task, "TailDelta", "tail-delta", 5.);
122  FromOption(task, "TailMaximum", "tail-max", -1);
123  FromOption(task, "MaxDelta", "max-delta", 25.);
124  FromOption(task, "DPhiShift", "dphi-shift", 0.0045);
125  FromOption(task, "ShiftedDPhiCut", "shifted-dphi-cut", -1.);
126  FromOption(task, "AbsMinCent", "abs-min-cent", -1.);
127  FromOption(task, "WeightMask", "reweigh-mask", 0xFF);
128  FromOption(task, "WeightVeto", "reweigh-veto", 0x0);
129  SetOnTask (task, "WeightCalc", mcal);
130  FromOption(task, "WeightInverse", "reweigh-inv", false);
131  FromOption(task, "TriggerEfficiency","trigEff", 0.);
132  SetOnTask (task, "MinEta1", minTrk);
133  // if (mc && we) {
134  // TUrl wurl(fOptions.AsString("reweight"));
135  // TFile* wfile = TFile::Open(wurl.GetFile());
136  // if (!wfile) {
137  // Warning("CreateTasks", "Failed to open weights file: %s",
138  // wurl.GetUrl());
139  // return;
140  // }
141  // TString wnam(wurl.GetAnchor());
142  // if (wnam.IsNull()) wnam = "weights";
143  // TObject* wobj = wfile->Get(wnam);
144  // if (!wobj) {
145  // Warning("CreateTasks", "Failed to get weights %s from file %s",
146  // wnam.Data(), wfile->GetName());
147  // return;
148  // }
149  // if (!wobj->IsA()->InheritsFrom("AliTrackletWeights")) {
150  // Warning("CreateTasks", "Object %s from file %s not an "
151  // "AliTrackletWeights but a %s",
152  // wnam.Data(), wfile->GetName(), wobj->ClassName());
153  // return;
154  // }
155  // SetOnTaskGeneric(task, "Weights",
156  // Form("((AliTrackletWeights*)%p)", wobj));
157  // }
158  Printf("Print the generated task");
159  task->Print("");
160  }
166  {
167  // --- Load libraries/pars ---------------------------------------
168  fRailway->LoadLibrary("PWGLFforward2");
169  // fRailway->LoadLibrary("AOD");
170  // gSystem->ListLibraries();
171  // gSystem->Load("libAOD");
172 
173  // --- Set load path ---------------------------------------------
174  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
175  gROOT->GetMacroPath()));
176 
177  // --- Add the task ----------------------------------------------
178  CoupleTrackletCar(mgr);
179 
180  }
181  //__________________________________________________________________
185  //__________________________________________________________________
186  // void CreateCentralitySelection(Bool_t) {}
192  AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; }
193  //__________________________________________________________________
199  AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
200  //__________________________________________________________________
201  const char* ClassName() const { return "TrackletdNdetaTrain"; }
202  //__________________________________________________________________
208  void SaveSetup(Bool_t asShellScript)
209  {
210  TrainSetup::SaveSetup(asShellScript);
211 
212  SaveCollect();
213  }
214  void SaveCollect()
215  {
216  std::ofstream o("Collect.C");
217  if (!o) {
218  Error("TrackletdNdetaTrain::SavePost", "Failed to open Collect.C");
219  return;
220  }
221  o << "// Created by " << ClassName() << "\n"
222  << "// Will draw dN/deta results from produced files\n"
223  << "// \n"
224  << "void Collect(const char* other,\n"
225  << " const char* output,\n"
226  << " UInt_t proc=0x22,\n"
227  << " UInt_t viz=0x32f,\n"
228  << " UInt_t n=10)\n"
229  << "{\n"
230  << " TString fwd=\n"
231  << " \"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/tracklets3\";\n"
232  << " if (gSystem->Getenv(\"ANA_SRC\"))\n"
233  << " fwd = \"$ANA_SRC/dndeta/tracklets3\";\n"
234  << " gROOT->LoadMacro(Form(\"%s/Post.C\",fwd.Data()));\n"
235  << " const char* thisDir = \"" << fEscapedName << "\";\n";
236  if (fRailway->IsMC())
237  o << " Post(thisDir,other,output,proc,viz,n);\n";
238  else
239  o << " Post(other,thisDir,output,proc,viz,n);\n";
240  o << "}\n"
241  << "// EOF\n"
242  << std::endl;
243  o.close();
244  }
245  void PostShellCode(std::ostream& f)
246  {
247  f << " echo \"=== Summarizing results ...\"\n"
248  << " aliroot -l -b -q ${prefix}Summarize.C\n"
249  << " echo \"=== Draw results ...\"\n"
250  << " aliroot -l -b -q ${prefix}Draw.C\n"
251  << std::endl;
252  }
253 };
254 //
255 // EOF
256 //
Railway * fRailway
Definition: TrainSetup.C:1674
TSystem * gSystem
const char * AsString(const TString &name, const TString &def="") const
Definition: Option.C:687
void CreateTasks(AliAnalysisManager *mgr)
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
TrackletdNdetaTrain(const char *name)
AliVEventHandler * CreateMCHandler(UShort_t, bool)
virtual Bool_t IsMC() const
Definition: Railway.C:354
void CoupleTrackletCar(AliAnalysisManager *mgr)
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
void SaveSetup(Bool_t asShellScript)
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1479
const char * ClassName() const
void PostShellCode(std::ostream &f)
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Double_t defval)
Definition: TrainSetup.C:1236
OptionList fOptions
Definition: TrainSetup.C:1673
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
TString fEscapedName
Definition: TrainSetup.C:1671
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
virtual Bool_t LoadSource(const TString &name, bool copy=false)
Definition: Railway.C:231
void SetOnTask(AliAnalysisTaskSE *task, const char *what, UInt_t val)
Definition: TrainSetup.C:1136
AliVEventHandler * CreateOutputHandler(UShort_t)