Project
Loading...
Searching...
No Matches
TRUElectronics.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
14#include <cstring>
15#include <gsl/span>
16#include <fairlogger/Logger.h> // for LOG
19
20using namespace o2::emcal;
21
22//____________________________________________________________________________
23TRUElectronics::TRUElectronics() : mPatchSize(2), mWhichSide(0), mWhichSuperModuleSize(0)
24{
25 // DEFAULT CONSTRUCTOR
26 mFastOrs.resize(96);
27}
28//____________________________________________________________________________
29TRUElectronics::TRUElectronics(int patchSize, int whichSide, int whichSuperModuleSize) : mPatchSize(patchSize), mWhichSide(whichSide), mWhichSuperModuleSize(whichSuperModuleSize)
30{
31 // CONSTRUCTOR
32 mFastOrs.resize(96);
33}
34//____________________________________________________________________________
36{
37 mIndexMapPatch.resize(77);
38 for (auto IndexMapPatch : mIndexMapPatch) {
39 (std::get<1>(IndexMapPatch)).resize(mPatchSize * mPatchSize);
40 }
42 for (auto FiredFastOrIndexMapPatch : mFiredFastOrIndexMapPatch) {
43 (std::get<1>(FiredFastOrIndexMapPatch)).resize(mPatchSize * mPatchSize);
44 }
45 mADCvalues.resize(77);
46 mTimesum.resize(77);
47 mPatchIDSeedFastOrIDs.resize(77);
48 mPreviousTimebinADCvalue.resize(77);
49 mFastOrs.resize(96);
50 for (auto FastOr : mFastOrs) {
51 FastOr.init();
52 }
55}
56//____________________________________________________________________________
58{
59 mIndexMapPatch.clear();
61 mADCvalues.clear();
62 mTimesum.clear();
65}
66//____________________________________________________________________________
68{
69 if (mWhichSide == 0) {
70 // A side
71 int rowSeed = patchID / 7;
72 int columnSeed = patchID % 7;
73 int SeedID = rowSeed + patchID;
74 std::get<1>(mPatchIDSeedFastOrIDs[patchID]) = SeedID;
75 } else if (mWhichSide == 1) {
76 // C side
77 int rowSeed = patchID / 7;
78 int columnSeed = patchID % 7;
79 int SeedID = 95 - (rowSeed + patchID);
80 std::get<1>(mPatchIDSeedFastOrIDs[patchID]) = SeedID;
81 }
82}
83//____________________________________________________________________________
85{
86 if (mWhichSide == 0) {
87 // A side
88 int rowSeed = patchID / 23;
89 int columnSeed = patchID % 23;
90 int SeedID = rowSeed + patchID;
91 std::get<1>(mPatchIDSeedFastOrIDs[patchID]) = SeedID;
92 } else if (mWhichSide == 1) {
93 // C side
94 int rowSeed = patchID / 23;
95 int columnSeed = patchID % 23;
96 int SeedID = 95 - (rowSeed + patchID);
97 std::get<1>(mPatchIDSeedFastOrIDs[patchID]) = SeedID;
98 }
99}
100//____________________________________________________________________________
102{
103 if (mWhichSuperModuleSize == 0) {
104 // Full Size
105 for (int i = 0; i < 77; i++) {
106 std::get<0>(mPatchIDSeedFastOrIDs[i]) = i;
108 }
109 } else if (mWhichSuperModuleSize == 1) {
110 // One third Size
111 for (int i = 0; i < 69; i++) {
112 std::get<0>(mPatchIDSeedFastOrIDs[i]) = i;
114 }
115 }
116}
117//____________________________________________________________________________
119{
120 if (mWhichSuperModuleSize == 0) {
121 // Full Size
122 for (int i = 0; i < 77; i++) {
123 auto& mIndexMapPatchID = std::get<0>(mIndexMapPatch[i]);
124 auto& mFiredFastOrIndexMapPatchID = std::get<0>(mFiredFastOrIndexMapPatch[i]);
125 auto& mADCvaluesID = std::get<0>(mADCvalues[i]);
126 auto& mPreviousTimebinADCvalueID = std::get<0>(mPreviousTimebinADCvalue[i]);
127 mIndexMapPatchID = i;
128 mFiredFastOrIndexMapPatchID = i;
129 mADCvaluesID = i;
130 mPreviousTimebinADCvalueID = i;
131 int SeedID = std::get<1>(mPatchIDSeedFastOrIDs[i]);
132 // assigning a square
133 if (mWhichSide == 0) {
134 // A side
135 for (int iRow = 0; iRow < mPatchSize; iRow++) { // row advancement
136 for (int iColumn = 0; iColumn < mPatchSize; iColumn++) { // column advancement
137 auto& IndexMapPatch = std::get<1>(mIndexMapPatch[i]);
138 IndexMapPatch.push_back(SeedID + iRow + iColumn * 8);
139 // (std::get<1>(mIndexMapPatch[i])).push_back(SeedID + k + l * 8);
140 }
141 }
142 } else if (mWhichSide == 1) {
143 // C side
144 for (int iRow = 0; iRow < mPatchSize; iRow++) { // row advancement
145 for (int iColumn = 0; iColumn < mPatchSize; iColumn++) { // column advancement
146 auto& IndexMapPatch = std::get<1>(mIndexMapPatch[i]);
147 IndexMapPatch.push_back(SeedID - iRow - iColumn * 8);
148 // (std::get<1>(mIndexMapPatch[i])).push_back(SeedID - k - l * 8);
149 }
150 }
151 }
152 }
153 } else if (mWhichSuperModuleSize == 1) {
154 // One third Size
155 for (int i = 0; i < 69; i++) {
156 auto& mIndexMapPatchID = std::get<0>(mIndexMapPatch[i]);
157 auto& mFiredFastOrIndexMapPatchID = std::get<0>(mFiredFastOrIndexMapPatch[i]);
158 auto& mADCvaluesID = std::get<0>(mADCvalues[i]);
159 auto& mPreviousTimebinADCvalueID = std::get<0>(mPreviousTimebinADCvalue[i]);
160 mIndexMapPatchID = i;
161 mFiredFastOrIndexMapPatchID = i;
162 mADCvaluesID = i;
163 mPreviousTimebinADCvalueID = i;
164 int SeedID = std::get<1>(mPatchIDSeedFastOrIDs[i]);
165 // assigning a square
166 if (mWhichSide == 0) {
167 // A side
168 for (int iRow = 0; iRow < mPatchSize; iRow++) { // row advancement
169 for (int iColumn = 0; iColumn < mPatchSize; iColumn++) { // column advancement
170 auto& IndexMapPatch = std::get<1>(mIndexMapPatch[i]);
171 IndexMapPatch.push_back(SeedID + iRow + iColumn * 24);
172 // (std::get<1>(mIndexMapPatch[i])).push_back(SeedID + k + l * 24);
173 }
174 }
175 } else if (mWhichSide == 1) {
176 // C side
177 for (int iRow = 0; iRow < mPatchSize; iRow++) { // row advancement
178 for (int iColumn = 0; iColumn < mPatchSize; iColumn++) { // column advancement
179 auto& IndexMapPatch = std::get<1>(mIndexMapPatch[i]);
180 IndexMapPatch.push_back(SeedID - iRow - iColumn * 8);
181 // (std::get<1>(mIndexMapPatch[i])).push_back(SeedID - k - l * 8);
182 }
183 }
184 }
185 }
186 }
187}
188//________________________________________________________
190{
191 // Loop over all patches and their ADC values
192 for (auto& patch : mADCvalues) {
193 auto& ADCvalues = std::get<1>(patch);
194 auto& PatchID = std::get<0>(patch);
195 if (ADCvalues.size() == 4) {
196 // If there are already four elements, pop the first
197 std::get<1>(mPreviousTimebinADCvalue[PatchID]) = ADCvalues.front();
198 ADCvalues.erase(ADCvalues.begin());
199 } else {
200 if (ADCvalues.size() > 4) {
201 LOG(debug) << "DIG TRU updateADC in TRUElectronics: ERROR!!!!! ";
202 }
203 }
204 double integralADCnew = 0;
205
206 for (auto FastOrs : std::get<1>(mIndexMapPatch[PatchID])) {
207 // Loop over all the fastOrs addigned to the current patch
208 // and sum the current ADC values together
209 auto elem = mFastOrs[FastOrs].mADCvalues;
210 if (elem.size() == 0) {
211 continue;
212 }
213 auto it = elem.end() - 1;
214 auto pointedvalue = *it;
215 integralADCnew += pointedvalue;
216 }
217 ADCvalues.push_back(integralADCnew);
218
219 // Saving the timesum
220 auto& CurrentPatchTimesum = std::get<1>(mTimesum[PatchID]);
221 if (CurrentPatchTimesum.size() == 4) {
222 CurrentPatchTimesum.erase(CurrentPatchTimesum.begin());
223 }
224 double IntegralADCvalues = 0;
225 for (auto ADC : ADCvalues) {
226 IntegralADCvalues += ADC;
227 }
228 CurrentPatchTimesum.push_back(IntegralADCvalues);
229 }
230}
int32_t i
EMCAL TRUElectronics for the LZEROElectronics.
std::ostringstream debug
int mPatchSize
! patch size (2x2 or 4x4 typically)
std::vector< std::tuple< int, std::vector< double > > > mTimesum
! Time sums for peak finding
std::vector< std::tuple< int, std::vector< int > > > mFiredFastOrIndexMapPatch
! mask of the FastOrs above threshold in each patch
void assignSeedModuleToPatchWithSTUIndexingFullModule(int &patchID)
Assign seed module to a Full SM.
int mWhichSuperModuleSize
! Either Full/2/3 = 0 or 1/3 = 1 size
TRUElectronics()
Default constructor.
void init()
Initialise internal members.
void updateADC()
Updates the patches.
void assignSeedModuleToAllPatches()
Assign seed module to all patches.
std::vector< FastOrStruct > mFastOrs
! FastOr objects
void assignModulesToAllPatches()
Assign modules to all patches.
std::vector< std::tuple< int, std::vector< int > > > mIndexMapPatch
! mask of the FastOrs assigned to each patch
std::vector< std::tuple< int, int > > mPatchIDSeedFastOrIDs
! mask containing Patch IDs, their seed FastOrs
void clear()
Clear internal members.
std::vector< std::tuple< int, std::vector< double > > > mADCvalues
! ADC values for peak finding
std::vector< std::tuple< int, double > > mPreviousTimebinADCvalue
! ADC that was just removed from the time bins
int mWhichSide
! Either A = 0 or C = 1 side
void assignSeedModuleToPatchWithSTUIndexingOneThirdModule(int &patchID)
Assign seed module to a 1/3 SM.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
pedsdata resize(norbits)