Project
Loading...
Searching...
No Matches
FT0DigitizerSpec.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
12#include "FT0DigitizerSpec.h"
17#include "Framework/Lifetime.h"
18#include "Headers/DataHeader.h"
19#include "Steer/HitProcessingManager.h" // for DigitizationContext
28#include "Framework/Task.h"
37#include <TChain.h>
38#include <TStopwatch.h>
39
40using namespace o2::framework;
42
43namespace o2
44{
45namespace ft0
46{
47
49{
50
52
53 public:
54 FT0DPLDigitizerTask(bool useCCDB) : o2::base::BaseDPLDigitizer(), mDigitizer(), mUseCCDB{useCCDB} {}
55 ~FT0DPLDigitizerTask() override = default;
56
65
66 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
67 {
68 if (matcher == ConcreteDataMatcher("FT0", "TimeOffset", 0)) {
69 mUpdateCCDB = false;
70 }
71
72 // Initialize the dead channel map only once
73 if (matcher == ConcreteDataMatcher("FT0", "DeadChannelMap", 0)) {
75 }
76 }
77
79 {
80
81 if (mFinished) {
82 return;
83 }
84
85 // read collision context from input
86 auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
88 const bool withQED = context->isQEDProvided() && !mDisableQED;
89 auto& timesview = context->getEventRecords(withQED);
90 // set CCDB for miscalibration
91 if (mUseCCDB) {
92 auto caliboffsets = pc.inputs().get<o2::ft0::FT0ChannelTimeCalibrationObject*>("ft0offsets");
93 mDigitizer.SetChannelOffset(caliboffsets.get());
94 }
95
96 // Initialize the dead channel map
98 auto deadChannelMap = pc.inputs().get<o2::fit::DeadChannelMap*>("ft0deadchannelmap");
99 mDigitizer.setDeadChannelMap(deadChannelMap.get());
100 }
101
102 // if there is nothing to do ... return
103 if (timesview.size() == 0) {
104 return;
105 }
106
107 TStopwatch timer;
108 timer.Start();
109
110 LOG(info) << "CALLING FT0 DIGITIZATION";
111
112 static std::vector<o2::ft0::HitType> hits;
113 // o2::dataformats::MCTruthContainer<o2::ft0::MCLabel> labelAccum;
115
116 // the interaction record marking the timeframe start
117 auto firstTF = InteractionTimeRecord(o2::raw::HBFUtils::Instance().getFirstSampledTFIR(), 0);
118
119 // mDigitizer.setMCLabels(&labels);
120 auto& eventParts = context->getEventParts(withQED);
121 // loop over all composite collisions given from context
122 // (aka loop over all the interaction records)
123 for (int collID = 0; collID < timesview.size(); ++collID) {
124 // Note: Very crude filter to neglect collisions coming before
125 // the first interaction record of the timeframe. Remove this, once these collisions can be handled
126 // within the digitization routine. Collisions before this timeframe might impact digits of this timeframe.
127 // See https://its.cern.ch/jira/browse/O2-5395.
128 if (timesview[collID] < firstTF) {
129 LOG(info) << "Too early: Not digitizing collision " << collID;
130 continue;
131 }
132
133 mDigitizer.setInteractionRecord(timesview[collID]);
134 LOG(debug) << " setInteractionRecord " << timesview[collID] << " bc " << mDigitizer.getBC() << " orbit " << mDigitizer.getOrbit();
135 // for each collision, loop over the constituents event and source IDs
136 // (background signal merging is basically taking place here)
137 for (auto& part : eventParts[collID]) {
138 // get the hits for this event and this source
139 hits.clear();
140 context->retrieveHits(mSimChains, "FT0Hit", part.sourceID, part.entryID, &hits);
141 LOG(debug) << "For collision " << collID << " eventID " << part.entryID << " source ID " << part.sourceID << " found " << hits.size() << " hits ";
142 if (hits.size() > 0) {
143 // call actual digitization procedure
144 mDigitizer.setEventID(part.entryID);
145 mDigitizer.setSrcID(part.sourceID);
147 }
148 }
149 }
151
152 // send out to next stage
153 pc.outputs().snapshot(Output{"FT0", "DIGITSBC", 0}, mDigitsBC);
154 pc.outputs().snapshot(Output{"FT0", "DIGITSCH", 0}, mDigitsCh);
155 pc.outputs().snapshot(Output{"FT0", "TRIGGERINPUT", 0}, mDigitsTrig);
156 if (pc.outputs().isAllowed({"FT0", "DIGITSMCTR", 0})) {
157 pc.outputs().snapshot(Output{"FT0", "DIGITSMCTR", 0}, labels);
158 }
159 LOG(info) << "FT0: Sending ROMode= " << mROMode << " to GRPUpdater";
160 pc.outputs().snapshot(Output{"FT0", "ROMode", 0}, mROMode);
161
162 timer.Stop();
163 LOG(info) << "Digitization took " << timer.CpuTime() << "s";
164
165 // we should be only called once; tell DPL that this process is ready to exit
166 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
167 mFinished = true;
168 }
169
170 protected:
171 bool mFinished = false;
172 std::vector<o2::ft0::ChannelData> mDigitsCh;
173 std::vector<o2::ft0::Digit> mDigitsBC;
174 std::vector<o2::ft0::DetTrigInput> mDigitsTrig;
175
176 Bool_t mContinuous = kFALSE;
177 double mFairTimeUnitInNS = 1;
179
180 // RS: at the moment using hardcoded flag for continuos readout
182
183 //
184 bool mDisableQED = false;
185 bool mUseCCDB = true;
186 bool mUpdateCCDB = true;
189 std::vector<TChain*> mSimChains;
190};
191
192o2::framework::DataProcessorSpec getFT0DigitizerSpec(int channel, bool mctruth, bool useCCDB)
193{
194 // create the full data processor spec using
195 // a name identifier
196 // input description
197 // algorithmic description (here a lambda getting called once to setup the actual processing function)
198 // options that can be used for this processor (here: input file names where to take the hits)
199 std::vector<OutputSpec> outputs;
200 outputs.emplace_back("FT0", "DIGITSBC", 0, Lifetime::Timeframe);
201 outputs.emplace_back("FT0", "DIGITSCH", 0, Lifetime::Timeframe);
202 outputs.emplace_back("FT0", "TRIGGERINPUT", 0, Lifetime::Timeframe);
203 if (mctruth) {
204 outputs.emplace_back("FT0", "DIGITSMCTR", 0, Lifetime::Timeframe);
205 }
206 outputs.emplace_back("FT0", "ROMode", 0, Lifetime::Timeframe);
207 std::vector<InputSpec> inputs;
208 inputs.emplace_back("collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
209 if (useCCDB) {
210 inputs.emplace_back("ft0offsets", "FT0", "TimeOffset", 0,
211 Lifetime::Condition,
212 ccdbParamSpec("FT0/Calib/ChannelTimeOffset"));
213 }
214 inputs.emplace_back("ft0deadchannelmap", "FT0", "DeadChannelMap", 0,
215 Lifetime::Condition,
216 ccdbParamSpec("FT0/Calib/DeadChannelMap", {}, -1));
217
218 return DataProcessorSpec{
219 "FT0Digitizer",
220 inputs,
221 outputs,
222 AlgorithmSpec{adaptFromTask<FT0DPLDigitizerTask>(useCCDB)},
223 Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}},
224 {"disable-qed", VariantType::Bool, false, {"disable QED handling"}},
225 {"disable-dead-channel-map", VariantType::Bool, false, {"Don't mask dead channels"}}}};
226}
227
228} // namespace ft0
229} // end namespace o2
Definition of the base digitizer task class.
Dead channel map for FIT.
o2::framework::DataAllocator::SubSpecificationType SubSpecificationType
Class to describe fired and stored channels for the BC and to refer to channel data.
Header of the General Run Parameters object.
Definition of the FIT hits class.
Definition of a container to keep Monte Carlo truth external to simulation objects.
std::ostringstream debug
A container to hold and manage MC truth information/labels.
static constexpr ID FT0
Definition DetID.h:75
void snapshot(const Output &spec, T const &object)
o2::header::DataHeader::SubSpecificationType SubSpecificationType
bool isAllowed(Output const &query)
check if a certain output is allowed
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
uint32_t getOrbit() const
Definition Digitizer.h:68
void setDeadChannelMap(o2::fit::DeadChannelMap const *deadChannelMap)
Definition Digitizer.h:77
bool isContinuous() const
Definition Digitizer.h:87
void setInteractionRecord(const o2::InteractionTimeRecord &src)
Definition Digitizer.h:67
void process(const std::vector< o2::ft0::HitType > *hits, std::vector< o2::ft0::Digit > &digitsBC, std::vector< o2::ft0::ChannelData > &digitsCh, std::vector< o2::ft0::DetTrigInput > &digitsTrig, o2::dataformats::MCTruthContainer< o2::ft0::MCLabel > &label)
uint16_t getBC() const
Definition Digitizer.h:69
void setSrcID(Int_t id)
Definition Digitizer.h:64
void flush_all(std::vector< o2::ft0::Digit > &digitsBC, std::vector< o2::ft0::ChannelData > &digitsCh, std::vector< o2::ft0::DetTrigInput > &digitsTrig, o2::dataformats::MCTruthContainer< o2::ft0::MCLabel > &label)
void SetChannelOffset(o2::ft0::FT0ChannelTimeCalibrationObject const *caliboffsets)
Definition Digitizer.h:75
void setEventID(Int_t id)
Definition Digitizer.h:63
o2::ft0::Digitizer mDigitizer
Digitizer.
o2::parameters::GRPObject::ROMode mROMode
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
~FT0DPLDigitizerTask() override=default
void initDigitizerTask(framework::InitContext &ic) override
double mFairTimeUnitInNS
Fair time unit in ns.
std::vector< o2::ft0::ChannelData > mDigitsCh
Bool_t mContinuous
flag to do continuous simulation
std::vector< o2::ft0::Digit > mDigitsBC
std::vector< TChain * > mSimChains
std::vector< o2::ft0::DetTrigInput > mDigitsTrig
void run(framework::ProcessingContext &pc)
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
header::DataHeader::SubSpecificationType SubSpecificationType
o2::framework::DataProcessorSpec getFT0DigitizerSpec(int channel, bool mctruth, bool useCCDB)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"