AliPhysics  d0c3a41 (d0c3a41)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  task->SelectCollisionCandidates(sel);
103  Int_t minTrk = trg.EqualTo("INELGT0") ? 1 : 0;
104 
105  // --- Figure out calculation mode -------------------------------
106  TString calc = fOptions.Get("reweigh-calc"); calc.ToUpper();
107  UChar_t mcal = 0;
108  if (calc.BeginsWith("PROD")) mcal = 0;
109  else if (calc.BeginsWith("SQ")) mcal = 1;
110  else if (calc.BeginsWith("SUM")) mcal = 2;
111  else if (calc.BeginsWith("AV")) mcal = 3;
112 
113  // --- Set various options on task -------------------------------
114  const char* defCent = "0-5-10-20-30-40-50-60-70-80-90";
115  FromOption(task, "CentralityMethod", "cent", "V0M");
116  FromOption(task, "CentralityAxis", "cent-bins", defCent);
117  FromOption(task, "EtaAxis", "eta-bins", "r16:2");
118  FromOption(task, "IPzAxis", "ipz-bins", "u15");
119  FromOption(task, "DeltaCut", "delta-cut", 1.5);
120  FromOption(task, "TailDelta", "tail-delta", 5.);
121  FromOption(task, "TailMaximum", "tail-max", -1);
122  FromOption(task, "MaxDelta", "max-delta", 25.);
123  FromOption(task, "DPhiShift", "dphi-shift", 0.0045);
124  FromOption(task, "ShiftedDPhiCut", "shifted-dphi-cut", -1.);
125  FromOption(task, "AbsMinCent", "abs-min-cent", -1.);
126  FromOption(task, "WeightMask", "reweigh-mask", 0xFF);
127  FromOption(task, "WeightVeto", "reweigh-veto", 0x0);
128  SetOnTask (task, "WeightCalc", mcal);
129  FromOption(task, "WeightInverse", "reweigh-inv", false);
130  FromOption(task, "TriggerEfficiency","trigEff", 0.);
131  SetOnTask (task, "MinEta1", minTrk);
132  // if (mc && we) {
133  // TUrl wurl(fOptions.AsString("reweight"));
134  // TFile* wfile = TFile::Open(wurl.GetFile());
135  // if (!wfile) {
136  // Warning("CreateTasks", "Failed to open weights file: %s",
137  // wurl.GetUrl());
138  // return;
139  // }
140  // TString wnam(wurl.GetAnchor());
141  // if (wnam.IsNull()) wnam = "weights";
142  // TObject* wobj = wfile->Get(wnam);
143  // if (!wobj) {
144  // Warning("CreateTasks", "Failed to get weights %s from file %s",
145  // wnam.Data(), wfile->GetName());
146  // return;
147  // }
148  // if (!wobj->IsA()->InheritsFrom("AliTrackletWeights")) {
149  // Warning("CreateTasks", "Object %s from file %s not an "
150  // "AliTrackletWeights but a %s",
151  // wnam.Data(), wfile->GetName(), wobj->ClassName());
152  // return;
153  // }
154  // SetOnTaskGeneric(task, "Weights",
155  // Form("((AliTrackletWeights*)%p)", wobj));
156  // }
157  Printf("Print the generated task");
158  task->Print("");
159  }
165  {
166  // --- Load libraries/pars ---------------------------------------
167  fRailway->LoadLibrary("PWGLFforward2");
168  // fRailway->LoadLibrary("AOD");
169  // gSystem->ListLibraries();
170  // gSystem->Load("libAOD");
171 
172  // --- Set load path ---------------------------------------------
173  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
174  gROOT->GetMacroPath()));
175 
176  // --- Add the task ----------------------------------------------
177  CoupleTrackletCar(mgr);
178 
179  }
180  //__________________________________________________________________
184  //__________________________________________________________________
185  // void CreateCentralitySelection(Bool_t) {}
191  AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; }
192  //__________________________________________________________________
198  AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
199  //__________________________________________________________________
200  const char* ClassName() const { return "TrackletdNdetaTrain"; }
201  //__________________________________________________________________
207  void SaveSetup(Bool_t asShellScript)
208  {
209  TrainSetup::SaveSetup(asShellScript);
210 
211  SaveCollect();
212  }
213  void SaveCollect()
214  {
215  std::ofstream o("Collect.C");
216  if (!o) {
217  Error("TrackletdNdetaTrain::SavePost", "Failed to open Collect.C");
218  return;
219  }
220  o << "// Created by " << ClassName() << "\n"
221  << "// Will draw dN/deta results from produced files\n"
222  << "// \n"
223  << "void Collect(const char* other,\n"
224  << " const char* output,\n"
225  << " UInt_t proc=0x22,\n"
226  << " UInt_t viz=0x32f,\n"
227  << " UInt_t n=10)\n"
228  << "{\n"
229  << " TString fwd=\n"
230  << " \"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/tracklets3\";\n"
231  << " if (gSystem->Getenv(\"ANA_SRC\"))\n"
232  << " fwd = \"$ANA_SRC/dndeta/tracklets3\";\n"
233  << " gROOT->LoadMacro(Form(\"%s/Post.C\",fwd.Data()));\n"
234  << " const char* thisDir = \"" << fEscapedName << "\";\n";
235  if (fRailway->IsMC())
236  o << " Post(thisDir,other,output,proc,viz,n);\n";
237  else
238  o << " Post(other,thisDir,output,proc,viz,n);\n";
239  o << "}\n"
240  << "// EOF\n"
241  << std::endl;
242  o.close();
243  }
244  void PostShellCode(std::ostream& f)
245  {
246  f << " echo \"=== Summarizing results ...\"\n"
247  << " aliroot -l -b -q ${prefix}Summarize.C\n"
248  << " echo \"=== Draw results ...\"\n"
249  << " aliroot -l -b -q ${prefix}Draw.C\n"
250  << std::endl;
251  }
252 };
253 //
254 // EOF
255 //
Railway * fRailway
Definition: TrainSetup.C:1667
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:1472
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:1229
OptionList fOptions
Definition: TrainSetup.C:1666
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
TString fEscapedName
Definition: TrainSetup.C:1664
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:1129
AliVEventHandler * CreateOutputHandler(UShort_t)