18 #ifndef TRAIN_HELPER_C
19 #define TRAIN_HELPER_C
26 # include <TObjString.h>
30 # include <TObjArray.h>
33 # include <AliAnalysisManager.h>
126 if (verbose < 3)
gSystem->RedirectOutput(
"/dev/null",
"w");
127 if (cl.Contains(
"proof", TString::kIgnoreCase) ||
128 cl.Contains(
"vaf", TString::kIgnoreCase) ||
129 cl.Contains(
"lite", TString::kIgnoreCase) ||
130 cl.Contains(
"aaf", TString::kIgnoreCase)) {
132 gSystem->Load(
"libProofPlayer");
135 gROOT->LoadMacro(Form(
"%s.C++g",cl.Data()));
136 Long_t ptr = gROOT->ProcessLine(Form(
"new %s(\"%s\", %d);",
137 cl.Data(), url.GetUrl(), verbose));
138 if (verbose < 3)
gSystem->RedirectOutput(0);
140 Warning(
"Railway::CreateObject",
"Failed to instantize a %s", cl.Data());
156 std::cout <<
" " << h->
UrlHelp() << std::endl;
168 std::cout << h->
Desc() <<
":\n"
169 <<
"==============\n"
170 <<
" " << h->
UrlHelp() <<
"\n\n"
171 <<
"Options: " << std::endl;
173 std::cout << std::endl;
204 if (!p.BeginsWith(
"-")) {
222 Bool_t forcePar=
false) = 0;
235 Warning(
"LoadSource",
"Failed to add aux source file %s", name.Data());
239 Info(
"LoadSource",
"Building %s", local.Data());
241 gROOT->LoadMacro(Form(
"%s+g", local.Data()));
243 Info(
"LoadSource",
"End of loading source");
258 if (!
AuxFile(local, copy))
return false;
267 if (
gSystem->Load(
"libTree") < 0)
return false;
268 if (
gSystem->Load(
"libGeom") < 0)
return false;
269 if (
gSystem->Load(
"libVMC") < 0)
return false;
270 if (
gSystem->Load(
"libPhysics") < 0)
return false;
271 if (
gSystem->Load(
"libMinuit") < 0)
return false;
281 if (!
gSystem->Getenv(
"ALICE_ROOT")) {
282 Error(
"Railway::LoadAliROOT",
"Local AliROOT not available");
300 if (!
gSystem->Getenv(
"ALICE_PHYSICS")) {
301 Error(
"Railway::LoadAliPhysics",
"Local AliPhysics not available");
341 if (ret !=
kUser)
return ret;
344 if (ret !=
kUser)
return ret;
372 if (!mgr || !mgr->GetOutputEventHandler())
return "";
376 path =
gSystem->WorkingDirectory();
382 u.SetAnchor(
"aodTree");
385 opt.ReplaceAll(
"AliESDs",
"AliAOD");
432 std::cout <<
"Url: " <<
fUrl.GetUrl() << std::endl;
442 virtual const char*
Desc()
const = 0;
503 if (!libName.BeginsWith(
"lib")) {
505 if (!
gSystem->AccessPathName(Form(
"%s_C.so", libName.Data())))
506 libName.Append(
"_C");
507 else if (!
gSystem->AccessPathName(Form(
"../%s_C.so", libName.Data())))
508 libName = Form(
"../%s_C", libName.Data());
510 libName = Form(
"lib%s", libName.Data());
512 if (!libName.EndsWith(
".so")) libName.Append(
".so");
528 search.ReplaceAll(
"-I",
":");
529 search.ReplaceAll(
" ",
"");
531 search.Append(gROOT->GetMacroPath());
533 if (!path.BeginsWith(
"/")) search.Prepend(
"../:");
536 if (path.EndsWith(
"+") || path.EndsWith(
"+g")) {
538 char c = path[path.Length()-1];
539 if (c !=
'+' && c !=
'g')
break;
540 path.Remove(path.Length()-1);
541 }
while (path.Length());
544 if (
gSystem->AccessPathName(query.Data())) {
546 Warning(
"Railway::AuxFile",
"File %s not accessible", path.Data());
551 if (
gSystem->AccessPathName(base.Data()) == 0) {
553 if (
gSystem->Unlink(base) != 0) {
554 Error(
"Railway::AuxFile",
"Failed to remove old %s", base.Data());
559 TFile::Cp(path, base);
561 gSystem->Exec(Form(
"ln -s %s .", query.Data()));
580 Error(
"LocalChain",
"No input source specified");
586 pattern.ReplaceAll(
"@",
"#");
587 pattern.ReplaceAll(
":",
"#");
595 AliAnalysisManager::GetAnalysisManager()
606 Error(
"LocalChain",
"Cannot generate TChain from %s", src.Data());
613 Error(
"LocalChain",
"No chain defined "
614 "(src=%s, treeName=%s, pattern=%s, flags=0x%x)",
615 src.Data(), treeName.Data(), pattern.Data(), flags);
635 if (str.IsNull())
return kUser;
636 if (str.Contains(
"aod", TString::kIgnoreCase))
return kAOD;
637 if (str.Contains(
"esd", TString::kIgnoreCase))
return kESD;
655 if (!url.IsValid()) {
656 Warning(
"Railway::Create",
"URL is invalid");
660 TString prot(url.GetProtocol());
664 TString opts(tmp.GetOptions());
667 if (prot.EqualTo(
"alien")) {
671 else if (prot.EqualTo(
"local")) {
675 else if (prot.EqualTo(
"proof")) {
679 else if (host.BeginsWith(
"alice-caf")) {
681 ::Warning(
"Railway::Create",
"CAF has been decommissioned");
682 cl = opts.Contains(
"plugin") ?
"AAFPluginRailway" :
"AAFRailway";
684 else if (host.BeginsWith(
"alivaf")) {
691 else if (prot.EqualTo(
"lite")) {
695 else if (prot.EqualTo(
"help")) {
697 if (host.Contains(
"options")) {
698 std::cout <<
"Possible URL types and options are:" << std::endl;
708 std::cout <<
"Possible URL types are:" << std::endl;
720 Error(
"Railway::Create",
"Unknown scheme: %s", prot.Data());
727 Error(
"Railway::Create",
"Failed to make object of class %s", cl.Data());
return jsonbuilder str().c_str()
virtual Bool_t ParseOptions()
void Help(std::ostream &o, const char *prefix=" ") const
const TString & MakeLibraryName(const TString &name)
static UShort_t CheckSource(TString &src, UShort_t flags)
static Railway * Create(const TUrl &url, Int_t verbose=0)
virtual Bool_t LoadAliPhysics()
virtual Long64_t Run(Long64_t nEvents=-1)=0
virtual void Print(Option_t *="") const
virtual const Char_t * UrlHelp() const =0
Railway & operator=(const Railway &)
virtual void AuxSave(const TString &, Bool_t)
virtual Bool_t LoadAliROOT()
static TChain * Create(const TUrl &url)
virtual const char * Desc() const =0
virtual Bool_t LoadROOT()
const TString & Get(const TString &name) const
virtual Bool_t PreSetup()=0
static UShort_t DeduceType(const TString &str)
static void ShowUrlHelp(const TString &cl)
virtual UShort_t Mode() const =0
Bool_t Has(const TString &name) const
Bool_t Parse(const TString &tmp, const TString &delims)
Railway(const Railway &o)
static Railway * CreateObject(const TString &cl, const TUrl &url, Int_t verbose=0)
virtual Bool_t PostSetup()=0
const OptionList & Options() const
virtual Bool_t IsMC() const
virtual Short_t InputType() const
virtual Bool_t AuxFile(TString &name, bool copy=false)
virtual Bool_t AddMonitor(const TString &)
virtual Bool_t AddIncludePath(const TString &path)
virtual const char * ModeString() const
Option * Add(const TString &name, const TString &arg, const TString &desc, const TString &val="")
virtual TString OutputLocation() const
virtual Bool_t LoadAux(const TString &name, Bool_t copy=false)
Railway(const TUrl &url, Int_t verbose)
virtual TString OutputPath() const
static void ShowFullHelp(const TString &cl)
virtual UShort_t Operation() const
void Show(std::ostream &o, const char *prefix=" ") const
virtual void UsePar(Bool_t &use)
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0
virtual Bool_t LoadSource(const TString &name, bool copy=false)