AliPhysics  d497547 (d497547)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrainSetup.C
Go to the documentation of this file.
1 
16 #ifndef TRAINSETUP_C
17 #define TRAINSETUP_C
18 #ifndef __CINT__
19 # include "Railway.C"
20 # include "Option.C"
21 # include <TDatime.h>
22 # include <TUrl.h>
23 # include <TString.h>
24 # include <TApplication.h>
25 # include <TStopwatch.h>
26 # include <AliAnalysisManager.h>
27 # include <AliVEvent.h>
28 # include <AliVEventHandler.h>
29 # include <AliPhysicsSelection.h>
30 # include <AliPhysicsSelectionTask.h>
31 # include <AliCentralitySelectionTask.h>
32 # include <AliESDInputHandler.h>
33 # include <AliESDInputHandlerRP.h>
34 # include <AliAODInputHandler.h>
35 # include <AliAODHandler.h>
36 # include <AliMCEventHandler.h>
37 # include <ctime>
38 #else
39 struct Railway;
40 struct OptionList;
41 class TDatime;
42 class TUrl;
43 class TString;
44 class TStopwatch;
45 class AliVEventHandler;
46 class AliAnalysisManager;
47 class AliInputEventHandler;
48 #endif
49 class AliAnalysisTask;
50 
51 //====================================================================
60 struct TrainSetup
61 {
65  enum {
67  };
73  TrainSetup(const TString& name)
74  : fName(name),
75  fEscapedName(name),
76  fDatimeString(""),
77  fOptions(),
78  fRailway(0)
79  {
80  fOptions.Add("help", "Show help", false);
81  fOptions.Add("date", "YYYY-MM-DD HH:MM", "Set date", "now");
82  fOptions.Add("ps", "MODE", "Physics selection mode", "");
83  fOptions.Add("verbose", "LEVEL", "Set verbosity level", 0);
84  fOptions.Add("url", "URL", "Job location & input URL","");
85  fOptions.Add("overwrite","Allow overwrite", false);
86  fOptions.Add("events", "N", "Number of events to analyse",-1);
87  fOptions.Add("type", "ESD|AOD|USER", "Input data stype", "");
88  fOptions.Add("setup", "Only do the setup", false);
89  fOptions.Add("branches", "Load only requested branches", false);
90  fOptions.Add("version", "Print version and exit", false);
91  fOptions.Add("tender", "WHICH", "Specify tender supplies","");
92  fOptions.Add("ocdb", "(TENDER_SNAPSHOT)","Enable OCDB", "");
93  fOptions.Add("friends","(AOD_FRIENDS)","Enable friends (list of files)","");
94  fOptions.Add("cent-oadb","PERIOD","Alternative OADB for centrality","");
95  fOptions.Add("no-link", "Do not make symlink to output", false);
96  fOptions.Add("old-cent", "Add old centrality task to train", false);
97  fOptions.Add("aod-cent", "Recalculate centrality in AODs", false);
98  fDatimeString = "";
100  }
107  : fName(o.fName),
110  fOptions(o.fOptions),
111  fRailway(o.fRailway)
112  {}
121  {
122  if (&o == this) return *this;
123  fName = o.fName;
126  fOptions = o.fOptions;
127  fRailway = o.fRailway;
128  return *this;
129  }
130 
134  virtual ~TrainSetup() {}
135  /* @} */
136  //__________________________________________________________________
147  {
148  // --- Print the version number ----------------------------------
149  Info("Init", "Running with TrainSetup version %d", kVersion);
150 
151  // --- Create the helper -----------------------------------------
152  TString url = fOptions.Get("url");
153  Int_t verbose = fOptions.AsInt("verbose");
154 
155  fRailway = Railway::Create(url.Data(), verbose);
156  if (!fRailway) {
157  Error("Init", "Failed to make the worker for URL %s", url.Data());
158  return false;
159  }
160 
161  // --- Check the type, if possible -------------------------------
162  UShort_t type = fRailway->InputType();
163  Bool_t mc = fRailway->IsMC();
164  if (fOptions.Has("type")) {
165  const TString& it = fOptions.Get("type");
166  if (it.EqualTo("ESD",TString::kIgnoreCase)) type = Railway::kESD;
167  else if (it.EqualTo("AOD",TString::kIgnoreCase)) type = Railway::kAOD;
168  else if (it.EqualTo("user",TString::kIgnoreCase))
169  type = Railway::kUser;
170  }
171 
172  // --- Rewrite the escpaed name ----------------------------------
173  if (fOptions.Has("date")) {
174  fDatimeString = fOptions.Get("date");
176  }
177 
178  // --- Get current directory and set-up sub-directory ------------
179  TString cwd = gSystem->WorkingDirectory();
180  if (!SetupWorkingDirectory()) return false;
181 
182  // --- Do initial helper setup -----------------------------------
183  if (!fRailway->PreSetup()) return false;
184 
185  // --- Load ROOT libraries ---------------------------------------
186  if (!fRailway->LoadROOT()) return false;
187 
188  // --- Load AliROOT libraries ------------------------------------
189  if (!fRailway->LoadAliROOT()) return false;
190 
191  // --- Load AliROOT libraries ------------------------------------
192  if (!fRailway->LoadAliPhysics()) return false;
193 
194  // --- Create analysis manager -----------------------------------
196 
197  // In test mode, collect system information on every event
198  // if (oper == kTest) mgr->SetNSysInfo(1);
199  if (verbose > 0) mgr->SetDebugLevel(verbose);
200  mgr->SetAutoBranchLoading(!fOptions.Has("branches"));
201  if (fRailway->Mode() == Railway::kLocal)
202  mgr->SetUseProgressBar(kTRUE, 100);
203 
204  // --- ESD input handler ------------------------------------------
205  AliVEventHandler* inputHandler = CreateInputHandler(type);
206  if (inputHandler) mgr->SetInputEventHandler(inputHandler);
207 
208  // --- Monte-Carlo ------------------------------------------------
209  AliVEventHandler* mcHandler = CreateMCHandler(type,mc);
210  if (mcHandler) mgr->SetMCtruthEventHandler(mcHandler);
211 
212  // --- AOD output handler -----------------------------------------
213  AliVEventHandler* outputHandler = CreateOutputHandler(type);
214  if (outputHandler) mgr->SetOutputEventHandler(outputHandler);
215 
216  // --- Include analysis macro path in search path ----------------
217  gROOT->SetMacroPath(Form("%s:%s:$ALICE_ROOT/ANALYSIS/macros:"
218  "$ALICE_PHYSICS/OADB/macros",
219  cwd.Data(), gROOT->GetMacroPath()));
220 
221  // --- Tender/OCDB -----------------------------------------------
222  if (type == Railway::kESD) {
223  TString supplies = fOptions.Get("tender");
224  if (!supplies.IsNull()) {
225  AddTender(supplies);
226  }
227  else if (fOptions.AsBool("ocdb")) {
228  AddOCDBConnect();
229  }
230  }
231 
232  // --- Physics selction - only for ESD ---------------------------
233  if (type == Railway::kESD) CreatePhysicsSelection(mc, mgr);
234 
235  // --- Create centrality task ------------------------------------
237 
238  // --- Create tasks ----------------------------------------------
239  CreateTasks(mgr);
240 
241  // --- Create monitor objects ------------------------------------
242  CreateMonitors();
243 
244  // --- Post set-up initialization of helper ----------------------
245  if (!fRailway->PostSetup()) return false;
246 
247  // --- Set debug level on defined tasks --------------------------
248  if (verbose > 0) {
249  TIter next(mgr->GetTasks());
250  AliAnalysisTask* sub = 0;
251  while ((sub = static_cast<AliAnalysisTask*>(next()))) {
252  AliAnalysisTaskSE* se = dynamic_cast<AliAnalysisTaskSE*>(sub);
253  if (!se) continue;
254  se->SetDebugLevel(verbose);
255  }
256  }
257 
258  // --- Print this setup ------------------------------------------
259  Print();
260 
261  // --- Initialise the train --------------------------------------
262  if (!mgr->InitAnalysis()) {
263  gSystem->ChangeDirectory(cwd.Data());
264  Error("Init","Failed to initialise train");
265  return false;
266  }
267 
268  // --- Enable progress bar ---------------------------------------
269  if (fRailway->Mode() != Railway::kGrid)
270  mgr->SetUseProgressBar(true, 100);
271 
272  // --- Save setup to disk ----------------------------------------
273  SaveSetup(true);
274 
275  // --- Some information ------------------------------------------
276  mgr->PrintStatus();
277  if (fRailway->Mode() != Railway::kLocal) {
278  TIter next(mgr->GetTasks());
279  AliAnalysisTask* sub = 0;
280  while ((sub = static_cast<AliAnalysisTask*>(next()))) {
281  sub->Print();
282  }
283  }
284  return true;
285  }
292  void PrintTimer(TStopwatch& timer, const char* where)
293  {
294  timer.Stop();
295  Double_t t = timer.RealTime();
296  Int_t h = Int_t(t / 3600); t -= h * 3600;
297  Int_t m = Int_t(t / 60); t -= m * 60;
298  if (t < 0) t = 0;
299  Info(where, "took %4d:%02d:%06.3f", h, m, t);
300  }
307  {
308  TString cwd = gSystem->WorkingDirectory();
309  Bool_t status = false;
310  TStopwatch timer;
311  timer.Start();
312  try {
313  if (!Init()) throw TString("Failed to intialize the train");
314  PrintTimer(timer, "Initialization");
315  timer.Continue();
316 
317  // Check if we're asked to only do the setup
318  if (fOptions.Has("setup")) {
319  status = true;
320  throw TString("Only did setup, no running");
321  }
322 
323  // if (r) SaveSetup(*r, nEvents, asShell);
324 
325  Long64_t nEvents = fOptions.AsLong("events", -1);
326  Long64_t ret = fRailway->Run(nEvents);
327  PrintTimer(timer, "Processing");
328  timer.Continue();
329 
330  // Make sure we go back
331  gSystem->ChangeDirectory(cwd.Data());
332 
333  // Return.
334  if (ret < 0) throw TString("Analysis failed");
335 
336  status = true;
337  }
338  catch (TString& e) {
339  if (status) Warning("Run", "%s", e.Data());
340  else Error("Run", "%s", e.Data());
341  }
342  if (fOptions.Has("date") &&
343  !fOptions.Get("date").EqualTo("none") &&
344  !fOptions.Has("no-link")) {
345  TString tmp = "";
346  TString escaped = EscapeName(fName, tmp);
347  gSystem->Exec(Form("rm -f last_%s", escaped.Data()));
348  gSystem->Exec(Form("ln -sf %s last_%s",
349  fEscapedName.Data(), escaped.Data()));
350  }
351  PrintTimer(timer, "Finish");
352  timer.Continue();
353  return status;
354  }
361  OptionList& Options() { return fOptions; }
366  void Print(Option_t* ="") const
367  {
368  std::cout << "Train: " << fName << " (" << fEscapedName << ")"
369  << std::endl;
370  fOptions.Show(std::cout);
371  if (fRailway) fRailway->Print();
372  }
380  Bool_t Version(std::ostream& o=std::cout)
381  {
382  if (!fOptions.Has("version")) return true;
383 
384  o << "TrainSetup version " << kVersion << std::endl;
385  return false;
386  }
395  Bool_t Help(std::ostream& o=std::cout, bool asProg=false)
396  {
397  if (!fOptions.Has("help")) return true;
398 
399  if (!asProg)
400  o << "Usage: RunTrain(NAME, CLASS, OPTIONS)";
401 
402  o << "\n\nTrain Options:\n";
403  fOptions.Help(o, asProg ? " --" : " ");
404  o << "\n";
405 
406  if (!fRailway && fOptions.Has("url")) {
407  TString url = fOptions.Get("url");
408  fRailway = Railway::Create(url.Data());
409  }
410  if (fRailway) {
411  o << fRailway->Desc() << " URL form:\n\n"
412  << " " << fRailway->UrlHelp() << "\n\n"
413  << "Options:\n";
414  fRailway->Options().Help(o, " ");
415  o << "\n";
416  }
417  else {
418  o << "Possible URL forms:\n\n";
419  Railway::ShowUrlHelp("LocalRailway");
420  Railway::ShowUrlHelp("ProofRailway");
421  Railway::ShowUrlHelp("LiteRailway");
422  Railway::ShowUrlHelp("VAFRailway");
423  Railway::ShowUrlHelp("AAFRailway");
424  Railway::ShowUrlHelp("AAFPluginRailway");
425  Railway::ShowUrlHelp("GridRailway");
426  o << "\n";
427  }
428  return false;
429  }
443  static Bool_t Main(const TString& name, const TString& cls,
444  const TCollection* opts,
445  Bool_t asProg=true,
446  Bool_t spawn=false)
447  {
448  Bool_t ret = false;
449  try {
450  if (cls.IsNull())
451  throw TString("No class name specified");
452  if (name.IsNull())
453  throw TString("No train name specified");
454  TString mkLib = gSystem->GetMakeSharedLib();
455  mkLib.ReplaceAll("-std=c++14", "-std=c++98");
456  // mkLib.Append("-ffpe-trap=invalid,zero,overflow,underflow,inexact");
457  gSystem->SetMakeSharedLib(mkLib);
458 
459  gROOT->ProcessLine("gSystem->RedirectOutput(\"build.log\",\"w\");");
460  Int_t error = 0;
461  Int_t r1 = gROOT->LoadMacro(Form("%s.C+g", cls.Data()), &error);
462  gROOT->ProcessLine("gSystem->RedirectOutput(0);");
463  if (r1 < 0 || error)
464  throw TString::Format("Failed to load setup %s: %d - see build.log",
465  cls.Data(), error);
466 
467  // Make our object using the interpreter
468  TString create = TString::Format("new %s(\"%s\")",
469  cls.Data(), name.Data());
470  gROOT->ProcessLine("gSystem->RedirectOutput(\"build.log\",\"a\");");
471  Long_t retP = gROOT->ProcessLine(create, &error);
472  gROOT->ProcessLine("gSystem->RedirectOutput(0);");
473  if (!retP || error)
474  throw TString::Format("Failed to make object of class %s "
475  "(see build.log): 0x%08lx/%d\n\t%s",
476  cls.Data(), retP, error, create.Data());
477 
478  TrainSetup* train = reinterpret_cast<TrainSetup*>(retP);
479 
480  // Now parse the options
481  if (!train->Options().Parse(opts))
482  throw TString("Failed to parse options");
483 
484  // Info("", "URL=%s", train->Options().Get("url").Data());
485 
486  // Check if we got a help request
487  if (!train->Help(std::cout, asProg)) {
488  ret = true;
489  throw TString("");
490  }
491  // Check if we got a version request
492  if (!train->Version(std::cout)) {
493  ret = true;
494  throw TString("");
495  }
496 
497  // return train->Init();
498  ret = train->Run();
499  }
500  catch (TString& e) {
501  if (!e.IsNull()) Error("Main", "%s", e.Data());
502  }
503  // Info("Main", "End of main loop (app=%p, asProg=%s, spawn=%s)",
504  // gApplication, asProg ? "true" : "false", spawn ? "true" : "false");
505  if (gApplication && asProg) {
506  if (!spawn) {
507  gSystem->Sleep(3);
508  gApplication->Terminate(ret ? 0 : 1);
509  }
510  }
511  return ret;
512  }
513 protected:
514  //__________________________________________________________________
526  virtual AliAnalysisManager* CreateAnalysisManager(const char* name)
527  {
528  return new AliAnalysisManager(name,"Analysis Train");
529  }
539  virtual AliVEventHandler* CreateInputHandler(UShort_t type,
540  Bool_t esdRecPoints=false)
541  {
542  Info("CreateInputHandler", "Making handler for %d (%d)",
543  type, esdRecPoints);
544  AliVEventHandler* ret = 0;
545  switch (type) {
546  case Railway::kESD: {
547  AliESDInputHandler* input = 0;
548  if (!esdRecPoints) input = new AliESDInputHandler();
549  else {
550  Info("CreateInputHandler", "Special handler for rec-points");
551  AliESDInputHandlerRP* esd = new AliESDInputHandlerRP();
552  // if (fRailway->Mode() != Railway::kGrid)
553  // esd->ReadFromDirectory();
554  input = esd;
555  }
556  input->SetReadFriends(fOptions.AsBool("friends"));
557  ret = input;
558  }
559  break;
560  case Railway::kAOD: {
561  AliAODInputHandler* input = new AliAODInputHandler();
562  TString fr = fOptions.Get("friends");
563  TObjArray* afr = fr.Tokenize(",+:");
564  TObject* ofr = 0;
565  TIter nfr(afr);
566  while ((ofr = nfr())) input->AddFriend(const_cast<char*>(ofr->GetName()));
567  afr->Delete();
568  ret = input;
569  }
570  break;
571  case Railway::kUser: return 0;
572  }
573  // Info("CreateInput", "Returning input handler %p", ret);
574  return ret;
575  }
583  virtual AliVEventHandler* CreateMCHandler(UShort_t /*type*/, bool mc)
584  {
585  if (!mc) return 0;
586  AliMCEventHandler* mcHandler = new AliMCEventHandler();
587  mcHandler->SetReadTR(true);
588  return mcHandler;
589  }
597  virtual AliVEventHandler* CreateOutputHandler(UShort_t type)
598  {
599  AliAODHandler* ret = new AliAODHandler();
600  switch (type) {
601  case Railway::kESD:
602  ret->SetOutputFileName("AliAOD.root");
603  break;
604  case Railway::kAOD:
605  ret->SetOutputFileName("AliAOD.pass2.root");
606  break;
607  case Railway::kUser:
608  break;
609  }
610 
611  return ret;
612  }
695  {
696  TString opt = fOptions.Get("ps");
697  // opt.ToUpper();
698 
699  if (opt.EqualTo("NONE",TString::kIgnoreCase)) return;
700 
701  // Possibly load as PAR
702  LoadOADB();
703 
704  AliPhysicsSelection* ps = 0;
705  AliInputEventHandler* input =
706  dynamic_cast<AliInputEventHandler*> (mgr->GetInputEventHandler());
707  if (!input) return;
708 
709  // --- Create object, either directory or via task ---------------
710  if (opt.Contains("BARE",TString::kIgnoreCase)) {
711  // --- Just create object and set on input handler -------------
712  ps = new AliPhysicsSelection();
713  if (mc) ps->SetAnalyzeMC();
714 
715  input->SetEventSelection(ps);
716  }
717  else {
718  // --- Create and add the task ---------------------------------
719  CoupleSECar("AddTaskPhysicsSelection.C", Form("%d", mc), AliVEvent::kAny);
720  mgr->RegisterExtraFile("event_stat.root");
721  // mgr->AddStatisticsTask(AliVEvent::kAny);
722 
723  // --- Retrive object from input handler -----------------------
724  ps = dynamic_cast<AliPhysicsSelection*>(input->GetEventSelection());
725  }
726  if (opt.Contains("CUSTOM",TString::kIgnoreCase)) {
727  // --- Load custom trigger definitions -------------------------
728  TString macro("CustomPS.C");
729  Int_t eq = opt.Index("custom=",7,0,TString::kIgnoreCase);
730  if (eq != kNPOS) {
731  Int_t end = opt.Index(".C",2,eq+7,TString::kIgnoreCase);
732  if (end != kNPOS) {
733  macro = opt(eq+7,end+2-eq-7);
734  }
735  }
736  fRailway->LoadAux(macro);
737  TString rmacro = gSystem->Which(gROOT->GetMacroPath(), macro);
738  if (rmacro.IsNull()) {
739  Error("CreatePhysicsSelection", "Custom PS script %s not found",
740  macro.Data());
741  return;
742  }
743  Info("CreatePhysicsSelection", "Loading custom PS from %s",rmacro.Data());
744  TString base(gSystem->BaseName(rmacro.Data()));
745  gROOT->Macro(Form("%s((AliPhysicsSelection*)%p)", base.Data(), ps));
746  }
747 
748  if (opt.Contains("ALL",TString::kIgnoreCase)) {
749  // --- Ignore trigger class when selecting events. This means -
750  // --- that we get offline+(A,C,E) events too ------------------
751  Info("CreatePhysicsSelection", "Skipping trigger selection");
752  ps->SetSkipTriggerClassSelection(true);
753  }
754  }
761  {
762  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
763  AliVEventHandler* inp = mgr->GetInputEventHandler();
764  if (!inp) return;
765 
766  // Check if input is AOD. Do not add MultSelection task, unless
767  // explicitly stated.
768  Bool_t isAOD = inp->IsA()->InheritsFrom(AliAODInputHandler::Class());
769  if (isAOD && !fOptions.AsBool("aod-cent")) return;
770 
771  // Possibly load as PAR
772  LoadOADB();
773 
774  gROOT->SetMacroPath(Form("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros"
775  ":%s", gROOT->GetMacroPath()));
776  AliAnalysisTaskSE* task = CoupleSECar("AddTaskMultSelection.C","false");
777  FromOption(task, "AlternateOADBforEstimators", "cent-oadb", "");
778  if (fOptions.Has("cent-oadb")) {
779  TString centOADB = fOptions.AsString("cent-oadb");
780  if (centOADB.EndsWith(".root")) {
781  TString base(gSystem->BaseName(centOADB.Data()));
782  TString per(base);
783  per.ReplaceAll("OADB-","");
784  per.ReplaceAll(".root","");
785  SetOnTask(task, "AlternateOADBforEstimators", per);
786  fRailway->LoadAux(centOADB);
787  if (mc)
788  SetOnTask(task, "AlternateOADBFullManualBypassMC", base);
789  else
790  SetOnTask(task, "AlternateOADBFullManualBypas", base);
791  }
792  }
793  if (!task->HasBranches()) {
794  // Everything except tracks since that slows does things and is
795  // really only needed for reference multiplicities
796  task->SetBranches("ESD:AliESDRun.,AliESDHeader.,AliESDZDC.,"
797  "AliESDVZERO.,AliESDTZERO.,TPCVertex.,"
798  "SPDVertex.,PrimaryVertex.,AliMultiplicity."
799  "SPDPileupVertices,TrkPileupVertices,"
800  "AliESDAD. "
801  "AOD:header,vertices,AliAODTZERO,AliAODVZERO,"
802  "AliAODZDC,AliAODAD");
803  }
804  if (!fOptions.Has("old-cent")) return;
805  if (isAOD) return;
806 
807  task = CoupleSECar("AddTaskCentrality.C",
808  Form("true,%s", isAOD ? "true" : "false"));
809  AliCentralitySelectionTask* ctask =
810  dynamic_cast<AliCentralitySelectionTask*>(task);
811  if (!ctask) return;
812  if (mc) ctask->SetMCInput();
813  }
819  virtual void CreateTasks(AliAnalysisManager* mgr)=0;
820  /* @} */
821  // -----------------------------------------------------------------
834  virtual AliAnalysisTask* CoupleCar(const TString& macro,
835  const TString& args)
836  {
837  TString p = gSystem->Which(gROOT->GetMacroPath(), macro.Data());
838  if (p.IsNull()) {
839  Error("CoupleCar", "Macro %s not found", macro.Data());
840  return 0;
841  }
842  TString cmd(p);
843  if (!args.IsNull())
844  cmd.Append(TString::Format("(%s)", args.Data()));
845  Info("CoupleCar", "Execute %s", cmd.Data());
846  Int_t err;
847  Long_t ret = gROOT->Macro(cmd.Data(), &err, false);
848  if (!ret) {
849  Error("CoupleCar", "Failed to execute %s (%ld)", cmd.Data(), ret);
850  return 0;
851  }
852  return reinterpret_cast<AliAnalysisTask*>(ret);
853  }
861  virtual AliAnalysisTask* CoupleCar(const TString& macro)
862  {
863  TString args;
864  return CoupleCar(macro, args);
865  }
876  virtual AliAnalysisTaskSE* CoupleSECar(const TString& macro,
877  const TString& args,
878  UInt_t mask=0)
879  {
880  AliAnalysisTaskSE* task =
881  dynamic_cast<AliAnalysisTaskSE*>(CoupleCar(macro, args));
882  // Explicitly set mask
883  if (mask > 0) task->SelectCollisionCandidates(mask);
884  return task;
885  }
895  virtual AliAnalysisTaskSE* CoupleSECar(const TString& macro,
896  UInt_t mask=0)
897  {
898  TString args;
899  return CoupleSECar(macro, args, mask);
900  }
909  virtual AliAnalysisTask* FindCar(const TString& name,
910  Bool_t verbose=true) const
911  {
912  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
913  if (!mgr) {
914  ::Warning("FindCar", "No manager defined");
915  return 0;
916  }
917  AliAnalysisTask* task = mgr->GetTask(name);
918  if (!task && verbose)
919  ::Warning("FindCar", "Task \"%s\" not found in train",
920  name.Data());
921  return task;
922  }
928  void LoadOADB(Bool_t asPar=false)
929  {
930  Bool_t usePar = asPar;
931  fRailway->UsePar(usePar); // Disabled pars temporarily
932  fRailway->LoadLibrary("OADB");
933  fRailway->UsePar(usePar); // Set to old value
934  }
935  /* @} */
940  virtual void AddOCDBConnect()
941  {
942  fRailway->LoadLibrary("PWGPP");
943  Long_t ret = gROOT->ProcessLine("new AliTaskCDBconnect(\"cdb\")");
944  if (!ret) {
945  Fatal("AddOCDBConnect", "Failed to add OCDB connection task");
946  return;
947  }
948  AliAnalysisTask* task = reinterpret_cast<AliAnalysisTask*>(ret);
949  if (!task->HasBranches()) task->SetBranches("ESD:AliESDRun. AOD:header");
950  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
951 
952  mgr->AddTask(task);
953  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
954  }
958  enum {
959  kTenderV0 = 0x0001,
960  kTenderTPC = 0x0002,
961  kTenderPtFix = 0x0004,
962  kTenderT0 = 0x0008,
963  kTenderTOF = 0x0010,
964  kTenderTRD = 0x0020,
965  kTenderVTX = 0x0040,
966  kTenderEMCAL = 0x0080,
967  kTenderPID = 0x0100,
968  kTenderHMPID = 0x0200,
969  kTenderPHOS = 0x0400
970  };
980  virtual void* AddTenderSupply(void* tender,
981  UShort_t flag,
982  Int_t debug)
983  {
984  if (flag == 0) return 0;
985 
986  TString c;
987  TString n;
988  switch (flag) {
989  case kTenderV0: n = "VZERO"; c = "VZERO"; break;
990  case kTenderTPC: n = "TPC"; c = "TPC"; break;
991  case kTenderPtFix: n = "TrackFix"; c = "PtInvFix"; break;
992  case kTenderT0: n = "T0"; c = "TZERO"; break;
993  case kTenderTOF: n = "TOF"; c = "TOF"; break;
994  case kTenderTRD: n = "TRD"; c = "TRD"; break;
995  case kTenderVTX: n = "Vtx"; c = "IP"; break;
996  case kTenderEMCAL: n = "EMCAL"; c = "EMCAL"; break;
997  case kTenderPID: n = "PID"; c = "PID"; break;
998  case kTenderHMPID: n = "HMPID"; c = "HMPID"; break;
999  case kTenderPHOS: n = "PHOS"; c = "PHOS"; break;
1000  default:
1001  Warning("AddTenderSupply", "Unknown tender flag: 0x%08x", flag);
1002  return 0;
1003  }
1004  TString m;
1005  switch (flag) {
1006  case kTenderV0: m = Form("s->SetDebug(%d);", debug); break;
1007  case kTenderEMCAL: // Fall through
1008  case kTenderTOF: // Fall through
1009  case kTenderTPC: // Fall through
1010  case kTenderPtFix: // Fall through
1011  case kTenderTRD: m = Form("s->SetDebugLevel(%d);", debug); break;
1012  }
1013 
1014  TString cls(Form("Ali%sTenderSupply", c.Data()));
1015  Long_t ret =
1016  gROOT->ProcessLine(Form("{ %s* s = new %s(\"%s\");"
1017  "((AliTender*)%p)->AddSupply(s);%s"
1018  "} s;",
1019  cls.Data(),
1020  cls.Data(),
1021  n.Data(),
1022  tender,
1023  m.Data()));
1024  void* ptr = reinterpret_cast<void*>(ret);
1025  Info("AddTenderSupply", "Adding supply %s (an %s object): %p",
1026  n.Data(), cls.Data(), ptr);
1027  return ptr;
1028  }
1033  virtual void AddTender(const TString& sup)
1034  {
1035  TString supplies = sup;
1036 
1037  UShort_t which = 0;
1038  supplies.ToUpper();
1039  if (supplies.Contains("V0") ||
1040  supplies.Contains("VZERO")) which |= kTenderV0 ;
1041  if (supplies.Contains("TPC")) which |= kTenderTPC ;
1042  if (supplies.Contains("PTFIX")) which |= kTenderPtFix ;
1043  if (supplies.Contains("T0")) which |= kTenderT0 ;
1044  if (supplies.Contains("TOF")) which |= kTenderTOF ;
1045  if (supplies.Contains("TRD")) which |= kTenderTRD ;
1046  if (supplies.Contains("VTX")) which |= kTenderVTX ;
1047  if (supplies.Contains("EMCAL")) which |= kTenderEMCAL ;
1048  if (supplies.Contains("PID")) which |= kTenderPID ;
1049 
1050  AddTender(which);
1051  }
1057  virtual void AddTender(UShort_t which)
1058  {
1059  if (which == 0) return;
1060 
1061  Int_t vrb = fOptions.AsInt("verbose", 3);
1062 
1063  fRailway->LoadLibrary("Tender");
1064  fRailway->LoadLibrary("TenderSupplies");
1065 
1066  Long_t ret = gROOT->ProcessLine("new AliTender(\"Tender\")");
1067  if (!ret) {
1068  Warning("AddTender", "Failed to make tender");
1069  return;
1070  }
1071  void* tender = reinterpret_cast<void*>(ret);
1072  gROOT->ProcessLine(Form("((AliTender*)%p)->SetCheckEventSelection(%d)",
1073  tender, (which & kTenderV0)));
1074  gROOT->ProcessLine(Form("((AliTender*)%p)->SetDebugLevel(%d)",
1075  tender, vrb));
1076 
1077  // OCDB settings for tender
1078  TString ocdb = fOptions.Get("ocdb");
1079  if (ocdb.IsNull())
1080  ocdb = "raw://";
1081  else if (ocdb.EndsWith(".root")) {
1082  fRailway->LoadLibrary("CDB");
1083  fRailway->LoadAux(ocdb);
1084  gROOT->ProcessLine(Form("AliCDBManager::Instance()->"
1085  "SetSnapshotMode(\"%s\");",
1086  ocdb.Data()));
1087  ocdb = "raw://";
1088  }
1089  gROOT->ProcessLine(Form("((AliTender*)%p)->SetDefaultCDBStorage(\"%s\")",
1090  tender, ocdb.Data()));
1091 
1092  AddTenderSupply(tender, which & kTenderV0, vrb);
1093  AddTenderSupply(tender, which & kTenderTPC, vrb);
1094  AddTenderSupply(tender, which & kTenderPtFix, vrb);
1095  AddTenderSupply(tender, which & kTenderT0, vrb);
1096  AddTenderSupply(tender, which & kTenderTOF, vrb);
1097  AddTenderSupply(tender, which & kTenderTRD, vrb);
1098  AddTenderSupply(tender, which & kTenderVTX, vrb);
1099  AddTenderSupply(tender, which & kTenderEMCAL, vrb);
1100  AddTenderSupply(tender, which & kTenderPID, vrb);
1101 
1102  gROOT->ProcessLine(Form("((AliTender*)%p)->GetSupplies()->Print()",tender));
1103 
1104  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
1105  AliAnalysisTask* tsk = reinterpret_cast<AliAnalysisTask*>(tender);
1106  mgr->AddTask(tsk);
1107  AliAnalysisDataContainer* cnt =
1108  mgr->CreateContainer("tender_event",
1109  AliESDEvent::Class(),
1110  AliAnalysisManager::kExchangeContainer,
1111  "default_tender");
1112  mgr->ConnectInput (tsk, 0, mgr->GetCommonInputContainer());
1113  mgr->ConnectOutput(tsk, 1, cnt);
1114 
1115  }
1116  /* @} */
1117  //------------------------------------------------------------------
1130  const char* what,
1131  UInt_t val)
1132  {
1133  SetOnTaskGeneric(task, what, Form("%u", val));
1134  }
1143  const char* what,
1144  Int_t val)
1145  {
1146  SetOnTaskGeneric(task, what, Form("%d", val));
1147  }
1156  const char* what,
1157  Long64_t val)
1158  {
1159  SetOnTaskGeneric(task, what, Form("%lld", val));
1160  }
1169  const char* what,
1170  Double_t val)
1171  {
1172  SetOnTaskGeneric(task, what, Form("%lg", val));
1173  }
1182  const char* what,
1183  Bool_t val)
1184  {
1185  SetOnTaskGeneric(task, what, Form("%d", val));
1186  }
1195  const char* what,
1196  const char* val)
1197  {
1198  SetOnTaskGeneric(task, what, Form("\"%s\"", val));
1199  }
1208  const char* what,
1209  const char* val)
1210  {
1211  const char* cls = task->ClassName();
1212  // Info("SetOnTask", "((%s)*%p)->Set%s(%s)", cls, task, what, val);
1213  gROOT->ProcessLine(Form("((%s*)%p)->Set%s(%s)",cls,task,what,val));
1214  }
1215  /* @} */
1216  //------------------------------------------------------------------
1230  const char* what,
1231  const char* opt,
1232  Double_t defval)
1233  {
1234  Double_t val = fOptions.AsDouble(opt,defval);;
1235  // Info("FromOption<D>"," %p, %s, %s, %f", task, what, opt, val);
1236  SetOnTask(task, what, val);
1237  }
1246  const char* what,
1247  const char* opt,
1248  Bool_t /*defval*/)
1249  {
1250  Bool_t val = fOptions.AsBool(opt);;
1251  // Info("FromOption<B>"," %p, %s, %s, %d", task, what, opt, val);
1252  SetOnTask(task, what, val);
1253  }
1263  const char* what,
1264  const char* opt,
1265  const char* defval)
1266  {
1267  TString val = fOptions.AsString(opt,defval);
1268  // Info("FromOption<S>"," %p, %s, %s, %s", task, what, opt, val);
1269  SetOnTask(task, what, val.Data());
1270  }
1280  const char* what,
1281  const char* opt,
1282  Int_t defval)
1283  {
1284  Int_t val = fOptions.AsInt(opt, defval);
1285  // Info("FromOption<I>"," %p, %s, %s, %d", task, what, opt, val);
1286  SetOnTask(task, what, val);
1287  }
1297  const char* what,
1298  const char* opt,
1299  Long64_t defval)
1300  {
1301  Long64_t val = fOptions.AsLong(opt, defval);
1302  // Info("FromOption<L>"," %p, %s, %s, %lld", task, what, opt, val);
1303  SetOnTask(task, what, val);
1304  }
1305  /* @} */
1306 
1307  // -----------------------------------------------------------------
1318  virtual Bool_t HasMCHandler() const
1319  {
1320  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
1321  if (!mgr) return false;
1322  return mgr->GetMCtruthEventHandler() != 0;
1323  }
1324  /* @} */
1331  virtual const Char_t* ClassName() const = 0;
1332  /* @} */
1333  //__________________________________________________________________
1334  virtual void AddMonitor(const TString& name)
1335  {
1336  if (fRailway->Mode() != Railway::kProof) return;
1337  Warning("CreateMonitors", "Monitoring not supported yet (%s)", name.Data());
1338  }
1339  //__________________________________________________________________
1344  virtual void CreateMonitors()
1345  {
1346  }
1347  //__________________________________________________________________
1360  static TString EscapeName(const char* name, TString& datimeStr)
1361  {
1362  TString escaped = name;
1363  char c[] = { ' ', '/', '@', 0 };
1364  char* p = c;
1365  while (*p) {
1366  char tmp[] = { *p, '\0' };
1367  escaped.ReplaceAll(tmp, "_");
1368  p++;
1369  }
1370  if (!datimeStr.IsNull() &&
1371  !datimeStr.EqualTo("none", TString::kIgnoreCase)) {
1372  TDatime datime;
1373  if (datimeStr.EqualTo("now", TString::kIgnoreCase))
1374  datime.Set();
1375  else {
1376  // Try various formats
1377  struct tm t;
1378  const char* formats[] = { "%Ec", // Locale
1379  "%c", // Locale
1380  "%Ex EX", // Locale
1381  "%x %X", // Locale
1382  "%Y%m%d_%H%M", // YYYYMMDD_HHMM
1383  "%F %R", // ISO standard, no seconds
1384  0 };
1385  const char** f = formats;
1386  Bool_t found = false;
1387  while (*f && !found) {
1388  // Reset needed fields
1389  t.tm_year = 0;
1390  t.tm_mon = 0;
1391  t.tm_mday = 0;
1392  t.tm_hour = 0;
1393  t.tm_min = 0;
1394  // Stop processing on first match
1395  if (strptime(datimeStr.Data(), *f, &t) != 0) found = true;
1396  f++;
1397  }
1398  if (found) {
1399  t.tm_mon += 1; // Return 0-based month
1400  datime.Set(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, 0);
1401  }
1402  }
1403  if (datime.GetYear() <= 1995 ||
1404  datime.GetMonth() == 0 ||
1405  datime.GetDay() == 0) return escaped;
1406  datimeStr = Form("%04d%02d%02d_%02d%02d",
1407  datime.GetYear(),
1408  datime.GetMonth(),
1409  datime.GetDay(),
1410  datime.GetHour(),
1411  datime.GetMinute());
1412  escaped.Append(Form("_%s", datimeStr.Data()));
1413  }
1414  return escaped;
1415  }
1422  {
1423  // Get the name of the target directory
1424  TString& nam = fEscapedName;
1425 
1426  // Check if the directory exists already
1427  Bool_t exists = gSystem->AccessPathName(nam.Data()) == 0;
1428  if (fRailway->Operation() == Railway::kTerminate && !exists) {
1429  Error("SetupWorkingDirectory", "File/directory %s does not exists",
1430  nam.Data());
1431  return false;
1432  }
1433 
1434  Bool_t overwrite = fOptions.Has("overwrite");
1435  // If we're not allowed to overwrite, then complain
1436  if (!overwrite && exists) {
1437  Error("SetupWorkingDirectory", "File/directory %s already exists",
1438  nam.Data());
1439  return false;
1440  }
1441 
1442  // Make the target directory if it doesn't exists
1443  if (!exists) {
1444  if (gSystem->MakeDirectory(nam.Data())) {
1445  Error("SetupWorkingDirectory", "Failed to make directory '%s'",
1446  nam.Data());
1447  return false;
1448  }
1449  }
1450 
1451  // Change directory to target directory
1452  if (!gSystem->ChangeDirectory(nam.Data())) {
1453  Error("SetupWorkingDirectory", "Failed to change directory to %s",
1454  nam.Data());
1455  return false;
1456  }
1457  // Info("SetupWorkingDirectory", "Made subdirectory %s, and cd'ed there",
1458  // nam.Data());
1459  return true;
1460  }
1461  /* @} */
1462  // -----------------------------------------------------------------
1472  virtual void SaveSetup(Bool_t asShellScript)
1473  {
1474  OptionList tmp(fOptions);
1475  const OptionList* uopts = (fRailway ? &fRailway->Options() : 0);
1476  if (tmp.Find("overwrite")) tmp.Set("overwrite");
1477  if (tmp.Find("date") && fEscapedName.Length() > fName.Length()+1) {
1478  Int_t n = fName.Length()+1;
1479  tmp.Set("date", fEscapedName(n, fEscapedName.Length()-n));
1480  }
1481  if (asShellScript)
1482  SaveSetupShell("rerun", ClassName(), fName, tmp, uopts);
1483  SaveSetupROOT("ReRun", ClassName(), fName, tmp, uopts);
1484  if (fRailway) fRailway->AuxSave(fEscapedName, asShellScript);
1486  }
1496  static void SaveSetupShell(const TString& out, const TString& cls,
1497  const TString& name, const OptionList& opts,
1498  const OptionList* uopts)
1499  {
1500  std::ofstream o(Form("%s.sh", out.Data()));
1501  TString url = opts.Get("url");
1502  OptionList tmp(opts);
1503  tmp.Set("url", "${url}");
1504  o << "#!/bin/bash\n\n"
1505  << "class=\"" << cls << "\"\n"
1506  << "name=\"" << name << "\"\n"
1507  << "url=\"" << url << "\"\n\n"
1508  << "# Available options\n"
1509  << "# \n";
1510  tmp.Help(o, "# --");
1511  if (uopts) {
1512  o << "#\n"
1513  << "# Available URI options\n"
1514  << "# \n";
1515  uopts->Help(o, "# ");
1516  }
1517  o << "#\n"
1518  << "opts=(--class=$class \\\n"
1519  << " --name=$name";
1520  tmp.Store(o, " \\\n --", "", true);
1521  o << ")\n\n"
1522  << "echo \"Running runTrain ${opts[@]} $@\"\n"
1523  << "runTrain \"${opts[@]}\" $@\n\n"
1524  << "# EOF" << std::endl;
1525  o.close();
1526  gSystem->Exec(Form("chmod a+x %s.sh", out.Data()));
1527  }
1537  static void SaveSetupROOT(const TString& out, const TString& cls,
1538  const TString& name, const OptionList& opts,
1539  const OptionList* uopts)
1540  {
1541  OptionList tmp(opts);
1542  tmp.Remove("url");
1543 
1544  std::ofstream o(Form("%s.C", out.Data()));
1545  o << "// Available options:\n"
1546  << "// \n";
1547  tmp.Help(o, "// ");
1548  if (uopts) {
1549  o << "// \n"
1550  << "// Available URI options\n";
1551  uopts->Help(o, "// ");
1552  }
1553  o << "//\n"
1554  << "Bool_t " << out << "()\n"
1555  << "{\n"
1556  << " TString name(\"" << name << "\");\n"
1557  << " TString cls(\"" << cls << "\");\n"
1558  << " TUrl uri(\"" << opts.Get("url") << "\");\n"
1559  << " \n"
1560  << " TString opts(";
1561  tmp.Store(o, "\"", ",\"\n ", false);
1562  o << ");\n\n"
1563  << " TString path(";
1564  TString path(gROOT->GetMacroPath());
1565  TObjArray* elements = path.Tokenize(":");
1566  TObjString* element = 0;
1567  TIter next(elements);
1568  while ((element = static_cast<TObjString*>(next()))) {
1569  if (element->String().IsNull()) continue;
1570  o << "\n \"" << element->GetName() << ":\"";
1571  }
1572  elements->Delete();
1573  o << ");\n"
1574  << " path.Append(\"$ALICE_PHYSICS/PWGLF/FORWARD/trains\");\n"
1575  << " gROOT->SetMacroPath(path);\n\n"
1576  << " gROOT->LoadMacro(\"RunTrain.C\");\n\n"
1577  << " return RunTrain(name, cls, uri, opts);\n"
1578  << "}\n"
1579  << "//\n"
1580  << "// EOF\n"
1581  << "//" << std::endl;
1582  o.close();
1583  }
1597  virtual void PostShellCode(std::ostream& o)
1598  {
1599  o << " echo \"Nothing to do for " << ClassName()
1600  << " train\"" << std::endl;
1601  }
1619  {
1620  std::ofstream f("post.sh");
1621  if (!f) {
1622  Error("SavePostAll", "Failed to open post.sh script");
1623  return;
1624  }
1625  f << "#!/bin/bash\n"
1626  << "# Generated by " << ClassName() << "\n"
1627  << "set -e\n"
1628  << "\n"
1629  << "dest=$1\n"
1630  << "prefix=\n"
1631  << "\n"
1632  << "doall() {"
1633  << std::endl;
1634  PostShellCode(f);
1635  f << "}\n"
1636  << "\n"
1637  << "if test ! -f Download.C ;then\n"
1638  << " doall\n"
1639  << " exit\n"
1640  << "fi\n"
1641  << "\n"
1642  << "if test ! -f .download ; then\n"
1643  << " aliroot -l -b -q Download.C\\(1\\)\n"
1644  << " touch .download\n"
1645  << "fi\n"
1646  << "prefix=../\n"
1647  << "\n"
1648  << "for i in root_archive_*.zip ; do\n"
1649  << " d=`basename $i .zip` \n"
1650  << " if test ! -d $d ; then\n"
1651  << " echo \"Directory $d missing\"\n"
1652  << " continue\n"
1653  << " fi\n"
1654  << " \n"
1655  << " (cd $d && doall)\n"
1656  << "done\n"
1657  << "# EOF"
1658  << std::endl;
1659  f.close();
1660  gSystem->Exec("chmod a+x post.sh");
1661  }
1662  /* @} */
1668 };
1669 #endif
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
virtual void CreateMonitors()
Definition: TrainSetup.C:1344
void SetOnTaskGeneric(AliAnalysisTaskSE *task, const char *what, const char *val)
Definition: TrainSetup.C:1207
virtual AliVEventHandler * CreateInputHandler(UShort_t type, Bool_t esdRecPoints=false)
Definition: TrainSetup.C:539
void Help(std::ostream &o, const char *prefix=" ") const
Definition: Option.C:903
double Double_t
Definition: External.C:58
void SavePostShellScript()
Definition: TrainSetup.C:1618
TString fDatimeString
Definition: TrainSetup.C:1665
Bool_t Run()
Definition: TrainSetup.C:306
const int debug
Definition: scanAll.C:15
const char * url
Railway * fRailway
Definition: TrainSetup.C:1667
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Bool_t)
Definition: TrainSetup.C:1245
static Railway * Create(const TUrl &url, Int_t verbose=0)
Definition: Railway.C:664
TString fName
Definition: TrainSetup.C:1663
Bool_t Help(std::ostream &o=std::cout, bool asProg=false)
Definition: TrainSetup.C:395
long long Long64_t
Definition: External.C:43
Option * Find(const TString &name) const
Definition: Option.C:401
virtual void AddOCDBConnect()
Definition: TrainSetup.C:940
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, const char *defval)
Definition: TrainSetup.C:1262
Bool_t AsBool(const TString &name) const
Definition: Option.C:631
virtual Bool_t LoadAliPhysics()
Definition: Railway.C:298
virtual Long64_t Run(Long64_t nEvents=-1)=0
TSystem * gSystem
virtual AliAnalysisTask * FindCar(const TString &name, Bool_t verbose=true) const
Definition: TrainSetup.C:909
char Char_t
Definition: External.C:18
virtual void Print(Option_t *="") const
Definition: Railway.C:430
void SetOnTask(AliAnalysisTaskSE *task, const char *what, const char *val)
Definition: TrainSetup.C:1194
virtual const Char_t * UrlHelp() const =0
virtual ~TrainSetup()
Definition: TrainSetup.C:134
void Store(std::ostream &o, const char *prefix="", const char *delim=",", bool quote=true, bool onlySet=false) const
Definition: Option.C:951
virtual void AddTender(UShort_t which)
Definition: TrainSetup.C:1057
TCanvas * c
Definition: TestFitELoss.C:172
virtual AliVEventHandler * CreateMCHandler(UShort_t, bool mc)
Definition: TrainSetup.C:583
Int_t AsInt(const TString &name, Int_t def=0) const
Definition: Option.C:645
virtual void AuxSave(const TString &, Bool_t)
Definition: Railway.C:460
const char * AsString(const TString &name, const TString &def="") const
Definition: Option.C:687
virtual Bool_t LoadAliROOT()
Definition: Railway.C:279
static void SaveSetupShell(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1496
static TString EscapeName(const char *name, TString &datimeStr)
Definition: TrainSetup.C:1360
virtual const char * Desc() const =0
void SetOnTask(AliAnalysisTaskSE *task, const char *what, Bool_t val)
Definition: TrainSetup.C:1181
virtual AliAnalysisTaskSE * CoupleSECar(const TString &macro, UInt_t mask=0)
Definition: TrainSetup.C:895
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Int_t defval)
Definition: TrainSetup.C:1279
virtual AliVEventHandler * CreateOutputHandler(UShort_t type)
Definition: TrainSetup.C:597
virtual Bool_t LoadROOT()
Definition: Railway.C:265
Definition: External.C:92
Long64_t AsLong(const TString &name, Long64_t def=0) const
Definition: Option.C:659
const TString & Get(const TString &name) const
Definition: Option.C:596
virtual Bool_t PreSetup()=0
virtual AliAnalysisTask * CoupleCar(const TString &macro)
Definition: TrainSetup.C:861
OptionList & Options()
Definition: TrainSetup.C:361
static void ShowUrlHelp(const TString &cl)
Definition: Railway.C:151
virtual UShort_t Mode() const =0
Bool_t Has(const TString &name) const
Definition: Option.C:584
int Int_t
Definition: External.C:63
void Print(Option_t *="") const
Definition: TrainSetup.C:366
virtual void CreateTasks(AliAnalysisManager *mgr)=0
unsigned int UInt_t
Definition: External.C:33
TrainSetup(const TrainSetup &o)
Definition: TrainSetup.C:106
virtual Bool_t PostSetup()=0
const OptionList & Options() const
Definition: Railway.C:454
virtual AliAnalysisManager * CreateAnalysisManager(const char *name)
Definition: TrainSetup.C:526
void Set(const TString &name, const TString &value)
Definition: Option.C:736
void PrintTimer(TStopwatch &timer, const char *where)
Definition: TrainSetup.C:292
virtual Bool_t IsMC() const
Definition: Railway.C:354
TrainSetup & operator=(const TrainSetup &o)
Definition: TrainSetup.C:120
virtual Short_t InputType() const
Definition: Railway.C:338
void SetOnTask(AliAnalysisTaskSE *task, const char *what, Int_t val)
Definition: TrainSetup.C:1142
void LoadOADB(Bool_t asPar=false)
Definition: TrainSetup.C:928
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Long64_t defval)
Definition: TrainSetup.C:1296
Option * Add(const TString &name, const TString &arg, const TString &desc, const TString &val="")
Definition: Option.C:421
TrainSetup(const TString &name)
Definition: TrainSetup.C:73
void SetOnTask(AliAnalysisTaskSE *task, const char *what, Double_t val)
Definition: TrainSetup.C:1168
virtual void SaveSetup(Bool_t asShellScript)
Definition: TrainSetup.C:1472
virtual Bool_t LoadAux(const TString &name, Bool_t copy=false)
Definition: Railway.C:255
Float_t nEvents[nProd]
Input train file.
Bool_t SetupWorkingDirectory()
Definition: TrainSetup.C:1421
Base class for analysis helpers.
void FromOption(AliAnalysisTaskSE *task, const char *what, const char *opt, Double_t defval)
Definition: TrainSetup.C:1229
virtual void * AddTenderSupply(void *tender, UShort_t flag, Int_t debug)
Definition: TrainSetup.C:980
OptionList fOptions
Definition: TrainSetup.C:1666
virtual Bool_t HasMCHandler() const
Definition: TrainSetup.C:1318
unsigned short UShort_t
Definition: External.C:28
virtual UShort_t Operation() const
Definition: Railway.C:327
const char Option_t
Definition: External.C:48
Bool_t Init()
Definition: TrainSetup.C:146
void Show(std::ostream &o, const char *prefix=" ") const
Definition: Option.C:928
virtual const Char_t * ClassName() const =0
virtual void UsePar(Bool_t &use)
Definition: Railway.C:662
bool Bool_t
Definition: External.C:53
static Bool_t Main(const TString &name, const TString &cls, const TCollection *opts, Bool_t asProg=true, Bool_t spawn=false)
Definition: TrainSetup.C:443
void SetOnTask(AliAnalysisTaskSE *task, const char *what, Long64_t val)
Definition: TrainSetup.C:1155
virtual AliAnalysisTask * CoupleCar(const TString &macro, const TString &args)
Definition: TrainSetup.C:834
virtual void AddMonitor(const TString &name)
Definition: TrainSetup.C:1334
Bool_t Version(std::ostream &o=std::cout)
Definition: TrainSetup.C:380
virtual void AddTender(const TString &sup)
Definition: TrainSetup.C:1033
virtual void PostShellCode(std::ostream &o)
Definition: TrainSetup.C:1597
TString fEscapedName
Definition: TrainSetup.C:1664
virtual void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager *mgr)
Definition: TrainSetup.C:694
virtual AliAnalysisTaskSE * CoupleSECar(const TString &macro, const TString &args, UInt_t mask=0)
Definition: TrainSetup.C:876
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
void Remove(const TString &name)
Definition: Option.C:564
static void SaveSetupROOT(const TString &out, const TString &cls, const TString &name, const OptionList &opts, const OptionList *uopts)
Definition: TrainSetup.C:1537
void SetOnTask(AliAnalysisTaskSE *task, const char *what, UInt_t val)
Definition: TrainSetup.C:1129