12#ifndef O2_FIT_FITINTEGRATECLUSTERREADER_SPEC
13#define O2_FIT_FITINTEGRATECLUSTERREADER_SPEC
16#include <boost/algorithm/string/predicate.hpp>
36template <
typename DataT>
49 std::unique_ptr<TChain> mChain;
50 std::vector<std::string> mFileNames;
53 std::vector<std::pair<unsigned long, int>> mIndices;
56template <
typename DataT>
59 const auto dontCheckFileAccess = ic.
options().
get<
bool>(
"dont-check-file-access");
63 if (fileList.size() == 1) {
64 if (boost::algorithm::ends_with(fileList.front(),
"txt")) {
65 LOGP(info,
"Reading files from input file {}", fileList.front());
66 std::ifstream is(fileList.front());
67 std::istream_iterator<std::string>
start(is);
68 std::istream_iterator<std::string>
end;
69 std::vector<std::string> fileNamesTmp(
start,
end);
70 fileList = fileNamesTmp;
75 for (
const auto&
file : fileList) {
76 if ((
file.find(
"alien://") == 0) && !gGrid && !TGrid::Connect(
"alien://")) {
77 LOG(fatal) <<
"Failed to open alien connection";
80 if (!dontCheckFileAccess) {
81 std::unique_ptr<TFile> filePtr(TFile::Open(fileDir.data()));
82 if (!filePtr || !filePtr->IsOpen() || filePtr->IsZombie()) {
83 LOGP(warning,
"Could not open file {}", fileDir);
87 mFileNames.emplace_back(fileDir);
90 if (mFileNames.size() == 0) {
91 LOGP(error,
"No input files to process");
96template <
typename DataT>
100 if (mChainEntry == 0) {
102 mIndices.reserve(mChain->GetEntries());
104 mChain->SetBranchStatus(
"*", 0);
105 mChain->SetBranchStatus(
"firstTForbit", 1);
106 for (
unsigned long i = 0;
i < mChain->GetEntries();
i++) {
108 mIndices.emplace_back(std::make_pair(mTFinfo.firstTForbit,
i));
110 mChain->SetBranchStatus(
"*", 1);
111 std::sort(mIndices.begin(), mIndices.end());
114 LOGP(
debug,
"Processing entry {}", mIndices[mChainEntry].second);
115 mChain->GetEntry(mIndices[mChainEntry++].second);
120 timingInfo.tfCounter = mTFinfo.tfCounter;
121 timingInfo.runNumber = mTFinfo.runNumber;
122 timingInfo.creation = mTFinfo.creation;
128 if (mChainEntry >= mChain->GetEntries()) {
134template <
typename DataT>
138 mChain.reset(
new TChain(treeName.data()));
139 for (
const auto&
file : mFileNames) {
140 LOGP(info,
"Adding file to chain: {}",
file);
141 mChain->AddFile(
file.data());
143 assert(mChain->GetEntries());
144 mChain->SetBranchAddress(
"IFITC", &mFITCPtr);
145 mChain->SetBranchAddress(
"tfID", &mTFinfoPtr);
148template <
typename DataT>
152 std::vector<OutputSpec> outputs;
153 outputs.emplace_back(FitType::getDataOrigin(), FitType::getDataDescriptionFITC(), 0, Lifetime::Sporadic);
156 fmt::format(
"{}-integrated-cluster-reader", FitType::getName()),
159 AlgorithmSpec{adaptFromTask<IntegratedClusterReader<DataT>>()},
161 {fmt::format(
"{}-currents-infiles", FitType::getName()), VariantType::String, fmt::format(
"o2currents_{}.root", FitType::getName()), {
"comma-separated list of input files or .txt file containing list of input files"}},
162 {
"input-dir", VariantType::String,
"none", {
"Input directory"}},
163 {
"dont-check-file-access", VariantType::Bool,
false, {
"Deactivate check if all files are accessible before adding them to the list of files"}},
Definition of the Names Generator class.
Helper function to tokenize sequences and ranges of integral numbers.
~IntegratedClusterReader() override=default
void run(ProcessingContext &pc) final
void init(InitContext &ic) final
IntegratedClusterReader()=default
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
DataProcessorSpec getFITIntegrateClusterReaderSpec()
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
TFitResultPtr fit(const size_t nBins, const T *arr, const T xMin, const T xMax, TF1 &func, std::string_view option="")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"