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 (auto & itr : layer2Depth_) {
65  if ((itr.first).first == eta) {
66  if ((itr.second) < dmin) dmin = (itr.second);
67  if ((itr.second) > dmax) dmax = (itr.second);
68  }
69  }
70  if (subdet == 2) {
71  if (eta == ietaMin_) dmin = dep16C_;
72  else if (eta == ietaMax_) dmax = dep29C_;
73  }
74  depthsEta_[eta] = std::pair<int,int>(dmin,dmax);
75  }
76 #ifdef EDM_ML_DEBUG
77  std::cout << "HcalLayerDepthMap: Subdet " << subdet_ << " iEta " << ietaMin_
78  << ":" << ietaMax_ << " depth " << depthMin_ << ":" << depthMax_
79  << "\nMaximum Depth for last HE towers " << dep29C_
80  << " Layer 0 Weight " << wtl0C_ << " iPhi";
81  for (unsigned int k=0; k<iphi_.size(); ++k) std::cout << ":" << iphi_[k];
82  std::cout << std::endl << "Layer2Depth_ with " << layer2Depth_.size()
83  << " elements" << std::endl;
84  for (std::map<std::pair<int,int>,int>::iterator itr=layer2Depth_.begin();
85  itr != layer2Depth_.end(); ++itr)
86  std::cout << "iEta " << (itr->first).first << " Layer "
87  << (itr->first).second << " Depth " << itr->second << std::endl;
88  std::cout << "Depth2LayerFront with " << depth2LayerF_.size()
89  << " elemsts" << std::endl;
90  for (std::map<std::pair<int,int>,int>::iterator itr=depth2LayerF_.begin();
91  itr != depth2LayerF_.end(); ++itr)
92  std::cout << "iEta " << (itr->first).first << " Depth "
93  << (itr->first).second << " Layer " << itr->second << std::endl;
94  std::cout << "Depth2LayerBack with " << depth2LayerB_.size()
95  << " elemets" << std::endl;
96  for (std::map<std::pair<int,int>,int>::iterator itr=depth2LayerB_.begin();
97  itr != depth2LayerB_.end(); ++itr)
98  std::cout << "iEta " << (itr->first).first << " Depth "
99  << (itr->first).second << " Layer " << itr->second << std::endl;
100  std::cout << "DepthsEta_ with " << depthsEta_.size() << " elements\n";
101  for (std::map<int,std::pair<int,int> >::iterator itr=depthsEta_.begin();
102  itr != depthsEta_.end(); ++itr)
103  std::cout << "iEta " << itr->first << " Depths "
104  << (itr->second).first << ":" << (itr->second).second
105  << std::endl;
106 #endif
107 }
108 
109 int HcalLayerDepthMap::getDepth(const int subdet, const int ieta,
110  const int iphi, const int zside,
111  const int layer) const {
112  int depth(-1);
113  if (isValid(subdet,iphi,zside)) {
114  std::map<std::pair<int,int>,int>::const_iterator itr = layer2Depth_.find(std::pair<int,int>(ieta,layer));
115  if (itr != layer2Depth_.end()) depth = itr->second;
116  }
117 #ifdef EDM_ML_DEBUG
118  std::cout << "getDepth::Input " << subdet << ":" << ieta << ":" << iphi
119  << ":" << zside << ":" << layer << " Output " << depth <<std::endl;
120 #endif
121  return depth;
122 }
123 
124 int HcalLayerDepthMap::getDepth16(const int subdet, const int iphi,
125  const int zside) const {
126  int depth(-1);
127  if (isValid(subdet,iphi,zside)) depth = dep16C_;
128 #ifdef EDM_ML_DEBUG
129  std::cout << "getDepth16::Input " << subdet << ":" << iphi << ":" << zside
130  << " Output " << depth << std::endl;
131 #endif
132  return depth;
133 }
134 
135 int HcalLayerDepthMap::getDepthMin(const int subdet, const int iphi,
136  const int zside) const {
137  int depth = (isValid(subdet,iphi,zside)) ? depthMin_ : -1;
138 #ifdef EDM_ML_DEBUG
139  std::cout << "getDepthMin::Input " << subdet << ":" << iphi << ":" << zside
140  << " Output " << depth << std::endl;
141 #endif
142  return depth;
143 }
144 
145 int HcalLayerDepthMap::getDepthMax(const int subdet, const int iphi,
146  const int zside) const {
147  int depth = (isValid(subdet,iphi,zside)) ? depthMax_ : -1;
148 #ifdef EDM_ML_DEBUG
149  std::cout << "getDepthMax::Input " << subdet << ":" << iphi << ":" << zside
150  << " Output " << depth << std::endl;
151 #endif
152  return depth;
153 }
154 
155 int HcalLayerDepthMap::getDepthMax(const int subdet, const int ieta,
156  const int iphi, const int zside) const {
157  int depth = (isValid(subdet,iphi,zside)) ? getDepth(subdet,ieta,iphi,zside,maxLayers_) : -1;
158 #ifdef EDM_ML_DEBUG
159  std::cout << "getDepthMax::Input " << subdet << ":" << iphi << ":" << zside
160  << " Output " << depth << std::endl;
161 #endif
162  return depth;
163 }
164 
165 std::pair<int,int> HcalLayerDepthMap::getDepths(const int eta) const {
166 
167  std::map<int,std::pair<int,int> >::const_iterator itr = depthsEta_.find(eta);
168  if (itr == depthsEta_.end()) return std::pair<int,int>(-1,-1);
169  else return itr->second;
170 }
171 
172 int HcalLayerDepthMap::getLayerFront(const int subdet, const int ieta,
173  const int iphi, const int zside,
174  const int depth) const {
175  int layer(-1);
176  if (isValid(subdet,iphi,zside)) {
177  std::map<std::pair<int,int>,int>::const_iterator itr = depth2LayerF_.find(std::pair<int,int>(ieta,depth));
178  if (itr != depth2LayerF_.end()) layer = itr->second;
179  }
180 #ifdef EDM_ML_DEBUG
181  std::cout << "getLayerFront::Input " << subdet << ":" << ieta << ":" << iphi
182  << ":" << zside << ":" << depth << " Output " << layer <<std::endl;
183 #endif
184  return layer;
185 }
186 
187 int HcalLayerDepthMap::getLayerBack(const int subdet, const int ieta,
188  const int iphi, const int zside,
189  const int depth) const {
190  int layer(-1);
191  if (isValid(subdet,iphi,zside)) {
192  std::map<std::pair<int,int>,int>::const_iterator itr = depth2LayerB_.find(std::pair<int,int>(ieta,depth));
193  if (itr != depth2LayerB_.end()) layer = itr->second;
194  }
195 #ifdef EDM_ML_DEBUG
196  std::cout << "getLayerBack::Input " << subdet << ":" << ieta << ":" << iphi
197  << ":" << zside << ":" << depth << " Output " << layer <<std::endl;
198 #endif
199  return layer;
200 }
201 
202 void HcalLayerDepthMap::getLayerDepth(const int subdet, const int eta,
203  const int phi, const int zside,
204  std::map<int,int>& layers) const {
205  layers.clear();
206  if (isValid(subdet,phi,zside)) {
207  for (const auto & itr : layer2Depth_) {
208  if ((itr.first).first == eta) {
209  layers[((itr.first).second)+1] = (itr.second);
210  }
211  }
212  }
213 #ifdef EDM_ML_DEBUG
214  std::cout << "getLayerDepth::Input " << subdet << ":" << eta << ":" << phi
215  << ":" << zside << " Output " << layers.size() << " entries\n";
216  for (std::map<int,int>::iterator itr=layers.begin(); itr != layers.end();
217  ++itr) std::cout << " [" << itr->first << "] " << itr->second;
218  std::cout << std::endl;
219 #endif
220 }
221 
223  std::map<int,int>& layers) const {
224  layers.clear();
225  if (subdet_ > 0) {
226  for (const auto & itr : layer2Depth_) {
227  if ((itr.first).first == eta) {
228  layers[((itr.first).second)+1] = (itr.second);
229  }
230  }
231  }
232 #ifdef EDM_ML_DEBUG
233  std::cout << "getLayerDepth::Input " << eta << " Output " << layers.size()
234  << " entries\n";
235  for (std::map<int,int>::iterator itr=layers.begin(); itr != layers.end();
236  ++itr) std::cout << " [" << itr->first << "] " << itr->second;
237  std::cout << std::endl;
238 #endif
239 }
240 
241 int HcalLayerDepthMap::getMaxDepthLastHE(const int subdet, const int iphi,
242  const int zside) const {
243  int depth = isValid(subdet,iphi,zside) ? dep29C_ : -1;
244 #ifdef EDM_ML_DEBUG
245  std::cout << "getMaxDepthLastHE::Input " << subdet << ":" << iphi << ":"
246  << zside << " Output " << depth << std::endl;
247 #endif
248  return depth;
249 }
250 
251 double HcalLayerDepthMap::getLayer0Wt(const int subdet, const int iphi,
252  const int zside) const {
253  double wt = isValid(subdet,iphi,zside) ? wtl0C_ : -1.0;
254 #ifdef EDM_ML_DEBUG
255  std::cout << "getLayer0Wt::Input " << subdet << ":" << iphi << ":" << zside
256  << " Output " << wt << std::endl;
257 #endif
258  return wt;
259 }
260 
261 bool HcalLayerDepthMap::isValid(const int subdet, const int iphi,
262  const int zside) const {
263  bool flag(false);
264  int kphi = (zside > 0) ? iphi : -iphi;
265  if (subdet == subdet_)
266  flag = (std::find(iphi_.begin(),iphi_.end(),kphi) != iphi_.end());
267  return flag;
268 }
269 
270 int HcalLayerDepthMap::validDet(std::vector<int>& phi) const {
271 
272  phi.insert(phi.end(),iphi_.begin(),iphi_.end());
273  return subdet_;
274 }
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
int zside(DetId 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