ATLAS Offline Software
Loading...
Searching...
No Matches
Pad.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cmath>
8#include <fstream>
9#include <iostream>
10
12
13using namespace std;
14
15//--------------------------------------------------------------------//
16Pad::Pad(int run, int event, CMAword debug, ubit16 subsys, ubit16 sect, ubit16 padad, ubit16 lowhig, bool oldSimulation, int NOBXS) {
17 //
18 // input parameters: run run number
19 // event event number
20 // subsys subsystem address (0=eta<0; 1=eta>0)
21 // sect address of the sector of this pad
22 // padad local address of this pad
23 // lowhig type of pad: lowpt or highpt pad
24 // OldSimulation true means using RPCcablingSim, false for MuonRPC_Cabling (M.Corradi 2/3/2010)
25 //
26 // CMA data are loaded in the PAD with the method "load"
27 //
29 // padDebug=0x3f; all debug ON
30
31 const ubit16 df = 0;
32 m_run = run;
33 m_event = event;
34 m_oldSimulation = oldSimulation;
35 m_subsystem = subsys;
36 m_sector = sect;
37 m_padadd = padad;
38 m_lowhigh = lowhig;
39 //
40 m_nBunMax = NOBXS;
41 m_feet_on = false;
42 m_feet_thresholds[0] = 0;
43 m_feet_thresholds[1] = 1;
44 m_feet_thresholds[2] = 2;
45 //
46 if (padDebug & 1 << df) {
47 cout << " ==================== " << endl;
48 cout << " = Pad::Pad = " << endl;
49 cout << " ==================== " << endl;
50 cout << " m_run= " << m_run << " m_event= " << m_event << " padDebug= " << hex << padDebug << dec << endl;
51 cout << " Pad parameters: Subsystem: " << m_subsystem << " Sector: " << m_sector << " Pad address: " << m_padadd
52 << " LowHigh: " << m_lowhigh << " m_oldSimulation: " << m_oldSimulation << endl;
53 } // end-of-if(*(lvl1dbg
54 //
55 reset();
57} // end-of-pad::pad
58//---------------------------------------------------------------------//
60 const ubit16 df = 1;
61 if (padDebug & 1 << df) cout << "Distructor of Pad called " << endl;
62} // end-of-Pad::~Pad
63//----------------------------------------------------------------------//
64void Pad::reset() {
65 ubit16 i, j, k, l, m;
66
67 //
68 // input to the PAD logic: initialize m_padIn
69 //
70 for (m = 0; m < 2; m++) {
71 for (k = 0; k < 2; k++) { // eta-phi matrix
72 for (j = 0; j < 2; j++) { // matrix local address
73 for (l = 0; l < m_nBunMax; l++) { // loop on NOBXS bunches
74 for (i = 0; i < 2; i++) { // type of input: i=0 => threshold; i=1 => overlap
75 m_padIn[m][k][j][l][i] = 0;
76 } // end-of-for(i
77 } // end-of-for(l
78 } // end-of-for(j
79 } // end-of-for(k
80 } // end-of-for(m
81 //
82 for (l = 0; l < m_nBunMax; l++) {
83 for (k = 0; k < 8; k++) { // reset m_padStep2 data per each bunch crossing
84 m_padStep2[l][0][k] = 0;
85 m_padStep2[l][1][k] = 0;
86 } // end-of-for(k
87 for (k = 0; k < 7; k++) { // reset m_padOut data per each bunch crossing
88 m_padOut[l][k] = 0;
89 } // end-of-for(k
90 } // end-of-for(l
91} // end-of-Pad::reset
92//----------------------------------------------------------------------//
94 const ubit16 df = 2;
96 //
97 // load "hitOuterPlane"
98 //
100 // put this in m_hitInOuterPlane
101 m_hitInOuterPlane[0] = 0;
102 m_hitInOuterPlane[1] = 0;
103 m_hitInOuterPlane[2] = 0;
105 if (padDebug & 1 << df) {
106 cout << " Pad: m_hitInOuterPlane= " << m_hitInOuterPlane[0] << " " << m_hitInOuterPlane[1] << " " << m_hitInOuterPlane[2] << " "
107 << endl;
108 cout << " Pad: projectionLogic= " << m_projectionLogic << endl;
109 } // end-of-if(padDebug&1<<df)
110} // end-of-Pad::setDefaultConfiguration
111//----------------------------------------------------------------------//
113 if (prologic < 4) {
114 m_projectionLogic = prologic;
115 } else {
116 cout << " Pad.setProjectionLogic; prologic= " << prologic << " not allowed; default value " << m_projectionLogic << " is retained "
117 << endl;
118 } // end-of-if
119} // end-of- Pad::setProjectionLogic(ubit16 prologic)
120//----------------------------------------------------------------------//
121void Pad::load(ubit16 lowhig, ubit16 etaphi, ubit16 locCMadd, ubit16 BX, ubit16 thres, ubit16 overl) {
122 //
123 // input data from Coincidence Matrix:
124 // lowhig = type of Matrix (low/high pt);
125 // etaphi = projection: eta=0, phi=1;
126 // locCMadd= local CM address (0,1)
127 // BX = "address" of this bunch
128 // thresOver= type of data: threshold or overlap
129 // thres = highest threshold
130 // over = overlap
131 //
132 if (lowhig > 1 || etaphi > 1 || locCMadd > 1 || BX >= m_nBunMax) {
133 cout << " Pad::load : lowhig=" << lowhig << " etaphi=" << etaphi << " locCMadd=" << locCMadd << " BX=" << BX << " not valid"
134 << endl;
135 } else {
136 m_padIn[lowhig][etaphi][locCMadd][BX][0] = thres;
137 m_padIn[lowhig][etaphi][locCMadd][BX][1] = overl;
138 } // end-of-if(lowhig
139} // end-of-Pad::load
140//----------------------------------------------------------------------//
142 const ubit16 df = 3;
143 if (padDebug & 1 << df) cout << " execute PAD " << endl;
144 if (m_lowhigh) {
145 threshold();
146 overlap();
147 makeOut();
148 if (m_feet_on) makeFeet();
149 if (padDebug & 1 << df) display(0);
150 } // end-of-if(m_lowhigh
151} // end-of-Pad::execute
152//---------------------------------------------------------//
154 const ubit16 df = 4;
155 //
156 // reminder: m_padIn[m][i][j][k][l] is 0 no trigger
157 // 1,2,3
158 //
159 ubit16 i, j, l, m;
160 ubit16 thisThreshold;
161 for (m = 0; m < 2; m++) { // Low- High-Pt
162 for (j = 0; j < 2; j++) { // eta-phi matrix address
163 for (i = 0; i < 2; i++) { // local matrix address
164 for (l = 0; l < m_nBunMax; l++) { // loop on m_nBunMax bunches
165 if (m_padIn[m][j][i][l][0]) {
166 if (m && m_hitInOuterPlane[m_padIn[m][j][i][l][0] - 1]) {
167 m_padStep2[l][i][6] = 1;
168 } else {
169 // define absolute threshold
170 thisThreshold = 3 * m + m_padIn[m][j][i][l][0];
171 // find highest threshold
172 if (thisThreshold > m_padStep2[l][j][i]) {
173 if (m_padStep2[l][j][i] == 0) m_padStep2[l][j][7]++; // num of RoI with threshold
174 m_padStep2[l][j][i] = thisThreshold;
175 } // end-of-if
176 // if( !j && (thisThreshold > m_padStep2[l][j][2]) ) {
177 if (thisThreshold > m_padStep2[l][j][2]) {
178 m_padStep2[l][j][2] = thisThreshold; // highest threshold
179 m_padStep2[l][j][3] = i; // CM with the highest thres.
180 if (padDebug & 1 << df) {
181 cout << " Pad::threshold; padStep2 eta-phi " << j << " localAdd " << i << " Bunch " << l
182 << " threshold " << m_padStep2[l][j][2] << endl;
183 } // end-of-if(padDebug&1<<df)
184 } // end-of-if(m_padStep2
185 m_padStep2[l][j][4]++; // number of CMs with thresh.
186 } // end-of-if( m && m_hitInOuterPlane
187 } // end-of-if(m_padIn
188 } // end-of-for(l
189 } // end-of-for(i
190 } // end-of-for(j
191 } // end-of-for(m
192} // end-of-Pad::threshold
193//---------------------------------------------------------//
195 // const ubit16 df=5;
196 ubit16 i, j, l;
197 for (l = 0; l < m_nBunMax; l++) { // loop on m_nBunMax bunches
198 for (j = 0; j < 2; j++) { // loop on Low- High-Pt systems
199 for (i = 0; i < 2; i++) { // eta-phi matrix address: eta=0; phi=1
200 // "external" overlapping strips
201 //
202 if (m_padIn[j][i][1][l][1] & 2) m_padStep2[l][i][5] = 1; // c1 ovl_sx
203 if (m_padIn[j][i][0][l][1] & 1) m_padStep2[l][i][5] = 1; // c0 ovl_dx
204 } // end-of-for(i
205 } // end-of-for(j
206 } // end-of-for(l
207} // end-of-Pad::overlap()
208//---------------------------------------------------------//
210 // const ubit16 df=6;
211 switch (m_projectionLogic) {
212 case 0: makeOutEta(); break;
213 case 1: makeOutPhi(); break;
214 case 2: makeOutEtaAndPhi(); break;
215 case 3: makeOutEtaOrPhi(); break;
216 default: cout << " Pad: problems with projectionLogic= " << m_projectionLogic << endl;
217 } // end-of-switch
218
219} // end-of-Pad::makeOut()
220//---------------------------------------------------------//
222 // const ubit16 df=6;
223 ubit16 l;
224 for (l = 0; l < m_nBunMax; l++) { // loop on Bunches
225 if (m_padStep2[l][0][2]) {
226 // RoI definition
227 if (m_oldSimulation) {
228 m_padOut[l][0] = 2 * m_padStep2[l][0][3];
229 } else {
230 m_padOut[l][0] = m_padStep2[l][0][3];
231 }
232 m_padOut[l][1] = m_padStep2[l][0][2];
233 m_padOut[l][2] = m_padStep2[l][0][6];
234 if (m_padStep2[l][0][5]) m_padOut[l][4] = 1;
235 m_padOut[l][5] = 1;
236 } // end-of-if(m_padStep2[l][0][2]) {
237 } // end-of-for(l
238} // end-of-makeOutEta()
239//---------------------------------------------------------//
241 // const ubit16 df=6;
242 ubit16 l;
243 for (l = 0; l < m_nBunMax; l++) { // loop on Bunches
244 if (m_padStep2[l][1][2]) {
245 // RoI definition
246 if (m_oldSimulation) {
247 m_padOut[l][0] = m_padStep2[l][1][3];
248 } else {
249 m_padOut[l][0] = 2 * m_padStep2[l][1][3];
250 }
251 m_padOut[l][1] = m_padStep2[l][1][2];
252 m_padOut[l][2] = m_padStep2[l][1][6];
253 if (m_padStep2[l][1][5]) m_padOut[l][3] = 1;
254 m_padOut[l][5] = 1;
255 } // end-of-if(m_padStep2[l][1][2]) {
256 } // end-of-for(l
257} // end-of-makeOutPhi()
258//---------------------------------------------------------//
260 // const ubit16 df=6;
261 ubit16 l;
262 for (l = 0; l < m_nBunMax; l++) { // loop on Bunches
263 if (m_padStep2[l][0][2] && m_padStep2[l][1][2]) {
264 // RoI definition
265 if (m_oldSimulation) {
266 m_padOut[l][0] = m_padStep2[l][1][3] + 2 * m_padStep2[l][0][3]; // th
267 } else {
268 m_padOut[l][0] = m_padStep2[l][0][3] + 2 * m_padStep2[l][1][3];
269 }
270 if (m_padStep2[l][0][2] < m_padStep2[l][1][2]) {
271 m_padOut[l][1] = m_padStep2[l][0][2]; // th
272 m_padOut[l][2] = m_padStep2[l][0][6]; // OPL
273 } else {
274 m_padOut[l][1] = m_padStep2[l][1][2];
275 m_padOut[l][2] = m_padStep2[l][1][6];
276 }
277 if (m_padStep2[l][1][5]) m_padOut[l][3] = 1; // ovl phi
278 if (m_padStep2[l][0][5]) m_padOut[l][4] = 1; // ovl eta
279 if (m_padStep2[l][0][7] + m_padStep2[l][1][7] > 2) m_padOut[l][5] = 1; // roi ambiguity
280 } // end-of-if
281 } // end-of-for(l
282} // end-of-Pad::makeOutEtaAndPhi()
283//---------------------------------------------------------//
285 // const ubit16 df=6;
286 ubit16 l;
287 for (l = 0; l < m_nBunMax; l++) { // loop on Bunches
288 if (m_padStep2[l][0][2] || m_padStep2[l][1][2]) {
289 if (m_padStep2[l][0][2] && !m_padStep2[l][1][2]) {
290 makeOutEta();
291 } else if (m_padStep2[l][1][2] && !m_padStep2[l][0][2]) {
292 makeOutPhi();
293 } else {
295 } // end-of-if( &&! )
296 } // end-of-if(m_padStep2[l][0][2] || m_padStep2[l][1][2])
297 } // end-of-for(l
298} // end-of-makeOuttaEOrPhi()
299//---------------------------------------------------------//
301 ubit16 l;
302 for (l = 0; l < m_nBunMax; l++) {
303 if (m_padOut[l][1] > 0) m_padOut[l][1] = m_feet_thresholds[m_padOut[l][1] - 1] + 1;
304 }
305}
306//---------------------------------------------------------//
307void Pad::display(int flag) {
308 //
309 // first dump the m_padStep2 registers
310 //
311 ubit16 i, j;
312 char padOutText[7][6];
313 strcpy(padOutText[0], "RoI");
314 strcpy(padOutText[1], "Ptcod");
315 strcpy(padOutText[2], "OPL");
316 strcpy(padOutText[3], "OvPhi");
317 strcpy(padOutText[4], "OvEta");
318 strcpy(padOutText[5], "RoIAm");
319 strcpy(padOutText[6], "BCDcn");
320 if (flag) {
321 cout << endl;
322 cout << " ************************************* " << endl;
323 cout << " * * " << endl;
324 cout << " * P A D D I S P L A Y * " << endl;
325 cout << " * * " << endl;
326 cout << " ************************************* " << endl;
327 cout << endl;
328 cout << " P A R A M E T E R S: " << endl;
329 cout << " Subsystem " << m_subsystem << endl;
330 cout << " Sector " << m_sector << endl;
331 cout << " PAD addr " << m_padadd << endl;
332 cout << " Low-High " << m_lowhigh << endl;
333 cout << "m_oldSimulation:" << m_oldSimulation << endl;
334 cout << " feet_on:" << m_feet_on;
335 if (m_feet_on)
336 cout << " feet_thresholds:" << m_feet_thresholds[0] << "," << m_feet_thresholds[1] << "," << m_feet_thresholds[2] << endl;
337 cout << endl;
338 }
339 if (flag - 1) {
340 cout << " D U M P padStep2 " << endl;
341 cout << " ";
342 cout << "Projection Eta ";
343 cout << " ";
344 cout << "Projection Phi " << endl;
345 cout << " ";
346 cout << "---------------";
347 cout << " ";
348 cout << "---------------" << endl;
349 cout << " ";
350 cout << "C C t a n o O A";
351 cout << " ";
352 cout << "C C t a n o O A" << endl;
353 cout << " ";
354 cout << "M M h d u v P m";
355 cout << " ";
356 cout << "M M h d u v P m" << endl;
357 cout << " ";
358 cout << "0 1 r d m e L b";
359 cout << " ";
360 cout << "0 1 r d m e L b" << endl;
361 cout << " ";
362 cout << " e r r i";
363 cout << " ";
364 cout << " e r r i" << endl;
365 //
366
367 for (j = 0; j < m_nBunMax; j++) {
368 cout << " Bunch Crossing Number " << j << " ";
369 for (i = 0; i < 2; i++) { // Eta-Phi system
370 cout << " " << m_padStep2[j][i][0] << " " << m_padStep2[j][i][1] << " " << m_padStep2[j][i][2] << " " << m_padStep2[j][i][3]
371 << " " << m_padStep2[j][i][4] << " " << m_padStep2[j][i][5] << " " << m_padStep2[j][i][6] << " "
372 << m_padStep2[j][i][7];
373 if (i == 0) cout << " ";
374 } // end-of-for(i
375 cout << endl;
376 } // end-of-for(j
377 cout << endl;
378 } // end-of-if
379 if (flag) {
380 //
381 // dump m_padOut
382 //
383 cout << " D U M P PadOut " << endl;
384 for (i = 0; i < m_nBunMax; i++) {
385 cout << " Pad: padOut Bunch=" << i << ":";
386 for (j = 0; j < 7; j++) { cout << " " << padOutText[j] << " " << m_padOut[i][j]; } // end-of-for(j
387 cout << endl;
388 } // end-of-for(i
389 cout << endl;
390 } // end-of-if(flag
391} // end-of-Pad::display
392//---------------------------------------------------------//
393//
394// readout method
395//
396int Pad::get_PADID() { // f
397 return m_padadd; // f
398} // f
399//---------------------------------------------------------//
401 ubit16 output = 0;
402 if (bunch < m_nBunMax) {
403 output = m_padOut[bunch][0];
404 } else {
405 cout << " getRoI; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
406 }
407 return output;
408} // end-of-getRoI
409//---------------------------------------------------------//
411 ubit16 output = 0;
412 if (bunch < m_nBunMax) {
413 output = m_padOut[bunch][1];
414 } else {
415 cout << " getPTCoding; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
416 }
417 return output;
418} // end-of-getPTCoding
419//---------------------------------------------------------//
421 ubit16 output = 0;
422 if (bunch < m_nBunMax) {
423 output = m_padOut[bunch][2];
424 } else {
425 cout << " getOPL; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
426 }
427 return output;
428} // end-of-getOPL
429//---------------------------------------------------------//
431 ubit16 output = 0;
432 if (bunch < m_nBunMax) {
433 output = m_padOut[bunch][3];
434 } else {
435 cout << " getOverlapPhi; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
436 }
437 return output;
438} // end-of-getOverlapPhi
439//---------------------------------------------------------//
441 ubit16 output = 0;
442 if (bunch < m_nBunMax) {
443 output = m_padOut[bunch][4];
444 } else {
445 cout << " getOverlapEta; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
446 }
447 return output;
448} // end-of-getOverlapEta
449//---------------------------------------------------------//
451 ubit16 output = 0;
452 if (bunch < m_nBunMax) {
453 output = m_padOut[bunch][5];
454 } else {
455 cout << " getRoIAmbiguity; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
456 }
457 return output;
458} // end-of-getRoIAmbiguity
459//---------------------------------------------------------//
461 ubit16 output = 0;
462 if (bunch < m_nBunMax) {
463 output = m_padOut[bunch][6];
464 } else {
465 cout << " getBCIDCounter; Error: bunch address " << bunch << " not consistent with m_nBunMax= " << m_nBunMax << endl;
466 }
467 return output;
468} // end-of-getBCIDCounter
469//-----------
471//----------
472//-----------
473void Pad::setOldSimulation(bool value) { m_oldSimulation = value; }
474//----------
uint32_t CMAword
Definition Lvl1Def.h:17
const bool debug
unsigned short int ubit16
void load(ubit16 lowhig, ubit16 etaphi, ubit16 CMadd, ubit16 BX, ubit16 thres, ubit16 overl)
Definition Pad.cxx:121
bool m_oldSimulation
Definition Pad.h:43
void display(int flag)
Definition Pad.cxx:307
ubit16 getPTCoding(ubit16 bunch)
Definition Pad.cxx:410
void makeFeet()
Definition Pad.cxx:300
bool m_feet_on
Definition Pad.h:44
ubit16 m_nBunMax
Definition Pad.h:52
void setDefaultConfiguration()
Definition Pad.cxx:93
void overlap()
Definition Pad.cxx:194
void threshold()
Definition Pad.cxx:153
ubit16 getBCIDCounter(ubit16 bunch)
Definition Pad.cxx:460
void makeOutPhi()
Definition Pad.cxx:240
void makeOutEtaAndPhi()
Definition Pad.cxx:259
bool isOldSimulation()
Definition Pad.cxx:470
ubit16 m_padStep2[8][2][8]
Definition Pad.h:134
Pad(int run, int event, CMAword debug, ubit16 subsys, ubit16 sect, ubit16 padad, ubit16 lowhig, bool oldSimulation, int NOBXS)
Definition Pad.cxx:16
void setOldSimulation(bool value)
Definition Pad.cxx:473
~Pad()
Definition Pad.cxx:59
void reset()
Definition Pad.cxx:64
ubit16 getRoI(ubit16 bunch)
Definition Pad.cxx:400
ubit16 getOPL(ubit16 bunch)
Definition Pad.cxx:420
ubit16 m_lowhigh
Definition Pad.h:68
ubit16 m_projectionLogic
Definition Pad.h:70
ubit16 m_padadd
Definition Pad.h:67
void makeOutEtaOrPhi()
Definition Pad.cxx:284
ubit16 m_padIn[2][2][2][8][2]
Definition Pad.h:113
void makeOutEta()
Definition Pad.cxx:221
void setProjectionLogic(ubit16 prologic)
Definition Pad.cxx:112
void makeOut()
Definition Pad.cxx:209
ubit16 m_sector
Definition Pad.h:66
int m_run
Definition Pad.h:41
ubit16 getRoIAmbiguity(ubit16 bunch)
Definition Pad.cxx:450
ubit16 m_subsystem
Definition Pad.h:65
int get_PADID()
Definition Pad.cxx:396
ubit16 m_hitInOuterPlane[3]
Definition Pad.h:59
ubit16 m_padOut[8][7]
Definition Pad.h:156
int m_event
Definition Pad.h:42
void execute()
Definition Pad.cxx:141
ubit16 getOverlapPhi(ubit16 bunch)
Definition Pad.cxx:430
ubit16 getOverlapEta(ubit16 bunch)
Definition Pad.cxx:440
unsigned short int m_feet_thresholds[3]
Definition Pad.h:45
ubit16 m_thHitOuterPlane
Definition Pad.h:53
CMAword padDebug
Definition Pad.h:25
Definition run.py:1
STL namespace.