LDMX Software
Functions
EcalDigiCollection.cxx File Reference
#include "Ecal/Event/EcalDigiCollection.h"

Go to the source code of this file.

Functions

 ClassImp (ldmx::EcalDigiCollection) namespace ldmx
 

Detailed Description

Author
Tom Eichlersmith, University of Minnesota

Definition in file EcalDigiCollection.cxx.

Function Documentation

◆ ClassImp()

ClassImp ( ldmx::EcalDigiCollection  )

Definition at line 8 of file EcalDigiCollection.cxx.

10 {
11 void EcalDigiCollection::Clear() {
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