37 mSkipClusRefs = ic.
options().
get<
bool>(
"skip-clusref");
38 connectTree(mInputFileName);
43 auto ent = mTree->GetReadEntry() + 1;
49 const bool noEntry = ent >= mTree->GetEntries();
51 LOG(info) <<
"no entry to read, publishing empty output";
59 if ((trackTune.sourceLevelTPC && trackTune.applyWhenReading) &&
60 (trackTune.useTPCInnerCorr || trackTune.useTPCOuterCorr ||
62 for (
auto& trc : mTracksOut) {
63 if (trc.getNClusters() == 0) {
66 if (trackTune.useTPCInnerCorr) {
67 trc.updateParams(trackTune.tpcParInner);
72 if (trackTune.useTPCOuterCorr) {
73 trc.getParamOut().updateParams(trackTune.tpcParOuter);
86 if (noEntry || mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
92void TrackReader::accumulate(
int from,
int n)
94 assert(from + n <= mTree->GetEntries());
96 mTree->GetEntry(from);
97 mTracksOut.swap(*mTracksInp);
98 mCluRefVecOut.swap(*mCluRefVecInp);
100 std::copy(mMCTruthInp->begin(), mMCTruthInp->end(), std::back_inserter(mMCTruthOut));
103 for (
int iev = 0; iev <
n; iev++) {
104 mTree->GetEntry(from + iev);
106 uint32_t shift = mCluRefVecOut.size();
108 auto cl0 = mCluRefVecInp->begin();
109 auto cl1 = mCluRefVecInp->end();
110 std::copy(cl0, cl1, std::back_inserter(mCluRefVecOut));
112 auto tr0 = mTracksInp->begin();
113 auto tr1 = mTracksInp->end();
116 for (
auto tr = tr0; tr != tr1; tr++) {
117 tr->shiftFirstClusterRef(shift);
120 std::copy(tr0, tr1, std::back_inserter(mTracksOut));
123 std::copy(mMCTruthInp->begin(), mMCTruthInp->end(), std::back_inserter(mMCTruthOut));
127 LOG(info) <<
"TPCTrackReader pushes " << mTracksOut.size() <<
" tracks from entries " << from <<
" : " << from +
n - 1;
130void TrackReader::connectTree(
const std::string&
filename)
132 mTree.reset(
nullptr);
133 mFile.reset(TFile::Open(
filename.c_str()));
134 if (!(mFile && !mFile->IsZombie())) {
135 throw std::runtime_error(
"Error opening tree file");
137 mTree.reset((TTree*)mFile->Get(mTrackTreeName.c_str()));
139 throw std::runtime_error(
"Error opening tree");
142 mTree->SetBranchAddress(mTrackBranchName.c_str(), &mTracksInp);
143 if (!mSkipClusRefs) {
144 mTree->SetBranchAddress(mClusRefBranchName.c_str(), &mCluRefVecInp);
146 mCluRefVecInp =
new std::vector<o2::tpc::TPCClRefElem>;
149 if (mTree->GetBranch(mTrackMCTruthBranchName.c_str())) {
150 mTree->SetBranchAddress(mTrackMCTruthBranchName.c_str(), &mMCTruthInp);
151 LOG(info) <<
"Will use MC-truth from " << mTrackMCTruthBranchName;
153 LOG(info) <<
"MC-truth is missing";
157 LOG(info) <<
"Loaded tree from " <<
filename <<
" with " << mTree->GetEntries() <<
" entries";
162 std::vector<OutputSpec> outputSpec;
163 outputSpec.emplace_back(
"TPC",
"TRACKS", 0, Lifetime::Timeframe);
164 outputSpec.emplace_back(
"TPC",
"CLUSREFS", 0, Lifetime::Timeframe);
166 outputSpec.emplace_back(
"TPC",
"TRACKSMCLBL", 0, Lifetime::Timeframe);
175 {
"infile", VariantType::String,
"tpctracks.root", {
"Name of the input track file"}},
176 {
"input-dir", VariantType::String,
"none", {
"Input directory"}},
177 {
"skip-clusref", VariantType::Bool,
false, {
"Skip reading cluster references"}}}};
Definition of the Names Generator class.
Configurable params for tracks ad hoc tuning.
static const TrackTuneParams & Instance()
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.
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
TrackReader(bool useMC=true)
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getTPCTrackReaderSpec(bool useMC=true)
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"