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