AliPhysics  64a5cfc (64a5cfc)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeMCCorrTrain.C
Go to the documentation of this file.
1 
10 #include "TrainSetup.C"
11 
12 //====================================================================
21 {
22 public:
29  MakeMCCorrTrain(const char* name)
30  : TrainSetup(name)
31  {
32  fOptions.Set("type", "ESD");
33  fOptions.Add("eff", "Effective SPD correction", false);
34  fOptions.Add("satellite", "Set-up for satellite-main", false);
35  fOptions.Add("reweigh","MODE","Whether to reweigh","");
36  fOptions.Add("max-strips", "NUMBER",
37  "Maximum consequtive strips", 2);
38  }
39 protected:
46  {
47  // --- Output file name ------------------------------------------
48  AliAnalysisManager::SetCommonFileName("forward_mccorr.root");
49 
50  // --- Load libraries/pars ---------------------------------------
51  fRailway->LoadLibrary("PWGLFforward2");
52 
53  // --- Set load path ---------------------------------------------
54  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
55  gROOT->GetMacroPath()));
56 
57  // --- Options ---------------------------------------------------
58  Bool_t spdEffective = fOptions.Has("eff");
59  Bool_t satellite = fOptions.AsBool("satellite");
60  TString reweigh = fOptions.AsString("reweigh","");
61  UShort_t maxStrips = fOptions.AsInt("max-strips");
62  UShort_t rflags = 0;
63  if (reweigh.Contains("track")) rflags |= 0x1;
64  if (reweigh.Contains("prim")) rflags |= 0x2;
65  if (reweigh.Contains("real")) rflags |= 0x4;
66 
67  // --- Check if this is MC ---------------------------------------
68  if (!mgr->GetMCtruthEventHandler()) return;
69 
70  // --- Task to copy header information ---------------------------
71  // gROOT->Macro("AddTaskCopyHeader.C");
72 
73  UInt_t mask = AliVEvent::kAny;
74  // --- Add the task ----------------------------------------------
75  CoupleSECar("AddTaskForwardMCCorr.C",
76  Form("%d,0x%x,%d", satellite, rflags, maxStrips), mask);
77 
78  // --- Add the task ----------------------------------------------
79  CoupleSECar("AddTaskCentralMCCorr.C",
80  Form("%d,%d", satellite, spdEffective), mask);
81  }
82  //__________________________________________________________________
90  AliAnalysisManager* mgr)
91  {
93 #if 0
94  // --- Get input event handler -----------------------------------
95  AliInputEventHandler* ih =
96  dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
97  if (!ih)
98  Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
99 
100  // --- Get Physics selection -------------------------------------
101  AliPhysicsSelection* ps =
102  dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
103  if (!ps)
104  Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps);
105 
106  // --- Ignore trigger class when selecting events. This means ---
107  // --- that we get offline+(A,C,E) events too --------------------
108  // ps->SetSkipTriggerClassSelection(true);
109 #endif
110  }
111  //__________________________________________________________________
115  virtual AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
119  // void CreateCentralitySelection(Bool_t) {}
120  //__________________________________________________________________
121  const char* ClassName() const { return "MakeMCCorrTrain"; }
122  //__________________________________________________________________
129  void SaveSetup(Bool_t asShellScript)
130  {
131  TrainSetup::SaveSetup(asShellScript);
132 
133  SaveExtract();
134  SaveSummarize();
135  SaveDraw();
136  }
137  void SaveExtract()
138  {
139  std::ofstream f("Extract.C");
140  if (!f) {
141  Error("SaveSetup", "Failed to open Extract.C");
142  return;
143  }
144  f << "// Generated by " << ClassName() << "\n"
145  << "void Extract()\n"
146  << "{\n"
147  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
148  << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractMCCorr.C\",fwd));\n"
149  << " ExtractMCCorr(\"forward_mccorr.root\");\n"
150  << "}\n"
151  << "// EOF" << std::endl;
152  f.close();
153  }
159  {
160  std::ofstream f("Summarize.C");
161  if (!f) {
162  Error("SaveSummarize", "Failed to open Summarize.C script");
163  return;
164  }
165  f << "// Generated by " << ClassName() << "\n"
166  << "// WHAT is a bit mask of\n"
167  << "// 0x001 Event inspector\n"
168  << "// 0x002 Track density\n"
169  << "// 0x004 Vertex bins\n"
170  << "// 0x008 Results\n"
171  << "// 0x080 Central\n"
172  << "// 0x100 Landscape\n"
173  << "// 0x200 Pause\n"
174  << "//\n"
175  << "void Summarize(const char* filename=\"forward_mccorr.root\",\n"
176  << " UShort_t what=0x11F)\n"
177  << "{\n"
178  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
179  << " gROOT->LoadMacro(Form(\"%s/DrawMCCorrSummary.C\",fwd));\n"
180  << " DrawMCCorrSummary(filename,what);\n"
181  << "}\n"
182  << "// EOF" << std::endl;
183  f.close();
184  }
189  void SaveDraw()
190  {
191  std::ofstream f("Draw.C");
192  if (!f) {
193  Error("SaveDraw", "Failed to open Draw.C script");
194  return;
195  }
196  f << "// Generated by " << ClassName() << "\n"
197  << "// WHAT is a bit mask of\n"
198  << "// 0x001 Event inspector\n"
199  << "// 0x002 Track density\n"
200  << "// 0x004 Vertex bins\n"
201  << "// 0x008 Results\n"
202  << "// 0x080 Central\n"
203  << "// 0x100 Landscape\n"
204  << "// 0x200 Pause\n"
205  << "//\n"
206  << "void Draw(bool details=false)\n"
207  << "{\n"
208  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
209  << " gROOT->LoadMacro(Form(\"%s/corrs/DrawCorrSecMap.C\",fwd));\n"
210  << " DrawCorrSecMap(999,0,0,999," << fOptions.Has("satellite")
211  << ",\"fmd_corrections.root\",details);\n"
212  << "}\n"
213  << "// EOF" << std::endl;
214  f.close();
215  }
216  void PostShellCode(std::ostream& f)
217  {
218  f << " echo \"=== Extracting Corrections ...\"\n"
219  << " aliroot -l -b -q ${prefix}Extract.C\n"
220  << " echo \"=== Summarizing results ...\"\n"
221  << " aliroot -l -b -q ${prefix}Summarize.C\n"
222  << " echo \"=== Draw results ...\"\n"
223  << " aliroot -l -b -q ${prefix}Draw.C\n"
224  << " if test x$dest = x ; then return ; fi\n"
225  << " echo \"=== Uploading to ${dest} ...\"\n"
226  << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);"
227  << std::endl;
228  }
229 };
230 
231 //
232 // EOF
233 //
Railway * fRailway
Definition: TrainSetup.C:1666
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
Int_t AsInt(const TString &name, Int_t def=0) const
Definition: Option.C:645
const char * AsString(const TString &name, const TString &def="") const
Definition: Option.C:687
Bool_t Has(const TString &name) const
Definition: Option.C:584
void PostShellCode(std::ostream &f)
unsigned int UInt_t
Definition: External.C:33
virtual AliVEventHandler * CreateOutputHandler(UShort_t)
void Set(const TString &name, const TString &value)
Definition: Option.C:736
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
const char * ClassName() const
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1471
OptionList fOptions
Definition: TrainSetup.C:1665
unsigned short UShort_t
Definition: External.C:28
void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager *mgr)
bool Bool_t
Definition: External.C:53
MakeMCCorrTrain(const char *name)
void CreateTasks(AliAnalysisManager *mgr)
virtual void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager *mgr)
Definition: TrainSetup.C:693
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