CMS 3D CMS Logo

HcalLayerDepthMap.cc
Go to the documentation of this file.
2 
5 #include<algorithm>
6 
7 //#define EDM_ML_DEBUG
8 
10  subdet_ = 0;
11  ietaMin_ = ietaMax_ = 0;
12  depthMin_= 99;
13  depthMax_=-1;
14  dep29C_ = 2;
15  wtl0C_ = 1.;
16 }
17 
19 
20 void HcalLayerDepthMap::initialize(const int subdet, const int ietaMax,
21  const int dep16C, const int dep29C,
22  const double wtl0C,
23  std::vector<int> const& iphi,
24  std::vector<int> const& ieta,
25  std::vector<int> const& layer,
26  std::vector<int> const& depth) {
27 
28  subdet_ = subdet;
29  ietaMin_ = ietaMax_ = ietaMax;
30  dep16C_ = dep16C;
31  dep29C_ = dep29C;
32  wtl0C_ = wtl0C;
33  iphi_.insert(iphi_.end(),iphi.begin(),iphi.end());
34  layer2Depth_.clear(); depth2LayerF_.clear(); depth2LayerB_.clear();
35  depthMin_= 99;
36  depthMax_=-1;
37  for (unsigned int k=0; k<ieta.size(); ++k) {
38  if (ieta[k] < ietaMin_) ietaMin_ = ieta[k];
39  if (depth[k] < depthMin_) depthMin_ = depth[k];
40  if (depth[k] > depthMax_) depthMax_ = depth[k];
41  }
42  //Assume ieta, layer, depth are in increasing order of ieta and depth
43  for (unsigned int k1=0; k1<ieta.size(); ++k1) {
44  int ietaMin = ieta[k1];
45  int ietaMax = ietaMax_;
46  int layMin = layer[k1];
47  int layMax = (k1+1 < ieta.size()) ? (layer[k1+1]-1) : maxLayers_;
48  for (unsigned int k2=k1+1; k2<ieta.size(); ++k2) {
49  if (ieta[k2] > ieta[k1]) {
50  ietaMax = ieta[k2] - 1;
51  if (k2 == k1+1) layMax = maxLayers_;
52  break;
53  }
54  }
55  for (int eta=ietaMin; eta<=ietaMax; ++eta) {
56  depth2LayerF_[std::pair<int,int>(eta,depth[k1])] = layMin;
57  depth2LayerB_[std::pair<int,int>(eta,depth[k1])] = layMax;
58  for (int lay=layMin; lay<=layMax; ++lay)
59  layer2Depth_[std::pair<int,int>(eta,lay)] = depth[k1];
60  }
61  }
62  for (int eta=ietaMin_; eta<=ietaMax_; ++eta) {
63  int dmin(99), dmax(-1);
64  for (std::map<std::pair<int,int>,int>::iterator itr=layer2Depth_.begin();
65  itr != layer2Depth_.end(); ++itr) {
66  if ((itr->first).first == eta) {
67  if ((itr->second) < dmin) dmin = (itr->second);
68  if ((itr->second) > dmax) dmax = (itr->second);
69  }
70  }
71  if (subdet == 2) {
72  if (eta == ietaMin_) dmin = dep16C_;
73  else if (eta == ietaMax_) dmax = dep29C_;
74  }
75  depthsEta_[eta] = std::pair<int,int>(dmin,dmax);
76  }
77 #ifdef EDM_ML_DEBUG
78  std::cout << "HcalLayerDepthMap: Subdet " << subdet_ << " iEta " << ietaMin_
79  << ":" << ietaMax_ << " depth " << depthMin_ << ":" << depthMax_
80  << "\nMaximum Depth for last HE towers " << dep29C_
81  << " Layer 0 Weight " << wtl0C_ << " iPhi";
82  for (unsigned int k=0; k<iphi_.size(); ++k) std::cout << ":" << iphi_[k];
83  std::cout << std::endl << "Layer2Depth_ with " << layer2Depth_.size()
84  << " elements" << std::endl;
85  for (std::map<std::pair<int,int>,int>::iterator itr=layer2Depth_.begin();
86  itr != layer2Depth_.end(); ++itr)
87  std::cout << "iEta " << (itr->first).first << " Layer "
88  << (itr->first).second << " Depth " << itr->second << std::endl;
89  std::cout << "Depth2LayerFront with " << depth2LayerF_.size()
90  << " elemsts" << std::endl;
91  for (std::map<std::pair<int,int>,int>::iterator itr=depth2LayerF_.begin();
92  itr != depth2LayerF_.end(); ++itr)
93  std::cout << "iEta " << (itr->first).first << " Depth "
94  << (itr->first).second << " Layer " << itr->second << std::endl;
95  std::cout << "Depth2LayerBack with " << depth2LayerB_.size()
96  << " elemets" << std::endl;
97  for (std::map<std::pair<int,int>,int>::iterator itr=depth2LayerB_.begin();
98  itr != depth2LayerB_.end(); ++itr)
99  std::cout << "iEta " << (itr->first).first << " Depth "
100  << (itr->first).second << " Layer " << itr->second << std::endl;
101  std::cout << "DepthsEta_ with " << depthsEta_.size() << " elements\n";
102  for (std::map<int,std::pair<int,int> >::iterator itr=depthsEta_.begin();
103  itr != depthsEta_.end(); ++itr)
104  std::cout << "iEta " << itr->first << " Depths "
105  << (itr->second).first << ":" << (itr->second).second
106  << std::endl;
107 #endif
108 }
109 
110 int HcalLayerDepthMap::getDepth(const int subdet, const int ieta,
111  const int iphi, const int zside,
112  const int layer) const {
113  int depth(-1);
114  if (isValid(subdet,iphi,zside)) {
115  std::map<std::pair<int,int>,int>::const_iterator itr = layer2Depth_.find(std::pair<int,int>(ieta,layer));
116  if (itr != layer2Depth_.end()) depth = itr->second;
117  }
118 #ifdef EDM_ML_DEBUG
119  std::cout << "getDepth::Input " << subdet << ":" << ieta << ":" << iphi
120  << ":" << zside << ":" << layer << " Output " << depth <<std::endl;
121 #endif
122  return depth;
123 }
124 
125 int HcalLayerDepthMap::getDepth16(const int subdet, const int iphi,
126  const int zside) const {
127  int depth(-1);
128  if (isValid(subdet,iphi,zside)) depth = dep16C_;
129 #ifdef EDM_ML_DEBUG
130  std::cout << "getDepth16::Input " << subdet << ":" << iphi << ":" << zside
131  << " Output " << depth << std::endl;
132 #endif
133  return depth;
134 }
135 
136 int HcalLayerDepthMap::getDepthMin(const int subdet, const int iphi,
137  const int zside) const {
138  int depth = (isValid(subdet,iphi,zside)) ? depthMin_ : -1;
139 #ifdef EDM_ML_DEBUG
140  std::cout << "getDepthMin::Input " << subdet << ":" << iphi << ":" << zside
141  << " Output " << depth << std::endl;
142 #endif
143  return depth;
144 }
145 
146 int HcalLayerDepthMap::getDepthMax(const int subdet, const int iphi,
147  const int zside) const {
148  int depth = (isValid(subdet,iphi,zside)) ? depthMax_ : -1;
149 #ifdef EDM_ML_DEBUG
150  std::cout << "getDepthMax::Input " << subdet << ":" << iphi << ":" << zside
151  << " Output " << depth << std::endl;
152 #endif
153  return depth;
154 }
155 
156 int HcalLayerDepthMap::getDepthMax(const int subdet, const int ieta,
157  const int iphi, const int zside) const {
158  int depth = (isValid(subdet,iphi,zside)) ? getDepth(subdet,ieta,iphi,zside,maxLayers_) : -1;
159 #ifdef EDM_ML_DEBUG
160  std::cout << "getDepthMax::Input " << subdet << ":" << iphi << ":" << zside
161  << " Output " << depth << std::endl;
162 #endif
163  return depth;
164 }
165 
166 std::pair<int,int> HcalLayerDepthMap::getDepths(const int eta) const {
167 
168  std::map<int,std::pair<int,int> >::const_iterator itr = depthsEta_.find(eta);
169  if (itr == depthsEta_.end()) return std::pair<int,int>(-1,-1);
170  else return itr->second;
171 }
172 
173 int HcalLayerDepthMap::getLayerFront(const int subdet, const int ieta,
174  const int iphi, const int zside,
175  const int depth) const {
176  int layer(-1);
177  if (isValid(subdet,iphi,zside)) {
178  std::map<std::pair<int,int>,int>::const_iterator itr = depth2LayerF_.find(std::pair<int,int>(ieta,depth));
179  if (itr != depth2LayerF_.end()) layer = itr->second;
180  }
181 #ifdef EDM_ML_DEBUG
182  std::cout << "getLayerFront::Input " << subdet << ":" << ieta << ":" << iphi
183  << ":" << zside << ":" << depth << " Output " << layer <<std::endl;
184 #endif
185  return layer;
186 }
187 
188 int HcalLayerDepthMap::getLayerBack(const int subdet, const int ieta,
189  const int iphi, const int zside,
190  const int depth) const {
191  int layer(-1);
192  if (isValid(subdet,iphi,zside)) {
193  std::map<std::pair<int,int>,int>::const_iterator itr = depth2LayerB_.find(std::pair<int,int>(ieta,depth));
194  if (itr != depth2LayerB_.end()) layer = itr->second;
195  }
196 #ifdef EDM_ML_DEBUG
197  std::cout << "getLayerBack::Input " << subdet << ":" << ieta << ":" << iphi
198  << ":" << zside << ":" << depth << " Output " << layer <<std::endl;
199 #endif
200  return layer;
201 }
202 
203 void HcalLayerDepthMap::getLayerDepth(const int subdet, const int eta,
204  const int phi, const int zside,
205  std::map<int,int>& layers) const {
206  layers.clear();
207  if (isValid(subdet,phi,zside)) {
208  for (std::map<std::pair<int,int>,int>::const_iterator itr=layer2Depth_.begin();
209  itr != layer2Depth_.end(); ++itr) {
210  if ((itr->first).first == eta) {
211  layers[((itr->first).second)+1] = (itr->second);
212  }
213  }
214  }
215 #ifdef EDM_ML_DEBUG
216  std::cout << "getLayerDepth::Input " << subdet << ":" << eta << ":" << phi
217  << ":" << zside << " Output " << layers.size() << " entries\n";
218  for (std::map<int,int>::iterator itr=layers.begin(); itr != layers.end();
219  ++itr) std::cout << " [" << itr->first << "] " << itr->second;
220  std::cout << std::endl;
221 #endif
222 }
223 
225  std::map<int,int>& layers) const {
226  layers.clear();
227  if (subdet_ > 0) {
228  for (std::map<std::pair<int,int>,int>::const_iterator itr=layer2Depth_.begin();
229  itr != layer2Depth_.end(); ++itr) {
230  if ((itr->first).first == eta) {
231  layers[((itr->first).second)+1] = (itr->second);
232  }
233  }
234  }
235 #ifdef EDM_ML_DEBUG
236  std::cout << "getLayerDepth::Input " << eta << " Output " << layers.size()
237  << " entries\n";
238  for (std::map<int,int>::iterator itr=layers.begin(); itr != layers.end();
239  ++itr) std::cout << " [" << itr->first << "] " << itr->second;
240  std::cout << std::endl;
241 #endif
242 }
243 
244 int HcalLayerDepthMap::getMaxDepthLastHE(const int subdet, const int iphi,
245  const int zside) const {
246  int depth = isValid(subdet,iphi,zside) ? dep29C_ : -1;
247 #ifdef EDM_ML_DEBUG
248  std::cout << "getMaxDepthLastHE::Input " << subdet << ":" << iphi << ":"
249  << zside << " Output " << depth << std::endl;
250 #endif
251  return depth;
252 }
253 
254 double HcalLayerDepthMap::getLayer0Wt(const int subdet, const int iphi,
255  const int zside) const {
256  double wt = isValid(subdet,iphi,zside) ? wtl0C_ : -1.0;
257 #ifdef EDM_ML_DEBUG
258  std::cout << "getLayer0Wt::Input " << subdet << ":" << iphi << ":" << zside
259  << " Output " << wt << std::endl;
260 #endif
261  return wt;
262 }
263 
264 bool HcalLayerDepthMap::isValid(const int subdet, const int iphi,
265  const int zside) const {
266  bool flag(false);
267  int kphi = (zside > 0) ? iphi : -iphi;
268  if (subdet == subdet_)
269  flag = (std::find(iphi_.begin(),iphi_.end(),kphi) != iphi_.end());
270  return flag;
271 }
272 
273 int HcalLayerDepthMap::validDet(std::vector<int>& phi) const {
274 
275  phi.insert(phi.end(),iphi_.begin(),iphi_.end());
276  return subdet_;
277 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
void getLayerDepth(const int subdet, const int ieta, const int iphi, const int zside, std::map< int, int > &layers) const
void initialize(const int subdet, const int ietaMax, const int dep16C, const int dep29C, const double wtl0C, std::vector< int > const &iphi, std::vector< int > const &ieta, std::vector< int > const &layer, std::vector< int > const &depth)
bool isValid(const int det, const int phi, const int zside) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int getLayerBack(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
int getLayerFront(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
U second(std::pair< T, U > const &p)
std::pair< int, int > getDepths(const int eta) const
std::map< int, std::pair< int, int > > depthsEta_
int validDet(std::vector< int > &phis) const
std::map< std::pair< int, int >, int > depth2LayerF_
int getMaxDepthLastHE(const int subdet, const int iphi, const int zside) const
int getDepth(const int subdet, const int ieta, const int iphi, const int zside, const int layer) const
int getDepthMin(const int subdet, const int iphi, const int zside) const
int k[5][pyjets_maxn]
double getLayer0Wt(const int subdet, const int iphi, const int zside) const
int getDepth16(const int subdet, const int iphi, const int zside) const
std::map< std::pair< int, int >, int > layer2Depth_
std::vector< int > iphi_
std::map< std::pair< int, int >, int > depth2LayerB_
static const int maxLayers_
int getDepthMax(const int subdet, const int iphi, const int zside) const