26#include "TTreeReader.h"
27#include "TTreeReaderValue.h"
56 mLabels = std::make_unique<TTreeReaderValue<dataformats::MCTruthContainer<MCLabel>>>(mTreeReader,
"MIDDigitMCLabels");
63 ic.
options().
get<std::string>(
"mid-digit-infile"));
82 TTreeReader mTreeReader{};
83 TTreeReaderValue<std::vector<ROFRecord>> mRofs = {mTreeReader,
"MIDROFRecords"};
84 TTreeReaderValue<std::vector<ColumnData>> mDigits = {mTreeReader,
"MIDDigit"};
85 std::unique_ptr<TTreeReaderValue<dataformats::MCTruthContainer<MCLabel>>> mLabels{};
87 bool mUseIRFrames =
false;
89 void connectTree(std::string
filename)
93 throw std::invalid_argument(fmt::format(
"Opening file {} failed",
filename));
96 auto tree =
file->Get<TTree>(
"o2sim");
98 throw std::invalid_argument(fmt::format(
"Tree o2sim not found in {}",
filename));
100 mTreeReader.SetTree(
tree);
101 mTreeReader.Restart();
107 if (!mTreeReader.Next()) {
108 throw std::invalid_argument(mTreeReader.fgEntryStatusText[mTreeReader.GetEntryStatus()]);
119 if (mTreeReader.GetCurrentEntry() + 1 >= mTreeReader.GetEntries()) {
127 std::vector<ROFRecord> rofs{};
128 std::vector<ColumnData>
digits{};
132 auto irFrames = pc.
inputs().
get<gsl::span<dataformats::IRFrame>>(
"driverInfo");
134 if (!irFrames.empty()) {
137 const auto irMin = irfSel.getIRFrames().front().getMin();
138 const auto irMax = irfSel.getIRFrames().back().getMax();
141 bool loadNextTF = mTreeReader.GetCurrentEntry() < 0;
145 if (loadNextTF && !mTreeReader.Next()) {
146 throw std::invalid_argument(mTreeReader.fgEntryStatusText[mTreeReader.GetEntryStatus()]);
150 if (!mRofs->empty() && mRofs->front().interactionRecord <= irMax &&
151 mRofs->back().interactionRecord >= irMin) {
152 for (
const auto& rof : *mRofs) {
153 if (irfSel.check(rof.interactionRecord) != -1) {
154 rofs.emplace_back(rof);
155 rofs.back().firstEntry =
digits.size();
156 rofs.back().nEntries = rof.nEntries;
157 digits.insert(
digits.end(), mDigits->begin() + rof.firstEntry, mDigits->begin() + rof.getEndIndex());
159 for (
auto idig = 0; idig < rof.nEntries; ++idig) {
160 labels.addElements(
labels.getIndexedSize(), (*mLabels)->getLabels(rof.firstEntry + idig));
168 if ((mRofs->empty() || mRofs->back().interactionRecord < irMax) &&
169 mTreeReader.GetCurrentEntry() + 1 < mTreeReader.GetEntries()) {
186 if (irFrames.empty() || irFrames.back().isLast()) {
195 std::vector<OutputSpec> outputs;
196 std::stringstream ss;
202 auto matchers =
select(ss.str().c_str());
203 for (
auto& matcher : matchers) {
212 Options{{
"mid-digit-infile", VariantType::String,
"middigits.root", {
"Name of the input file"}},
213 {
"input-dir", VariantType::String,
"none", {
"Input directory"}}}};
std::vector< std::string > labels
Strip pattern (aka digits)
Class to check if give InteractionRecord or IRFrame is selected by the external IRFrame vector.
Class to delimit start and end IR of certain time period.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Data processor specs for MID digits reader device.
bool hasOption(const char *key) const
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.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void init(InitContext &ic)
void run(ProcessingContext &pc)
DigitsReaderDeviceDPL(bool useMC)
void setSelectedIRFrames(const SPAN &sp, size_t bwd=0, size_t fwd=0, long shift=0, bool removeOverlaps=true)
constexpr o2::header::DataOrigin gDataOriginMID
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > select(char const *matcher="")
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getDigitReaderSpec(bool useMC, const char *baseDescription="DATAMC")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static OutputSpec asOutputSpec(InputSpec const &spec)
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
std::vector< Digit > digits