Process the event and put new data products into it.
39 {
40
41
42
43
44
45
46
47
48
49
50
51 if (verbose_) {
52 ldmx_log(debug)
53 << "TrigScintFirmwareTracker: produce() starts! Event number: "
54 << event.getEventHeader().getEventNumber();
55 }
56
57
60
61
62 for (int i = 0; i < NCENT; ++i) {
63 for (int j = 0; j < COMBO; ++j) {
64 for (int k = 0; k < 2; ++k) {
66 }
67 }
68 }
69
70
71
72
73
74 for (int i = 0; i < NCENT; i++) {
75 for (int j = 0; j < COMBO; j++) {
76 LOOKUP[i][j][0] = (i - A[1] + A[0]);
77 LOOKUP[i][j][1] = (i - A[2] + A[0]);
78 if (j / 3 == 0) {
79 LOOKUP[i][j][0] -= 1;
80 } else if (j / 3 == 2) {
81 LOOKUP[i][j][0] += 1;
82 }
83 if (j % 3 == 0) {
84 LOOKUP[i][j][1] -= 1;
85 } else if (j % 3 == 2) {
86 LOOKUP[i][j][1] += 1;
87 }
88 if (not((LOOKUP[i][j][0] >= 0) and (LOOKUP[i][j][1] >= 0) and
89 (LOOKUP[i][j][0] < NCENT) and (LOOKUP[i][j][1] < NCENT))) {
90 LOOKUP[i][j][0] = -1;
91 LOOKUP[i][j][1] = -1;
92 }
93 }
94 }
95
99
100
101
106
107 for (int j = 0; j < NHITS; j++) {
108 clearHit(HPad1[j]);
109 clearHit(HPad2[j]);
110 clearHit(HPad3[j]);
111 }
112 for (int j = 0; j < NCLUS; j++) {
113 if (j < NTRK) {
114 clearClus(Pad1[j]);
115 }
116 clearClus(Pad2[j]);
117 clearClus(Pad3[j]);
118 }
119 for (int j = 0; j < NTRK; j++) {
120 clearTrack(outTrk[j]);
121 }
122
123 const auto &digis1{
125 const auto &digis2{
127 const auto &digis3{
129
130 if (verbose_) {
131 ldmx_log(debug) << "Got digi collection " << digis1_collection_ << "_"
132 << passName_ << " with " << digis1.size() << " entries ";
133 }
134
135
136
137
138 int occupied[NCHAN];
139 for (int i = 0; i < NCHAN; i++) {
140 occupied[i] = -1;
141 }
142 int count = 0;
143 for (const auto &digi : digis1) {
144 if ((digi.getPE() >
minThr_) and (digi.getBarID() <= NCHAN) and
145 (digi.getBarID() >= 0)) {
148 if (occupied[digi.getBarID()] >= 0) {
149 if (HPad1[occupied[digi.getBarID()]].Amp < digi.getPE()) {
150 HPad1[occupied[digi.getBarID()]].bID = (
ap_int<12>)(digi.getBarID());
151 HPad1[occupied[digi.getBarID()]].mID =
153 HPad1[occupied[digi.getBarID()]].Amp = (
ap_int<12>)(digi.getPE());
154 HPad1[occupied[digi.getBarID()]].Time = (
ap_int<12>)(digi.getTime());
155 }
156 } else {
157 HPad1[count].bID = (
ap_int<12>)(digi.getBarID());
158 HPad1[count].mID = (
ap_int<12>)(digi.getModuleID());
159 HPad1[count].Amp = (
ap_int<12>)(digi.getPE());
160 HPad1[count].Time = (
ap_int<12>)(digi.getTime());
161 occupied[digi.getBarID()] = count;
162 count++;
163 }
164 }
165 }
166
167 for (int i = 0; i < NCHAN; i++) {
168 occupied[i] = -1;
169 }
170 count = 0;
171 for (const auto &digi : digis2) {
172 if ((digi.getPE() >
minThr_) and (digi.getBarID() <= NCHAN) and
173 (digi.getBarID() >= 0)) {
176 if (occupied[digi.getBarID()] >= 0) {
177 if (HPad2[occupied[digi.getBarID()]].Amp < digi.getPE()) {
178 HPad2[occupied[digi.getBarID()]].bID = (
ap_int<12>)(digi.getBarID());
179 HPad2[occupied[digi.getBarID()]].mID =
181 HPad2[occupied[digi.getBarID()]].Amp = (
ap_int<12>)(digi.getPE());
182 HPad2[occupied[digi.getBarID()]].Time = (
ap_int<12>)(digi.getTime());
183 }
184 } else {
185 HPad2[count].bID = (
ap_int<12>)(digi.getBarID());
186 HPad2[count].mID = (
ap_int<12>)(digi.getModuleID());
187 HPad2[count].Amp = (
ap_int<12>)(digi.getPE());
188 HPad2[count].Time = (
ap_int<12>)(digi.getTime());
189 occupied[digi.getBarID()] = count;
190 count++;
191 }
192 }
193 }
194 for (int i = 0; i < NCHAN; i++) {
195 occupied[i] = -1;
196 }
197 count = 0;
198 for (const auto &digi : digis3) {
199 if ((digi.getPE() >
minThr_) and (digi.getBarID() <= NCHAN) and
200 (digi.getBarID() >= 0)) {
203 if (occupied[digi.getBarID()] >= 0) {
204 if (HPad3[occupied[digi.getBarID()]].Amp < digi.getPE()) {
205 HPad3[occupied[digi.getBarID()]].bID = (
ap_int<12>)(digi.getBarID());
206 HPad3[occupied[digi.getBarID()]].mID =
208 HPad3[occupied[digi.getBarID()]].Amp = (
ap_int<12>)(digi.getPE());
209 HPad3[occupied[digi.getBarID()]].Time = (
ap_int<12>)(digi.getTime());
210 }
211 } else {
212 HPad3[count].bID = (
ap_int<12>)(digi.getBarID());
213 HPad3[count].mID = (
ap_int<12>)(digi.getModuleID());
214 HPad3[count].Amp = (
ap_int<12>)(digi.getPE());
215 HPad3[count].Time = (
ap_int<12>)(digi.getTime());
216 occupied[digi.getBarID()] = count;
217 count++;
218 }
219 }
220 }
221
222
223
224
225 int counterN = 0;
226 std::array<Cluster, NCLUS> Point1 = clusterproducer_sw(HPad1);
227 int topSeed = 0;
228 for (int i = 0; i < NCLUS; i++) {
229 if ((Point1[i].Seed.Amp < 450) and (Point1[i].Seed.Amp > 30) and
230 (Point1[i].Seed.bID < (NCHAN + 1)) and (Point1[i].Seed.bID >= 0) and
231 (Point1[i].Sec.Amp < 450) and (counterN < NTRK)) {
232 if (Point1[i].Seed.bID >= topSeed) {
233 cpyHit(Pad1[counterN].Seed, Point1[i].Seed);
234 cpyHit(Pad1[counterN].Sec, Point1[i].Sec);
235 calcCent(Pad1[counterN]);
236 counterN++;
237 topSeed = Point1[i].Seed.bID;
238 }
239 }
240 }
241 std::array<Cluster, NCLUS> Point2 = clusterproducer_sw(HPad2);
242 topSeed = 0;
243 for (int i = 0; i < NCLUS; i++) {
244 if ((Point2[i].Seed.Amp < 450) and (Point2[i].Seed.Amp > 30) and
245 (Point2[i].Seed.bID < (NCHAN + 1)) and (Point2[i].Seed.bID >= 0) and
246 (Point2[i].Sec.Amp < 450)) {
247 if (Point2[i].Seed.bID >= topSeed) {
248 cpyHit(Pad2[i].Seed, Point2[i].Seed);
249 cpyHit(Pad2[i].Sec, Point2[i].Sec);
250 calcCent(Pad2[i]);
251 topSeed = Point2[i].Seed.bID;
252 }
253 }
254 }
255 std::array<Cluster, NCLUS> Point3 = clusterproducer_sw(HPad3);
256 topSeed = 0;
257 for (int i = 0; i < NCLUS; i++) {
258 if ((Point3[i].Seed.Amp < 450) and (Point3[i].Seed.Amp > 30) and
259 (Point3[i].Seed.bID < (NCHAN + 1)) and (Point3[i].Seed.bID >= 0) and
260 (Point3[i].Sec.Amp < 450)) {
261 if (Point3[i].Seed.bID >= topSeed) {
262 cpyHit(Pad3[i].Seed, Point3[i].Seed);
263 cpyHit(Pad3[i].Sec, Point3[i].Sec);
264 calcCent(Pad3[i]);
265 topSeed = Point3[i].Seed.bID;
266 }
267 }
268 }
269
270
271
272
273
274
275
276
277
278
279 trackproducer_hw(Pad1, Pad2, Pad3, outTrk, LOOKUP);
280 for (int I = 0; I < NTRK; I++) {
281 if (outTrk[I].Pad1.Seed.Amp > 0. && outTrk[I].Pad1.Sec.Amp >= 0. &&
282 outTrk[I].Pad2.Seed.Amp > 0. && outTrk[I].Pad2.Sec.Amp >= 0. &&
283 outTrk[I].Pad3.Seed.Amp > 0. && outTrk[I].Pad3.Sec.Amp >= 0.) {
285 tracks_.push_back(trk);
286 }
287 }
288 event.add(output_collection_, tracks_);
289 tracks_.resize(0);
290
291 return;
292}
Sign Arbitrary Precision Type.