ATLAS Offline Software
RegSelSubDetector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /**************************************************************************
6  **
7  ** File: RegSelSubDetector.cxx
8  **
9  ** Description:
10  **
11  **
12  **
13  ** Author: M.Sutton
14  **
15  ** Created: Wed Apr 4 16:20:07 BST 2007
16  ** Modified:
17  **
18  **
19  **
20  **************************************************************************/
21 
22 
24 
25 #include <iostream>
26 #include <set>
27 
28 
29 
30 
31 void RegSelSubDetector::getModules(const RegSelRoI& roi, std::vector<const RegSelModule*>& modules) const {
32  for ( unsigned i=m_layer.size() ; i-- ; ) {
33  if ( m_layer[i].inRoI(roi) ) m_layer[i].getModules(roi, modules);
34  }
35 }
36 
37 
38 
39 void RegSelSubDetector::getModules(const RegSelRoI& roi, unsigned layer, std::vector<const RegSelModule*>& modules) const {
40 
41  // if mapping between logical and physical layers is needed...
42  if ( m_mapped ) {
43  std::map<unsigned, unsigned>::const_iterator litr = m_layermap.find(layer);
44  if ( litr==m_layermap.end() ) return;
45  else layer = litr->second;
46  }
47 
48  if ( layer<m_layer.size() ) {
49  if ( m_layer[layer].inRoI(roi) ) m_layer[layer].getModules(roi, modules);
50  }
51 
52 }
53 
54 
55 
56 
57 void RegSelSubDetector::getModules( unsigned layer, std::vector<const RegSelModule*>& modules) const {
58 
59  // if mapping between logical and physical layers is needed...
60  if ( m_mapped ) {
61  std::map<unsigned, unsigned>::const_iterator litr = m_layermap.find(layer);
62  if ( litr==m_layermap.end() ) return;
63  else layer = litr->second;
64  }
65 
66  if ( layer<m_layer.size() ) {
67  m_layer[layer].getModules(modules);
68  }
69 
70 }
71 
72 
73 
74 // setup the disabled modules list for this subdetector
75 
79  while ( litr!=lend ) {
80  (*litr++).setupDisabledModuleList();
81  }
82 }
83 
84 
86  for ( unsigned i=0 ; i<m_Nlayers ; i++ ) m_layer[i].reset();
87 }
88 
89 
90 void RegSelSubDetector::addModules(std::vector<RegSelModule>& modules)
91 {
92  // barrel
93  // make the layer vector have the correct number of layers
94 
95  // calculate the number of layers, and get the map of logical
96  // layer number to physical layer number
97 
98  std::set<unsigned> layerset;
99 
100  std::vector<RegSelModule>::iterator mptr(modules.begin());
101 
102  for ( ; mptr!=modules.end() ; ++mptr ) {
103  int layer = mptr->layer();
104  int detector = mptr->detector();
105 
106  if ( !mptr->enabled() ) continue;
107 
108  if ( detector == ID() ) layerset.insert(layer);
109  }
110 
111  // if no modules, don't need to do anything...
112 
113  m_Nlayers = layerset.size();
114 
115  if ( m_Nlayers==0 ) return;
116 
117  // set up the layer map, the variable m_mapped will be used
118  // to know whether to use logical, or physical layer numbers
119  // in subsequent lookups
120 
121  std::set<unsigned>::iterator litr = layerset.begin();
122  std::set<unsigned>::iterator lend = layerset.end();
123 
124  m_mapped = false;
125  for ( unsigned i=0 ; litr!=lend ; ++litr, i++ ) {
126  // std::cout << "\t\tRegSelSubDetector::addModules() layer " << *litr << " -> " << i << std::endl;
127  if ( *litr!=i ) m_mapped = true;
128  m_layermap.insert( std::map<unsigned, unsigned>::value_type( *litr, i ) );
129  }
130 
131  // now actually create and set up the layers for this subdetector
132 
133  // std::cout << "\t\tRegSelSubDetector::addModules() created with " << m_Nlayers << " layers\tmapped " << m_mapped << std::endl;
134 
135  m_layer.resize(m_Nlayers);
136 
137  for ( mptr=modules.begin() ; mptr!=modules.end() ; ++mptr ) {
138 
139  int detector = mptr->detector();
140 
141  if ( detector == ID() ) {
142 
143  if ( !mptr->enabled() ) continue;
144 
145  if ( !m_mapped ) m_layer[mptr->layer()].addModule(*mptr);
146  else {
147  std::map<unsigned, unsigned>::iterator litr = m_layermap.find(mptr->layer());
148  // if ( litr!=m_layermap.end() )
149  m_layer[litr->second].addModule(*mptr);
150  // else std::cerr << "module - layer mismatch " << *mptr << std::endl;
151  }
152 
153  }
154  }
155 
156  // std::cout << "RegSelSubDetector::addModules() detector extent" << std::endl;
157 
158  for ( unsigned i=0 ; i<m_Nlayers ; i++ ) {
159  m_layer[i].ID(i);
160 
161  if ( i==0 ) {
162  rMin(m_layer[i].rMin());
163  rMax(m_layer[i].rMax());
164 
165  zMin(m_layer[i].zMin());
166  zMax(m_layer[i].zMax());
167  }
168  else {
169  if ( m_layer[i].rMin()<rMin() ) rMin(m_layer[i].rMin());
170  if ( m_layer[i].rMax()>rMax() ) rMax(m_layer[i].rMax());
171 
172  if ( m_layer[i].zMin()<zMin() ) zMin(m_layer[i].zMin());
173  if ( m_layer[i].zMax()>zMax() ) zMax(m_layer[i].zMax());
174  }
175 
176  // std::cout << m_layer[i] << std::endl;
177  m_layer[i].createMaps();
178 
179  }
180 
181  // std::cout << "Detector " << getName()
182  // << "\tr=" << rMin() << " - " << rMax()
183  // << ",\tz=" << zMin() << " - " << zMax()
184  // << std::endl;
185 
186 }
187 
188 
189 
190 // disabling and enabling an entire layer
191 
193  if ( !m_mapped ) {
194  if ( layer<m_Nlayers ) m_layer[layer].disable();
195  }
196  else {
198  if ( litr!=m_layermap.end() ) m_layer[litr->second].disable();
199  }
200 }
201 
203  if ( !m_mapped ) {
204  if ( layer<m_Nlayers ) m_layer[layer].enable();
205  }
206  else {
208  if ( litr!=m_layermap.end() ) m_layer[litr->second].enable();
209  }
210 }
211 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RegSelSubDetector::m_Nlayers
unsigned m_Nlayers
Definition: RegSelSubDetector.h:120
RegSelSubDetector::m_mapped
bool m_mapped
Definition: RegSelSubDetector.h:124
TRTCalib_cfilter.detector
detector
Definition: TRTCalib_cfilter.py:241
ZRObject::rMin
double rMin() const
Definition: ZRObject.h:80
RegSelSubDetector::reset
void reset()
Definition: RegSelSubDetector.cxx:85
RegSelSubDetector::m_layer
std::vector< RegSelLayer > m_layer
Definition: RegSelSubDetector.h:121
ZRObject::rMax
double rMax() const
Definition: ZRObject.h:81
RegSelSubDetector::addModules
void addModules(std::vector< RegSelModule > &modules)
Definition: RegSelSubDetector.cxx:90
ZRObject::zMin
double zMin() const
Definition: ZRObject.h:83
RegSelSubDetector::ID
int ID() const
Definition: RegSelSubDetector.h:103
lumiFormat.i
int i
Definition: lumiFormat.py:85
RegSelSubDetector::setupDisabledModules
void setupDisabledModules()
Definition: RegSelSubDetector.cxx:76
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
RegSelRoI
Definition: RegSelRoI.h:32
ZRObject::zMax
double zMax() const
Definition: ZRObject.h:84
RegSelSubDetector.h
RegSelSubDetector::m_layermap
std::map< unsigned, unsigned > m_layermap
Definition: RegSelSubDetector.h:123
RegSelSubDetector::enableLayer
void enableLayer(unsigned layer)
Definition: RegSelSubDetector.cxx:202
RegSelSubDetector::disableLayer
void disableLayer(unsigned layer)
Definition: RegSelSubDetector.cxx:192
ZRObject::inRoI
virtual bool inRoI(const RegSelRoI &roi) const
Definition: ZRObject.h:71
RegSelSubDetector::getModules
void getModules(const RegSelRoI &roi, std::vector< const RegSelModule * > &modules) const
Definition: RegSelSubDetector.cxx:31