Project
Loading...
Searching...
No Matches
Digitizer.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
16
17namespace o2::mch
18{
19
21 : mRandom{DigitizerParam::Instance().seed == 0 ? std::random_device{}() : DigitizerParam::Instance().seed}
22{
24 mDEDigitizers[deId] = std::make_unique<DEDigitizer>(deId, transformationCreator(deId), mRandom);
25 });
26}
27
28void Digitizer::setFirstTFOrbit(uint32_t firstTFOrbit)
29{
30 for (auto& d : mDEDigitizers) {
31 d.second->setFirstTFOrbit(firstTFOrbit);
32 }
33}
34
35void Digitizer::processHits(gsl::span<const Hit> hits, const InteractionRecord& collisionTime, int evID, int srcID)
36{
37 for (const auto& hit : hits) {
38 mDEDigitizers[hit.detElemId()]->processHit(hit, collisionTime, evID, srcID);
39 }
40}
41
42void Digitizer::addNoise(const InteractionRecord& firstIR, const InteractionRecord& lastIR)
43{
44 for (auto& d : mDEDigitizers) {
45 d.second->addNoise(firstIR, lastIR);
46 }
47}
48
49size_t Digitizer::digitize(std::vector<ROFRecord>& rofs,
50 std::vector<Digit>& digits,
52{
53 // digitize every DE and store digits and labels ordered per IR
54 size_t nPileup = 0;
55 std::map<InteractionRecord, DEDigitizer::DigitsAndLabels> irDigitsAndLabels{};
56 for (auto& d : mDEDigitizers) {
57 nPileup += d.second->digitize(irDigitsAndLabels);
58 }
59
60 // fill the external containers, skipping digits produced before the beginning of the TF
62 for (const auto& [ir, digitsAndLabels] : irDigitsAndLabels) {
63 if (ir.orbit >= firstTFOrbit) {
64 rofs.emplace_back(ROFRecord(ir, digits.size(), digitsAndLabels.first.size()));
65 digits.insert(digits.end(), digitsAndLabels.first.begin(), digitsAndLabels.first.end());
66 labels.mergeAtBack(digitsAndLabels.second);
67 }
68 }
69
70 return nPileup;
71}
72
74{
75 for (auto& d : mDEDigitizers) {
76 d.second->clear();
77 }
78}
79
80} // namespace o2::mch
void mergeAtBack(MCTruthContainer< TruthElement > const &other)
Digitizer(geo::TransformationCreator transformationCreator)
Definition Digitizer.cxx:20
void addNoise(const InteractionRecord &firstIR, const InteractionRecord &lastIR)
Definition Digitizer.cxx:42
void setFirstTFOrbit(uint32_t firstTFOrbit)
Definition Digitizer.cxx:28
void processHits(gsl::span< const Hit > hits, const InteractionRecord &collisionTime, int evID, int srcID)
Definition Digitizer.cxx:35
size_t digitize(std::vector< ROFRecord > &rofs, std::vector< Digit > &digits, dataformats::MCLabelContainer &labels)
Definition Digitizer.cxx:49
std::function< o2::math_utils::Transform3D(int detElemId)> TransformationCreator
void forEachDetectionElement(CALLABLE &&func)
Defining DataPointCompositeObject explicitly as copiable.
uint32_t orbit
LHC orbit.
IR getFirstSampledTFIR() const
get TF and HB (abs) for this IR
Definition HBFUtils.h:74
o2::InteractionRecord ir(0, 0)
std::vector< Digit > digits