Skip to content

Commit c71f30c

Browse files
Andreas Mathissawenzel
authored andcommitted
Use HitProcessingManager for TPC Digitization
1 parent f2dbeb8 commit c71f30c

File tree

10 files changed

+339
-248
lines changed

10 files changed

+339
-248
lines changed

Detectors/TPC/simulation/include/TPCSimulation/DigitContainer.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class DigitContainer
5050
/// Reset the container
5151
void reset();
5252

53+
/// Set the first time bin for computing mEffectiveTimeBin
54+
/// \param firstTB First time bin to be processed
55+
void setFirstTimeBin(TimeBin firstTB) { mFirstTimeBin = firstTB; }
56+
5357
/// Add digit to the container
5458
/// \param eventID MC Event ID
5559
/// \param trackID MC Track ID
@@ -78,10 +82,16 @@ class DigitContainer
7882

7983
inline DigitContainer::DigitContainer() : mSector(-1), mFirstTimeBin(0), mEffectiveTimeBin(0), mTimeBins(500) {}
8084

81-
inline void DigitContainer::setup(const Sector& sector) { mSector = sector; }
85+
inline void DigitContainer::setup(const Sector& sector)
86+
{
87+
reset();
88+
mSector = sector;
89+
}
8290

8391
inline void DigitContainer::reset()
8492
{
93+
mFirstTimeBin = 0;
94+
mEffectiveTimeBin = 0;
8595
for (auto& time : mTimeBins) {
8696
time.reset();
8797
}

Detectors/TPC/simulation/include/TPCSimulation/Digitizer.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "TPCSimulation/Point.h"
2121

2222
#include "TPCBase/Mapper.h"
23+
#include "Steer/HitProcessingManager.h"
2324

2425
#include <cmath>
2526

@@ -60,11 +61,23 @@ class Digitizer
6061
void init();
6162

6263
/// Steer conversion of points to digits
63-
/// \param points Container with TPC points
64+
/// \param sector Sector to be processed
65+
/// \param hits Container with TPC hit groups
66+
/// \param eventID ID of the processed event
67+
/// \param eventTime Time of the bunch crossing of the processed event
6468
/// \return digits container
6569
DigitContainer* Process(const Sector& sector, const std::vector<o2::TPC::HitGroup>& hits, int eventID,
6670
float eventTime);
6771

72+
/// Steer conversion of points to digits
73+
/// \param sector Sector to be processed
74+
/// \param hits Container with sorted TPC hit groups
75+
/// \param hitids Container with additional information which hit groups to process
76+
/// \param context Container with event information
77+
/// \return digits container
78+
DigitContainer* Process2(const Sector& sector, const std::vector<std::vector<o2::TPC::HitGroup>*>& hits,
79+
const std::vector<o2::TPC::TPCHitGroupID>& hitids, const o2::steer::RunContext& context);
80+
6881
/// Process a single hit group
6982
/// \param inputgroup Hit group to be processed
7083
/// \param sector Sector to be processed

Detectors/TPC/simulation/include/TPCSimulation/DigitizerTask.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "SimulationDataFormat/MCTruthContainer.h"
2323
#include "TPCBase/Sector.h"
2424
#include "TPCSimulation/Digitizer.h"
25+
#include "Steer/HitProcessingManager.h"
2526

2627
namespace o2
2728
{
@@ -46,6 +47,9 @@ class DigitizerTask : public FairTask
4647
/// Inititializes the digitizer and connects input and output container
4748
InitStatus Init() override;
4849

50+
/// Inititializes the digitizer and connects input and output container
51+
InitStatus Init2();
52+
4953
/// Sets the debug flags for the sub-tasks
5054
/// \param debugsString String containing the debug flags
5155
/// o PRFdebug - Debug output after application of the PRF
@@ -60,12 +64,48 @@ class DigitizerTask : public FairTask
6064
/// \param nTimeBinsMax Maximal number of time bins to be written out
6165
void setMaximalTimeBinWriteOut(int i) { mTimeBinMax = i; }
6266

67+
/// Setter for time-chunk wise processing
68+
/// \param isTimeChunk Process time-chunk wise
69+
void setTimeChunkProcessing(bool isTimeChunk) { mProcessTimeChunks = isTimeChunk; }
70+
71+
/// Setup a sector for processing
72+
/// \param s Sector to be processed
73+
void setupSector(int s);
74+
75+
void setStartTime(double tstart) { mStartTime = tstart; }
76+
void setEndTime(double tend) { mEndTime = tend; }
77+
6378
/// Digitization
6479
/// \param option Option
6580
void Exec(Option_t* option) override;
6681

82+
/// Digitization
83+
/// \param option Option
84+
void Exec2(Option_t* option);
85+
6786
void FinishTask() override;
6887

88+
void FinishTask2();
89+
90+
void setData(const std::vector<std::vector<o2::TPC::HitGroup>*>* lefthits,
91+
const std::vector<std::vector<o2::TPC::HitGroup>*>* righthits,
92+
const std::vector<o2::TPC::TPCHitGroupID>* leftids, const std::vector<o2::TPC::TPCHitGroupID>* rightids,
93+
const o2::steer::RunContext* context)
94+
{
95+
mAllSectorHitsLeft = lefthits;
96+
mAllSectorHitsRight = righthits;
97+
mHitIdsLeft = leftids;
98+
mHitIdsRight = rightids;
99+
mRunContext = context;
100+
}
101+
102+
void setOutputData(std::vector<o2::TPC::Digit>* digitsArray,
103+
o2::dataformats::MCTruthContainer<o2::MCCompLabel>* mcTruthArray)
104+
{
105+
mDigitsArray = digitsArray;
106+
mMCTruthArray = mcTruthArray;
107+
}
108+
69109
/// Temporary stuff for bunch train simulation
70110
///
71111
/// Initialise the event times using a bunch train structure
@@ -84,12 +124,21 @@ class DigitizerTask : public FairTask
84124

85125
int mTimeBinMax; ///< Maximum time bin to be written out
86126
bool mIsContinuousReadout; ///< Switch for continuous readout
127+
bool mProcessTimeChunks; ///< Switch for time-chunk wise processing
87128
bool mDigitDebugOutput; ///< Switch for the debug output of the DigitMC
88129
int mHitSector = -1; ///< which sector to treat
89130

90131
const std::vector<o2::TPC::HitGroup>* mSectorHitsArrayLeft;
91132
const std::vector<o2::TPC::HitGroup>* mSectorHitsArrayRight;
92133

134+
const std::vector<std::vector<o2::TPC::HitGroup>*>* mAllSectorHitsLeft = nullptr;
135+
const std::vector<std::vector<o2::TPC::HitGroup>*>* mAllSectorHitsRight = nullptr;
136+
const std::vector<o2::TPC::TPCHitGroupID>* mHitIdsLeft = nullptr;
137+
const std::vector<o2::TPC::TPCHitGroupID>* mHitIdsRight = nullptr;
138+
const o2::steer::RunContext* mRunContext = nullptr;
139+
double mStartTime; // = tstart [ns]
140+
double mEndTime; // = tend [ns]
141+
93142
// Temporary stuff for bunch train structure simulation
94143
std::vector<float> mEventTimes; ///< Simulated event times in us
95144
int mCurrentEvent = 0; ///< Current event
@@ -112,6 +161,18 @@ inline void DigitizerTask::setContinuousReadout(bool isContinuous)
112161
mIsContinuousReadout = isContinuous;
113162
o2::TPC::Digitizer::setContinuousReadout(isContinuous);
114163
}
164+
165+
inline void DigitizerTask::setupSector(int s)
166+
{
167+
mDigitContainer->setup(s);
168+
if (mDigitsArray)
169+
mDigitsArray->clear();
170+
if (mMCTruthArray)
171+
mMCTruthArray->clear();
172+
if (mDigitsDebugArray)
173+
mDigitsDebugArray->clear();
174+
mHitSector = s;
175+
}
115176
}
116177
}
117178

