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