AliPhysics  b555aef (b555aef)
VAFRailway.C
Go to the documentation of this file.
1 
11 #ifndef VAFHELPER_C
12 #define VAFHELPER_C
13 #include "ProofRailway.C"
14 #ifndef __CINT__
15 # include <TUrl.h>
16 # include <TString.h>
17 # include <TProof.h>
18 # include <TSystem.h>
19 #else
20 class TUrl;
21 #endif
22 
23 // ===================================================================
68 struct VAFRailway : public ProofRailway
69 {
76  VAFRailway(const TUrl& url, Int_t verbose)
77  : ProofRailway(url, verbose)
78  {
79  fOptions.Add("nocache", "Disable tree cache");
80  fOptions.Add("pattern","SEARCH","Search pattern", "");
81  fOptions.Add("alien","Enable ALIEN file access",true); //MUST be true
82  }
83  virtual ~VAFRailway() {}
89  virtual Bool_t LoadAliROOT()
90  {
91  Bool_t enabPhys = true;
92  TString aliVer = gSystem->Getenv("VafAliRootVersion");
93  TString aliPhys = gSystem->Getenv("VafAliPhysicsVersion");
94  if (!aliVer.IsNull()) {
95  Info("VAFRailway::LoadAliROOT", "Using AliROOT=%s", aliVer.Data());
96  if (!aliPhys.IsNull()) {
97  Warning("VAFRailway::LoadAliROOT",
98  "AliPhysics not loaded, even though version %s was requested",
99  aliPhys.Data());
100  }
101  enabPhys = false;
102  }
103  else if (aliPhys.IsNull()) {
104  Error("VAFRailway::LoadAliROOT", "Neither AliROOT nor AliPhysics "
105  "versions specified, giving up");
106  return false;
107  }
108  else
109  Info("VAFRailway::LoadAliROOT", "Using AliPhysics=%s", aliPhys.Data());
110 
111  fOptions.Set("alien");
112  return ProofRailway::LoadAliROOT();
113  }
119  virtual const char* AliPhysicsParName() const { return 0; }
120  virtual Bool_t CreateAliPhysicsPar() { return true; }
121  virtual Bool_t EnableAliPhysics() { return true; }
127  virtual const char* AliROOTParName() const
128  {
129  return "/afs/cern.ch/alice/offline/vaf/AliceVaf.par";
130  }
132  {
133  return true;
134  }
141  virtual Bool_t PreSetup()
142  {
143  if (!gSystem->Getenv("VafPodRemoteEnv")) {
144  Printf("\n"
145  "=== ERROR:\n"
146  "Are you sure you're on alivaf-XXX and did 'vaf-enter'? "
147  "'cause I'm not so I have to give up!\n");
148  return false;
149  }
150 
151  fBasePars = false;
152 
153  if (!ProofRailway::PreSetup()) return false;
154 
155  if (fOptions.Has("nocache"))
156  gProof->SetParameter("PROOF_UseTreeCache", 0);
157  return true;
158  }
164  virtual void GetDataSet(TString& dsName)
165  {
166  dsName = "Find;";
167  dsName.Append(Form("BasePath=%s;", fUrl.GetFile()));
168  TString pat = fOptions.Get("pattern");
169  Int_t idx = pat.Index("@");
170  if (idx != kNPOS) {
171  TString fn = pat(0,idx);
172  TString an = pat(idx+1,pat.Length()-idx-1);
173  dsName.Append(Form("FileName=%s;",fn.Data()));
174  dsName.Append(Form("Anchor=%s;", an.Data()));
175  }
176  else
177  dsName.Append(Form("FileName=%s;",pat.Data()));
178  dsName.Append(Form("Tree=/%s;", fUrl.GetAnchor()));
179  dsName.Append("Mode=remote;");
180 
181  }
190  virtual Bool_t Connect(const TUrl& url, const TString& opt)
191  {
192  TUrl tmp(url);
193  tmp.SetProtocol("pod");
194  return ProofRailway::Connect(tmp, opt);
195  }
199  virtual const Char_t* UrlHelp() const
200  {
201  return "proof://alivaf/<datadir>?[&<options>][#<treename>]";
202  }
206  virtual const char* Desc() const { return "VAF"; }
207 };
208 #endif
209 //
210 // EOF
211 //
virtual Bool_t CreateAliROOTPar()
Definition: VAFRailway.C:131
virtual const char * AliPhysicsParName() const
Definition: VAFRailway.C:119
OptionList fOptions
Definition: Railway.C:663
const char * url
TSystem * gSystem
virtual ~VAFRailway()
Definition: VAFRailway.C:83
char Char_t
Definition: External.C:18
virtual Bool_t Connect(const TUrl &url, const TString &opt)
Definition: VAFRailway.C:190
Definition: External.C:92
virtual Bool_t CreateAliPhysicsPar()
Definition: VAFRailway.C:120
const TString & Get(const TString &name) const
Definition: Option.C:596
virtual Bool_t PreSetup()
Definition: ProofRailway.C:641
virtual Bool_t Connect(const TUrl &url, const TString &opts)
Definition: ProofRailway.C:621
virtual const char * Desc() const
Definition: VAFRailway.C:206
Bool_t Has(const TString &name) const
Definition: Option.C:584
int Int_t
Definition: External.C:63
virtual Bool_t EnableAliPhysics()
Definition: VAFRailway.C:121
VAFRailway(const TUrl &url, Int_t verbose)
Definition: VAFRailway.C:76
void Set(const TString &name, const TString &value)
Definition: Option.C:736
virtual void GetDataSet(TString &dsName)
Definition: VAFRailway.C:164
TUrl fUrl
Definition: Railway.C:662
virtual Bool_t LoadAliROOT()
Definition: ProofRailway.C:251
Option * Add(const TString &name, const TString &arg, const TString &desc, const TString &val="")
Definition: Option.C:421
virtual const Char_t * UrlHelp() const
Definition: VAFRailway.C:199
virtual Bool_t PreSetup()
Definition: VAFRailway.C:141
virtual const char * AliROOTParName() const
Definition: VAFRailway.C:127
virtual Bool_t LoadAliROOT()
Definition: VAFRailway.C:89
bool Bool_t
Definition: External.C:53
Bool_t fBasePars