AliPhysics  9ce65a0 (9ce65a0)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LiteRailway.C
Go to the documentation of this file.
1 
11 #ifndef LITEHELPER_C
12 #define LITEHELPER_C
13 #include "ProofRailway.C"
14 #ifndef __CINT__
15 # include <TUrl.h>
16 # include <TString.h>
17 # include <TChain.h>
18 # include <TDSet.h>
19 # include <AliAnalysisManager.h>
20 # include <AliVEventHandler.h>
21 #else
22 class TChain;
23 class TUrl;
24 #endif
25 
26 // ===================================================================
74 struct LiteRailway : public ProofRailway
75 {
82  LiteRailway(const TUrl& url, Int_t verbose)
83  : ProofRailway(url, verbose), fChain(0)
84  {
85  fOptions.Add("recursive","Recursive scan");
86  fOptions.Add("trackref", "For MC input, check TrackRef.root presence");
87  fOptions.Add("scan", "Scan for number of events in chain");
88  fOptions.Add("clean", "Clean chain elements");
89  fOptions.Add("pattern", "GLOB", "File name pattern", "*.root");
90  fOptions.Remove("dsname");
91  fOptions.Remove("storage");
92  }
99  : ProofRailway(o), fChain(o.fChain)
100  {}
109  {
110  if (&o == this) return *this;
112  fChain = o.fChain;
113  return *this;
114  }
118  virtual ~LiteRailway() {}
124  virtual Bool_t PreSetup()
125  {
126  fUrl.SetProtocol("lite");
128  return ret;
129  }
135  virtual Bool_t PostSetup()
136  {
137  // --- Create the chain ------------------------------------------
138  fChain = LocalChain();
139  if (!fChain) return false;
140 
141  return ProofRailway::PostSetup();
142  }
150  {
151  TString tmp2 = fExtraSrcs.Strip(TString::kBoth, ':');
152  TObjArray* srcs = tmp2.Tokenize(":");
153  TIter next2(srcs);
154  TObject* obj = 0;
155  while ((obj = next2())) {
156  TString full = gSystem->ConcatFileName(gSystem->WorkingDirectory(),
157  obj->GetName());
158  Info("LoadExtraSrcs", "Will load %s", full.Data());
159  Int_t ret = gProof->Load(Form("%s+g", full.Data()), true,true);
160  if (ret < 0) {
161  Error("ProofRailway::PostSetup", "Failed to compile %s",obj->GetName());
162  return false;
163  }
164  }
165  return true;
166  }
175  {
176  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
177  gProof->SetLogLevel(TMath::Max(fVerbose-2,0),
178  /* TProofDebug::kPacketizer| */
179  TProofDebug::kLoop|
180  /* TProofDebug::kSelector|
181  TProofDebug::kOutput|
182  TProofDebug::kInput|
183  TProofDebug::kGlobal|*/
184  TProofDebug::kPackage);
185  if (nEvents < 0) nEvents = fChain->GetEntries();
186  Long64_t off = fOptions.AsLong("offset", 0);
187  if (nEvents > 0 && nEvents < off) {
188  Warning("Run", "Number of events %lld < offset (%lld), stopping",
189  nEvents, off);
190  return 0;
191  }
192  Long64_t ret = mgr->StartAnalysis("proof", fChain, nEvents, off);
193 
194  if (fVerbose > 2)
195  TProof::Mgr(fUrl.GetUrl())->GetSessionLogs()->Save("*","lite.log");
196  return ret;
197  }
203  virtual TString OutputPath() const
204  {
205  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
206  if (!mgr) return "";
207 
208  AliVEventHandler* outH = mgr->GetOutputEventHandler();
209  if (!outH) return "";
210 
211  TString ret = gSystem->ConcatFileName(gSystem->WorkingDirectory(),
212  outH->GetOutputFileName());
213  return ret;
214  }
215 
219  virtual const Char_t* UrlHelp() const
220  {
221  return "lite://<datadir_or_list>[?<options>][#<treeName]";
222  }
226  virtual const char* Desc() const { return "PROOF-lite"; }
229 };
230 #endif
231 //
232 // EOF
233 //
234 
ProofRailway & operator=(const ProofRailway &o)
Definition: ProofRailway.C:130
LiteRailway & operator=(const LiteRailway &o)
Definition: LiteRailway.C:108
OptionList fOptions
Definition: Railway.C:643
const char * url
long long Long64_t
Definition: External.C:43
TSystem * gSystem
char Char_t
Definition: External.C:18
Int_t fVerbose
Definition: Railway.C:644
TChain * fChain
Definition: LiteRailway.C:228
virtual ~LiteRailway()
Definition: LiteRailway.C:118
virtual Bool_t LoadExtraSrcs()
Definition: LiteRailway.C:149
Definition: External.C:92
Long64_t AsLong(const TString &name, Long64_t def=0) const
Definition: Option.C:659
virtual Bool_t PreSetup()
Definition: ProofRailway.C:641
TChain * LocalChain()
Definition: Railway.C:575
virtual Long64_t Run(Long64_t nEvents=-1)
Definition: LiteRailway.C:174
int Int_t
Definition: External.C:63
virtual const char * Desc() const
Definition: LiteRailway.C:226
TUrl fUrl
Definition: Railway.C:642
virtual Bool_t PostSetup()
Definition: ProofRailway.C:804
TString fExtraSrcs
virtual Bool_t PreSetup()
Definition: LiteRailway.C:124
Option * Add(const TString &name, const TString &arg, const TString &desc, const TString &val="")
Definition: Option.C:421
Float_t nEvents[nProd]
virtual TString OutputPath() const
Definition: LiteRailway.C:203
virtual const Char_t * UrlHelp() const
Definition: LiteRailway.C:219
bool Bool_t
Definition: External.C:53
LiteRailway(const LiteRailway &o)
Definition: LiteRailway.C:98
void Remove(const TString &name)
Definition: Option.C:564
virtual Bool_t PostSetup()
Definition: LiteRailway.C:135
LiteRailway(const TUrl &url, Int_t verbose)
Definition: LiteRailway.C:82