AliPhysics  e34b7ac (e34b7ac)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeFMDMCTrackTrain.C
Go to the documentation of this file.
1 
10 #include "TrainSetup.C"
11 // #include "ParUtilities.C"
12 
13 //====================================================================
22 {
23 public:
30  MakeFMDMCTrackTrain(const char* name)
31  : TrainSetup(name)
32  {
33  fOptions.Add("use-tuple", "Whether to make an NTuple of hits");
34  fOptions.Add("max-strips", "NUMBER", "Max strips/cluster", 2);
35  fOptions.Set("type", "ESD");
36  }
37 protected:
44  {
45  // --- Output file name ------------------------------------------
46  AliAnalysisManager::SetCommonFileName("forward_mctracks.root");
47 
48 
49  // --- Load libraries/pars ---------------------------------------
50  fRailway->LoadLibrary("PWGLFforward2");
51  // fRailway->LoadLibrary("Proof");
52  // fRailway->LoadLibrary("Gui"); // Sigh! CDB depends on GUI!
53  // fRailway->LoadLibrary("CDB");
54  // fRailway->LoadLibrary("RAWDatabase");
55  // fRailway->LoadLibrary("STEER");
56  // fRailway->LoadLibrary("FMDbase");
57  // fRailway->LoadLibrary("FMDsim");
58  // fRailway->LoadLibrary("PWGLFforwardhit");
59 
60  // --- Set load path ---------------------------------------------
61  gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
62  gROOT->GetMacroPath()));
63 
64  // --- Check if this is MC ---------------------------------------
65  if (!mgr->GetMCtruthEventHandler())
66  Fatal("CreateTasks", "No MC truth handler");
67 
68  Bool_t useTuple = fOptions.AsBool("use-tuple");
69  UShort_t maxStrips = fOptions.AsInt("max-strips");
70  Int_t verbose = fOptions.AsInt("verbose");
71 
72  TString args = TString::Format("%d,%d,%d",
73  useTuple,
74  maxStrips,
75  verbose);
76  if (!CoupleCar("AddTaskFMDMCTracks.C", args))
77  Fatal("CreateTasks", "Couldn't add our task");
78  }
79  //__________________________________________________________________
87  AliAnalysisManager* mgr)
88  {
90 
91  // --- Get input event handler -----------------------------------
92  AliInputEventHandler* ih =
93  dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
94  if (!ih)
95  Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
96 
97  // --- Get Physics selection -------------------------------------
98  AliPhysicsSelection* ps =
99  dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
100  if (!ps)
101  Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps);
102 
103  // --- Ignore trigger class when selecting events. This means ---
104  // --- that we get offline+(A,C,E) events too --------------------
105  // ps->SetSkipTriggerClassSelection(true);
106  }
107  //__________________________________________________________________
111  virtual AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
115  // void CreateCentralitySelection(Bool_t) {}
116  //__________________________________________________________________
117  const char* ClassName() const { return "MakeFMDMCTrackTrain"; }
118 
125  void SaveSetup(Bool_t asShellScript)
126  {
127  TrainSetup::SaveSetup(asShellScript);
128  SaveSummarize();
130  SaveReFit();
131 
132 
133  if (!fRailway || fRailway->Mode() != Railway::kGrid) return;
134 
136 
137  }
143  {
144  std::ofstream f("Summarize.C");
145  if (!f) {
146  Error("SaveSummarize", "Failed to open Summarize.C script");
147  return;
148  }
149  f << "// Generated by " << ClassName() << "\n"
150  << "// WHAT is a bit mask of\n"
151  << "// 0x001 Event inspector\n"
152  << "// 0x002 Track inspector\n"
153  << "// 0x004 Energy loss fits\n"
154  << "// 0x100 Landscape\n"
155  << "// 0x200 Pause\n"
156  << "//\n"
157  << "void Summarize(const char* filename=\"forward_mctracks.root\",\n"
158  << " UShort_t what=0x10F)\n"
159  << "{\n"
160  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
161  << " gROOT->LoadMacro(Form(\"%s/scripts/SummaryMCTrackDrawer.C+g\",fwd));\n"
162  << " SummaryMCTrackDrawer smd;\n"
163  << " smd.Run(filename,what);\n"
164  << "}\n"
165  << "// EOF" << std::endl;
166  f.close();
167  }
173  {
174  std::ofstream f("DownloadTrees.C");
175  if (!f) {
176  Error("SaveDownloadTrees", "Failed to open DownloadTrees.C");
177  return;
178  }
179  f << "// Generated by " << ClassName() << "\n"
180  << "void DownloadTrees(Bool_t force=false)\n"
181  << "{\n"
182  << " if (!TGrid::Connect(\"alien://\")) {\n"
183  << " Error(\"DownloadTrees\",\"Failed to connect to AliEn\");\n"
184  << " return;\n"
185  << " }\n\n"
186  << " TString dir(\"" << fRailway->OutputPath() << "\");\n"
187  << " TString pat(\"*/forward_tuple.root\");\n"
188  << " TGridResult* r = gGrid->Query(dir,pat);\n"
189  << " if (!r) {\n"
190  << " Error(\"DownloadTrees\",\"No result from query\");\n"
191  << " return;\n"
192  << " }\n\n"
193  << " Int_t n = r->GetEntries();\n"
194  << " Printf(\"=== Got a total of %d AOD files\",n);\n"
195  << " for (Int_t i = 0; i < n; i++) {\n"
196  << " TString path(r->GetKey(i, \"turl\"));\n"
197  << " TString dir(gSystem->DirName(path));\n"
198  << " TString sub(gSystem->BaseName(dir));\n"
199  << " TString subsub(gSystem->BaseName(gSystem->DirName(dir)));\n"
200  << " TString out = TString::Format(\"forward_tree_%s_%s.root\",\n"
201  << " subsub.Data(),sub.Data());\n"
202  << " if (!gSystem->AccessPathName(out.Data()) && !force) {\n"
203  << " Printf(\"=== Already have %s\",out.Data());\n"
204  << " continue;\n"
205  << " }\n"
206  << " Printf(\"=== Getting %s %s (%3d/%3d)\",\n"
207  << " subsub.Data(),sub.Data(),i,n);\n"
208  << " if (!TFile::Cp(path, out)) {\n"
209  << " Warning(\"DownloadTrees\",\"Failed to copy %s -> %s\",\n"
210  << " path.Data(), out.Data());\n"
211  << " continue;\n"
212  << " }\n"
213  << " }\n"
214  << "}\n"
215  << "// EOF\n"
216  << std::endl;
217  f.close();
218  }
224  {
225  std::ofstream f("AnalyseNTuple.C");
226  if (!f) {
227  Error("SaveAnalyseNTuple", "Failed to open AnalyseNTuple.C");
228  return;
229  }
230  f << "// Generated by " << ClassName() << "\n"
231  << "// Process with bare ROOT in ProofLite\n"
232  << "void AnalyseNTuple(Bool_t proof=true,\n"
233  << " Long64_t max=-1,\n"
234  << " const char* opt=\"\")\n"
235  << "{\n"
236  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
237  << " gSystem->AddIncludePath(\"-I${ALICE_PHYSICS}/include\");\n"
238  << " gROOT->Macro(Form(\"%s/scripts/LoadLibs.C\",fwd));\n"
239  << " gROOT->LoadMacro(Form(\"%s/scripts/TupleSelector.C+%s\",\n"
240  << " fwd, opt));\n"
241  << " if (proof) TupleSelector::Proof(maxEvents, opt);\n"
242  << " else TupleSelector::Run(maxEvents);\n"
243  << "}\n"
244  << "// EOF" << std::endl;
245  f.close();
246  }
247  void SaveReFit()
248  {
249  std::ofstream f("ReFit.C");
250  if (!f) {
251  Error("SaveRerun", "Failed to open ReFit.C script");
252  return;
253  }
254  f << std::boolalpha
255  << "// Generated by " << ClassName() << "\n"
256  << "// If force=true, then force set parameters\n"
257  << "//\n"
258  << "void ReFit(Bool_t force=false,\n"
259  << " const char* filename=\"forward_mctracks.root\")\n"
260  << "{\n"
261  << " const char* fwd=\"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2\";\n"
262  << " gROOT->LoadMacro(Form(\"%s/corrs/RerunTrackELoss.C\",fwd));\n"
263  << " RerunTrackELoss(force,filename);\n"
264  << "}\n"
265  << "// EOF" << std::endl;
266  f.close();
267  }
268 
269  void PostShellCode(std::ostream& f)
270  {
271  f << " echo \"=== Summarizing results ...\"\n"
272  << " aliroot -l -b -q ${prefix}Summarize.C\n"
273  << std::endl;
274  }
275 
276 };
277 
278 //
279 // EOF
280 //
Railway * fRailway
Definition: TrainSetup.C:1664
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
void SaveSetup(Bool_t asShellScript)
void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager *mgr)
virtual UShort_t Mode() const =0
int Int_t
Definition: External.C:63
const char * ClassName() const
void Set(const TString &name, const TString &value)
Definition: Option.C:736
void CreateTasks(AliAnalysisManager *mgr)
void PostShellCode(std::ostream &f)
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
OptionList fOptions
Definition: TrainSetup.C:1663
virtual TString OutputPath() const
Definition: Railway.C:361
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
MakeFMDMCTrackTrain(const char *name)
virtual AliAnalysisTask * CoupleCar(const TString &macro, const TString &args)
Definition: TrainSetup.C:831
virtual void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager *mgr)
Definition: TrainSetup.C:692
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
virtual AliVEventHandler * CreateOutputHandler(UShort_t)