15#include <boost/algorithm/string/predicate.hpp>
46 std::unique_ptr<TChain> mChain;
47 std::vector<std::string> mFileNames;
48 std::vector<float> mTOFCNCl, *mTOFCNClPtr = &mTOFCNCl;
49 std::vector<float> mTOFCqTot, *mTOFCqTotPtr = &mTOFCqTot;
51 std::vector<std::pair<unsigned long, int>> mIndices;
56 const auto dontCheckFileAccess = ic.
options().
get<
bool>(
"dont-check-file-access");
57 auto fileList = o2::RangeTokenizer::tokenize<std::string>(ic.
options().
get<std::string>(
"tof-currents-infiles"));
60 if (fileList.size() == 1) {
61 if (boost::algorithm::ends_with(fileList.front(),
"txt")) {
62 LOGP(info,
"Reading files from input file {}", fileList.front());
63 std::ifstream is(fileList.front());
64 std::istream_iterator<std::string>
start(is);
65 std::istream_iterator<std::string>
end;
66 std::vector<std::string> fileNamesTmp(
start,
end);
67 fileList = fileNamesTmp;
72 for (
const auto&
file : fileList) {
73 if ((
file.find(
"alien://") == 0) && !gGrid && !TGrid::Connect(
"alien://")) {
74 LOG(fatal) <<
"Failed to open alien connection";
77 if (!dontCheckFileAccess) {
78 std::unique_ptr<TFile> filePtr(TFile::Open(fileDir.data()));
79 if (!filePtr || !filePtr->IsOpen() || filePtr->IsZombie()) {
80 LOGP(warning,
"Could not open file {}", fileDir);
84 mFileNames.emplace_back(fileDir);
87 if (mFileNames.size() == 0) {
88 LOGP(error,
"No input files to process");
96 if (mChainEntry == 0) {
98 mIndices.reserve(mChain->GetEntries());
100 mChain->SetBranchStatus(
"*", 0);
101 mChain->SetBranchStatus(
"firstTForbit", 1);
102 for (
unsigned long i = 0;
i < mChain->GetEntries();
i++) {
104 mIndices.emplace_back(std::make_pair(mTFinfo.
firstTForbit,
i));
106 mChain->SetBranchStatus(
"*", 1);
107 std::sort(mIndices.begin(), mIndices.end());
110 LOGP(
debug,
"Processing entry {}", mIndices[mChainEntry].second);
111 mChain->GetEntry(mIndices[mChainEntry++].second);
116 timingInfo.tfCounter = mTFinfo.
tfCounter;
117 timingInfo.runNumber = mTFinfo.
runNumber;
118 timingInfo.creation = mTFinfo.
creation;
124 if (mChainEntry >= mChain->GetEntries()) {
130void IntegratedClusterReader::connectTrees()
132 mChain.reset(
new TChain(
"itofc"));
133 for (
const auto&
file : mFileNames) {
134 LOGP(info,
"Adding file to chain: {}",
file);
135 mChain->AddFile(
file.data());
137 assert(mChain->GetEntries());
138 mChain->SetBranchAddress(
"ITOFCN", &mTOFCNClPtr);
139 mChain->SetBranchAddress(
"ITOFCQ", &mTOFCqTotPtr);
140 mChain->SetBranchAddress(
"tfID", &mTFinfoPtr);
145 std::vector<OutputSpec> outputs;
150 "tof-integrated-cluster-reader",
155 {
"tof-currents-infiles", VariantType::String,
"o2currents_tof.root", {
"comma-separated list of input files or .txt file containing list of input files"}},
156 {
"input-dir", VariantType::String,
"none", {
"Input directory"}},
157 {
"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.
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.
virtual void endOfStream(EndOfStreamContext &context)
This is invoked whenever we have an EndOfStream event.
void init(InitContext &ic) final
~IntegratedClusterReader() override=default
void run(ProcessingContext &pc) final
IntegratedClusterReader()=default
constexpr o2::header::DataOrigin gDataOriginTOF
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
o2::framework::DataProcessorSpec getTOFIntegrateClusterReaderSpec()
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"