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