AliPhysics  35e5fca (35e5fca)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackletAODdNdeta.C
Go to the documentation of this file.
1 
11 #include "TrainSetup.C"
12 #ifndef __CINT__
13 #include <AliESDInputHandlerRP.h>
14 // #include <AliMixInputEventHandler.h>
15 // #include <AliMixEventPool.h>
16 // #include <AliMixEventCutObj.h>
17 #include <TMacro.h>
18 #else
19 class AliAnalysisTaskSE;
20 #endif
21 
46 {
52  TrackletAODdNdeta(const char* name)
53  : TrainSetup(name)
54  {
55  // Define all our options here
56  const char* defCent = DefaultCentBins();
57  fOptions.Add("trig", "NAME", "Trigger to use", "V0AND");
58  fOptions.Add("cent", "METHOD", "Centrality selector", "V0M");
59  fOptions.Add("cent-bins", "BINS", "Centrality bins", defCent);
60  fOptions.Add("eta-bins", "BINS", "Eta bins", "r16:-2:+2");
61  fOptions.Add("ipz-bins", "BINS", "IPz bins", "u15");
62  fOptions.Add("max-delta", "X", "Cut on weighted distance",25.);
63  fOptions.Add("tail-delta", "X", "Tail cut on distance", 5.);
64  fOptions.Add("tail-max", "X", "Tail cut on distance", -1.);
65  fOptions.Add("delta-cut", "X", "Cut on weighted distance",1.5);
66  fOptions.Add("dphi-shift", "RADIANS","Bending shift", 0.0045);
67  fOptions.Add("shifted-dphi-cut", "RADIANS", "Cut on dPhi-phiBent", -1.);
68  fOptions.Add("mc", "For MC data", false);
69  fOptions.Add("multsel", "Enable MultSelection", false);
70  fOptions.Add("abs-min-cent","PERCENT","Absolute least cent.", -1);
71  fOptions.Add("reweigh", "FILE", "File with weights", "");
72  fOptions.Add("reweigh-calc", "MODE", "prod,square,sum", "prod");
73  fOptions.Add("reweigh-mask", "MASK", "Tracklet mask for weighing", 0xFF);
74  fOptions.Add("reweigh-veto", "VETO", "Tracklet veto for weighing", 0x0);
75  fOptions.Add("reweigh-inv", "W -> 1/W", false);
76  fOptions.SetDescription("Analyse AOD for dN/deta from tracklets");
77  fOptions.Set("type", "AOD");
78  }
84  const char* DefaultCentBins() const
85  {
86  return "0-5-10-20-30-40-50-60-70-80-90";
87  }
94  virtual AliVEventHandler* CreateOutputHandler(UShort_t)
95  {
96  return 0;
97  }
104  {
105  mc = fOptions.Has("mc");
106  if (!mc) mc = fRailway->IsMC();
107  if (fOptions.AsBool("multsel"))
109  }
116  {
117  Info("CreateTasks", "Loading code");
118  fRailway->LoadSource("FixPaths.C");
119  fRailway->LoadSource("AliAODSimpleHeader.C");
120  fRailway->LoadSource("AliAODTracklet.C");
121  fRailway->LoadSource("AliTrackletWeights.C");
122  fRailway->LoadSource("AliTrackletAODUtils.C");
123  fRailway->LoadSource("AliTrackletAODdNdeta.C");
124 
125  // --- Create the task using interpreter -------------------------
126  Bool_t mc = fOptions.Has("mc");
127  if (!mc) mc = fRailway->IsMC();
128  Long_t ret =
129  gROOT->ProcessLine(Form("AliTrackletAODdNdeta::Create(%d,\"%s\")",mc,
130  fOptions.AsString("reweigh")));
131  AliAnalysisTaskSE* task = reinterpret_cast<AliAnalysisTaskSE*>(ret);
132  if (!task) return;
133 
134  // --- Figure out the trigger options ----------------------------
135  TString trg = fOptions.Get("trig"); trg.ToUpper();
136  UInt_t sel = AliVEvent::kINT7;
137  if (trg.EqualTo("MB")) sel = AliVEvent::kMB;
138  else if (trg.EqualTo("V0AND")) sel = AliVEvent::kINT7;
139  else if (trg.EqualTo("V0OR")) sel = AliVEvent::kCINT5;
140  else if (trg.EqualTo("ANY")) sel = AliVEvent::kAny;
141  task->SelectCollisionCandidates(sel);
142 
143  // --- Figure out calculation mode -------------------------------
144  TString calc = fOptions.Get("reweigh-calc"); calc.ToUpper();
145  UChar_t mcal = 0;
146  if (calc.BeginsWith("PROD")) mcal = 0;
147  else if (calc.BeginsWith("SQ")) mcal = 1;
148  else if (calc.BeginsWith("SUM")) mcal = 2;
149  else if (calc.BeginsWith("AV")) mcal = 3;
150 
151  // --- Set various options on task -------------------------------
152  const char* defCent = DefaultCentBins();
153  FromOption(task, "CentralityMethod","cent", "V0M");
154  FromOption(task, "CentralityAxis", "cent-bins", defCent);
155  FromOption(task, "EtaAxis", "eta-bins", "r16:2");
156  FromOption(task, "IPzAxis", "ipz-bins", "u15");
157  FromOption(task, "DeltaCut", "delta-cut", 1.5);
158  FromOption(task, "TailDelta", "tail-delta", 5.);
159  FromOption(task, "TailMaximum", "tail-max", -1);
160  FromOption(task, "MaxDelta", "max-delta", 25.);
161  FromOption(task, "DPhiShift", "dphi-shift", 0.0045);
162  FromOption(task, "ShiftedDPhiCut", "shifted-dphi-cut",-1.);
163  FromOption(task, "AbsMinCent", "abs-min-cent", -1.);
164  FromOption(task, "WeightMask", "reweigh-mask", 0xFF);
165  FromOption(task, "WeightVeto", "reweigh-veto", 0x0);
166  SetOnTask (task, "WeightCalc", mcal);
167  FromOption(task, "WeightInverse", "reweigh-inv", false);
168  task->Print("");
169  }
170  //__________________________________________________________________
176  void SaveSetup(Bool_t asShellScript)
177  {
178  TrainSetup::SaveSetup(asShellScript);
179 
180  SaveCollect();
181  }
188  void SaveCollect()
189  {
190  std::ofstream o("Collect.C");
191  if (!o) {
192  Error("TrackletAODdNdeta::SavePost", "Failed to open Collect.C");
193  return;
194  }
195  o << "// Created by " << ClassName() << "\n"
196  << "// Will draw dN/deta results from produced files\n"
197  << "// \n"
198  << "// Arguments:\n"
199  << "// other Directory of other result (MC or real)\n"
200  << "// output Optional output directory name\n"
201  << "// proc Bit mask of processing options\n"
202  << "// - 0x1 Unit normalisation of C\n"
203  << "// - 0x2 Constant normalisation of C\n"
204  << "// - 0x4 eta-dependent normalisation of C\n"
205  << "// - 0x8 (eta,IPz)-dependent normalisation of C\n"
206  << "// viz Bit mask of visualisation options\n"
207  << "// - 0x0001 General information\n"
208  << "// - 0x0002 Parameters used\n"
209  << "// - 0x0004 Show weights if used\n"
210  << "// - 0x0008 Show dN/deta \n"
211  << "// - 0x0010 Show species\n"
212  << "// - 0x0020 Show delta distribtions\n"
213  << "// - 0x0040 Show details of the calculation\n"
214  << "// - 0x0080 Reserved\n"
215  << "// - 0x0100 Generate PDF and PNGs\n"
216  << "// - 0x0200 Pause after each page\n"
217  << "// - 0x0400 Generate plots in landscape orientation\n"
218  << "// - 0x0800 Use an alternate marker\n"
219  << "// n Number of centrality bins to process\n"
220  << "// \n"
221  << "// Output is generated in the sub-directory\n"
222  << "// \n";
223  if (fRailway->IsMC())
224  o << "// " << fEscapedName << "_<other>\n";
225  else
226  o << "// <other>_" << fEscapedName << "\n";
227  o << "//\n"
228  << "// where <other> is the first argument given\n"
229  << "void Collect(const char* other,\n"
230  << " const char* output=0\n"
231  << " UInt_t proc=0x2,\n"
232  << " UInt_t viz=0x32f,\n"
233  << " UInt_t n=10)\n"
234  << "{\n"
235  << " TString fwd=\n"
236  << " \"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/tracklets3\";\n"
237  << " gSystem->AddIncludePath(Form(\"-I%s\",fwd.Data()));\n"
238  << " gROOT->LoadMacro(Form(\"%s/AliTrackletAODUtils.C+g\",fwd.Data()));"
239  << "\n"
240  << " gROOT->LoadMacro(Form(\"%s/AliTrackletdNdeta2.C+g\",fwd.Data()));"
241  << "\n";
242  TString oName(fEscapedName); oName.Append("/AnalysisResults.root");
243  if (fRailway->IsMC())
244  o << " TString realFile = Form(\"%s/AnalysisResults.root\",other);\n"
245  << " TString simFile = \"" << oName << "\";\n"
246  << " TString outFile = Form(\""<<fEscapedName <<"_%s\",other);\n";
247  else
248  o << " TString realFile = \"" << oName << "\";\n"
249  << " TString simFile = Form(\"%s/AnalysisResults.root\",other);\n"
250  << " TString outFile = Form(\"%s_"<<fEscapedName <<"\",other);\n";
251  o << " if (output && output[0] != '\0') outFile = output;\n"
252  << " AliTrackletdNdeta2* p = new AliTrackletdNdeta2;\n"
253  << " if (proc & 0x1) outFile.Append(\"_unit\");\n"
254  << " if (proc & 0x2) outFile.Append(\"_const\");\n"
255  << " if (proc & 0x4) outFile.Append(\"_eta\");\n"
256  << " if (proc & 0x8) outFile.Append(\"_etaipz\");\n"
257  << " \n"
258  << " p->Run(proc,viz,n,realFile,simFile,outFile);\n"
259  << " \n"
260  << " gROOT->LoadMacro(Form(\"%s/ExtractGSE2.C\",fwd.Data()));\n"
261  << " ExtractGSE2(outFile);\n"
262  << "}\n"
263  << "// EOF\n"
264  << std::endl;
265  o.close();
266  }
272  const char* ClassName() const { return "TrackletAODdNdeta"; }
273 };
274 //
275 // EOF
276 //
virtual void CreateCentralitySelection(Bool_t mc)
Definition: TrainSetup.C:759
Railway * fRailway
Definition: TrainSetup.C:1666
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
const char * AsString(const TString &name, const TString &def="") const
Definition: Option.C:687
void SaveSetup(Bool_t asShellScript)
const TString & Get(const TString &name) const
Definition: Option.C:596
const char * ClassName() const
Bool_t Has(const TString &name) const
Definition: Option.C:584
void CreateTasks(AliAnalysisManager *mgr)
unsigned int UInt_t
Definition: External.C:33
TrackletAODdNdeta(const char *name)
virtual void CreateCentralitySelection(Bool_t mc)
void Set(const TString &name, const TString &value)
Definition: Option.C:736
virtual Bool_t IsMC() const
Definition: Railway.C:354
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
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1471
const char * DefaultCentBins() const
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
bool Bool_t
Definition: External.C:53
TString fEscapedName
Definition: TrainSetup.C:1663
virtual AliVEventHandler * CreateOutputHandler(UShort_t)
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:1128