Skip to content

Commit e85b558

Browse files
maciaccoGiorgioAlbertoLucia
authored andcommitted
add first element in workflow enabling digit processing
1 parent 34e6113 commit e85b558

1 file changed

Lines changed: 59 additions & 42 deletions

File tree

Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "DataFormatsITSMFT/ROFRecord.h"
2929
#include "IOTOFSimulation/Digitizer.h"
3030
#include "Headers/DataHeader.h"
31+
#include "IOTOFBase/GeometryTGeo.h"
3132

3233
#include <TChain.h>
3334
#include <TStopwatch.h>
@@ -52,11 +53,11 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
5253
void initDigitizerTask(framework::InitContext& ic) override
5354
{
5455
mDisableQED = ic.options().get<bool>("disable-qed");
55-
mDigits.resize(mLayers);
56-
mROFRecords.resize(mLayers);
57-
mROFRecordsAccum.resize(mLayers);
58-
mLabels.resize(mLayers);
59-
mLabelsAccum.resize(mLayers);
56+
auto geom = GeometryTGeo::Instance();
57+
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G)); // make sure L2G matrices are loaded
58+
mDigitizer.setGeometry(geom);
59+
mDigitizer.setChargeThreshold(-1000.f);
60+
mDigitizer.init();
6061
}
6162

6263
void run(framework::ProcessingContext& pc)
@@ -84,38 +85,60 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
8485
timer.Start();
8586
LOG(info) << " CALLING TF3 DIGITIZATION ";
8687

