/** * @file LiteRailway.C * @author Christian Holm Christensen * @date Tue Oct 16 18:59:59 2012 * * @brief Proof-Lite analysis helper * * @ingroup pwglf_forward_trains_helper * */ #ifndef LITEHELPER_C #define LITEHELPER_C #include "ProofRailway.C" #ifndef __CINT__ # include "ChainBuilder.C" # include # include # include # include # include # include #else class TChain; class TUrl; #endif // =================================================================== /** * Handler of analysis in Proof-Lite. This is triggered by URIs of the * form * * @code * local:///[?][#treeName] * local:///[?][#treeName] * local:///[?][#treeName] * @endcode * * where * *
*
<datadir>
*
is the base directory holding data files
*
<collection>
*
is an ASCII or XML list of input sources
*
<file>
*
is a single ROOT file
*
<options>
*
A & separated list of options *
*
recursive
*
Scan <datadir> recursively
*
mc
*
Scan also for MC files (galice.root, * Kinematics.root, and TrackRefs.root) when * scanning <datadir>
*
pattern=<GLOB>
*
Shell glob pattern that files must check when scanning * <datadir>
*
workers=N[x]
*
Set the number of workers to use. If x is appended, * then it's maximum number of workers per slave
*
par[=all]
*
Use PAR files. If the value all is given, then also * PAR files of STEERBase, ESD, AOD, ANALYSIS, OADB, ANALYSISalice * are used.
*
mode=[default,rec,sim,train,custom]
*
Set the AliROOT mode. If not specified default * is assumed. See also CreateAliROOTPar
*
*
*
* * @ingroup pwglf_forward_trains_helper */ struct LiteRailway : public ProofRailway { /** * Constructor * * @param url Url * @param verbose Verbosity */ LiteRailway(const TUrl& url, Int_t verbose) : ProofRailway(url, verbose), fChain(0) { fOptions.Add("recursive","Recursive scan"); fOptions.Add("pattern", "GLOB", "File name pattern", "*.root"); fOptions.Remove("dsname"); fOptions.Remove("storage"); } /** * Copy constructor * * @param o Object to copy from */ LiteRailway(const LiteRailway& o) : ProofRailway(o), fChain(o.fChain) {} /** * Assignment operator * * @param o Object to assign from * * @return Reference to this */ LiteRailway& operator=(const LiteRailway& o) { if (&o == this) return *this; ProofRailway::operator=(o); fChain = o.fChain; return *this; } /** * Destructor */ virtual ~LiteRailway() {} /** * Set-up done before task set-ups * * @return true on success */ virtual Bool_t PreSetup() { fUrl.SetProtocol("lite"); Bool_t ret = ProofRailway::PreSetup(); return ret; } /** * Set-up done after task set-ups * * @return true on success */ virtual Bool_t PostSetup() { // -- Check for local chain -------------------------------------- TString pattern = (fOptions.Has("pattern") ?fOptions.Get("pattern") :""); TString treeName = fUrl.GetAnchor(); Bool_t recursive = fOptions.Has("recursive"); Bool_t mc = fOptions.Has("mc"); TString src = fUrl.GetFile(); UShort_t type = ChainBuilder::CheckSource(src, 0); if (type == ChainBuilder::kInvalid) { Error("LiteRailway", "Cannot generate TChain from %s", src.Data()); return false; } // --- Create the chain ------------------------------------------ pattern.ReplaceAll("@", "#"); Bool_t chainMC = (mc && AliAnalysisManager::GetAnalysisManager() ->GetMCtruthEventHandler() != 0); fChain = ChainBuilder::Create(type, src, treeName, pattern, chainMC, recursive, fVerbose > 5); if (!fChain) { Error("PostSetup", "No chain defined " "(src=%s, treeName=%s, pattern=%s, mc=%s, recursive=%s)", src.Data(), treeName.Data(), pattern.Data(), (mc ? "true" : "false"), (recursive ? "true" : "false")); return false; } return ProofRailway::PostSetup(); } /** * Start the analysis * * @param nEvents Number of events to analyse * * @return The return value of AliAnalysisManager::StartAnalysis */ virtual Long64_t Run(Long64_t nEvents=-1) { AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager(); gProof->SetLogLevel(TMath::Max(fVerbose-2,0), /* TProofDebug::kPacketizer| */ TProofDebug::kLoop| /* TProofDebug::kSelector| TProofDebug::kOutput| TProofDebug::kInput| TProofDebug::kGlobal|*/ TProofDebug::kPackage); if (nEvents < 0) nEvents = fChain->GetEntries(); Long64_t off = fOptions.AsLong("offset", 0); if (nEvents > 0 && nEvents < off) { Warning("Run", "Number of events %lld < offset (%lld), stopping", nEvents, off); return 0; } Long64_t ret = mgr->StartAnalysis("proof", fChain, nEvents, off); if (fVerbose > 2) TProof::Mgr(fUrl.GetUrl())->GetSessionLogs()->Save("*","lite.log"); return ret; } /** * Path of output * * @return Path to output - possibly a data set */ virtual TString OutputPath() const { AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager(); if (!mgr) return ""; AliVEventHandler* outH = mgr->GetOutputEventHandler(); if (!outH) return ""; TString ret = gSystem->ConcatFileName(gSystem->WorkingDirectory(), outH->GetOutputFileName()); return ret; } /** * @return URL help string */ virtual const Char_t* UrlHelp() const { return "lite://[?][#