AliPhysics  9b6b435 (9b6b435)
MakeAODTrain.C
Go to the documentation of this file.
1 
10 #include "TrainSetup.C"
11 #include <sstream>
12 
13 //====================================================================
21 class MakeAODTrain : public TrainSetup
22 {
23 public:
29  MakeAODTrain(const TString& name)
30  : TrainSetup(name)
31  {
32  fOptions.Add("run", "NUMBER", "Run number for corrs", 0);
33  fOptions.Add("sys", "SYSTEM", "1:pp, 2:PbPb, 3:pPb", 0);
34  fOptions.Add("snn", "ENERGY", "Center of mass energy in GeV", 0);
35  fOptions.Add("field","STRENGTH","L3 field strength in kG", 0);
36  fOptions.Add("corr", "DIR", "Corrections dir", "");
37  fOptions.Add("dead", "FILE", "Additional dead-map script", "");
38  fOptions.Add("copy", "LIST", "',' separated list to copy","cent");
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("tpc-ep", "Use TPC event plane");
48  fOptions.Add("satelitte", "Use satelitte interactions");
49  fOptions.Add("secmap", "Use secondary maps to correct", false);
50  fOptions.Add("mc-tracks", "Enable MC track filter", false);
51  fOptions.Add("hit-threshold", "CUT", "Threshold for hits", 0.9);
52  fOptions.Set("type", "ESD");
53  }
54 protected:
63  const TString& call,
64  const TString& arg)
65  {
66  TString cmd;
67  cmd.Form("((AliForwardMultiplicityBase*)%p)->%s(%s)",
68  task, call.Data(), arg.Data());
69  gROOT->ProcessLine(cmd);
70  }
79  const TString& call,
80  const TString& arg)
81  {
82  TString cmd;
83  cmd.Form("((AliForwardMCMultiplicityTask*)%p)->%s(%s)",
84  task, call.Data(), arg.Data());
85  gROOT->ProcessLine(cmd);
86  }
93  {
94  // --- Output file name ------------------------------------------
95  AliAnalysisManager::SetCommonFileName("forward.root");
96 
97  // --- Load libraries/pars ---------------------------------------
98  fRailway->LoadLibrary("PWGLFforward2");
99 
100  // --- Set load path ---------------------------------------------
101  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
102  gROOT->GetMacroPath()));
103  gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/ANALYSIS/macros",
104  gROOT->GetMacroPath()));
105 
106  // --- Check if this is MC ---------------------------------------
107  Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
108 
109  UInt_t mask = AliVEvent::kAny;
110  // --- Add TPC eventplane task
111  if (fOptions.Has("tpc-ep")) CoupleSECar("AddTaskEventplane.C","", mask);
112 
113  // --- Task to copy header information ---------------------------
114  TString cpy = fOptions.Get("copy");
115  Info("", "What to copy: %s", cpy.Data());
116  CoupleSECar("AddTaskCopyHeader.C", Form("\"%s\"", cpy.Data()), mask);
117 
118  // --- Get options -----------------------------------------------
119  ULong_t run = fOptions.AsInt("run", 0);
120  UShort_t sys = fOptions.AsInt("sys", 0);
121  UShort_t sNN = fOptions.AsInt("snn", 0);
122  UShort_t fld = fOptions.AsInt("field", 0);
123  UShort_t mSt = fOptions.AsInt("max-strips", 2);
124  Double_t thr = fOptions.AsDouble("hit-threshold", .9);
125  Bool_t sec = fOptions.Has("secmap");
126  TString corr = "";
127  TString dead = "";
128  if (fOptions.Has("corr")) corr = fOptions.Get("corr");
129  if (fOptions.Has("dead")) dead = fOptions.Get("dead");
130 
131  // --- Add the task ----------------------------------------------
132  TString fwdConfig = fOptions.Get("forward-config");
134  CoupleSECar("AddTaskForwardMult.C",
135  Form("%d,%ld,%d,%d,%d,\"%s\",\"%s\",\"%s\"",
136  mc, run, sys, sNN, fld,
137  fwdConfig.Data(), corr.Data(),
138  dead.Data()), mask);
139  if (!fwd)
140  Fatal("CoupleCars", "Failed to add forward task");
141  SetOnFwd(fwd, "GetCorrections().SetUseSecondaryMap", Form("%d",sec));
142  SetOnFwd(fwd, "GetDensityCalculator()->SetHitThreshold", Form("%f", thr));
143  if (mc)
144  SetOnMCFwd(fwd, "GetTrackDensity().SetMaxConsequtiveStrips",
145  Form("%d",mSt));
146  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(), fwdConfig), true);
147  if (!corr.IsNull()) {
148  // fRailway->LoadAux(Form("%s/fmd_corrections.root",corr.Data()), true);
149  const char* names[] = {
150  "secondary",
151  "elossfits",
152  // "vertexbias",
153  // "merging",
154  // "doublehit",
155  "acceptance",
156  "noisegain",
157  0 };
158  const char** ptr = names;
159  while (*ptr) {
160  fRailway->LoadAux(Form("%s/%s",corr.Data(),*ptr),true);
161  ptr++;
162  }
163  }
164  if (!dead.IsNull())
165  fRailway->LoadAux(Form("%s",dead.Data()), true);
166 
167  // --- Add the task ----------------------------------------------
168  Bool_t noCentral = fOptions.Has("no-central");
169  AliAnalysisTask* cen = 0;
170  TString cenConfig = "";
171  if (!noCentral) {
172  cenConfig = fOptions.Get("central-config");
173  cen = CoupleSECar("AddTaskCentralMult.C",
174  Form("%d,%ld,%d,%d,%d,\"%s\",\"%s\"",
175  mc, run, sys, sNN, fld,
176  cenConfig.Data(), corr.Data()), mask);
177  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(),cenConfig),true);
178  if (!corr.IsNull())
179  fRailway->LoadAux(Form("%s/spd_corrections.root",corr.Data()), true);
180  gROOT->ProcessLine(Form("((AliCentralMultiplicityTask*)%p)"
181  "->SetUseSecondary(%d)",
182  cen, sec));
183  }
184 
185  // --- Add MC particle task --------------------------------------
186  if (mc && fOptions.Has("mc-tracks"))
187  CoupleSECar("AddTaskMCParticleFilter.C","", mask);
188  }
189  //__________________________________________________________________
196  {
197  if (!fOptions.Has("cent")) return;
199  }
200  //__________________________________________________________________
201  const char* ClassName() const { return "MakeAODTrain"; }
202  //__________________________________________________________________
209  void SaveSetup(Bool_t asShellScript)
210  {
211  TrainSetup::SaveSetup(asShellScript);
212  SaveSummarize();
213  SavedNdeta(asShellScript);
214  }
215  void SavedNdeta(Bool_t asShellScript)
216  {
217  if (!fRailway) {
218  Warning("MakeAODTrain::SaveSetup",
219  "Cannot make dNdeta.C script without helper");
220  return;
221  }
222 
223  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
224  Bool_t mc = mgr && (mgr->GetMCtruthEventHandler() != 0);
225  OptionList uopts(fRailway->Options());
226  OptionList opts(fOptions);
227  TString cls("MakedNdetaTrain");
228  TString name(fName);
229  Int_t sys = fOptions.AsInt("sys", 0);
230  if (name.Contains("aod")) name.ReplaceAll("aod", "dndeta");
231  else name.Append("_dndeta");
232  opts.Remove("run");
233  opts.Remove("sys");
234  opts.Remove("snn");
235  opts.Remove("field");
236  opts.Remove("tpc-ep");
237  opts.Remove("corr");
238  opts.Remove("max-strips");
239  opts.Remove("mc-tracks");
240  opts.Remove("secmap");
241  opts.Remove("dead");
242  opts.Add("abs-min-cent","PERCENT", "Absolute least centrality",-1.);
243  opts.Add("cent-bins", "BINS", "Centrality bins", "");
244  opts.Add("satellite", "Restrict analysis to satellite events", false);
245  opts.Add("trig", "TRIGGER", "Trigger type", "INEL");
246  opts.Add("filter", "FILTER", "Filter type", "OUTLIER|PILEUP-BIN");
247  opts.Add("ipz-bins", "BINS", "Lower bound on Ip Z", "u10");
248  opts.Add("scheme", "FLAGS", "Normalization scheme", "TRIGGER,EVENT");
249  opts.Add("trigEff", "EFFICIENCY","Trigger efficiency", 1.);
250  opts.Add("trigEff0", "EFFICIENCY","0-bin trigger efficiency", 1.);
251  opts.Add("mc", "Also analyse MC truth", fRailway->IsMC());
252  opts.Add("truth-config","FILE", "MC-Truth configuration", "");
253  opts.Add("mean-ipz", "MU", "Mean of IPz dist.", 0);
254  opts.Add("var-ipz", "SIGMA", "Variance of IPz dist.", -1);
255 
256  // Rewrite our URL
257  TString outString = fRailway->OutputLocation();
258  if (outString.IsNull()) outString = fEscapedName;
259  TUrl outUrl(outString);
260 
261  if (uopts.Find("pattern")) // && outString.EndsWith("AliAOD.root"))
262  uopts.Set("pattern", "*/AliAOD.root");
263  // if (uopts.Find("concat")) uopts.Set("concat", true);
264  if (uopts.Find("par")) uopts.Set("par", "task");
265 
266  std::stringstream s;
267  uopts.Store(s, "", "&", false, true);
268  outUrl.SetOptions(s.str().c_str());
269 
270  const char* defConfig="$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dNdetaConfig.C";
271  opts.Set("url", outUrl.GetUrl());
272  opts.Set("type", "AOD");
273  opts.Set("forward-config",defConfig);
274  opts.Set("central-config",defConfig);
275  opts.Set("truth-config",defConfig);
276  if (!fDatimeString.IsNull()) opts.Set("date", fDatimeString);
277 
278  if (sys != 1) {
279  opts.Set("cent", "default");
280  opts.Set("trig", "V0AND");
281  opts.Set("scheme", "default");
282  opts.Set("centBins", "default");
283  SaveSetupROOT("dNdeta", cls, name, opts, &uopts);
284  if (asShellScript)
285  SaveSetupShell("dndeta", cls, name, opts, &uopts);
286  }
287  else {
288  name.ReplaceAll("dndeta", "dndeta_inel");
289  SaveSetupROOT("dNdetaINEL", cls, name, opts, &uopts);
290  if (asShellScript)
291  SaveSetupShell("dndeta_inel", cls, name, opts, &uopts);
292 
293  name.ReplaceAll("inel", "nsd");
294  opts.Set("trig", "V0AND");
295  SaveSetupROOT("dNdetaNSD", cls, name, opts, &uopts);
296  if (asShellScript)
297  SaveSetupShell("dndeta_nsd", cls, name, opts, &uopts);
298 
299  name.ReplaceAll("nsd", "inelgt0");
300  opts.Set("trig", "INELGT0");
301  SaveSetupROOT("dNdetaINELGt0", cls, name, opts, &uopts);
302  if (asShellScript)
303  SaveSetupShell("dndeta_inelgt0", cls, name, opts, &uopts);
304  }
305  }
311  {
312  std::ofstream f("Summarize.C");
313  if (!f) {
314  Error("SaveSummarize", "Failed to open Summarize.C script");
315  return;
316  }
317  f << "// Generated by " << ClassName() << "\n"
318  << "// WHAT is a bit mask of\n"
319  << "// 0x001 Event inspector\n"
320  << "// 0x002 Sharing filter\n"
321  << "// 0x004 Density calculator\n"
322  << "// 0x008 Corrector\n"
323  << "// 0x010 Histogram collector\n"
324  << "// 0x020 Analysis step cartoon\n"
325  << "// 0x040 Results\n"
326  << "// 0x080 Central\n"
327  << "// 0x100 Landscape\n"
328  << "// 0x200 Pause\n"
329  << "//\n"
330  << "void Summarize(const char* filename=\"forward.root\",\n"
331  << " UShort_t what=0x1FF)\n"
332  << "{\n"
333  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
334  << " gROOT->LoadMacro(Form(\"%s/DrawAODSummary.C\",fwd));\n"
335  << " DrawAODSummary(filename,what);\n"
336  << "}\n"
337  << "// EOF" << std::endl;
338  f.close();
339  }
340  void PostShellCode(std::ostream& f)
341  {
342  f << " echo \"=== Summarizing results ...\"\n"
343  << " aliroot -l -b -q ${prefix}Summarize.C\n"
344  << std::endl;
345  }
346 };
347 //
348 // EOF
349 //
Double_t AsDouble(const TString &name, Double_t def=0) const
Definition: Option.C:673
virtual void CreateCentralitySelection(Bool_t mc)
Definition: TrainSetup.C:760
double Double_t
Definition: External.C:58
TString fDatimeString
Definition: TrainSetup.C:1672
Railway * fRailway
Definition: TrainSetup.C:1674
TString fName
Definition: TrainSetup.C:1670
void SaveSetup(Bool_t asShellScript)
Definition: MakeAODTrain.C:209
TSystem * gSystem
const char * ClassName() const
Definition: MakeAODTrain.C:201
Int_t AsInt(const TString &name, Int_t def=0) const
Definition: Option.C:645
static void SaveSetupShell(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1503
void SetOnMCFwd(AliAnalysisTask *task, const TString &call, const TString &arg)
Definition: MakeAODTrain.C:78
Definition: External.C:92
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
void CreateTasks(AliAnalysisManager *mgr)
Definition: MakeAODTrain.C:92
const OptionList & Options() const
Definition: Railway.C:454
MakeAODTrain(const TString &name)
Definition: MakeAODTrain.C:29
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 SaveSummarize()
Definition: MakeAODTrain.C:310
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1479
virtual Bool_t LoadAux(const TString &name, Bool_t copy=false)
Definition: Railway.C:255
void SavedNdeta(Bool_t asShellScript)
Definition: MakeAODTrain.C:215
OptionList fOptions
Definition: TrainSetup.C:1673
unsigned short UShort_t
Definition: External.C:28
void PostShellCode(std::ostream &f)
Definition: MakeAODTrain.C:340
void SetOnFwd(AliAnalysisTask *task, const TString &call, const TString &arg)
Definition: MakeAODTrain.C:62
bool Bool_t
Definition: External.C:53
TString fEscapedName
Definition: TrainSetup.C:1671
virtual AliAnalysisTaskSE * CoupleSECar(const TString &macro, const TString &args, UInt_t mask=0)
Definition: TrainSetup.C:883
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
void CreateCentralitySelection(Bool_t mc)
Definition: MakeAODTrain.C:195
static void SaveSetupROOT(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1544