Project
Loading...
Searching...
No Matches
HMPMatchedReaderSpec.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
16#include "TTree.h"
17#include "TFile.h"
18
22#include "Headers/DataHeader.h"
30
31using namespace o2::framework;
32
33namespace o2
34{
35namespace hmpid
36{
38{
39 // get the option from the init context
40 LOG(debug) << "Init HMPID matching info reader!";
41 connectTree(mInFileName);
42}
43
44void HMPMatchedReader::connectTree(const std::string& filename)
45{
46 mTree.reset(nullptr); // in case it was already loaded
47 mFile.reset(TFile::Open(filename.c_str()));
48 assert(mFile && !mFile->IsZombie());
49 mTree.reset((TTree*)mFile->Get(mInTreeName.c_str()));
50 assert(mTree);
51 mTree->SetBranchAddress("HMPMatchInfo", &mMatchesPtr);
52 if (mUseMC) {
53 mTree->SetBranchAddress("MatchHMPMCTruth", &mLabelHMPPtr);
54 }
55 LOG(debug) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
56}
57
59{
60 auto currEntry = mTree->GetReadEntry() + 1;
61 assert(currEntry < mTree->GetEntries()); // this should not happen
62 mTree->GetEntry(currEntry);
63 LOG(debug) << "Pushing " << mMatches.size() << " HMP matchings at entry " << currEntry;
64
65 pc.outputs().snapshot(Output{o2::header::gDataOriginHMP, "MATCHES", 0}, mMatches);
66 if (mUseMC) {
67 pc.outputs().snapshot(Output{o2::header::gDataOriginHMP, "MCLABELS", 0}, mLabelHMP);
68 }
69
70 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
72 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
73 }
74}
75
77{
78 std::vector<OutputSpec> outputs;
79 outputs.emplace_back(o2::header::gDataOriginHMP, "MATCHES", 0, Lifetime::Timeframe);
80 if (useMC) {
81 outputs.emplace_back(o2::header::gDataOriginHMP, "MCLABELS", 0, Lifetime::Timeframe);
82 }
83
84 return DataProcessorSpec{
85 "HMPMatchedReader",
86 Inputs{},
87 outputs,
88 AlgorithmSpec{adaptFromTask<HMPMatchedReader>(useMC)},
89 /*Options{
90 {"hmp-matched-infile", VariantType::String, "o2match_hmp.root", {"Name of the input file"}},
91 {"input-dir", VariantType::String, "none", {"Input directory"}},
92 {"treename", VariantType::String, "matchHMP", {"Name of top-level TTree"}},
93 }*/
94 };
95}
96} // namespace hmpid
97} // namespace o2
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Definition of a container to keep Monte Carlo truth external to simulation objects.
Class to store the output of the matching to HMPID.
Defintions for the inter-detector matching type.
Definition of the Names Generator class.
std::ostringstream debug
void snapshot(const Output &spec, T const &object)
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
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
constexpr o2::header::DataOrigin gDataOriginHMP
Definition DataHeader.h:569
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getHMPMatchedReaderSpec(bool useMC)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"