Skip to content
Snippets Groups Projects
Commit dfab995d authored by Volker Friese's avatar Volker Friese Committed by David Emschermann
Browse files

Removed C++17 features; added handling of a list of sources, following PAL's suggestions.

parent 134aa473
No related branches found
No related tags found
1 merge request!768Execution of reconstruction from timeslice with steering class and minimal run macro. Refs #2275.
......@@ -16,15 +16,16 @@
#include <iostream>
#include <memory>
#include <string>
using std::cout;
using std::endl;
using std::make_unique;
using std::string;
// ----- Constructor ------------------------------------------------------
CbmReco::CbmReco(TString source, TString outFile, int32_t numTs, const CbmRecoConfig& config)
: fInputFileName(source)
// ----- Constructor from single source -----------------------------------
CbmReco::CbmReco(string source, TString outFile, int32_t numTs, const CbmRecoConfig& config)
: fSourceNames {source}
, fOutputFileName(outFile)
, fNumTs(numTs)
, fConfig(config)
......@@ -33,6 +34,30 @@ CbmReco::CbmReco(TString source, TString outFile, int32_t numTs, const CbmRecoCo
// ----------------------------------------------------------------------------
// ----- Constructor from multiple sources --------------------------------
CbmReco::CbmReco(std::vector<string> sources, TString outFile, int32_t numTs, const CbmRecoConfig& config)
: fSourceNames(sources)
, fOutputFileName(outFile)
, fNumTs(numTs)
, fConfig(config)
{
}
// ----------------------------------------------------------------------------
// ----- List of source names ---------------------------------------------
std::string CbmReco::ListSources() const
{
std::string result = "{";
for (auto& source : fSourceNames) {
result += source + ", ";
}
result += "}";
return result;
}
// ----------------------------------------------------------------------------
// ----- Configure and execute run ----------------------------------------
int32_t CbmReco::Run()
{
......@@ -41,16 +66,19 @@ int32_t CbmReco::Run()
TStopwatch timer;
timer.Start();
// TODO: I cannot yet use unique pointers for the objects to be passed to FairRunline.
// Ownership, however, is passed to FairRunOnline, which takes care of deleting the objects.
// --- Input source
auto source = make_unique<CbmSourceTs>(fInputFileName.Data());
if (source) LOG(info) << "Reco: Using source " << fInputFileName.Data();
auto source = new CbmSourceTs(fSourceNames);
if (source) LOG(info) << "Reco: Using sources " << ListSources();
else {
LOG(error) << "Reco: Could not open source " << fInputFileName.Data() << "; aborting.";
LOG(error) << "Reco: Could not open sources " << ListSources() << "; aborting.";
return -1;
}
// --- Output file
auto sink = make_unique<FairRootFileSink>(fOutputFileName.Data());
auto sink = new FairRootFileSink(fOutputFileName.Data());
if (sink) LOG(info) << "Reco: Using output file " << fOutputFileName.Data();
else {
LOG(error) << "Reco: Could not open output " << fOutputFileName.Data() << "; aborting.";
......@@ -58,31 +86,31 @@ int32_t CbmReco::Run()
}
// --- Event header
auto header = make_unique<CbmTsEventHeader>();
auto header = new CbmTsEventHeader();
// --- Unpacking
auto unpack = make_unique<CbmTaskUnpack>();
auto unpack = new CbmTaskUnpack();
unpack->SetOutputBranchPersistent("DigiTimeslice.", fConfig.fStoreTimeslice);
// --- Digi trigger
auto trigger = make_unique<CbmTaskTriggerDigi>();
auto trigger = new CbmTaskTriggerDigi();
trigger->AddSystem(fConfig.fTriggerDet);
trigger->SetAlgoParams(fConfig.fTriggerWin, fConfig.fTriggerThreshold, fConfig.fTriggerDeadTime);
trigger->SetOutputBranchPersistent("Trigger", fConfig.fStoreTrigger);
// --- Event building
auto evtBuild = make_unique<CbmTaskBuildEvents>();
auto evtBuild = new CbmTaskBuildEvents();
for (auto& entry : fConfig.fEvtbuildWindows)
evtBuild->SetEventWindow(entry.first, entry.second.first, entry.second.second);
evtBuild->SetOutputBranchPersistent("DigiEvent", fConfig.fStoreEvents);
// --- Run configuration
FairRunOnline run(source.release());
run.SetSink(sink.release());
run.SetEventHeader(header.release());
run.AddTask(unpack.release());
run.AddTask(trigger.release());
run.AddTask(evtBuild.release());
FairRunOnline run(source);
run.SetSink(sink);
run.SetEventHeader(header);
run.AddTask(unpack);
run.AddTask(trigger);
run.AddTask(evtBuild);
// --- Initialise and start run
timer.Stop();
......
......@@ -10,6 +10,7 @@
#include <TString.h>
#include <map>
#include <string>
#include <utility>
......@@ -58,19 +59,34 @@ public:
CbmReco() {};
/** @brief Standard constructor
** @param source Name of input file or input source
/** @brief Standard constructor for a single source
** @param source Name of input file or stream
** @param outFile Name of output file
** @param numTs Number of timeslices to process. If negative, all available will be used.
** @param config Configuration
**/
CbmReco(TString source, TString outFile, int32_t numTs, const CbmRecoConfig& config);
CbmReco(std::string source, TString outFile, int32_t numTs, const CbmRecoConfig& config);
/** @brief Standard constructor for list of sources
** @param source Vector of names of input files or input sources
** @param outFile Name of output file
** @param numTs Number of timeslices to process. If negative, all available will be used.
** @param config Configuration
**/
CbmReco(std::vector<std::string> sources, TString outFile, int32_t numTs, const CbmRecoConfig& config);
/** @brief Destructor **/
virtual ~CbmReco() {};
/** @brief List all entries in the input vector
** @return String concatenating the sources names
**/
std::string ListSources() const;
/** @brief Configure and execute run
** @return Number of processed timeslices. -1 if error encountered.
**/
......@@ -78,10 +94,10 @@ public:
private:
TString fInputFileName = "";
TString fOutputFileName = "";
int32_t fNumTs = -1;
CbmRecoConfig fConfig = {};
std::vector<std::string> fSourceNames = {}; ///< Sources (input files or stream)
TString fOutputFileName = "";
int32_t fNumTs = -1;
CbmRecoConfig fConfig = {};
ClassDef(CbmReco, 1);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment