Project
Loading...
Searching...
No Matches
FDDDigitizerSpec.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 "FDDDigitizerSpec.h"
13#include "TChain.h"
19#include "Framework/Lifetime.h"
20#include "Headers/DataHeader.h"
21#include "Steer/HitProcessingManager.h" // for DigitizationContext
24#include "Framework/Task.h"
27#include "FDDBase/Geometry.h"
34
35using namespace o2::framework;
37
38namespace o2
39{
40namespace fdd
41{
42
44{
46
47 public:
49 {
50 LOG(info) << "initializing FDD digitization";
51
52 //mDigitizer.setCCDBServer(dopt.ccdb);
53 mDigitizer.init();
54 //mROMode = mDigitizer.isContinuous() ? o2::parameters::GRPObject::CONTINUOUS : o2::parameters::GRPObject::PRESENT;
55 mUseDeadChannelMap = !ic.options().get<bool>("disable-dead-channel-map");
56 mUpdateDeadChannelMap = mUseDeadChannelMap;
57 }
58
59 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
60 {
61 // Initialize the dead channel map only once
62 if (matcher == ConcreteDataMatcher("FDD", "DeadChannelMap", 0)) {
63 mUpdateDeadChannelMap = false;
64 }
65 }
66
68 {
69 if (mFinished) {
70 return;
71 }
72 LOG(info) << "Doing FDD digitization";
73
74 // TODO: this should eventually come from the framework and depend on the TF timestamp
75 //mDigitizer.refreshCCDB();
76
77 // read collision context from input
78 auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
79 auto& irecords = context->getEventRecords();
80
81 context->initSimChains(o2::detectors::DetID::FDD, mSimChains);
82 mDigitizer.setEventTime(context->getGRP().getTimeStart());
83 for (auto& record : irecords) {
84 LOG(info) << "FDD TIME RECEIVED " << record.getTimeNS();
85 }
86
87 // Initialize the dead channel map
88 if (mUpdateDeadChannelMap && mUseDeadChannelMap) {
89 auto deadChannelMap = pc.inputs().get<o2::fit::DeadChannelMap*>("fdddeadchannelmap");
90 mDigitizer.setDeadChannelMap(deadChannelMap.get());
91 }
92
93 auto& eventParts = context->getEventParts();
94
95 // loop over all composite collisions given from context
96 // (aka loop over all the interaction records)
97 std::vector<o2::fdd::Hit> hits;
99
100 // the interaction record marking the timeframe start
101 auto firstTF = InteractionTimeRecord(o2::raw::HBFUtils::Instance().getFirstSampledTFIR(), 0);
102
103 for (int collID = 0; collID < irecords.size(); ++collID) {
104 // Note: Very crude filter to neglect collisions coming before
105 // the first interaction record of the timeframe. Remove this, once these collisions can be handled
106 // within the digitization routine. Collisions before this timeframe might impact digits of this timeframe.
107 // See https://its.cern.ch/jira/browse/O2-5395.
108 if (irecords[collID] < firstTF) {
109 LOG(info) << "Too early: Not digitizing collision " << collID;
110 continue;
111 }
112
113 const auto& irec = irecords[collID];
114 mDigitizer.setInteractionRecord(irec);
115
116 for (auto& part : eventParts[collID]) {
117
118 // get the hits for this event and this source
119 context->retrieveHits(mSimChains, "FDDHit", part.sourceID, part.entryID, &hits);
120 LOG(info) << "For collision " << collID << " eventID " << part.entryID << " found FDD " << hits.size() << " hits ";
121
122 mDigitizer.setEventID(part.entryID);
123 mDigitizer.setSrcID(part.sourceID);
124
125 mDigitizer.process(hits, mDigitsBC, mDigitsCh, mDigitsTrig, labels);
126 }
127 }
128
129 o2::InteractionTimeRecord terminateIR;
130 terminateIR.orbit = 0xffffffff; // supply IR in the infinite future to flush all cached BC
131 mDigitizer.setInteractionRecord(terminateIR);
132 mDigitizer.flush(mDigitsBC, mDigitsCh, mDigitsTrig, labels);
133
134 // send out to next stage
135 pc.outputs().snapshot(Output{"FDD", "DIGITSBC", 0}, mDigitsBC);
136 pc.outputs().snapshot(Output{"FDD", "DIGITSCH", 0}, mDigitsCh);
137 pc.outputs().snapshot(Output{"FDD", "TRIGGERINPUT", 0}, mDigitsTrig);
138 if (pc.outputs().isAllowed({"FDD", "DIGITLBL", 0})) {
139 auto& sharedlabels = pc.outputs().make<o2::dataformats::ConstMCTruthContainer<o2::fdd::MCLabel>>(Output{"FDD", "DIGITLBL", 0});
140 labels.flatten_to(sharedlabels);
141 labels.clear_andfreememory();
142 }
143
144 LOG(info) << "FDD: Sending ROMode= " << mROMode << " to GRPUpdater";
145 pc.outputs().snapshot(Output{"FDD", "ROMode", 0}, mROMode);
146
147 // we should be only called once; tell DPL that this process is ready to exit
148 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
149 mFinished = true;
150 }
151
152 private:
153 bool mFinished = false;
154 Digitizer mDigitizer;
155 std::vector<TChain*> mSimChains;
156 std::vector<o2::fdd::ChannelData> mDigitsCh;
157 std::vector<o2::fdd::Digit> mDigitsBC;
158 std::vector<o2::fdd::DetTrigInput> mDigitsTrig;
159
160 // RS: at the moment using hardcoded flag for continuous readout
162
163 bool mUseDeadChannelMap = true;
164 bool mUpdateDeadChannelMap = true;
165};
166
168{
169 // create the full data processor spec using
170 // a name identifier
171 // input description
172 // algorithmic description (here a lambda getting called once to setup the actual processing function)
173 // options that can be used for this processor (here: input file names where to take the hits)
174 std::vector<InputSpec> inputs;
175 inputs.emplace_back("collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
176 inputs.emplace_back("fdddeadchannelmap", "FDD", "DeadChannelMap", 0,
177 Lifetime::Condition,
178 ccdbParamSpec("FDD/Calib/DeadChannelMap", {}, -1));
179 std::vector<OutputSpec> outputs;
180 outputs.emplace_back("FDD", "DIGITSBC", 0, Lifetime::Timeframe);
181 outputs.emplace_back("FDD", "DIGITSCH", 0, Lifetime::Timeframe);
182 outputs.emplace_back("FDD", "TRIGGERINPUT", 0, Lifetime::Timeframe);
183 if (mctruth) {
184 outputs.emplace_back("FDD", "DIGITLBL", 0, Lifetime::Timeframe);
185 }
186 outputs.emplace_back("FDD", "ROMode", 0, Lifetime::Timeframe);
187
188 return DataProcessorSpec{
189 "FDDDigitizer",
190 inputs,
191 outputs,
192 AlgorithmSpec{adaptFromTask<FDDDPLDigitizerTask>()},
193 Options{{"disable-dead-channel-map", VariantType::Bool, false, {"Don't mask dead channels"}}}};
194}
195} // namespace fdd
196} // namespace o2
Definition of the base digitizer task class.
A const (ready only) version of MCTruthContainer.
Dead channel map for FIT.
o2::framework::DataAllocator::SubSpecificationType SubSpecificationType
Base definition of FIT-FDD geometry.
Container class to store values of single FDD channel.
Header of the General Run Parameters object.
A read-only version of MCTruthContainer allowing for storage optimisation.
A container to hold and manage MC truth information/labels.
size_t flatten_to(ContainerType &container) const
static constexpr ID FDD
Definition DetID.h:77
void setEventID(int id)
Definition Digitizer.h:79
void setEventTime(long value)
Definition Digitizer.h:78
void setSrcID(int id)
Definition Digitizer.h:80
void setInteractionRecord(const o2::InteractionTimeRecord &src)
Definition Digitizer.h:81
void setDeadChannelMap(o2::fit::DeadChannelMap const *deadChannelMap)
Definition Digitizer.h:91
void process(const std::vector< o2::fdd::Hit > &hits, std::vector< o2::fdd::Digit > &digitsBC, std::vector< o2::fdd::ChannelData > &digitsCh, std::vector< o2::fdd::DetTrigInput > &digitsTrig, o2::dataformats::MCTruthContainer< o2::fdd::MCLabel > &labels)
Definition Digitizer.cxx:36
void flush(std::vector< o2::fdd::Digit > &digitsBC, std::vector< o2::fdd::ChannelData > &digitsCh, std::vector< o2::fdd::DetTrigInput > &digitsTrig, o2::dataformats::MCTruthContainer< o2::fdd::MCLabel > &labels)
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
void run(framework::ProcessingContext &pc)
void initDigitizerTask(framework::InitContext &ic) override
void snapshot(const Output &spec, T const &object)
o2::header::DataHeader::SubSpecificationType SubSpecificationType
decltype(auto) make(const Output &spec, Args... args)
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.
std::vector< o2::InteractionTimeRecord > & getEventRecords(bool withQED=false)
o2::framework::DataProcessorSpec getFDDDigitizerSpec(int channel, bool mctruth)
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
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t orbit
LHC orbit.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"