87-
auto& eventParts = context->getEventParts(withQED);
8888
uint64_t nDigits{0};
89-
for (uint32_t iLayer = 0; iLayer < static_cast<uint32_t>(mLayers); ++iLayer) {
90-
mDigits[iLayer].clear();
91-
// mROFRecords[iLayer].clear();
92-
// mROFRecordsAccum[iLayer].clear();
93-
if (mWithMCTruth) {
94-
// mLabels[iLayer].clear();
95-
// mLabelsAccum[iLayer].clear();
96-
// mMC2ROFRecordsAccum[iLayer].clear();
97-
}
98-
99-
mDigitizer.setDigits(&mDigits[iLayer]);
100-
// mDigitizer.setROFRecords(&mROFRecords[iLayer]);
101-
// mDigitizer.setMCLabels(&mLabels[iLayer]);
10289

103-
for (int collID = 0; collID < timesview.size(); ++collID) {
104-
for (const auto& part : eventParts[collID]) {
105-
106-
// get the hits for this event and this source
107-
mHits.clear();
108-
context->retrieveHits(mSimChains, o2::detectors::SimTraits::DETECTORBRANCHNAMES[mID][0].c_str(), part.sourceID, part.entryID, &mHits);
90+
mDigitizer.setDigits(&mDigits);
91+
mDigitizer.setROFRecords(&mROFRecords);
92+
if (mWithMCTruth) {
93+
mDigitizer.setMCLabels(&mLabels);
94+
}
10995

110-
if (mHits.size() > 0) {
111-
LOG(debug) << "For collision " << collID << " eventID " << part.entryID << " found " << mHits.size() << " hits ";
112-
// mDigitizer.process(&mHits, part.entryID, part.sourceID, layer); // call actual digitization procedure
96+
auto& eventParts = context->getEventParts(withQED);
97+
// loop over all composite collisions given from context
98+
// (aka loop over all the interaction records)
99+
// o2::InteractionTimeRecord firstorbit(o2::InteractionRecord(0, o2::raw::HBFUtils::Instance().orbitFirstSampled), 0.0);
100+
for (int collID = 0; collID < timesview.size(); ++collID) {
101+
o2::InteractionTimeRecord orbit(timesview[collID]);
102+
// orbit += firstorbit
103+
mDigitizer.setEventTime(orbit);
104+
105+
// for each collision, loop over the constituents event and source IDs
106+
// (background signal merging is basically taking place here)
107+
for (const auto& part : eventParts[collID]) {
108+
109+
// get the hits for this event and this source
110+
mHits.clear();
111+
context->retrieveHits(mSimChains, o2::detectors::SimTraits::DETECTORBRANCHNAMES[mID][0].c_str(), part.sourceID, part.entryID, &mHits);
112+
113+
if (mHits.size() > 0) {
114+
mDigits.clear();
115+
if (mWithMCTruth) {
116+
mLabels.clear();
113117
}
118+
119+
LOG(debug) << "For collision " << collID << " eventID " << part.entryID << " found " << mHits.size() << " hits ";
120+
mDigitizer.process(&mHits, part.entryID, part.sourceID); // call actual digitization procedure
114121
}
115122
}
123+
}
124+
if (mDigitizer.isContinuous()) {
125+
mDigits.clear();
126+
if (mWithMCTruth) {
127+
mLabels.clear();
128+
}
129+
mDigitizer.fillOutputContainer();
130+
}
116131

132+
// here we have all digits and we can send them to consumer (aka snapshot it onto output)
133+
pc.outputs().snapshot(Output{mOrigin, "DIGITS", 0}, mDigits);
134+
pc.outputs().snapshot(Output{mOrigin, "DIGITSROF"}, mROFRecords);
135+
if (mWithMCTruth) {
136+
//
117137
}
118138

139+
LOG(info) << mID.getName() << ": Sending ROMode= " << mROMode << " to GRPUpdater";
140+
pc.outputs().snapshot(Output{mOrigin, "ROMode", 0}, mROMode);
141+
119142
timer.Stop();
120143
LOG(info) << "Digitization took " << timer.CpuTime() << "s";
121144
LOG(info) << "Produced " << nDigits << " digits";
@@ -130,33 +153,27 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
130153
bool mDisableQED = false;
131154
bool mWithMCTruth{true};
132155
bool mFinished{false};
133-
int mLayers{2};
134156
unsigned long mFirstOrbitTF = 0x0;
135157
const o2::detectors::DetID mID{o2::detectors::DetID::TF3};
136158
const o2::header::DataOrigin mOrigin{o2::header::gDataOriginTF3};
137159
o2::iotof::Digitizer mDigitizer{};
138-
std::vector<std::vector<o2::iotof::Digit>> mDigits{};
139-
std::vector<std::vector<o2::itsmft::ROFRecord>> mROFRecords{};
140-
std::vector<std::vector<o2::itsmft::ROFRecord>> mROFRecordsAccum{};
160+
std::vector<o2::iotof::Digit> mDigits{};
161+
std::vector<o2::itsmft::ROFRecord> mROFRecords{};
141162
std::vector<o2::itsmft::Hit> mHits{};
142163
std::vector<o2::itsmft::Hit>* mHitsP{&mHits};
143-
std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mLabels{};
144-
std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mLabelsAccum{};
145-
std::vector<std::vector<o2::itsmft::MC2ROFRecord>> mMC2ROFRecordsAccum{};
164+
o2::dataformats::MCTruthContainer<o2::MCCompLabel> mLabels{};
146165
std::vector<TChain*> mSimChains{};
147166
o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::PRESENT; // readout mode
148167
};
149168

150169
std::vector<o2::framework::OutputSpec> makeOutChannels(o2::header::DataOrigin detOrig, bool mctruth)
151170
{
152171
std::vector<o2::framework::OutputSpec> outputs;
153-
for (uint32_t iLayer = 0; iLayer < 3; ++iLayer) {
154-
outputs.emplace_back(detOrig, "DIGITS", iLayer, o2::framework::Lifetime::Timeframe);
155-
outputs.emplace_back(detOrig, "DIGITSROF", iLayer, o2::framework::Lifetime::Timeframe);
156-
if (mctruth) {
157-
outputs.emplace_back(detOrig, "DIGITSMC2ROF", iLayer, o2::framework::Lifetime::Timeframe);
158-
outputs.emplace_back(detOrig, "DIGITSMCTR", iLayer, o2::framework::Lifetime::Timeframe);
159-
}
172+
outputs.emplace_back(detOrig, "DIGITS", o2::framework::Lifetime::Timeframe);
173+
outputs.emplace_back(detOrig, "DIGITSROF", o2::framework::Lifetime::Timeframe);
174+
if (mctruth) {
175+
outputs.emplace_back(detOrig, "DIGITSMC2ROF", o2::framework::Lifetime::Timeframe);
176+
outputs.emplace_back(detOrig, "DIGITSMCTR", o2::framework::Lifetime::Timeframe);
160177
}
161178
outputs.emplace_back(detOrig, "ROMode", 0, o2::framework::Lifetime::Timeframe);
162179
return outputs;

0 commit comments

Comments
 (0)