AliPhysics  781d0c7 (781d0c7)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakedNdetaTrain.C
Go to the documentation of this file.
1 
12 #include "TrainSetup.C"
13 #include <TF1.h>
14 
15 //====================================================================
24 {
25 public:
31  MakedNdetaTrain(const char* name)
32  : TrainSetup(name)
33  {
34  fOptions.Add("trig", "TYPE", "Trigger type", "INEL");
35  fOptions.Add("filter", "TYPE", "Filter type","OUTLIER|PILEUP-BIN");
36  fOptions.Add("cent", "ESTIMATOR", "Use centrality", "none");
37  fOptions.Add("cent-bins", "BINS", "Centrality bins", "default");
38  fOptions.Add("ipz-bins", "BINS", "IPz bins", "u15");
39  fOptions.Add("scheme", "SCHEME","Normalization scheme","EVENT,TRIGGER");
40  fOptions.Add("trigEff", "EFFICIENCY","Trigger efficiency", 1.);
41  fOptions.Add("trigEff0", "EFFICIENCY","0-bin trigger effeciency", 1.);
42  fOptions.Add("mc", "Also make dN/deta for MC truth", false);
43  fOptions.Add("satellite", "Restrict analysis to satellite events",false);
44  fOptions.Add("forward-config","FILE", "Forward configuration",
45  "dNdetaConfig.C");
46  fOptions.Add("central-config","FILE", "Central configuration",
47  "dNdetaConfig.C");
48  fOptions.Add("truth-config", "FILE", "MC-Truth configuration",
49  "dNdetaConfig.C");
50  fOptions.Add("mean-ipz", "MU", "Mean of IPz dist.", 0);
51  fOptions.Add("var-ipz", "SIGMA", "Variance of IPz dist.", -1);
52  fOptions.Add("no-central", "Do not at SPD cluster task", false);
53  fOptions.Add("abs-min-cent", "PERCENT", "Absolute least centrality", -1.);
54  }
55 protected:
56  Bool_t CoupledNdetaCar(const char* which,
57  const char* cfg)
58  {
59  UInt_t mask = AliVEvent::kAny;
60  AliAnalysisTaskSE* tsk = CoupleSECar("AddTaskdNdeta.C",
61  Form("\"%s\",\"%s\"", which, cfg),
62  mask);
63  if (!tsk) {
64  Printf("Failed to add task via AddTaskdNdeta.C(%s,%s)", cfg);
65  return false;
66  }
67  FromOption(tsk, "TriggerMask", "trig", "INEL");
68  FromOption(tsk, "FilterMask", "filter", "OUTLIER|PILEUP-BIN");
69  FromOption(tsk, "NormalizationScheme", "scheme", "EVENT,TRIGGER");
70  FromOption(tsk, "CentralityMethod", "cent", "default");
71  FromOption(tsk, "CentralityAxis", "cent-bins", "default");
72  FromOption(tsk, "IPzAxis", "ipz-bins", "u10");
73  FromOption(tsk, "TriggerEff", "trigEff", 1.);
74  FromOption(tsk, "TriggerEff0", "trigEff0", 1.);
75  FromOption(tsk, "SatelliteVertices", "satellite", false);
76  FromOption(tsk, "AbsMinCent", "abs-min-cent",-1.);
77 
78  if (!TString(which).BeginsWith("forward",TString::kIgnoreCase)) return true;
79 
80  Double_t muIpz = fOptions.AsDouble("mean-ipz",0);
81  Double_t sigmaIpz = fOptions.AsDouble("var-ipz",-1);
82  if (sigmaIpz <= 0) return true;
83 
84  TF1* f=new TF1("ipZw","TMath::Gaus(x,[0],[1],1)/TMath::Gaus(x,[2],[3],1)");
85  f->SetParNames("#mu_{emp}","#sigma_{emp}","#mu_{this}","#sigma_{this}");
86  f->SetParameters(0.592,6.836,muIpz,sigmaIpz);
87  // f->SetParErrors(0.023,0.029,eMuIpz,eSigmaIpz);
88 
89  Printf("Created re-weight function");
90  f->Print();
91 
92  gROOT
93  ->ProcessLine(Form("((AliBasedNdetaTask*)%p)->SetIpzReweight((TF1*)%p);",
94  tsk, f));
95  return true;
96 
97  }
103  {
104  // --- Output file name ------------------------------------------
105  AliAnalysisManager::SetCommonFileName("forward_dndeta.root");
106 
107  // --- Load libraries/pars ---------------------------------------
108  fRailway->LoadLibrary("PWGLFforward2");
109  // fRailway->LoadLibrary("AOD");
110  // gSystem->ListLibraries();
111  // gSystem->Load("libAOD");
112 
113  // --- Set load path ---------------------------------------------
114  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
115  gROOT->GetMacroPath()));
116 
117  // --- Get parameters --------------------------------------------
118  Bool_t mc = fOptions.Has("mc");
119  TString fwdCfg = fOptions.Get("forward-config");
120  TString cenCfg = fOptions.Get("central-config");
121  TString mcCfg = fOptions.Get("truth-config");
122  if (!mc) mc = fRailway->IsMC();
123 
124  // --- Add the task ----------------------------------------------
125  CoupledNdetaCar("Forward", fwdCfg);
126  Bool_t noCentral = fOptions.Has("no-central");
127  if (!noCentral)
128  CoupledNdetaCar("Central", cenCfg);
129  if (mc) CoupledNdetaCar("MCTruth", mcCfg);
130 
131  }
132  //__________________________________________________________________
136  //__________________________________________________________________
137  // void CreateCentralitySelection(Bool_t) {}
143  AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; }
144  //__________________________________________________________________
150  AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
151  //__________________________________________________________________
152  const char* ClassName() const { return "MakedNdetaTrain"; }
153  //__________________________________________________________________
159  void SaveSetup(Bool_t asShellScript)
160  {
161  TrainSetup::SaveSetup(asShellScript);
162 
163  SaveDraw();
164  SaveSummarize();
165  }
167  {
168  std::ofstream f("Summarize.C");
169  if (!f) {
170  Error("SaveSummarize", "Failed to open Summarize.C script");
171  return;
172  }
173  f << "// Generated by " << ClassName() << "\n"
174  << "// WHAT is a bit mask of\n"
175  << "// 0x001 Forward\n"
176  << "// 0x002 Central\n"
177  << "// 0x004 Sums\n"
178  << "// 0x008 Results\n"
179  << "// 0x010 Only min-bias (no centrality)\n"
180  << "// 0x080 Assume simulation results\n"
181  << "// 0x100 Landscape\n"
182  << "// 0x200 Pause\n"
183  << "// 0x400 Also draw single result canvas\n"
184  << "//\n"
185  << "void Summarize(const char* filename=\"forward_dndeta.root\",\n"
186  << " UShort_t what=0x10F)\n"
187  << "{\n"
188  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
189  << " gROOT->LoadMacro(Form(\"%s/DrawdNdetaSummary.C\",fwd));\n"
190  << " DrawdNdetaSummary(filename,what & 0x3FF);\n"
191  << "\n"
192  << " if (!(what & 0x400)) return;\n"
193  << " gROOT->SetMacroPath(Form(\"../:%s\",gROOT->GetMacroPath()));\n"
194  << " gROOT->Macro(\"Draw.C\");\n"
195  << "}\n"
196  << "// EOF" << std::endl;
197  f.close();
198  }
203  void SaveDraw()
204  {
205  std::ofstream o("Draw.C");
206  if (!o) {
207  Error("MakedNdetaTrain::SaveSetup", "Failed to open Draw.C");
208  return;
209  }
210 
211  o << "// Created by " << ClassName() << "\n"
212  << "// Will draw dN/deta results from produced file\n"
213  << "// \n"
214  << "void Draw(UShort_t rebin=5,\n"
215  << " Double_t eff=1,\n"
216  << " Bool_t raw=false,\n"
217  << " Bool_t cutEdges=false,\n"
218  << " const char* which=\"Forward\")\n"
219  << "{\n"
220  << " TString fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta\";\n"
221  << " gROOT->LoadMacro(Form(\"%s/ExtractGSEs.C\",fwd.Data()));\n"
222  << " ExtractGSEs(\"forward_dndeta.root\",\n"
223  << " rebin,eff,raw,cutEdges,which);\n"
224  << "}\n"
225  << "//\n"
226  << "// EOF\n"
227  << "//" << std::endl;
228  o.close();
229  }
230  void PostShellCode(std::ostream& f)
231  {
232  f << " echo \"=== Summarizing results ...\"\n"
233  << " aliroot -l -b -q ${prefix}Summarize.C\n"
234  << " echo \"=== Draw results ...\"\n"
235  << " aliroot -l -b -q ${prefix}Draw.C\n"
236  << std::endl;
237  }
238 };
239 //
240 // EOF
241 //
Double_t AsDouble(const TString &name, Double_t def=0) const
Definition: Option.C:673
double Double_t
Definition: External.C:58
Railway * fRailway
Definition: TrainSetup.C:1666
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
unsigned int UInt_t
Definition: External.C:33
virtual Bool_t IsMC() const
Definition: Railway.C:354
MakedNdetaTrain(const char *name)
void CreateTasks(AliAnalysisManager *)
Bool_t CoupledNdetaCar(const char *which, const char *cfg)
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
AliVEventHandler * CreateMCHandler(UShort_t, bool)
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Double_t defval)
Definition: TrainSetup.C:1228
OptionList fOptions
Definition: TrainSetup.C:1665
AliVEventHandler * CreateOutputHandler(UShort_t)
unsigned short UShort_t
Definition: External.C:28
void PostShellCode(std::ostream &f)
bool Bool_t
Definition: External.C:53
virtual AliAnalysisTaskSE * CoupleSECar(const TString &macro, const TString &args, UInt_t mask=0)
Definition: TrainSetup.C:875
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0