LDMX Software
EcalDigiCollection.cxx
Go to the documentation of this file.
1
7
9
10 namespace ldmx {
12 channelIDs_.clear();
13 samples_.clear();
14
15 return;
16 }
17
18 void EcalDigiCollection::Print() const {
19 std::cout << "EcalDigiCollection { Num Channel IDs: " << channelIDs_.size()
20 << ", Num Samples: " << samples_.size()
21 << ", Samples Per Digi: " << numSamplesPerDigi_
22 << ", Index for SOI: " << sampleOfInterest_ << "}" << std::endl;
23
24 return;
25 }
26
27 std::vector<EcalDigiSample> EcalDigiCollection::getDigi(
28 unsigned int digiIndex) const {
29 std::vector<EcalDigiSample> digi;
30 for (unsigned int sampleIndex = 0;
31 sampleIndex < this->getNumSamplesPerDigi(); sampleIndex++) {
32 EcalDigiSample sample;
33
34 sample.rawID_ = channelIDs_.at(digiIndex);
35
36 int32_t word = samples_.at(digiIndex * numSamplesPerDigi_ + sampleIndex);
37
38 // this is where the word --> measurements translation occurs
39 int firstMeas = TEN_BIT_MASK & (word >> FIRSTMEAS_POS);
40 int seconMeas = TEN_BIT_MASK & (word >> SECONMEAS_POS);
41 int lastMeas = TEN_BIT_MASK & (word);
42
43 // the chip returns flags that determine what the three measurements are
44 // I (Tom E) don't know right now what that mapping is, so I will not use
45 // them.
46
47 sample.adc_t_ = firstMeas;
48 sample.tot_ = seconMeas;
49 sample.toa_ = lastMeas;
50 sample.adc_tm1_ = -99;
51
52 digi.push_back(sample);
53 }
54
55 return digi;
56 }
57
58 void EcalDigiCollection::addDigi(std::vector<EcalDigiSample> newSamples) {
59 if (newSamples.size() != this->getNumSamplesPerDigi()) {
60 std::cerr
61 << "[ WARN ] [ EcalDigiCollection ] Input list of samples has size '"
62 << newSamples.size()
63 << "' that does not match the number of samples per digi '"
64 << this->getNumSamplesPerDigi() << "'!." << std::endl;
65 return;
66 }
67
68 int channelID = newSamples.at(0).rawID_;
69 channelIDs_.push_back(channelID);
70
71 for (auto const &sample : newSamples) {
72 int32_t word;
73
74 // this is where the measurements --> word translation occurs
75
76 // check if over largest number possible ==> set to largest if over
77 // don't want wrapping
78 int adc_t = (sample.adc_t_ > TEN_BIT_MASK) ? TEN_BIT_MASK : sample.adc_t_;
79 int tot = (sample.tot_ > TEN_BIT_MASK) ? TEN_BIT_MASK : sample.tot_;
80 int toa = (sample.toa_ > TEN_BIT_MASK) ? TEN_BIT_MASK : sample.toa_;
81
82 // the chip returns flags that determine what the three measurements are
83 // I (Tom E) don't know right now what that mapping is, so I will not use
84 // them. Just hard-coding ADCt, TOT, and TOA right now
85
86 word = (1 << FIRSTFLAG_POS) + (1 << SECONFLAG_POS) +
87 ((adc_t & TEN_BIT_MASK) << FIRSTMEAS_POS) +
88 ((tot & TEN_BIT_MASK) << SECONMEAS_POS) + (toa & TEN_BIT_MASK);
89
90 samples_.push_back(word);
91 }
92
93 return;
94 }
95} // namespace ldmx
Class that represents a digitized hit in a calorimeter cell within the ECal.
Represents a collection of the ECal digi hits.
std::vector< EcalDigiSample > getDigi(unsigned int digiIndex) const
Get samples for the input digi index.
void addDigi(std::vector< EcalDigiSample > newSamples)
Translate and add samples to collection.
unsigned int sampleOfInterest_
index for the sample of interest in the samples list
std::vector< int > channelIDs_
list of channel IDs that we have digis for
std::vector< int32_t > samples_
list of samples that we have been given
static const int SECONFLAG_POS
Bit position of second flag.
static const int TEN_BIT_MASK
Mask for lowest order ten bits in an int.
static const int FIRSTFLAG_POS
Bit position of first flag.
unsigned int numSamplesPerDigi_
number of samples for each digi
static const int SECONMEAS_POS
Bit position of second measurement.
static const int FIRSTMEAS_POS
Bit position of first measurement.
void Print() const
Print out the object.
void Clear()
Clear the data in the object.
unsigned int getNumSamplesPerDigi() const
Get number of samples per digi.