AliPhysics  5eaf189 (5eaf189)
MakeFMDELossTrain.C
Go to the documentation of this file.
1 
11 #include "TrainSetup.C"
12 
13 //====================================================================
21 {
22 public:
28  MakeFMDELossTrain(const char* name = "FMD Energy Loss")
29  : TrainSetup(name)
30  {
31  fOptions.Add("only-mb", "Only collect statistics from MB events");
32  fOptions.Add("config", "FILE", "Configuration", "elossFitConfig.C");
33  fOptions.Add("corr", "DIR", "Corrections dir", "");
34  fOptions.Add("dead", "FILE", "Additional dead-map script", "");
35  fOptions.Add("low-cut", "VALUE","Low cut on eloss", -1);
36  fOptions.Set("type", "ESD");
37  }
38 protected:
39  //------------------------------------------------------------------
47  virtual AliAnalysisManager* CreateAnalysisManager(const char* name)
48  {
50  // mgr->SetAutoBranchLoading(false);
51  return mgr;
52  }
53  //__________________________________________________________________
60  {
61  // --- Output file name ------------------------------------------
62  AliAnalysisManager::SetCommonFileName("forward_eloss.root");
63 
64  // --- Load libraries/pars ---------------------------------------
65  fRailway->LoadLibrary("PWGLFforward2");
66 
67  // --- Set load path ---------------------------------------------
68  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
69  gROOT->GetMacroPath()));
70 
71  // --- Check if this is MC ---------------------------------------
72  Bool_t mc = HasMCHandler();
73  Bool_t onlyMB = fOptions.AsBool("only-mb");
74  Double_t lowCut = fOptions.AsDouble("low-cut", -1);
75  TString config = fOptions.Get("config");
76  TString corrs = "";
77  TString dead = "";
78  if (fOptions.Has("corr")) corrs = fOptions.Get("corr");
79  if (fOptions.Has("dead")) dead = fOptions.Get("dead");
80 
81  // --- Add the task ----------------------------------------------
82  AliAnalysisTask* task =
83  CoupleSECar("AddTaskFMDELoss.C", Form("%d,%d,%f,\"%s\",\"%s\",\"%s\"",
84  mc, onlyMB, lowCut,
85  config.Data(),
86  corrs.Data(),
87  dead.Data()), AliVEvent::kAny);
88  if (!task)
89  Fatal("CoupleCars", "Failed to add energy loss task");
90 
91  fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(), config), true);
92  if (!corrs.IsNull())
93  fRailway->LoadAux(Form("%s/fmd_corrections.root",corrs.Data()), true);
94  if (!dead.IsNull())
95  fRailway->LoadAux(Form("%s",dead.Data()), true);
96 
97  }
104  {
105  if (!fOptions.Has("cent")) return;
107  }
113  AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
114 
115  //__________________________________________________________________
116  const char* ClassName() const { return "MakeFMDELossTrain"; }
117  //__________________________________________________________________
124  void SaveSetup(Bool_t asShellScript)
125  {
126  TrainSetup::SaveSetup(asShellScript);
127  SaveExtract();
128  SaveSummarize();
129  SaveReFit();
130  }
131  void SaveExtract()
132  {
133  std::ofstream f("Extract.C");
134  if (!f) {
135  Error("SaveSetup", "Failed to open Extract.C");
136  return;
137  }
138  f << "// Generated by " << ClassName() << "\n"
139  << "void Extract(Bool_t mc=" << HasMCHandler() << ",\n"
140  << " const char* file=\"forward_eloss.root\")\n"
141  << "{\n"
142  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
143  << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractELoss.C\",fwd));\n"
144  << " ExtractELoss(file,mc);\n"
145  << "}\n"
146  << "// EOF" << std::endl;
147  f.close();
148  }
150  {
151  std::ofstream f("Summarize.C");
152  if (!f) {
153  Error("SaveSummarize", "Failed to open Summarize.C script");
154  return;
155  }
156  f << std::boolalpha
157  << "// Generated by " << ClassName() << "\n"
158  << "//\n"
159  << "void Summarize(Bool_t mc=" << HasMCHandler() << ",\n"
160  << " const char* filename=\"forward_eloss.root\")\n"
161  << "{\n"
162  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
163  << " gROOT->LoadMacro(Form(\"%s/corrs/DrawCorrELoss.C\",fwd));\n"
164  << " DrawCorrELoss(mc,filename);\n"
165  << "}\n"
166  << "// EOF" << std::endl;
167  f.close();
168  }
169  void SaveReFit()
170  {
171  std::ofstream f("ReFit.C");
172  if (!f) {
173  Error("SaveRerun", "Failed to open ReFit.C script");
174  return;
175  }
176  f << std::boolalpha
177  << "// Generated by " << ClassName() << "\n"
178  << "// If force=true, then force set parameters\n"
179  << "// If shift=true, enable extra shift in Delta from sigma/xi\n"
180  << "//\n"
181  << "void ReFit(Bool_t force=false,\n"
182  << " Bool_t shift=true,\n"
183  << " const char* filename=\"forward_eloss.root\")\n"
184  << "{\n"
185  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
186  << " gROOT->LoadMacro(Form(\"%s/corrs/RerunELossFits.C\",fwd));\n"
187  << " RerunELossFits(force,filename);\n"
188  << "}\n"
189  << "// EOF" << std::endl;
190  f.close();
191  }
192  void PostShellCode(std::ostream& f)
193  {
194  f << " mc=" << std::boolalpha << HasMCHandler() << "\n"
195  << " echo \"=== Extracting Corrections ...\"\n"
196  << " aliroot -l -b -q ${prefix}Extract.C\\($mc\\)\n"
197  << " echo \"=== Summarizing results ...\"\n"
198  << " aliroot -l -b -q ${prefix}Summarize.C\\($mc\\)\n"
199  << " if test x$dest = x ; then return ; fi\n"
200  << " echo \"=== Uploading to ${dest} ...\"\n"
201  << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);\n"
202  << std::endl;
203  }
204 };
205 
206 //
207 // EOF
208 //
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
void CreateTasks(AliAnalysisManager *mgr)
Railway * fRailway
Definition: TrainSetup.C:1674
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
TSystem * gSystem
virtual void CreateCentralitySelection(Bool_t mc)
void PostShellCode(std::ostream &f)
const TString & Get(const TString &name) const
Definition: Option.C:596
MakeFMDELossTrain(const char *name="FMD Energy Loss")
Bool_t Has(const TString &name) const
Definition: Option.C:584
virtual AliAnalysisManager * CreateAnalysisManager(const char *name)
Definition: TrainSetup.C:526
void Set(const TString &name, const TString &value)
Definition: Option.C:736
const char * ClassName() const
void SaveSetup(Bool_t asShellScript)
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:1479
virtual Bool_t LoadAux(const TString &name, Bool_t copy=false)
Definition: Railway.C:255
OptionList fOptions
Definition: TrainSetup.C:1673
virtual AliAnalysisManager * CreateAnalysisManager(const char *name)
virtual Bool_t HasMCHandler() const
Definition: TrainSetup.C:1325
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
AliVEventHandler * CreateOutputHandler(UShort_t)
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