CMS 3D CMS Logo

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