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;
473 Printf(
"URL is %s",
fUrl.GetUrl());
478 std::cout <<
"Url options: \"" <<
fUrl.GetOptions() <<
"\"" << std::endl;
504 if (!libName.BeginsWith(
"lib")) {
506 if (!
gSystem->AccessPathName(Form(
"%s_C.so", libName.Data())))
507 libName.Append(
"_C");
508 else if (!
gSystem->AccessPathName(Form(
"../%s_C.so", libName.Data())))
509 libName = Form(
"../%s_C", libName.Data());
511 libName = Form(
"lib%s", libName.Data());
513 if (!libName.EndsWith(
".so")) libName.Append(
".so");
529 search.ReplaceAll(
"-I",
":");
530 search.ReplaceAll(
" ",
"");
532 search.Append(gROOT->GetMacroPath());
534 if (!path.BeginsWith(
"/")) search.Prepend(
"../:");
537 if (path.EndsWith(
"+") || path.EndsWith(
"+g")) {
539 char c = path[path.Length()-1];
540 if (c !=
'+' && c !=
'g')
break;
541 path.Remove(path.Length()-1);
542 }
while (path.Length());
547 Printf(
"Searching for %s in ", path.Data());
550 while ((objC = nextC())) Printf(
" %s", objC->GetName());
556 if (
gSystem->AccessPathName(query.Data())) {
558 Warning(
"Railway::AuxFile",
"File %s not accessible", path.Data());
563 if (
gSystem->AccessPathName(base.Data()) == 0) {
565 if (
gSystem->Unlink(base) != 0) {
566 Error(
"Railway::AuxFile",
"Failed to remove old %s", base.Data());
571 TFile::Cp(query, base);
573 gSystem->Exec(Form(
"ln -s %s .", query.Data()));
591 if (su.BeginsWith(
"local", TString::kIgnoreCase))
592 su.Replace(0, 5,
"file", 4);
598 Error(
"LocalChain",
"No input source specified: %s (%s)",
599 url.GetUrl(),
fUrl.GetUrl());
605 pattern.ReplaceAll(
"@",
"#");
606 pattern.ReplaceAll(
":",
"#");
609 TString treeName = url.GetAnchor();
614 AliAnalysisManager::GetAnalysisManager()
625 Error(
"LocalChain",
"Cannot generate TChain from %s", src.Data());
632 Error(
"LocalChain",
"No chain defined " 633 "(url=%s, src=%s, treeName=%s, pattern=%s, flags=0x%x)",
634 url.GetUrl(), src.Data(), treeName.Data(), pattern.Data(), flags);
655 if (str.IsNull())
return kUser;
656 if (str.Contains(
"aod", TString::kIgnoreCase))
return kAOD;
657 if (str.Contains(
"esd", TString::kIgnoreCase))
return kESD;
675 if (!url.IsValid()) {
676 Warning(
"Railway::Create",
"URL is invalid");
680 TString prot(url.GetProtocol());
684 TString opts(tmp.GetOptions());
687 if (prot.EqualTo(
"alien")) {
691 else if (prot.EqualTo(
"local")) {
695 else if (prot.EqualTo(
"proof")) {
699 else if (host.BeginsWith(
"alice-caf")) {
701 ::Warning(
"Railway::Create",
"CAF has been decommissioned");
702 cl = opts.Contains(
"plugin") ?
"AAFPluginRailway" :
"AAFRailway";
704 else if (host.BeginsWith(
"alivaf")) {
711 else if (prot.EqualTo(
"lite")) {
715 else if (prot.EqualTo(
"help")) {
717 if (host.Contains(
"options")) {
718 std::cout <<
"Possible URL types and options are:" << std::endl;
728 std::cout <<
"Possible URL types are:" << std::endl;
740 Error(
"Railway::Create",
"Unknown scheme: %s", prot.Data());
747 Error(
"Railway::Create",
"Failed to make object of class %s", cl.Data());
753 Error(
"Railway::Create",
"Failed to parse options: %s", url.GetOptions());
757 Printf(
"URL of helper is %s", url.GetUrl());
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)
const char * AsString(const TString &name, const TString &def="") const
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
Double_t nEvents
plot quality messages
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)