Project
Loading...
Searching...
No Matches
DigitReaderSpec.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 <TTree.h>
18#include "Framework/Logger.h"
25
26using namespace o2::framework;
27
28namespace o2
29{
30namespace ft0
31{
32
34{
36 ic.options().get<std::string>("ft0-digit-infile"));
37 mFile.reset(TFile::Open(filename.c_str()));
38 if (!mFile->IsOpen()) {
39 LOG(error) << "Cannot open the " << filename.c_str() << " file !";
40 throw std::runtime_error("cannot open input digits file");
41 }
42 mTree.reset((TTree*)mFile->Get("o2sim"));
43 if (!mTree) {
44 LOG(error) << "Did not find o2sim tree in " << filename.c_str();
45 throw std::runtime_error("Did not fine o2sim file in FT0 digits tree");
46 }
47}
48
50{
51 std::vector<o2::ft0::Digit> digits, *pdigits = &digits;
52 std::vector<o2::ft0::DetTrigInput> trgInput, *ptrTrgInput = &trgInput;
53 std::vector<o2::ft0::ChannelData> channels, *pchannels = &channels;
54 mTree->SetBranchAddress("FT0DIGITSBC", &pdigits);
55 mTree->SetBranchAddress("FT0DIGITSCH", &pchannels);
56 if (mUseTrgInput) {
57 mTree->SetBranchAddress("TRIGGERINPUT", &ptrTrgInput);
58 }
60 if (mUseMC) {
61 mTree->SetBranchAddress("FT0DIGITSMCTR", &plabels);
62 }
63 auto ent = mTree->GetReadEntry() + 1;
64 assert(ent < mTree->GetEntries()); // this should not happen
65 mTree->GetEntry(ent);
66 LOG(debug) << "FT0DigitReader pushed " << channels.size() << " channels in " << digits.size() << " digits";
67 pc.outputs().snapshot(Output{"FT0", "DIGITSBC", 0}, digits);
68 pc.outputs().snapshot(Output{"FT0", "DIGITSCH", 0}, channels);
69 if (mUseMC) {
70 pc.outputs().snapshot(Output{"FT0", "DIGITSMCTR", 0}, labels);
71 }
72 if (mUseTrgInput) {
73 pc.outputs().snapshot(Output{"FT0", "TRIGGERINPUT", 0}, trgInput);
74 }
75 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
77 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
78 }
79}
80
81DataProcessorSpec getDigitReaderSpec(bool useMC, bool useTrgInput)
82{
83 std::vector<OutputSpec> outputs;
84 outputs.emplace_back("FT0", "DIGITSBC", 0, Lifetime::Timeframe);
85 outputs.emplace_back("FT0", "DIGITSCH", 0, Lifetime::Timeframe);
86 if (useMC) {
87 outputs.emplace_back("FT0", "DIGITSMCTR", 0, Lifetime::Timeframe);
88 }
89 if (useTrgInput) {
90 outputs.emplace_back("FT0", "TRIGGERINPUT", 0, Lifetime::Timeframe);
91 }
92 return DataProcessorSpec{
93 "ft0-digit-reader",
94 Inputs{},
95 outputs,
96 AlgorithmSpec{adaptFromTask<DigitReader>(useMC, useTrgInput)},
97 Options{
98 {"ft0-digit-infile", VariantType::String, "ft0digits.root", {"Name of the input file"}},
99 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
100}
101
102} // namespace ft0
103} // namespace o2
Class to describe fired and stored channels for the BC and to refer to channel data.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the Names Generator class.
std::ostringstream debug
A container to hold and manage MC truth information/labels.
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 run(framework::ProcessingContext &pc) final
void init(framework::InitContext &ic) final
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getDigitReaderSpec(bool useMC=false, bool useTrgInput=true)
struct o2::upgrades_utils::@462 ft0
structure to keep V0C information
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"
std::vector< ChannelData > channels
std::vector< Digit > digits