Project
Loading...
Searching...
No Matches
TrackReaderSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
14#include <vector>
15#include <cassert>
18#include "Framework/Logger.h"
21
22using namespace o2::framework;
23using namespace o2::mft;
24
25namespace o2
26{
27namespace mft
28{
29
31{
32 mUseMC = useMC;
33}
34
36{
38 ic.options().get<std::string>("mft-tracks-infile"));
40}
41
43{
44 auto ent = mTree->GetReadEntry() + 1;
45 assert(ent < mTree->GetEntries()); // this should not happen
46 mTree->GetEntry(ent);
47 LOG(info) << "Pushing " << mTracks.size() << " track in " << mROFRec.size() << " ROFs at entry " << ent;
48 pc.outputs().snapshot(Output{mOrigin, "MFTTrackROF", 0}, mROFRec);
49 pc.outputs().snapshot(Output{mOrigin, "TRACKS", 0}, mTracks);
50 pc.outputs().snapshot(Output{mOrigin, "TRACKCLSID", 0}, mClusInd);
51 if (mUseMC) {
52 pc.outputs().snapshot(Output{mOrigin, "TRACKSMCTR", 0}, mMCTruth);
53 }
54
55 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
57 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
58 }
59}
60
61void TrackReader::connectTree(const std::string& filename)
62{
63 mTree.reset(nullptr); // in case it was already loaded
64 mFile.reset(TFile::Open(filename.c_str()));
65 assert(mFile && !mFile->IsZombie());
66 mTree.reset((TTree*)mFile->Get(mTrackTreeName.c_str()));
67 assert(mTree);
68 assert(mTree->GetBranch(mROFBranchName.c_str()));
69
70 mTree->SetBranchAddress(mROFBranchName.c_str(), &mROFRecInp);
71 mTree->SetBranchAddress(mTrackBranchName.c_str(), &mTracksInp);
72 mTree->SetBranchAddress(mClusIdxBranchName.c_str(), &mClusIndInp);
73
74 if (mUseMC) {
75 if (mTree->GetBranch(mTrackMCTruthBranchName.c_str())) {
76 mTree->SetBranchAddress(mTrackMCTruthBranchName.c_str(), &mMCTruthInp);
77 } else {
78 LOG(warning) << "MC-truth is missing, message will be empty";
79 }
80 }
81 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
82}
83
85{
86 std::vector<OutputSpec> outputSpec;
87 outputSpec.emplace_back("MFT", "MFTTrackROF", 0, Lifetime::Timeframe);
88 outputSpec.emplace_back("MFT", "TRACKS", 0, Lifetime::Timeframe);
89 outputSpec.emplace_back("MFT", "TRACKCLSID", 0, Lifetime::Timeframe);
90 if (useMC) {
91 outputSpec.emplace_back("MFT", "TRACKSMCTR", 0, Lifetime::Timeframe);
92 }
93
94 return DataProcessorSpec{
95 "mft-track-reader",
96 Inputs{},
97 outputSpec,
98 AlgorithmSpec{adaptFromTask<TrackReader>(useMC)},
99 Options{
100 {"mft-tracks-infile", VariantType::String, "mfttracks.root", {"Name of the input track file"}},
101 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
102}
103
104} // namespace mft
105} // namespace o2
Definition of the Names Generator class.
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
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.
Definition Task.h:43
std::vector< int > * mClusIndInp
std::string mTrackMCTruthBranchName
void init(o2::framework::InitContext &ic) final
TrackReader(bool useMC=true)
std::vector< o2::itsmft::ROFRecord > mROFRec
std::vector< o2::mft::TrackMFT > mTracks
void run(o2::framework::ProcessingContext &pc) final
std::unique_ptr< TTree > mTree
std::vector< o2::MCCompLabel > mMCTruth
std::string mTrackBranchName
std::vector< int > mClusInd
std::vector< o2::MCCompLabel > * mMCTruthInp
std::unique_ptr< TFile > mFile
std::string mClusIdxBranchName
std::vector< o2::itsmft::ROFRecord > * mROFRecInp
std::vector< o2::mft::TrackMFT > * mTracksInp
o2::header::DataOrigin mOrigin
void connectTree(const std::string &filename)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getMFTTrackReaderSpec(bool useMC=true)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"