Project
Loading...
Searching...
No Matches
CalibClusReaderSpec.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
19#include "Framework/Logger.h"
20
21using namespace o2::framework;
22using namespace o2::tof;
23
24namespace o2
25{
26namespace tof
27{
28
30{
31 LOG(debug) << "Init Cluster reader!";
32 auto filename = ic.options().get<std::string>("tof-calclus-infile");
33 connectTree(filename);
34}
35
37{
38 auto ent = mTree->GetReadEntry() + 1;
39 assert(ent < mTree->GetEntries()); // this should not happen
40 mTree->GetEntry(ent);
41 LOG(debug) << "Pushing " << mPclusInfos->size() << " TOF clusters calib info at entry " << ent;
42 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "INFOCALCLUS", 0}, mClusInfos);
43
44 if (mIsCosmics) {
45 LOG(debug) << "Pushing " << mPcosmicInfo->size() << " TOF cosmics info at entry " << ent;
46 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "INFOCOSMICS", 0}, mCosmicInfo);
47 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "INFOTRACKCOS", 0}, mCosmicTrack);
48 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "INFOTRACKSIZE", 0}, mCosmicTrackSize);
49 }
50
51 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
53 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
54 }
55}
56
57void CalibClusReader::connectTree(const std::string& filename)
58{
59 mTree.reset(nullptr); // in case it was already loaded
60 mFile.reset(TFile::Open(filename.c_str()));
61 assert(mFile && !mFile->IsZombie());
62 mTree.reset((TTree*)mFile->Get("o2sim"));
63 assert(mTree);
64 mTree->SetBranchAddress("TOFClusterCalInfo", &mPclusInfos);
65 if (mIsCosmics) {
66 mTree->SetBranchAddress("TOFCosmics", &mPcosmicInfo);
67 mTree->SetBranchAddress("TOFTracks", &mPcosmicTrack);
68 mTree->SetBranchAddress("TOFTracksSize", &mPcosmicTrackSize);
69 }
70 LOG(debug) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
71}
72
74{
75 std::vector<OutputSpec> outputs;
76 outputs.emplace_back(o2::header::gDataOriginTOF, "INFOCALCLUS", 0, Lifetime::Timeframe);
77 if (isCosmics) {
78 outputs.emplace_back(o2::header::gDataOriginTOF, "INFOCOSMICS", 0, Lifetime::Timeframe);
79 outputs.emplace_back(o2::header::gDataOriginTOF, "INFOTRACKCOS", 0, Lifetime::Timeframe);
80 outputs.emplace_back(o2::header::gDataOriginTOF, "INFOTRACKSIZE", 0, Lifetime::Timeframe);
81 }
82
83 return DataProcessorSpec{
84 "tof-calclus-reader",
85 Inputs{},
86 outputs,
87 AlgorithmSpec{adaptFromTask<CalibClusReader>(isCosmics)},
88 Options{
89 {"tof-calclus-infile", VariantType::String, "tofclusCalInfo.root", {"Name of the input file"}}}};
90}
91
92} // namespace tof
93} // namespace o2
std::ostringstream debug
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
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
constexpr o2::header::DataOrigin gDataOriginTOF
Definition DataHeader.h:575
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
DataProcessorSpec getCalibClusReaderSpec(bool isCosmics)
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"