AliPhysics  6f1d526 (6f1d526)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackletdNdetaTrain.C
Go to the documentation of this file.
1 #include "TrainSetup.C"
2 #ifndef __CINT__
3 #include <AliESDInputHandlerRP.h>
4 // #include <AliMixInputEventHandler.h>
5 // #include <AliMixEventPool.h>
6 // #include <AliMixEventCutObj.h>
7 #include <TMacro.h>
8 #else
10 #endif
11 
34 {
40  TrackletdNdetaTrain(const char* name)
41  : TrainSetup(name)
42  {
43  // Define all our options here
44  fOptions.Add("trig", "NAME", "Trigger to use", "V0AND");
45  fOptions.Add("cent", "METHOD","Centrality selector", "V0M");
46  fOptions.Add("cent-bins", "BINS", "Centrality bins",
47  "0-5-10-20-30-40-50-60-70-80");
48  fOptions.Add("max-delta", "X", "Cut on weighted distance",25.);
49  fOptions.Add("tail-delta", "X", "Tail cut on distance", 5.);
50  fOptions.Add("scale-dtheta", "Scale dTheta" , true);
51  fOptions.Add("cut-dtheta", "Cut dTheta", false);
52  fOptions.Add("dphi-window", "X", "dPhi window", 0.06);
53  fOptions.Add("dtheta-window", "X", "dTheta window", 0.025);
54  fOptions.Add("dphi-shift", "X", "Bending shift", 0.0045);
55  fOptions.Add("phi-overlap-cut", "X", "Phi overlap cut", 0.005);
56  fOptions.Add("z-eta-overlap-cut","X", "Z-Eta overlap cut", 0.05);
57  fOptions.Add("phi-rotation", "X", "Rotation BG angle",TMath::Pi());
58  fOptions.Add("inj-scale", "X", "Injection BG scale", 1.);
59  fOptions.Add("shifted-dphi-cut", "X", "Cut on dPhi-phiBent", -1.);
60  fOptions.Add("delta-cut", "X", "Cut on weighted distance", 1.5);
61  fOptions.Add("eta-bins", "BINS", "Eta bins", "r16:-2:+2");
62  fOptions.Add("ipz-bins", "BINS", "IPz bins", "u15");
63  fOptions.Add("reconstruct", "WHAT", "Reconstruction types",
64  "NORMAL,INJECTION");
65  fOptions.Add("reweight", "OPTIONS","','-seperates list", "");
66  fOptions.SetDescription("Run tracklet analysis on ESD data files to "
67  "extract dNch/deta. The train should be run on "
68  "both real data and simulated data.\n"
69  "BINS are specified as comma or colon separated "
70  "lists of bins. If prefixed by 'r', then the "
71  "specification assumes the first number is the "
72  "number of bins, and the following one or two "
73  "numbers give the min/max. If prefixed by 'u' "
74  "then unit bins are assumed, and the following "
75  "one or two numbers give the min/max.\n"
76  "When processing simulated data, it is possible to "
77  "reweigh the particles according to predefined "
78  "histograms in pT. These histograms should "
79  "be stored in separate files. The option to "
80  "select reweighting is 'reweight', which is "
81  "a comma separated list of options:\n"
82  "- pt, pid, str: Reweigh according to pT, PID or "
83  "weak decays\n"
84  "- up, down: Vary reweight up or down\n"
85  "- pi, K, p: For PID reweigh of particular specie");
86 
87  }
98  AliVEventHandler* CreateInputHandler(UShort_t type, Bool_t needRec=false)
99  {
100  TString recMode = fOptions.AsString("reconstruct");
101  recMode.ToLower();
102  Bool_t needRP = (recMode.Contains("nor") ||
103  recMode.Contains("inj") ||
104  recMode.Contains("rot") || needRec);
105  // Info("CreateInputHandler", "Will create for %d (%d)", type, needRP);
106  return TrainSetup::CreateInputHandler(type, needRP);
107  }
117  AliVEventHandler* CreateMCHandler(UShort_t type, bool mc)
118  {
119  AliMCEventHandler* ret =
120  static_cast<AliMCEventHandler*>(TrainSetup::CreateMCHandler(type,mc));
121  if (ret) ret->SetPreReadMode(AliMCEventHandler::kLmPreRead);
122  return ret;
123  }
130  virtual AliVEventHandler* CreateOutputHandler(UShort_t)
131  {
132  return 0;
133  }
165  {
166  TString sel = fOptions.AsString("reweight");
167  sel.ToLower();
168  if (sel.IsNull() || sel.BeginsWith("no"))
169  return;
170 
171  TList files;
172  Int_t what = 0;
173  Int_t opt = 0;
174  TObjArray* tokens = sel.Tokenize(", ");
175  TIter next(tokens);
176  TObjString* ostr;
177  // First find what should be done
178  while ((ostr = static_cast<TObjString*>(next()))) {
179  const TString& token = ostr->String();
180 
181  if (token.EqualTo("pt")) {
182  what |= 0x1;
183  files.Add(new TObjString("REWEIGHTpt.root"));
184  Printf("Will reweigh in pT");
185  }
186  else if (token.EqualTo("pid")) {
187  what |= 0x2;
188  Printf("Will reweigh particle species");
189  }
190  else if (token.EqualTo("str")) {
191  what |= 0x4;
192  Printf("Will reweight particles from strange weak decays");
193  }
194  }
195  if (what == 0x0) return;
196 
197  // Now figure out how to do it
198  next.Reset();
199  TString part;
200  while ((ostr = static_cast<TObjString*>(next()))) {
201  const TString& token = ostr->String();
202  Int_t aOpt = TMath::Abs(opt);
203  if (token.EqualTo("up") || token.EqualTo("+"))
204  opt = (aOpt==0 ? +1 : +aOpt);
205  else if (token.EqualTo("down") || token.EqualTo("-"))
206  opt = (aOpt==0 ? -1 : -aOpt);
207  else if (token.EqualTo("pi") || token.EqualTo("pion")){
208  opt = 1; part = "pi";
209  }
210  else if (token.EqualTo("k") || token.EqualTo("kaon")) {
211  opt = 2; part = "ka";
212  }
213  else if (token.EqualTo("p") || token.EqualTo("proton")) {
214  opt = 3; part = "pr";
215  }
216  }
217  if (opt != 0)
218  Printf("Will reweigh %s (%c30%% for pT<0.05)",
219  opt < 0 ? "down" : "up", opt < 0 ? '-' : '+');
220  if (what & 0x2) {
221  if (!part.IsNull()) {
222  Printf("Will reweight %s in particular", part.Data());
223  part.Prepend("_");
224  part.Append(opt < 0 ? "-" : "+");
225  }
226  files.Add(new TObjString(Form("REWEIGHTpid%s.root", part.Data())));
227  }
228  if (what & 0x4)
229  files.Add(new TObjString(Form("REWEIGHTstr%s.root",
230  opt == -1 ? "-" :
231  opt == +1 ? "+" : "")));
232  delete tokens;
233 
234  Printf("Setting reweighing flag=0x%x with option=%d", what, opt);
235  SetOnTask(task, "ReweightStack", what);
236  SetOnTask(task, "ReweightFlag", opt);
237 
238  TIter nextF(&files);
239  while ((ostr = static_cast<TObjString*>(nextF()))) {
240  Printf("Loading reweighting file %s", ostr->GetName());
241  fRailway->LoadAux(ostr->GetName());
242  }
243  }
253  {
254  // Enable these lines to load the code from PWGUD directory.
255  // These do not seem to be up-to-speed with the latest
256  // developments, so for now, we use private scripts - sigh!
257  //
258  // Note, PWGLF also has these scripts, but it is not clear that
259  // they are anymore current than the ones in PWGUD.
260  //
261  // gROOT->SetMacroPath(Form("%s:$ALICE_PHYSICS/PWGUD/multVScentPbPb",
262  // gROOT->GetMacroPath()));
263  // gSystem->AddIncludePath("-I$ALICE_PHYSICS/PWGUD/multVScentPbPb");
264  Info("CreateTasks", "Loading code");
265  fRailway->LoadSource("FixPaths.C");
266  fRailway->LoadSource("AliTrackletdNdetaUtils.C");
267  fRailway->LoadSource("AliTrackletdNdetaTask.C");
268 
269  // --- Create the task using interpreter -------------------------
270  Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
271  const char* nme = (mc ? "MidMCdNdeta" : "MiddNdeta");
272  const char* cls = (mc ?
273  "AliTrackletdNdetaMCTask" :
274  "AliTrackletdNdetaTask");
275  Long_t ret = gROOT->ProcessLine(Form("new %s(\"%s\")",cls,nme));
276  AliAnalysisTaskSE* task =reinterpret_cast<AliAnalysisTaskSE*>(ret);
277  if (!task) return 0;
278 
279  // --- Add task to train -----------------------------------------
280  gROOT->ProcessLine(Form("((%s*)%p)->Connect()", cls, task));
281 
282  // --- Figure out the trigger options ----------------------------
283  TString trg = fOptions.Get("trig");
284  trg.ToUpper();
285  UInt_t sel = AliVEvent::kINT7;
286  if (trg.EqualTo("MB")) sel = AliVEvent::kMB;
287  else if (trg.EqualTo("V0AND")) sel = AliVEvent::kINT7;
288  else if (trg.EqualTo("V0OR")) sel = AliVEvent::kCINT5;
289  else if (trg.EqualTo("ANY")) sel = AliVEvent::kAny;
290 
291 
292  // --- Set various options on task -------------------------------
293  const char* defCent = "0-5-10-20-30-40-50-60-70-80-90";
294  task->SelectCollisionCandidates(sel);
295  FromOption(task, "ReconstructionMode", "reconstruct", "nor,inj");
296  FromOption(task, "CentralityMethod", "cent", "V0M");
297  FromOption(task, "CentralityAxis", "cent-bins", defCent);
298  FromOption(task, "EtaAxis", "eta-bins", "r16:2");
299  FromOption(task, "IPzAxis", "ipz-bins", "u15");
300  // FromOption(task, "CheckReconstructables", "check-reco", false);
301  FromOption(task, "MaxDelta", "max-delta", 25.);
302  FromOption(task, "TailDelta", "tail-delta", 5.);
303  FromOption(task, "ScaleDTheta", "scale-dtheta", false);
304  FromOption(task, "DPhiWindow", "dphi-window", 0.06);
305  FromOption(task, "DThetaWindow", "dtheta-window", 0.025);
306  FromOption(task, "DPhiShift", "dphi-shift", 0.0045);
307  FromOption(task, "PhiOverlapCut", "phi-overlap-cut" ,0.005);
308  FromOption(task, "ZEtaOverlapCut", "z-eta-overlap-cut",0.05);
309  FromOption(task, "PhiRotation", "phi-rotation", TMath::Pi());
310  // FromOption(task, "InjScale", "inj-scale", 1.);
311  FromOption(task, "ShiftedDPhiCut", "shifted-dphi-cut",-1.);
312  FromOption(task, "DeltaCut", "delta-cut", 1.5);
313  if (fOptions.AsBool("cut-dtheta"))
314  FromOption(task, "ScaleDThetaCut", "dtheta-window", 0.025);
315 
316  SetupReweighting(task);
317 
318  task->Print("");
319 
320  return task;
321  }
328  {
329  AliAnalysisTaskSE* task = CreateTask(mgr);
330  if (!task) {
331  Fatal("", "Failed to create the task");
332  return;
333  }
334 
335 #if 0
336  gSystem->RedirectOutput("settings.txt");
337  Printf("=== Settings for %s train === ", mc ? "mc" : "dt");
338  task->Dump();
339  gSystem->RedirectOutput(0);
340 #endif
341 
342  }
348  const char* ClassName() const { return "TrackletdNdetaTrain"; }
349 };
350 //
351 // EOF
352 //
virtual AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t esdRecPoints=false)
Definition: TrainSetup.C:539
Railway * fRailway
Definition: TrainSetup.C:1667
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
TSystem * gSystem
virtual AliVEventHandler * CreateMCHandler(UShort_t, bool mc)
Definition: TrainSetup.C:583
const char * AsString(const TString &name, const TString &def="") const
Definition: Option.C:687
void CreateTasks(AliAnalysisManager *mgr)
AliAnalysisTaskSE * CreateTask(AliAnalysisManager *mgr)
const TString & Get(const TString &name) const
Definition: Option.C:596
void SetupReweighting(AliAnalysisTaskSE *task)
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
TrackletdNdetaTrain(const char *name)
void SetDescription(const TString &d)
Definition: Option.C:359
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 * ClassName() const
virtual Bool_t LoadAux(const TString &name, Bool_t copy=false)
Definition: Railway.C:255
AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t needRec=false)
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
virtual AliVEventHandler * CreateOutputHandler(UShort_t)
AliVEventHandler * CreateMCHandler(UShort_t type, bool mc)
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