Skip to content

Commit 34e6113

Browse files
maciaccoGiorgioAlbertoLucia
authored andcommitted
add first information to digitizer spec and test reader
1 parent 557b717 commit 34e6113

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include <memory>
3737
#include <string>
3838

39+
using namespace o2::framework;
40+
3941
namespace o2::iotof
4042
{
4143

@@ -49,14 +51,100 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
4951

5052
void initDigitizerTask(framework::InitContext& ic) override
5153
{
54+
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);
5260
}
5361

5462
void run(framework::ProcessingContext& pc)
5563
{
64+
if (mFinished) {
65+
return;
66+
}
67+
mFirstOrbitTF = pc.services().get<o2::framework::TimingInfo>().firstTForbit;
68+
const o2::InteractionRecord firstIR(0, mFirstOrbitTF);
69+
70+
// read collision context from input
71+
auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
72+
context->initSimChains(mID, mSimChains);
73+
const bool withQED = context->isQEDProvided() && !mDisableQED;
74+
auto& timesview = context->getEventRecords();
75+
LOG(info) << "GOT " << timesview.size() << " COLLISION TIMES";
76+
LOG(info) << "SIMCHAINS " << mSimChains.size();
77+
78+
// if there is nothing to do ... return
79+
if (timesview.empty()) {
80+
return;
81+
}
82+
83+
TStopwatch timer;
84+
timer.Start();
85+
LOG(info) << " CALLING TF3 DIGITIZATION ";
86+
87+
auto& eventParts = context->getEventParts(withQED);
88+
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]);
102+
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);
109+
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
113+
}
114+
}
115+
}
116+
117+
}
118+
119+
timer.Stop();
120+
LOG(info) << "Digitization took " << timer.CpuTime() << "s";
121+
LOG(info) << "Produced " << nDigits << " digits";
122+
123+
// we should be only called once; tell DPL that this process is ready to exit
124+
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
125+
126+
mFinished = true;
56127
}
57128

58129
private:
130+
bool mDisableQED = false;
59131
bool mWithMCTruth{true};
132+
bool mFinished{false};
133+
int mLayers{2};
134+
unsigned long mFirstOrbitTF = 0x0;
135+
const o2::detectors::DetID mID{o2::detectors::DetID::TF3};
136+
const o2::header::DataOrigin mOrigin{o2::header::gDataOriginTF3};
137+
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{};
141+
std::vector<o2::itsmft::Hit> mHits{};
142+
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{};
146+
std::vector<TChain*> mSimChains{};
147+
o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::PRESENT; // readout mode
60148
};
61149

62150
std::vector<o2::framework::OutputSpec> makeOutChannels(o2::header::DataOrigin detOrig, bool mctruth)

0 commit comments

Comments
 (0)