/** * @file AAFPluginRailway.C * @author Christian Holm Christensen * @date Tue Oct 16 19:01:45 2012 * * @brief AAF (using AliAnalysisAlien) analysis helper * * @ingroup pwglf_forward_trains_helper * */ #ifndef AAFPLUGINHELPER_C #define AAFPLUGINHELPER_C #include "PluginRailway.C" #ifndef __CINT__ # include # include # include # include #else class TUrl; class AliAnalysisAlien; #endif // =================================================================== /** * Handle analysis on an Alice Analysis Facility (AAF) * * This helper is triggered by a URL of the form * * @code * proof://[@][:]/[?][#] * @endcode * where <host> is a known AAF (e.g., alice-caf.cern.ch), * and the <options> contains plugin *
*
<user>
*
Optional user name
*
<host>
*
PROOF cluster master host
*
<port>
*
Optional PROOF cluster port on master host
*
<dsname>
*
Data set name
*
<treename>
*
Optional tree name in data set, often esdTree or * aodTree
*
<options>
*
List of options separated by an & *
*
dsname[=<output dataset>]
*
Register tree output (e.g., AOD) as a new data set on the * PROOF cluster. If <output dataset> is not specified, take * the name of the train.
*
storage=<url>
*
Specify a non-default storage location for special output * (e.g., AOD trees). <url> should be a valid XRootd * server URI accessible to the slaves - e.g., * root://lxplus.cern.ch:10930//tmp.
*
mode=[default,rec,sim,train,custom]
*
Set the AliROOT mode. If not specified default * is assumed. See also CreateAliROOTPar
*
par
*
Use PAR files
*
workers=N[x]
*
Set the number of workers to use. If x is appended, * then it's maximum number of workers per slave
*
*
*
* * @ingroup pwglf_forward_trains_helper */ struct AAFPluginRailway : public PluginRailway { /** * Constructor * * @param url Url * @param verbose Verbosity level */ AAFPluginRailway(const TUrl& url, Int_t verbose) : PluginRailway(url, verbose) { fOptions.Add("workers", "N[x]", "Number of workers to use", 0); fOptions.Add("dsname", "NAME", "Make output dataset", ""); fOptions.Add("wrapper", "CMD", "Wrapper command", ""); fOptions.Add("clear", "Clear all packages"); fOptions.Add("reset", "soft|hard", "Reset cluster", "hard"); } /** * Destructor */ virtual ~AAFPluginRailway() {} /** * Called before setting up * * @return true on success */ virtual Bool_t PreSetup() { // --- Handle software options ----------------------------------- TString root = fOptions.Get("root"); fHandler->SetRootVersionForProof(Form("VO_ALICE@ROOT::%s", root.Data())); fHandler->SetProofCluster(fUrl.GetHost()); fHandler->SetProofDataSet(fUrl.GetFile()); // --- Handle worker options ------------------------------------- if (fOptions.Has("workers")) { TString nwork = fOptions.Get("workers"); if (nwork.EndsWith("x")) fHandler->SetNproofWorkersPerSlave(nwork.Atoi()); else fHandler->SetNproofWorkers(nwork.Atoi()); } // --- Check if we're using a wrapper ---------------------------- if (fOptions.Has("wrapper")) { TString wrapper = fOptions.Get("wrapper"); if (wrapper.IsNull()) // In case of no argument, use GDB // Just run and backtrace wrapper = "/usr/bin/gdb --batch -ex run -ex bt --args"; Info("ProofRailway::PreSetup", "Using wrapper command: %s", wrapper.Data()); TProof::AddEnvVar("PROOF_WRAPPERCMD", wrapper); } // --- Check if we need to clear packages ------------------------ fHandler->SetClearPackages(fOptions.Has("clear")); // --- Check if we need to reset first --------------------------- if (fOptions.Has("reset")) { TString reset = fOptions.Get("reset"); Bool_t hard = (reset.IsNull() || reset.EqualTo("hard", TString::kIgnoreCase)); Info("AAFPluginRailway::PreSetup", "Will do a %s reset of %s", hard ? "hard" : "soft", fUrl.GetHost()); fHandler->SetProofReset(hard ? 2 : 1); } return PluginRailway::PreSetup(); } /** * Set-up done after the task set-ups * * @return true on success */ virtual Bool_t PostSetup() { if (!PluginRailway::PostSetup()) return false; if (fOptions.Has("dsname")) OutputUtilities::RegisterDataset(fOptions.Get("dsname")); return true; }; /** * Get the mode identifier * * @return Always kProof */ virtual UShort_t Mode() const { return kProof; } /** * Get the mode string used for AliAnalysisManager::StartAnalysis */ virtual const char* ModeString() const { return "proof"; } /** * 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(); TString dsName(fUrl.GetFile()); if (fUrl.GetAnchor() && fUrl.GetAnchor()[0] != '\0') dsName.Append(Form("#%s", fUrl.GetAnchor())); return mgr->StartAnalysis(fUrl.GetProtocol(), dsName, nEvents); } /** * @return URI help string */ virtual const Char_t* UrlHelp() const { return "proof:///?plugin[&][#]"; } /** * @return Short description */ virtual const char* Desc() const { return "CAF w/plugin"; } }; #endif // // EOF //