ATLAS Offline Software
RegSelectorMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <cmath>
8 #include <cstring>
9 
10 
11 
12 
14 
15 
17 
18 void RegSelectorMap::HashIDList( const IRoiDescriptor& roi, std::vector<IdentifierHash>& idlist ) const {
19  IRegSelLUT::IDList<RegSelectorMap>( roi, idlist, &RegSelectorMap::HashIDList_internal );
20 }
21 
22 void RegSelectorMap::HashIDList( long layer, const IRoiDescriptor& roi, std::vector<IdentifierHash>& idlist ) const {;
23  IRegSelLUT::IDList_layer<RegSelectorMap>( layer, roi, idlist, &RegSelectorMap::HashIDList_internal );
24 }
25 
27 
28 void RegSelectorMap::ROBIDList( const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const {
29  IRegSelLUT::IDList<RegSelectorMap>( roi, roblist, &RegSelectorMap::ROBIDList_internal );
30 }
31 
32 void RegSelectorMap::ROBIDList( long layer, const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const {
33  IRegSelLUT::IDList_layer<RegSelectorMap>( layer, roi, roblist, &RegSelectorMap::ROBIDList_internal );
34 }
35 
36 
37 
39 
40 void RegSelectorMap::HashIDList_internal( const IRoiDescriptor& roi, std::vector<IdentifierHash>& idlist ) const {
41  if ( roi.isFullscan() ) regionSelector( TILE, -4.9, 4.9, 0, 2*M_PI, idlist );
42  regionSelector( TILE, roi.etaMinus(), roi.etaPlus(), roi.phiMinus(), roi.phiPlus(), idlist );
43 }
44 
45 void RegSelectorMap::HashIDList_internal( long layer, const IRoiDescriptor& roi, std::vector<IdentifierHash>& idlist ) const {;
46  if ( roi.isFullscan() ) regionSelector( layer, -4.9, 4.9, 0, 2*M_PI, idlist );
47  regionSelector( layer, roi.etaMinus(), roi.etaPlus(), roi.phiMinus(), roi.phiPlus(), idlist );
48 }
49 
51 
52 void RegSelectorMap::ROBIDList_internal( const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const {
53  if ( roi.isFullscan() ) regionSelectorRobIdUint( TILE, -4.9, 4.9, 0, 2*M_PI, roblist );
54  regionSelectorRobIdUint( TILE, roi.etaMinus(), roi.etaPlus(), roi.phiMinus(), roi.phiPlus(), roblist );
55 }
56 
57 void RegSelectorMap::ROBIDList_internal( long layer, const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const {
58  if ( roi.isFullscan() ) regionSelectorRobIdUint( layer, -4.9, 4.9, 0, 2*M_PI, roblist );
59  regionSelectorRobIdUint( layer, roi.etaMinus(), roi.etaPlus(), roi.phiMinus(), roi.phiPlus(), roblist );
60 }
61 
62 
64 
65 double RegSelectorMap::etaminValue(void) const {
66  return m_etaminDet;
67 }
68 
69 double RegSelectorMap::etamaxValue(void) const {
70  return m_etamaxDet;
71 }
72 
73 double RegSelectorMap::phiminValue(void) const {
74  return m_phiminDet;
75 }
76 
77 double RegSelectorMap::phimaxValue(void) const {
78  return m_phimaxDet;
79 }
80 
81 const std::vector<IdentifierHash>& RegSelectorMap::hashIdOut(void) const {
82  return m_hashId;
83 }
84 
85 const std::vector<uint32_t>& RegSelectorMap::robIdOut(void) const {
86  return m_robId;
87 }
88 
89 const std::vector<int>& RegSelectorMap::barORendOut(void) const {
90  return m_barORend;
91 }
92 
93 const std::vector<int>& RegSelectorMap::layORdskOut(void) const {
94  return m_layORdsk;
95 }
96 
97 const std::vector<double>& RegSelectorMap::etaMinOut(void) const {
98  return m_etamin;
99 }
100 
101 const std::vector<double>& RegSelectorMap::etaMaxOut(void) const {
102  return m_etamax;
103 }
104 
105 const std::vector<double>& RegSelectorMap::phiMinOut(void) const {
106  return m_phimin;
107 }
108 
109 const std::vector<double>& RegSelectorMap::phiMaxOut(void) const {
110  return m_phimax;
111 }
112 
114  int nLines = m_barORend.size();
115  int i;
116 
117  for( i = 0; i < nLines; ++i){ // creating list of RegSelectElementUint
119  m_etamin[i], m_etamax[i],
120  m_phimin[i], m_phimax[i],
121  m_hashId[i], m_robId[i] );
122  }
124  // find max and min values of each barrel layer and endcap disk
125  for(it = m_barreldataList.begin();it != m_barreldataList.end(); ++it)
126  (*it).findMaxMinElem();
127  for(it = m_posdataList.begin();it != m_posdataList.end(); ++it)
128  (*it).findMaxMinElem();
129  for(it = m_negdataList.begin();it != m_negdataList.end(); ++it)
130  (*it).findMaxMinElem();
131  // find max and min values of a subdetector
132  m_etaminDet = 1000; m_etamaxDet = -1000;
133  m_phiminDet = 1000; m_phimaxDet = -1000;
137 }
138 
140  double etaminIn, double etamaxIn,
141  double phiminIn, double phimaxIn,
142  std::vector<uint32_t>& outList ) const {
143 
144  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
145 
146  std::list<RegSelectorMapElement>::const_iterator it;
147  std::set<uint32_t> outset;
148  std::set<uint32_t>::const_iterator itset, negbarrelbeg, negbarrelend;
149  bool divideEta = false;
150 
151  for( it = m_barreldataList.begin(); //barrel list
152  it != m_barreldataList.end(); ++it){ // runs trought all RegSelectElementUints
153  (*it).selectionRobIdUint( etaminIn, etamaxIn, phiminIn, phimaxIn, outset );
154  }
155 
156  switch(TYPE){
157  case TILE: divideEta = true; break;
158  default: break;
159  }
160 
161  if( divideEta ){
162  if(etaminIn < 0 || etamaxIn < 0){ // negative data list
163  for(it = m_negdataList.begin();it != m_negdataList.end(); ++it){ // runs trought all RegSelectElementUints
164  (*it).selectionRobIdUint(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
165  }
166  }
167 
168  if( etaminIn >= 0 || etamaxIn >= 0 ){ // positive data list
169  for(it = m_posdataList.begin();it != m_posdataList.end(); ++it){ // runs trought all RegSelectElementUints
170  (*it).selectionRobIdUint(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
171  }
172  }
173  }
174  else{
175  for(it = m_negdataList.begin();it != m_negdataList.end(); ++it){ // runs trought all RegSelectElementUints
176  (*it).selectionRobIdUint(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
177  }
178  for(it = m_posdataList.begin();it != m_posdataList.end(); ++it){ // runs trought all RegSelectElementUints
179  (*it).selectionRobIdUint(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
180  }
181  }
182 
183  if (TYPE==TILE){
184  negbarrelbeg = outset.upper_bound(0x51000f);
185  negbarrelend = outset.lower_bound(0x530000);
186  for(itset = negbarrelbeg; itset != negbarrelend; ++itset){
187  outList.push_back(*itset);
188  }
189  for(itset = outset.begin(); itset != negbarrelbeg; ++itset){
190  outList.push_back(*itset);
191  }
192  for(itset = negbarrelend; itset != outset.end(); ++itset){
193  outList.push_back(*itset);
194  }
195  }else{
196  for(itset = outset.begin(); itset != outset.end(); ++itset){
197  outList.push_back(*itset);
198  }
199  }
200 
201 }
202 
204 
205 
206  for( size_t i=0; i< detLut->maxHash(); ++i) {
207  writeLine(detLut->layerDiskPosition(i),
208  detLut->layerDiskNumber(i),
209  detLut->hashId(i),
210  detLut->robId(i),
211  detLut->etaMin(i),
212  detLut->etaMax(i),
213  detLut->phiMin(i),
214  detLut->phiMax(i));
215  // std::cout << "RSDEBUG i=" << i << " hashid=" << detLut.hashId(i) << std::endl;
216  }
217 
218 }
219 
221  double etaminIn, double etamaxIn,
222  double phiminIn, double phimaxIn,
223  std::vector<IdentifierHash>& outList) const {
224 
225  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
226 
227  std::list<RegSelectorMapElement>::const_iterator it;
228  std::set<IdentifierHash> outset;
229  std::set<IdentifierHash>::const_iterator itset, negbarrelbeg,negbarrelend;
230  bool divideEta = false;
231 
232  for(it = m_barreldataList.begin(); //barrel list
233  it != m_barreldataList.end(); ++it){ // runs trought all RegSelectElementUints
234  (*it).selection(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
235  }
236 
237  switch(TYPE){
238  case TILE: divideEta = true; break;
239  default: break;
240  }
241 
242  if( divideEta ){
243  if(etaminIn < 0 || etamaxIn < 0){ // negative data list
244  for(it = m_negdataList.begin();it != m_negdataList.end(); ++it){ // runs trought all RegSelectElementUints
245  (*it).selection(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
246  }
247  }
248 
249  if( etaminIn >= 0 || etamaxIn >= 0 ){ // positive data list
250  for(it = m_posdataList.begin();it != m_posdataList.end(); ++it){ // runs trought all RegSelectElementUints
251  (*it).selection(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
252  }
253  }
254  }
255  else{
256  for(it = m_negdataList.begin();it != m_negdataList.end(); ++it){ // runs trought all RegSelectElementUints
257  (*it).selection(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
258  }
259  for(it = m_posdataList.begin();it != m_posdataList.end(); ++it){ // runs trought all RegSelectElementUints
260  (*it).selection(etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
261  }
262  }
263 
264  if (TYPE==TILE){
265  negbarrelbeg = outset.upper_bound(0x3f);
266  negbarrelend = outset.lower_bound(0x80);
267  for(itset = negbarrelbeg; itset != negbarrelend; ++itset){
268  outList.push_back(*itset);
269  }
270  for(itset = outset.begin(); itset != negbarrelbeg; ++itset){
271  outList.push_back(*itset);
272  }
273  for(itset = negbarrelend; itset != outset.end(); ++itset){
274  outList.push_back(*itset);
275  }
276  } else{
277  for(itset = outset.begin(); itset != outset.end(); ++itset){
278  outList.push_back(*itset);
279  }
280  }
281 
282 }
283 
285  double etaminIn, double etamaxIn,
286  double phiminIn, double phimaxIn,
287  std::vector<IdentifierHash>& outList) const {
288 
289  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
290 
291  std::list<RegSelectorMapElement>::const_iterator it;
292  std::set<IdentifierHash> outset;
293  std::set<IdentifierHash>::const_iterator itset;
294  bool posORneg;
295 
296 
297  if( etaminIn > 0 && etamaxIn > 0 ){ //search positive list to find TYPEID
298  posORneg = false; // it's POSITIVE
299  findPosition(typeinID,posORneg, it);
300  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
301  }
302  else if( etaminIn < 0 && etamaxIn < 0 ){ //search negative list to find TYPEID
303  posORneg = true; // it's NEGATIVE
304  findPosition(typeinID,posORneg, it);
305  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
306  }
307  else { //search both list to find TYPEID
308  posORneg = false;
309  findPosition(typeinID,posORneg, it);
310  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
311  posORneg = true;
312  findPosition(typeinID,posORneg, it);
313  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
314  }
315 
316  for(itset = outset.begin(); itset != outset.end(); ++itset){
317  outList.push_back(*itset);
318  }
319 }
320 
321 
322 
323 void RegSelectorMap::regionSelector( long layNumber,
324  double etaminIn, double etamaxIn,
325  double phiminIn, double phimaxIn,
326  std::vector<IdentifierHash>& outList) const {
327 
328  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
329 
330  std::list<RegSelectorMapElement>::const_iterator it, itEnd;
331  std::set<IdentifierHash> outset;
332  std::set<IdentifierHash>::const_iterator itset;
333  bool posORneg;
334 
335 
336  if( etaminIn > 0 && etamaxIn > 0 ){ //search positive list to find layNumber
337  posORneg = false; // it's POSITIVE
338  findPosition(layNumber,posORneg, it);
339  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
340  }
341  else if( etaminIn < 0 && etamaxIn < 0 ){ //search negative list to find layNumber
342  posORneg = true; // it's NEGATIVE
343  findPosition(layNumber,posORneg, it);
344  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
345  }
346 
347  // barrel
348  it = m_barreldataList.begin();
349  itEnd = m_barreldataList.end();
350 
351  while(it != itEnd) {
352  if( (*it).layerDiskNumber() == layNumber )
353  break;
354  ++it;
355  }
356  // cppcheck-suppress derefInvalidIteratorRedundantCheck; we assume the above loop
357  // always succeeds finding the layer, see also the comment in ::findPosition().
358  (*it).selection( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
359 
360  for(itset = outset.begin(); itset != outset.end(); ++itset){
361  outList.push_back(*itset);
362  }
363 
364 }
365 
367 
368  StatusCode sc = StatusCode::SUCCESS;
369 
370  // use path resolver to find full path to file
371  std::string unresolvedFileName(filename);
372  std::string fullFileName = PathResolver::find_file (unresolvedFileName, "DATAPATH");
373  //log << MSG::DEBUG << "PathResolver found " << fullFileName << endmsg;
374  if (fullFileName == "") {
375  //log << MSG::FATAL << "Could not find input file in DATAPATH" << unresolvedFileName<< endmsg;
376  std::cerr << "RegSelectorMap: FATAL: Could not find input file in DATAPATH" << unresolvedFileName<< std::endl;
377  return StatusCode::FAILURE;
378  }
379  //std::cout << "RegSelectDataIdentifierHash::read fullFileName=" << fullFileName << std::endl;
380 
381  switch(type){
382  case TILE:
383  sc = readTILE(fullFileName.c_str());
384  break;
385  default:
388  // ATH_MSG_ERROR( "Don't EVER use this code for anything except the Tile Calorimeter" );
389  sc = StatusCode::FAILURE;
390  }
391  return sc;
392 }
393 
394 void RegSelectorMap::summaryDataFile(std::list<RegSelectorMapElement> &dataList){
396 
397  for(it = dataList.begin(); it != dataList.end(); ++it){ // runs through entire list
398  std::cout << "position: " << (*it).layerDiskPosition() << " number: " << (*it).layerDiskNumber() << std::endl;
399  std::cout << "etamin: " << m_etaminDet << " etamax: " << m_etamaxDet << std::endl;
400  std::cout << "phimin: " << m_phiminDet << " phimax: " << m_phimaxDet << std::endl;
401  std::cout << "hashId: ";
402  std::vector<IdentifierHash> aux = (*it).hashId();
403  for(std::vector<IdentifierHash>::iterator i = aux.begin(); i != aux.end(); ++i)
404  std::cout << (*i) << " ";
405  std::cout << std::endl;
406  std::cin.get();
407  }
408 }
409 
410 
411 
412 void RegSelectorMap::verifyInputsInternal( double &etaminIn, double &etamaxIn,
413  double &phiminIn, double &phimaxIn ) const {
414 
415  while (phiminIn > 2*M_PI) phiminIn -= 2*M_PI;
416  while (phiminIn < 0 ) phiminIn += 2*M_PI;
417  while (phimaxIn > 2*M_PI) phimaxIn -= 2*M_PI;
418  while (phimaxIn < 0 ) phimaxIn += 2*M_PI;
419 
420  if( ( (etaminIn < m_etaminDet) && (etamaxIn < m_etaminDet) ) ||
421  ( (etaminIn > m_etamaxDet) && (etamaxIn > m_etamaxDet) ) ){
422  }
423  else{
424  if( (etaminIn < m_etaminDet) && (etamaxIn > m_etaminDet) ){
425  etaminIn = m_etaminDet;
426  }
427  if( (etamaxIn > m_etamaxDet) && (etaminIn < m_etamaxDet) ){
428  etamaxIn = m_etamaxDet;
429  }
430  }
431 
432 }
433 
434 
435 StatusCode RegSelectorMap::verifyInputs( double &etaminIn, double &etamaxIn,
436  double &phiminIn, double &phimaxIn ) const {
437  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
438  return StatusCode::SUCCESS;
439 }
440 
441 
442 
443 StatusCode RegSelectorMap::verifyInputsMinusPi( double &etaminIn, double &etamaxIn,
444  double &phiminIn, double &phimaxIn) const {
445 
446  StatusCode sc = StatusCode::SUCCESS;
447 
448  while (phiminIn > M_PI) phiminIn -= 2*M_PI;
449  while (phiminIn < -M_PI) phiminIn += 2*M_PI;
450  while (phimaxIn > M_PI) phimaxIn -= 2*M_PI;
451  while (phimaxIn < -M_PI) phimaxIn += 2*M_PI;
452 
453  if( ( (etaminIn < m_etaminDet) && (etamaxIn < m_etaminDet) ) ||
454  ( (etaminIn > m_etamaxDet) && (etamaxIn > m_etamaxDet) ) ){
455  //sc = StatusCode::FAILURE;
456  }
457  else{
458  if( (etaminIn < m_etaminDet) && (etamaxIn > m_etaminDet) ){
459  etaminIn = m_etaminDet;
460  }
461  if( (etamaxIn > m_etamaxDet) && (etaminIn < m_etamaxDet) ){
462  etamaxIn = m_etamaxDet;
463  }
464  }
465 
466  return sc;
467 }
468 
469 void RegSelectorMap::verifyOutput( double etaminIn, double etamaxIn,
470  double phiminIn, double phimaxIn,
471  const std::vector<IdentifierHash>& outputIdlist) const {
472 
473  std::vector<IdentifierHash> outset;
474  int i;
475  unsigned int j;
476  double etamin, etamax, phimin, phimax;
477  int vecsize = m_etamin.size();
478  for( i= 0; i < vecsize; ++i){
479  if(m_etamin[i] > m_etamax[i]){
480  etamin = m_etamax[i]; etamax = m_etamin[i];
481  }
482  else{
483  etamin = m_etamin[i]; etamax = m_etamax[i];
484  }
485  if(m_phimin[i] > m_phimax[i]){
486  phimin = m_phimin[i];
487  phimax = phimaxValue();
488  if( (etaminIn <= etamax) && (etamaxIn >= etamin) ){
489  if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
490  outset.push_back(m_hashId[i]);
491  }
492  }
493  phimin = phiminValue();
494  phimax = m_phimax[i];
495  if( (etaminIn <= etamax) && (etamaxIn >= etamin) ){
496  if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
497  outset.push_back(m_hashId[i]);
498  }
499  }
500  }
501  else{
502  phimin = m_phimin[i]; phimax = m_phimax[i];
503  if( (etaminIn <= etamax) && (etamaxIn >= etamin) ){
504  if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
505  outset.push_back(m_hashId[i]);
506  }
507  }
508  }
509  }
510  if(outset == outputIdlist)
511  std::cout << "equal vectors " << std::endl;
512  std::cout << "desired output ";
513  for( j=0; j < outset.size(); ++j)
514  std::cout << std::dec << outset[j] << " ";
515  std::cout << std::endl;
516  std::cout << "obtained output ";
517  for( j=0; j < outputIdlist.size(); ++j)
518  std::cout << std::dec << outputIdlist[j] << " ";
519  std::cout << std::endl;
520 }
521 
522 
523 void RegSelectorMap::regionSelectorRobIdUint( double etaminIn, double etamaxIn,
524  double phiminIn, double phimaxIn,
525  std::vector<uint32_t>& outList) const {
526 
527  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
528 
529  std::set<uint32_t> outset;
530  int i;
531  unsigned int j;
532  double etamin, etamax, phimin, phimax;
533  std::vector<uint32_t> outvec;
534 
535  int vecsize = m_etamin.size();
536  for( i= 0; i < vecsize; ++i){
537  if(m_etamin[i] > m_etamax[i]){
538  etamin = m_etamax[i]; etamax = m_etamin[i];
539  }
540  else{
541  etamin = m_etamin[i]; etamax = m_etamax[i];
542  }
543  if(m_phimin[i] > m_phimax[i]){
544  phimin = m_phimin[i];
545  phimax = phimaxValue();
546  if( (etaminIn <= etamax) && (etamaxIn >= etamin) ){
547  if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
548  outset.insert(m_robId[i]);
549  }
550  }
551  phimin = phiminValue();
552  phimax = m_phimax[i];
553  if( (etaminIn <= etamax) && (etamaxIn >= etamin) ){
554  if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
555  outset.insert(m_robId[i]);
556  }
557  }
558  }
559  else{
560  phimin = m_phimin[i]; phimax = m_phimax[i];
561  if( (etaminIn <= etamax) && (etamaxIn >= etamin) ){
562  if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
563  outset.insert(m_robId[i]);
564  }
565  }
566  }
567  }
568 
570  for(it = outset.begin(); it != outset.end(); ++it)
571  outvec.push_back(*it);
572 
573  if(outvec == outList)
574  std::cout << "equal vectors " << std::endl;
575  std::cout << "desired output ";
576  for( j=0; j < outvec.size(); ++j)
577  std::cout << std::dec << outvec[j] << " ";
578  std::cout << std::endl;
579  std::cout << "obtained output ";
580  for( j=0; j < outList.size(); ++j)
581  std::cout << std::dec << outList[j] << " ";
582  std::cout << std::endl;
583 }
584 
585 
586 
587 
589  double etaminIn, double etamaxIn,
590  double phiminIn, double phimaxIn,
591  std::vector<uint32_t>& outList) const {
592 
593  verifyInputsInternal( etaminIn, etamaxIn, phiminIn, phimaxIn );
594 
595  std::set<uint32_t> outset;
596  std::list<RegSelectorMapElement>::const_iterator it, itEnd;
597  std::set<uint32_t>::const_iterator itset;
598  bool posORneg;
599 
600 
601  if( etaminIn > 0 && etamaxIn > 0 ){ //search positive list to find layNumber
602  posORneg = false; // it's POSITIVE
603  findPosition(layNumber,posORneg, it);
604  (*it).selectionRobIdUint( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
605  }
606  else if( etaminIn < 0 && etamaxIn < 0 ){ //search negative list to find layNumber
607  posORneg = true; // it's NEGATIVE
608  findPosition(layNumber,posORneg, it);
609  (*it).selectionRobIdUint( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
610  }
611 
612  // barrel
613  it = m_barreldataList.begin();
614  itEnd = m_barreldataList.end();
615 
616  while(it != itEnd) {
617  if( (*it).layerDiskNumber() == layNumber )
618  break;
619  ++it;
620  }
621  // cppcheck-suppress derefInvalidIteratorRedundantCheck; we assume the above loop
622  // always succeeds finding the layer, see also the comment in ::findPosition().
623  (*it).selectionRobIdUint( etaminIn, etamaxIn, phiminIn, phimaxIn, outset);
624 
625  for(itset = outset.begin(); itset != outset.end(); ++itset){
626  outList.push_back(*itset);
627  }
628 
629 }
630 
631 void RegSelectorMap::findPosition( TYPEID typeinID, bool posORneg,
632  std::list<RegSelectorMapElement>::const_iterator& it) const {
633 
634  std::list<RegSelectorMapElement>::const_iterator itPos, itNeg, itEnd;
635 
636  itPos = m_posdataList.begin(); // positioning iterator at the begining of POSITIVE eta value list
637  // each element of this list is a EtaPhiMap of a MDT chamber
638  itNeg = m_negdataList.begin(); // NEGATIVE eta value list of MDT chambers
639 
640  if(posORneg == false){ // it's positive
641  it = itPos;
642  itEnd = m_posdataList.end();
643  }
644  else{
645  it = itNeg;
646  itEnd = m_negdataList.end();
647  }
648 
653 
654  while(it != itEnd) {
655  if( (*it).layerDiskNumber() == typeinID )
656  break;
657  ++it;
658  }
659 
660 }
661 
662 void RegSelectorMap::findPosition( long layNumber, bool posORneg,
663  std::list<RegSelectorMapElement>::const_iterator& it) const {
664 
665  std::list<RegSelectorMapElement>::const_iterator itPos, itNeg, itEnd;
666 
667  itPos = m_posdataList.begin(); // positioning iterator at the begining of POSITIVE eta value list
668  itNeg = m_negdataList.begin(); // NEGATIVE eta value list
669 
670  if(posORneg == false){ // it's positive
671  it = itPos;
672  itEnd = m_posdataList.end();
673  }
674  else{
675  it = itNeg;
676  itEnd = m_negdataList.end();
677  }
678 
679  while(it != itEnd) {
680  if( (*it).layerDiskNumber() == layNumber )
681  break;
682  ++it;
683  }
684 
685 }
686 
687 void RegSelectorMap::findMaxMinValues(std::list<RegSelectorMapElement> &dataList) {
688 
690 
691  for(it = dataList.begin(); it != dataList.end(); ++it){ // runs through entire list
692  if( (*it).etaminElem() < m_etaminDet )
693  m_etaminDet = (*it).etaminElem();
694  if( (*it).etamaxElem() > m_etamaxDet )
695  m_etamaxDet = (*it).etamaxElem();
696  if( (*it).phiminElem() < m_phiminDet )
697  m_phiminDet = (*it).phiminElem();
698  if( (*it).phimaxElem() > m_phimaxDet )
699  m_phimaxDet = (*it).phimaxElem();
700  }
701 
702 }
703 
704 RegSelectorMapElement RegSelectorMap::creatingElement( int& positionIn, int& numberIn, //????
705  double& etaminIn, double& etamaxIn,
706  double& phiminIn, double& phimaxIn,
707  IdentifierHash& hashIdIn, uint32_t& robIdIn ) {
708  RegSelectorMapElement newElement;
709 
710  newElement.additem( hashIdIn,
711  etaminIn, etamaxIn,
712  phiminIn, phimaxIn,
713  numberIn, positionIn, robIdIn );
714 
715  return newElement;
716 }
717 
718 void RegSelectorMap::insertList(std::list<RegSelectorMapElement> &dataList, int positionIn,
719  int numberIn, double etaminIn, double etamaxIn,
720  double phiminIn, double phimaxIn,
721  IdentifierHash hashIdIn, uint32_t& robIdIn){
722  bool flag = false;
723  RegSelectorMapElement newElement;
725 
726  for(it = dataList.begin(); it != dataList.end(); ++it){ // runs through entire positive list
727  if( positionIn == (*it).layerDiskPosition() ){ // position already exist
728  flag = false;
729  if( numberIn == (*it).layerDiskNumber() ) {// number already exist
730  (*it).additem( hashIdIn, etaminIn, etamaxIn,
731  phiminIn, phimaxIn, numberIn, positionIn, robIdIn );
732  break;
733  }
734  else
735  flag = true;
736  }
737  else // position & number doesn't exist
738  flag = true;
739  } // end for
740 
741  if(flag == true || dataList.size() == 0){ // inserting new element
742  newElement = creatingElement(positionIn, numberIn,
743  etaminIn,etamaxIn,
744  phiminIn, phimaxIn,
745  hashIdIn, robIdIn);
746  dataList.push_back( newElement );
747  }
748 }
749 
750 void RegSelectorMap::insertDataElement(int& positionIn, int& numberIn, double& etaminIn, double& etamaxIn,
751  double& phiminIn, double& phimaxIn, IdentifierHash& hashIdIn, uint32_t& robIdIn){
752  if(positionIn > 0 ){ // list of positive values
753  insertList(m_posdataList, positionIn, numberIn,
754  etaminIn, etamaxIn, phiminIn, phimaxIn, hashIdIn, robIdIn);
755  }
756  else if(positionIn < 0){ // list of negative values
757  insertList(m_negdataList, positionIn, numberIn,
758  etaminIn, etamaxIn, phiminIn, phimaxIn, hashIdIn, robIdIn);
759  }
760  else if(positionIn == 0){
761  insertList(m_barreldataList, positionIn, numberIn,
762  etaminIn, etamaxIn, phiminIn, phimaxIn, hashIdIn, robIdIn);
763  }
764 }
765 
766 void RegSelectorMap::writeLine(int barORend, int layORdsk, IdentifierHash hashId, uint32_t robId,
767  double emin, double emax,
768  double pmin, double pmax){
769 
770  m_barORend.push_back(barORend);
771  m_layORdsk.push_back(layORdsk);
772  m_hashId.push_back(hashId);
773  m_robId.push_back(robId);
774  m_etamin.push_back(emin);
775  m_etamax.push_back(emax);
776  m_phimin.push_back(pmin);
777  m_phimax.push_back(pmax);
778 }
779 
781  StatusCode sc = StatusCode::SUCCESS;
782  char buffer_[256];
783  char *buffer = buffer_;
784  int barORend =0, layORwhe =0;
785  IdentifierHash hashId;
786  double emin, emax, pmin, pmax;
787  uint32_t robid, collid;
788 
789  std::ifstream fin(filename);
790  if(fin.bad()){ //Test if the file failed:
791  sc = StatusCode::FAILURE;
792  return sc;
793  }
794  fin.getline(buffer,128,'\n');
795  while (fin.getline(buffer, 128, '\n')){
796  if (strncmp(buffer,"#",1)!=0){
797  sscanf(buffer, "%x %x %x %lf %lf %lf %lf", &robid, &collid, (unsigned int*)&hashId, &emin, &emax, &pmin, &pmax);
798  writeLine(barORend, layORwhe, hashId, robid, emin, emax, pmin, pmax);
799  }
800  }
801  fin.close();
802 
803  return sc;
804 }
805 
806 
807 
809  double *etaMin, double *etaMax,
810  double *phiMin, double *phiMax) const {
811 
812  (*etaMin) = m_etamin[hashId];
813  (*etaMax) = m_etamax[hashId];
814  (*phiMin) = m_phimin[hashId];
815  (*phiMax) = m_phimax[hashId];
816 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RegSelectorMap::phimaxValue
double phimaxValue(void) const
Definition: RegSelectorMap.cxx:77
RegSelectorMap::read
StatusCode read(const char *filename, DETID type)
Definition: RegSelectorMap.cxx:366
RegSelectorMap::phiminValue
double phiminValue(void) const
Definition: RegSelectorMap.cxx:73
RegSelectorMap::writeLine
void writeLine(int barORend, int layORdsk, IdentifierHash hashId, uint32_t robId, double emin, double emax, double pmin, double pmax)
Definition: RegSelectorMap.cxx:766
RegSelectorMap::etaminValue
double etaminValue(void) const
the rest of the class starts here
Definition: RegSelectorMap.cxx:65
RegionSelectorLUT::layerDiskPosition
int layerDiskPosition(int hashId) const
Definition: RegionSelectorLUT.cxx:32
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
IRoiDescriptor::etaMinus
virtual double etaMinus() const =0
RegSelectorMap::insertList
void insertList(std::list< RegSelectorMapElement > &dataList, int positionIn, int numberIn, double etaminIn, double etamaxIn, double phiminIn, double phimaxIn, IdentifierHash hashIdIn, uint32_t &robIdIn)
Definition: RegSelectorMap.cxx:718
RegSelectorMap::etamaxValue
double etamaxValue(void) const
Definition: RegSelectorMap.cxx:69
RegSelectorMapElement
Definition: RegSelectorMapElement.h:17
RegSelectorMap::hashIdOut
const std::vector< IdentifierHash > & hashIdOut(void) const
Definition: RegSelectorMap.cxx:81
RegSelectorMap::getEtaPhi
void getEtaPhi(IdentifierHash hashId, double *etaMin, double *etaMax, double *phiMin, double *phiMax) const
Definition: RegSelectorMap.cxx:808
RegSelectorMap::m_barORend
std::vector< int > m_barORend
Definition: RegSelectorMap.h:152
skel.it
it
Definition: skel.GENtoEVGEN.py:396
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
RegionSelectorLUT::maxHash
unsigned int maxHash(void) const
Definition: RegionSelectorLUT.cxx:68
IRoiDescriptor::etaPlus
virtual double etaPlus() const =0
RegionSelectorLUT::etaMin
double etaMin(int hashId) const
Definition: RegionSelectorLUT.cxx:40
RegSelectorMap::m_phimaxDet
double m_phimaxDet
Definition: RegSelectorMap.h:164
RegSelectorMap::m_posdataList
std::list< RegSelectorMapElement > m_posdataList
Definition: RegSelectorMap.h:150
RegSelectorMapElement::additem
void additem(const IdentifierHash hashId, const double etaMin, const double etaMax, const double phiMin, const double phiMax, const int layerDiskNumber, const int layerDiskPosition, const uint32_t robId)
Definition: RegSelectorMapElement.cxx:193
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
RegSelectorMap::verifyInputsMinusPi
StatusCode verifyInputsMinusPi(double &etaminIn, double &etamaxIn, double &phiminIn, double &phimaxIn) const
Definition: RegSelectorMap.cxx:443
RegSelectorMap::m_layORdsk
std::vector< int > m_layORdsk
Definition: RegSelectorMap.h:152
DETID
DETID
An enum to define subdetector names.
Definition: RegSelEnums.h:23
RegionSelectorLUT::phiMax
double phiMax(int hashId) const
Definition: RegionSelectorLUT.cxx:52
RegSelectorMap::addLut
void addLut(const RegionSelectorLUT *detLut)
Definition: RegSelectorMap.cxx:203
RegSelectorMap::HashIDList_internal
virtual void HashIDList_internal(const IRoiDescriptor &roi, std::vector< IdentifierHash > &idlist) const
internal lookup table access for full interface ...
Definition: RegSelectorMap.cxx:40
RegSelectorMap::layORdskOut
const std::vector< int > & layORdskOut(void) const
Definition: RegSelectorMap.cxx:93
RegSelectorMap::etaMinOut
const std::vector< double > & etaMinOut(void) const
Definition: RegSelectorMap.cxx:97
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
lumiFormat.i
int i
Definition: lumiFormat.py:85
RegSelectorMap::creatingElement
RegSelectorMapElement creatingElement(int &positionIn, int &numberIn, double &etaminIn, double &etamaxIn, double &phiminIn, double &phimaxIn, IdentifierHash &hashIdIn, uint32_t &robId)
Definition: RegSelectorMap.cxx:704
RegSelectorMap::barORendOut
const std::vector< int > & barORendOut(void) const
Definition: RegSelectorMap.cxx:89
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
master.flag
bool flag
Definition: master.py:29
RegSelectorMap::ROBIDList_internal
virtual void ROBIDList_internal(const IRoiDescriptor &roi, std::vector< uint32_t > &roblist) const
Rob identifier methods.
Definition: RegSelectorMap.cxx:52
IRoiDescriptor::phiMinus
virtual double phiMinus() const =0
RegSelectorMap::phiMinOut
const std::vector< double > & phiMinOut(void) const
Definition: RegSelectorMap.cxx:105
RegSelectorMap::ROBIDList
virtual void ROBIDList(const IRoiDescriptor &roi, std::vector< uint32_t > &roblist) const override
Rob identifier methods.
Definition: RegSelectorMap.cxx:28
TYPEID
TYPEID
An enum to define Muon chambers names.
Definition: RegSelEnums.h:9
IRoiDescriptor::phiPlus
virtual double phiPlus() const =0
extreme phi values
RegSelectorMap.h
TYPE
#define TYPE(CODE, TYP, IOTYP)
RegSelectorMap::regionSelector
void regionSelector(DETID TYPE, double etaminIn, double etamaxIn, double phiminIn, double phimaxIn, std::vector< IdentifierHash > &outList) const
Definition: RegSelectorMap.cxx:220
RegSelectorMap::m_etamin
std::vector< double > m_etamin
Definition: RegSelectorMap.h:158
RegionSelectorLUT::robId
int robId(int hashId) const
Definition: RegionSelectorLUT.cxx:60
PathResolver.h
RegSelectorMap::m_etamaxDet
double m_etamaxDet
Definition: RegSelectorMap.h:162
RegSelectorMap::verifyInputsInternal
void verifyInputsInternal(double &etaminIn, double &etamaxIn, double &phiminIn, double &phimaxIn) const
Definition: RegSelectorMap.cxx:412
RegSelectorMap::phiMaxOut
const std::vector< double > & phiMaxOut(void) const
Definition: RegSelectorMap.cxx:109
RegionSelectorLUT::layerDiskNumber
int layerDiskNumber(int hashId) const
Definition: RegionSelectorLUT.cxx:36
RegSelectorMap::insertDataElement
void insertDataElement(int &positionIn, int &numberIn, double &etaminIn, double &etamaxIn, double &phiminIn, double &phimaxIn, IdentifierHash &hashIdIn, uint32_t &robIdIn)
Definition: RegSelectorMap.cxx:750
TILE
@ TILE
Definition: RegSelEnums.h:30
RegSelectorMap::m_etaminDet
double m_etaminDet
Definition: RegSelectorMap.h:162
RegSelectorMap::m_barreldataList
std::list< RegSelectorMapElement > m_barreldataList
Definition: RegSelectorMap.h:150
RegSelectorMap::m_etamax
std::vector< double > m_etamax
Definition: RegSelectorMap.h:158
RegSelectorMap::m_phimin
std::vector< double > m_phimin
Definition: RegSelectorMap.h:160
RegionSelectorLUT::etaMax
double etaMax(int hashId) const
Definition: RegionSelectorLUT.cxx:44
RegSelectorMap::m_phiminDet
double m_phiminDet
Definition: RegSelectorMap.h:164
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
RegSelectorMap::etaMaxOut
const std::vector< double > & etaMaxOut(void) const
Definition: RegSelectorMap.cxx:101
RegSelectorMap::verifyOutput
void verifyOutput(double etaminIn, double etamaxIn, double phiminIn, double phimaxIn, const std::vector< IdentifierHash > &outputIdlist) const
Definition: RegSelectorMap.cxx:469
RegSelectorMap::findPosition
void findPosition(TYPEID typeinID, bool posORneg, std::list< RegSelectorMapElement >::const_iterator &it) const
Definition: RegSelectorMap.cxx:631
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
zebraShift.outList
list outList
Definition: zebraShift.py:103
RegSelectorMap::m_robId
std::vector< uint32_t > m_robId
Definition: RegSelectorMap.h:156
IRoiDescriptor::isFullscan
virtual bool isFullscan() const =0
is this a full detector RoI?
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
RegSelectorMap::HashIDList
virtual void HashIDList(const IRoiDescriptor &roi, std::vector< IdentifierHash > &idlist) const override
implementation of the IRegSelUT interface - intentionally inlined
Definition: RegSelectorMap.cxx:18
compute_lumi.fin
fin
Definition: compute_lumi.py:19
RegSelectorMap::findMaxMinValues
void findMaxMinValues(std::list< RegSelectorMapElement > &dataList)
Definition: RegSelectorMap.cxx:687
RegSelectorMap::m_negdataList
std::list< RegSelectorMapElement > m_negdataList
Definition: RegSelectorMap.h:150
RegSelectorMap::summaryDataFile
void summaryDataFile(std::list< RegSelectorMapElement > &dataList)
Definition: RegSelectorMap.cxx:394
RegSelectorMap::robIdOut
const std::vector< uint32_t > & robIdOut(void) const
Definition: RegSelectorMap.cxx:85
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
RegSelectorMap::readTILE
StatusCode readTILE(const char *filename)
Definition: RegSelectorMap.cxx:780
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
RegSelectorMap::regionSelectorRobIdUint
void regionSelectorRobIdUint(DETID TYPE, double etaminIn, double etamaxIn, double phiminIn, double phimaxIn, std::vector< uint32_t > &outList) const
Definition: RegSelectorMap.cxx:139
RegionSelectorLUT::hashId
int hashId(int value) const
Definition: RegionSelectorLUT.cxx:64
RegionSelectorLUT
Definition: RegionSelectorLUT.h:14
RegSelectorMap::m_hashId
std::vector< IdentifierHash > m_hashId
Definition: RegSelectorMap.h:154
RegSelectorMap::m_phimax
std::vector< double > m_phimax
Definition: RegSelectorMap.h:160
RegionSelectorLUT::phiMin
double phiMin(int hashId) const
Definition: RegionSelectorLUT.cxx:48
RegSelectorMap::verifyInputs
StatusCode verifyInputs(double &etaminIn, double &etamaxIn, double &phiminIn, double &phimaxIn) const
Definition: RegSelectorMap.cxx:435
RegSelectorMap::mountDataStruct
void mountDataStruct(void)
Definition: RegSelectorMap.cxx:113