Detectors/TPC/simulation/include/TPCSimulation/Point.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class ElementalHit {
4545
ClassDefNV(ElementalHit,1);
4646
};
4747

48+
// an index to uniquely identify a single hit of TPC
49+
struct TPCHitGroupID {
50+
TPCHitGroupID() = default;
51+
TPCHitGroupID(int e, int gid) : entry{ e }, groupID{ gid } {}
52+
int entry = -1;
53+
int groupID = -1;
54+
};
55+
4856
// a higher order hit class encapsulating
4957
// a set of elemental hits belonging to the same trackid (and sector)
5058
// construct used to do less MC truth linking and to save memory
@@ -134,13 +142,13 @@ class HitGroup : public o2::BaseHit {
134142
#ifdef HIT_AOS
135143
std::vector<o2::TPC::ElementalHit> mHits; // the hits for this group
136144
#else
137-
std::vector<float> mHitsXVctr;
138-
std::vector<float> mHitsYVctr;
139-
std::vector<float> mHitsZVctr;
140-
std::vector<float> mHitsTVctr;
141-
std::vector<short> mHitsEVctr;
142-
float mZAbsMin = 1E10; // minimal abs z position of all hits in this group
143-
float mZAbsMax = 0.; // maximal z position of all hits in this group
145+
std::vector<float> mHitsXVctr;
146+
std::vector<float> mHitsYVctr;
147+
std::vector<float> mHitsZVctr;
148+
std::vector<float> mHitsTVctr;
149+
std::vector<short> mHitsEVctr;
150+
float mZAbsMin = 1E10; // minimal abs z position of all hits in this group
151+
float mZAbsMax = 0.; // maximal z position of all hits in this group
144152
#endif
145153
ClassDefNV(HitGroup, 1);
146154
};

Detectors/TPC/simulation/macro/runTPCDigitization.C

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)