CMS 3D CMS Logo

HcalDDDRecConstants.cc
Go to the documentation of this file.
2 
6 #include "CLHEP/Units/GlobalPhysicalConstants.h"
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 #include <cmath>
9 
10 //#define EDM_ML_DEBUG
11 using namespace geant_units::operators;
12 
13 enum {kHOSizePreLS1 = 2160, kHFSizePreLS1 = 1728} ;
14 
16  const HcalDDDSimConstants& hc) :
17  hpar(hp), hcons(hc) {
18 
19 #ifdef EDM_ML_DEBUG
20  edm::LogVerbatim("HcalGeom") << "HcalDDDRecConstants::HcalDDDRecConstants (const HcalParameters* hp) constructor";
21 #endif
22  initialize();
23 }
24 
26 #ifdef EDM_ML_DEBUG
27  edm::LogVerbatim("HcalGeom") << "HcalDDDRecConstants::destructed!!!";
28 #endif
29 }
30 
31 std::vector<int> HcalDDDRecConstants::getDepth(const unsigned int& eta,
32  const bool& extra) const {
33 
34  if (!extra) {
35  std::vector<HcalParameters::LayerItem>::const_iterator last = hpar->layerGroupEtaRec.begin();
36  for (std::vector<HcalParameters::LayerItem>::const_iterator it = hpar->layerGroupEtaRec.begin(); it != hpar->layerGroupEtaRec.end(); ++it) {
37  if (it->layer == eta + 1) return it->layerGroup;
38  if (it->layer > eta + 1 ) return last->layerGroup;
39  last = it;
40  }
41  return last->layerGroup;
42  } else {
43  std::map<int,int> layers;
44  hcons.ldMap()->getLayerDepth(eta+1, layers);
45  std::vector<int> depths;
46  for (unsigned int lay=0; lay < layers.size(); ++lay)
47  depths.emplace_back(layers[lay+1]);
48  return depths;
49  }
50 }
51 
52 std::vector<int> HcalDDDRecConstants::getDepth(const int& det, const int& phi, const int& zside,
53  const unsigned int& eta) const {
54  std::map<int,int> layers;
55  hcons.ldMap()->getLayerDepth(det, eta+1, phi, zside, layers);
56  if (layers.empty()) {
57  return getDepth(eta, false);
58  } else {
59  std::vector<int> depths;
60  for (unsigned int lay=0; lay < layers.size(); ++lay)
61  depths.emplace_back(layers[lay+1]);
62  return depths;
63  }
64 }
65 
66 std::vector<HcalDDDRecConstants::HcalEtaBin>
67 HcalDDDRecConstants::getEtaBins(const int& itype) const {
68 
69  std::vector<HcalDDDRecConstants::HcalEtaBin> bins;
70  unsigned int type = (itype == 0) ? 0 : 1;
71  HcalSubdetector subdet = HcalSubdetector(type+1);
72  std::vector<int> phiSp;
73  HcalSubdetector subdetSp = HcalSubdetector(hcons.ldMap()->validDet(phiSp));
74  std::map<int,int> layers;
75  for (int iz=0; iz<2; ++iz) {
76  int zside = 2*iz - 1;
77  for (int ieta = iEtaMin[type]; ieta <= iEtaMax[type]; ++ieta) {
78  std::vector<std::pair<int,double> > phis = getPhis(subdet,ieta);
79  std::vector<std::pair<int,double> > phiUse;
80  getLayerDepth(ieta,layers);
81  if (subdet == subdetSp) {
82  for (auto & phi : phis) {
83  if (std::find(phiSp.begin(),phiSp.end(),(zside*phi.first)) ==
84  phiSp.end()){
85  phiUse.emplace_back(phi);
86  }
87  }
88  } else {
89  phiUse.insert(phiUse.end(),phis.begin(),phis.end());
90  }
91  if (!phiUse.empty())
92  getOneEtaBin(subdet,ieta,zside,phiUse,layers,false,bins);
93  }
94  }
95  if (subdetSp == subdet) {
96  for (int ieta = iEtaMin[type]; ieta <= iEtaMax[type]; ++ieta) {
97  std::vector<std::pair<int,double> > phis = getPhis(subdet,ieta);
98  for (int iz=0; iz<2; ++iz) {
99  int zside = 2*iz - 1;
100  std::vector<std::pair<int,double> > phiUse;
101  for (int i : phiSp) {
102  for (auto & phi : phis) {
103  if (i == zside*phi.first) {
104  phiUse.emplace_back(phi);
105  break;
106  }
107  }
108  }
109  if (!phiUse.empty()) {
110  hcons.ldMap()->getLayerDepth(subdet,ieta,phiUse[0].first,zside,layers);
111  getOneEtaBin(subdet,ieta,zside,phiUse,layers,true,bins);
112  }
113  }
114  }
115  }
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HcalGeom") << "Prepares " << bins.size()
118  << " eta bins for type " << type;
119  for (unsigned int i=0; i<bins.size(); ++i) {
120  edm::LogVerbatim("HcalGeom") << "Bin[" << i << "]: Eta = (" << bins[i].ieta
121  << ":" << bins[i].etaMin << ":"
122  << bins[i].etaMax << "), Zside = "
123  << bins[i].zside << ", phis = ("
124  << bins[i].phis.size() << ":" << bins[i].dphi
125  << ") and " << bins[i].layer.size()
126  << " depths (start) " << bins[i].depthStart;
127  for (unsigned int k=0; k<bins[i].layer.size(); ++k)
128  edm::LogVerbatim("HcalGeom") << " [" << k << "] "<< bins[i].layer[k].first
129  << ":" << bins[i].layer[k].second;
130  edm::LogVerbatim("HcalGeom") << "Phi sets";
131  for (unsigned int k=0; k<bins[i].phis.size(); ++k)
132  edm::LogVerbatim("HcalGeom") << "[" << k << "] " << bins[i].phis[k].first
133  << ":" <<bins[i].phis[k].second;
134  }
135 #endif
136  return bins;
137 }
138 
139 std::pair<double,double>
140 HcalDDDRecConstants::getEtaPhi(const int& subdet, const int& ieta, const int& iphi) const {
141  int ietaAbs = (ieta > 0) ? ieta : -ieta;
142  double eta(0), phi(0);
143  if ((subdet == static_cast<int>(HcalBarrel)) ||
144  (subdet == static_cast<int>(HcalEndcap)) ||
145  (subdet == static_cast<int>(HcalOuter))) { // Use Eta Table
146  int unit = hcons.unitPhi(phibin[ietaAbs-1]);
147  int kphi = (unit == 2) ? ((iphi-1)/2 + 1) : iphi;
148  double foff = (ietaAbs <= iEtaMax[0]) ? hpar->phioff[0] : hpar->phioff[1];
149  eta = 0.5*(etaTable[ietaAbs-1]+etaTable[ietaAbs]);
150  phi = foff + (kphi-0.5)*phibin[ietaAbs-1];
151  } else {
152  ietaAbs -= iEtaMin[2];
153  int unit = hcons.unitPhi(hpar->phitable[ietaAbs-1]);
154  int kphi = (unit == 4) ? ((iphi-3)/4 + 1) : ((iphi-1)/2 + 1);
155  double foff = (unit > 2) ? hpar->phioff[4] : hpar->phioff[2];
156  eta = 0.5*(hpar->etaTableHF[ietaAbs-1]+hpar->etaTableHF[ietaAbs]);
157  phi = foff + (kphi-0.5)*hpar->phitable[ietaAbs-1];
158  }
159  if (ieta < 0) eta = -eta;
160  if (phi > M_PI) phi -= (2*M_PI);
161 #ifdef EDM_ML_DEBUG
162  edm::LogVerbatim("HcalGeom") << "getEtaPhi: subdet|ieta|iphi " << subdet << "|"
163  << ieta << "|" << iphi << " eta|phi " << eta
164  << "|" << phi;
165 #endif
166  return std::pair<double,double>(eta,phi);
167 }
168 
170 HcalDDDRecConstants::getHCID(int subdet, int keta, int iphi, int lay,
171  int idepth) const {
172 
173  int ieta = (keta > 0) ? keta : -keta;
174  int zside= (keta > 0) ? 1 : -1;
175  int eta(ieta), phi(iphi), depth(idepth);
176  if ((subdet == static_cast<int>(HcalOuter)) ||
177  ((subdet == static_cast<int>(HcalBarrel)) && (lay > maxLayerHB_+1))) {
178  subdet= static_cast<int>(HcalOuter);
179  depth = 4;
180  } else if (subdet == static_cast<int>(HcalBarrel) ||
181  subdet == static_cast<int>(HcalEndcap)) {
182  eta = ietaMap[ieta-1];
183  int unit = phiUnitS[ieta-1];
184  int phi0 = (iphi-1)/(hpar->phigroup[eta-1]);
185  if (unit == 2) {
186  phi0 = (iphi+1)/2;
187  phi0 = (phi0-1)/(hpar->phigroup[eta-1]);
188  } else if (unit == 4) {
189  phi0 = (iphi+1)/4;
190  phi0 = (phi0-1)/(hpar->phigroup[eta-1]);
191  }
192  ++phi0;
193  unit = hcons.unitPhi(phibin[eta-1]);
194  phi = hcons.phiNumber(phi0,unit);
195  depth = hcons.findDepth(subdet,eta,phi,zside,lay-1);
196  if (depth <= 0) depth = layerGroup(eta-1, lay-1);
197  if (eta == iEtaMin[1]) {
198  if (subdet == static_cast<int>(HcalBarrel)) {
199  if (depth > hcons.getDepthEta16(subdet,phi,zside))
200  depth = hcons.getDepthEta16(subdet,phi,zside);
201  } else {
202  if (depth < hcons.getDepthEta16(subdet,phi,zside))
203  depth = hcons.getDepthEta16(subdet,phi,zside);
204  }
205  } else if (eta == hpar->noff[0] && lay > 1) {
206  int kphi = phi + int((hpar->phioff[3]+0.1)/phibin[eta-1]);
207  kphi = (kphi-1)%4 + 1;
208  if (kphi == 2 || kphi == 3) depth = layerGroup(eta-1, lay-2);
209  } else if (eta == hpar->noff[1] &&
210  depth > hcons.getDepthEta29(phi,zside,0)) {
211  eta -= hcons.getDepthEta29(phi,zside,1);
212  }
213  }
214 #ifdef EDM_ML_DEBUG
215  edm::LogVerbatim("HcalGeom") << "getHCID: input " << subdet << ":" << ieta
216  << ":" << iphi << ":" << idepth << ":" << lay
217  << " output " << eta << ":" << phi << ":" <<depth;
218 #endif
219  return HcalDDDRecConstants::HcalID(subdet,eta,phi,depth);
220 }
221 
222 std::vector<HcalDDDRecConstants::HFCellParameters>
224 
225  std::vector<HcalDDDRecConstants::HFCellParameters> cells;
226  unsigned int nEta = hcons.getPhiTableHF().size();
227  if (maxDepth[2] > 0) {
228  for (unsigned int k=0; k<nEta; ++k) {
229  int ieta = iEtaMin[2] + k;
230  int dphi = (int)(0.001 + hcons.getPhiTableHF()[k]/(5._deg));
231  int iphi = (dphi == 4) ? 3 : 1;
232  int nphi = 72/dphi;
233  double rMin = hcons.getRTableHF()[nEta-k-1]/CLHEP::cm;
234  double rMax = hcons.getRTableHF()[nEta-k]/CLHEP::cm;
235  HcalDDDRecConstants::HFCellParameters cell1( ieta,1,iphi,dphi,nphi,rMin,rMax);
236  cells.emplace_back(cell1);
237  HcalDDDRecConstants::HFCellParameters cell2(-ieta,1,iphi,dphi,nphi,rMin,rMax);
238  cells.emplace_back(cell2);
239  }
240  }
241  if (maxDepth[2] > 2) {
242  if (!hcons.getIdHF2QIE().empty()) {
243  for (unsigned int k=0; k<hcons.getIdHF2QIE().size(); ++k) {
244  int ieta = hcons.getIdHF2QIE()[k].ieta();
245  int ind = std::abs(ieta) - iEtaMin[2];
246  int dphi = (int)(0.001 + hcons.getPhiTableHF()[ind]/(5._deg));
247  int iphi = hcons.getIdHF2QIE()[k].iphi();
248  double rMin = hcons.getRTableHF()[nEta-ind-1]/CLHEP::cm;
249  double rMax = hcons.getRTableHF()[nEta-ind]/CLHEP::cm;
250  HcalDDDRecConstants::HFCellParameters cell1( ieta,3,iphi,dphi,1,rMin,rMax);
251  cells.emplace_back(cell1);
252  }
253  } else {
254  for (unsigned int k=0; k<nEta; ++k) {
255  int ieta = iEtaMin[2] + k;
256  int dphi = (int)(0.001 + hcons.getPhiTableHF()[k]/(5._deg));
257  int iphi = (dphi == 4) ? 3 : 1;
258  int nphi = 72/dphi;
259  double rMin = hcons.getRTableHF()[nEta-k-1]/CLHEP::cm;
260  double rMax = hcons.getRTableHF()[nEta-k]/CLHEP::cm;
261  HcalDDDRecConstants::HFCellParameters cell1( ieta,3,iphi,dphi,nphi,rMin,rMax);
262  cells.emplace_back(cell1);
263  HcalDDDRecConstants::HFCellParameters cell2(-ieta,3,iphi,dphi,nphi,rMin,rMax);
264  cells.emplace_back(cell2);
265  }
266  }
267  }
268 #ifdef EDM_ML_DEBUG
269  edm::LogVerbatim("HcalGeom") << "HcalDDDRecConstants returns " << cells.size()
270  << " HF cell parameters";
271  for (unsigned int k=0; k<cells.size(); ++k)
272  edm::LogVerbatim("HcalGeom") << "Cell[" << k <<"] : (" << cells[k].ieta
273  << ", " << cells[k].depth << ", "
274  << cells[k].firstPhi << ", " << cells[k].stepPhi
275  << ", " << cells[k].nPhi << ", " <<cells[k].rMin
276  << ", " << cells[k].rMax << ")";
277 #endif
278  return cells;
279 }
280 
281 void HcalDDDRecConstants::getLayerDepth(const int& ieta, std::map<int,int>& layers) const {
282 
283  layers.clear();
284  for (unsigned int l=0; l<layerGroupSize(ieta-1); ++l) {
285  int lay = l + 1;
286  layers[lay] = layerGroup(ieta-1,l);
287  }
288 #ifdef EDM_ML_DEBUG
289  edm::LogVerbatim("HcalGeom") << "getLayerDepth::Input " << ieta << " Output "
290  << layers.size() << " entries";
291  for (std::map<int,int>::iterator itr=layers.begin(); itr != layers.end();
292  ++itr)
293  edm::LogVerbatim("HcalGeom") << " [" << itr->first << "] " << itr->second;
294 #endif
295 }
296 
297 int HcalDDDRecConstants::getLayerBack(const int& idet, const int& ieta,
298  const int& iphi, const int& depth) const{
299  int subdet = (idet == 1) ? 1 : 2;
300  int zside = (ieta > 0) ? 1 : -1;
301  int eta = zside*ieta;
302  int layBack = hcons.ldMap()->getLayerBack(subdet,eta,iphi,zside,depth);
303  int laymax = hcons.getLastLayer(subdet, ieta);
304  if (layBack < 0 && eta <= hpar->etaMax[1]) {
305  for (unsigned int k=0; k<layerGroupSize(eta-1); ++k) {
306  if (depth+1 == (int)layerGroup(eta-1, k)) {
307  layBack = k - 1;
308  break;
309  }
310  }
311  }
312  if (layBack < 0 || layBack > laymax) layBack = laymax;
313 #ifdef EDM_ML_DEBUG
314  edm::LogVerbatim("HcalGeom") << "getLayerBack::Input " << idet << ":" << ieta
315  << ":" << iphi << ":" << depth << " Output "
316  << layBack;
317 #endif
318  return layBack;
319 }
320 
321 int HcalDDDRecConstants::getLayerFront(const int& idet, const int& ieta,
322  const int& iphi, const int& depth) const {
323  int subdet = (idet == 1) ? 1 : 2;
324  int zside = (ieta > 0) ? 1 : -1;
325  int eta = zside*ieta;
326  int layFront = hcons.ldMap()->getLayerFront(subdet,eta,iphi,zside,depth);
327  int laymin = hcons.getFrontLayer(subdet, ieta);
328  if ((layFront < 0) ||
329  ((subdet == static_cast<int>(HcalEndcap)) && (eta == 16))) {
330  if ((subdet == static_cast<int>(HcalEndcap)) && (eta == 16)) {
331  layFront = laymin;
332  } else if (eta <= hpar->etaMax[1]) {
333  for (unsigned int k=0; k<layerGroupSize(eta-1); ++k) {
334  if (depth == (int)layerGroup(eta-1, k)) {
335  if ((int)(k) >= laymin) {
336  layFront = k;
337  break;
338  }
339  }
340  }
341  }
342  } else {
343  if (layFront < laymin) layFront = laymin;
344  }
345 #ifdef EDM_ML_DEBUG
346  edm::LogVerbatim("HcalGeom") << "getLayerFront::Input " << idet << ":" << ieta
347  << ":" << iphi << ":" << depth << " Output "
348  << layFront;
349 #endif
350  return layFront;
351 }
352 
353 int HcalDDDRecConstants::getMaxDepth (const int& itype, const int& ieta,
354  const int& iphi, const int& zside) const {
355 
356  unsigned int type = (itype == 0) ? 0 : 1;
357  int lmax = hcons.getMaxDepth(type+1, ieta, iphi, zside, true);
358  if (lmax < 0) {
359  unsigned int lymax = (type == 0) ? maxLayerHB_+1 : maxLayer_+1;
360  lmax = 0;
361  if (layerGroupSize(ieta-1) > 0) {
362  if (layerGroupSize(ieta-1) < lymax) lymax = layerGroupSize(ieta-1);
363  lmax = (int)(layerGroup(ieta-1, lymax-1));
364  if (type == 0 && ieta == iEtaMax[type]) lmax = hcons.getDepthEta16M(1);
365  if (type == 1 && ieta >= hpar->noff[1]) lmax = hcons.getDepthEta29M(0,false);
366  }
367  }
368 #ifdef EDM_ML_DEBUG
369  edm::LogVerbatim("HcalGeom") << "getMaxDepth::Input " << itype << ":" << ieta
370  << ":" << iphi << ":" << zside << " Output "
371  << lmax;
372 #endif
373  return lmax;
374 }
375 
376 int HcalDDDRecConstants::getMinDepth (const int& itype, const int& ieta,
377  const int& iphi, const int& zside) const {
378 
379  int lmin = hcons.getMinDepth(itype+1, ieta, iphi, zside, true);
380  if (lmin < 0) {
381  if (itype == 2) { // HFn
382  lmin = 1;
383  } else if (itype == 3) { //HO
384  lmin = maxDepth[3];
385  } else {
386  unsigned int type = (itype == 0) ? 0 : 1;
387  if (layerGroupSize(ieta-1) > 0) {
388  if (type == 1 && ieta == iEtaMin[type])
389  lmin = hcons.getDepthEta16M(2);
390  else
391  lmin = (int)(layerGroup(ieta-1, 0));
392  }
393  }
394  }
395  return lmin;
396 }
397 
398 std::vector<std::pair<int,double> >
399 HcalDDDRecConstants::getPhis(const int& subdet, const int& ieta) const {
400 
401  std::vector<std::pair<int,double> > phis;
402  int ietaAbs = (ieta > 0) ? ieta : -ieta;
403  int keta = (subdet != HcalForward) ? etaSimValu[ietaAbs-1].first : ietaAbs;
404  std::pair<double,double> ficons = hcons.getPhiCons(subdet, keta);
405  double fioff = ficons.first;
406  double dphi = (subdet != HcalForward) ? phibin[ietaAbs-1] : ficons.second;
407  int nphi = int((2._pi+0.1*dphi)/dphi);
408  int units = hcons.unitPhi(subdet, keta);
409  for (int ifi = 0; ifi < nphi; ++ifi) {
410  double phi =-fioff + (ifi+0.5)*dphi;
411  int iphi = hcons.phiNumber(ifi+1,units);
412  phis.emplace_back(std::pair<int,double>(iphi,phi));
413  }
414 #ifdef EDM_ML_DEBUG
415  edm::LogVerbatim("HcalGeom") << "getEtaPhi: subdet|ieta|iphi " << subdet << "|"
416  << ieta << " with " << phis.size() << " phi bins";
417  for (unsigned int k=0; k<phis.size(); ++k)
418  edm::LogVerbatim("HcalGeom") << "[" << k << "] iphi " << phis[k].first
419  << " phi " << convertRadToDeg(phis[k].second);
420 #endif
421  return phis;
422 }
423 
424 int HcalDDDRecConstants::getPhiZOne(std::vector<std::pair<int,int>>& phiz) const {
425 
426  phiz.clear();
427  int subdet = hcons.ldMap()->getSubdet();
428  if (subdet > 0) {
429  std::vector<int> phis = hcons.ldMap()->getPhis();
430  for (int k : phis) {
431  int zside = (k > 0) ? 1 : -1;
432  int phi = (k > 0) ? k : -k;
433  phiz.emplace_back(std::pair<int,int>(phi,zside));
434  }
435  }
436 #ifdef EDM_ML_DEBUG
437  edm::LogVerbatim("HcalGeom") << "Special RBX for detector " << subdet
438  << " with " << phiz.size() << " phi/z bins";
439  for (unsigned int k=0; k<phiz.size(); ++k)
440  edm::LogVerbatim("HcalGeom") << " [" << k << "] " << phiz[k].first << ":"
441  << phiz[k].second;
442 #endif
443  return subdet;
444 }
445 
446 double HcalDDDRecConstants::getRZ(const int& subdet, const int& ieta,
447  const int& depth) const {
448 
449  return getRZ(subdet, ieta, 1, depth);
450 }
451 
452 double HcalDDDRecConstants::getRZ(const int& subdet, const int& ieta, const int& iphi,
453  const int& depth) const {
454  int layf = getLayerFront(subdet,ieta,iphi,depth);
455  double rz = (layf < 0) ? 0.0 :
456  ((subdet == static_cast<int>(HcalBarrel)) ? (gconsHB[layf].first) :
457  (gconsHE[layf].first));
458 #ifdef EDM_ML_DEBUG
459  edm::LogVerbatim("HcalGeom") << "getRZ: subdet|ieta|ipho|depth " << subdet
460  << "|" << ieta << "|" << iphi << "|" << depth
461  << " lay|rz " << layf << "|" << rz;
462 #endif
463  return rz;
464 }
465 
466 double HcalDDDRecConstants::getRZ(const int& subdet, const int& layer) const {
467 
468  double rz(0);
469  if (layer > 0 && layer <= (int)(layerGroupSize(0)))
470  rz = ((subdet == static_cast<int>(HcalBarrel)) ? (gconsHB[layer-1].first) :
471  (gconsHE[layer-1].first));
472 #ifdef EDM_ML_DEBUG
473  edm::LogVerbatim("HcalGeom") << "getRZ: subdet|layer " << subdet << "|"
474  << layer << " rz " << rz;
475 #endif
476  return rz;
477 }
478 
479 std::pair<double,double> HcalDDDRecConstants::getRZ(const HcalDetId& id) const{
480  int subdet = id.subdetId();
481  int ieta = id.ieta();
482  int iphi = id.iphi();
483  int depth = id.depth();
484  int zside = (subdet == static_cast<int>(HcalBarrel)) ? 1 : id.zside();
485  int layf = getLayerFront(subdet,ieta,iphi,depth);
486  double rzf = (layf < 0) ? 0.0 :
487  ((subdet == static_cast<int>(HcalBarrel)) ?
488  zside*(gconsHB[layf].first-gconsHB[layf].second) :
489  zside*(gconsHE[layf].first-gconsHE[layf].second));
490  int layb = getLayerBack(subdet,ieta,iphi,depth);
491  double rzb = (layb < 0) ? 0.0 :
492  ((subdet == static_cast<int>(HcalBarrel)) ?
493  zside*(gconsHB[layb].first+gconsHB[layb].second) :
494  zside*(gconsHE[layb].first+gconsHE[layb].second));
495 #ifdef EDM_ML_DEBUG
496  edm::LogVerbatim("HcalGeom") << "getRZ: subdet|ieta|ipho|depth " << subdet
497  << "|" << ieta << "|" << iphi << "|" << depth
498  << " lay|rz (front) " << layf << "|" << rzf
499  << " lay|rz (back) " << layb << "|" << rzb;
500 #endif
501  return std::pair<double,double>(rzf,rzb);
502 }
503 
504 std::vector<HcalDDDRecConstants::HcalActiveLength>
506 
507  std::vector<HcalDDDRecConstants::HcalActiveLength> actives;
508  std::vector<HcalDDDRecConstants::HcalEtaBin> bins = getEtaBins(type);
509 #ifdef EDM_ML_DEBUG
510  unsigned int kount(0);
511 #endif
512  for (auto & bin : bins) {
513  int ieta = bin.ieta;
514  int zside = bin.zside;
515  int stype = (bin.phis.size() > 4) ? 0 : 1;
516  int layf = getLayerFront(type+1,zside*ieta,bin.phis[0].first,bin.depthStart) + 1;
517  int layl = hcons.getLastLayer(type+1,zside*ieta) + 1;
518  double eta = 0.5*(bin.etaMin+bin.etaMax);
519  double theta = 2*atan(exp(-eta));
520  double scale = 1.0/((type == 0) ? sin(theta) : cos(theta));
521  int depth = bin.depthStart;
522 #ifdef EDM_ML_DEBUG
523  edm::LogVerbatim("HcalGeom") << "Eta " << ieta << " zside " << zside
524  << " depth " << depth << " Layers " << layf
525  << ":" << layl << ":" << bin.layer.size();
526  for (auto ll : bin.layer)
527  edm::LogVerbatim("HcalGeom") << "Layer " << ll.first << ":" << ll.second;
528  for (auto phi : bin.phis)
529  edm::LogVerbatim("HcalGeom") << "Phi " << phi.first << ":"
530  << convertRadToDeg(phi.second);
531 #endif
532  for (unsigned int i = 0; i < bin.layer.size(); ++i) {
533  double thick(0);
534  int lmin = (type == 1 && ieta == iEtaMin[1]) ? layf :
535  std::max(bin.layer[i].first,layf);
536  int lmax = std::min(bin.layer[i].second,layl);
537  for (int j = lmin; j <= lmax; ++j) {
538  double t = ((type == 0) ? gconsHB[j-1].second : gconsHE[j-1].second);
539  if ((type == 1) && (ieta <= 18)) t = gconsHE[j].second;
540  if (t > 0) thick += t;
541  }
542 #ifdef EDM_ML_DEBUG
543  edm::LogVerbatim("HcalGeom") << "Type " << type << " L " << lmin << ":"
544  << lmax << " T " << thick;
545 #endif
546  thick *= (2.*scale);
547  HcalDDDRecConstants::HcalActiveLength active(ieta,depth,zside,stype,zside*eta,thick);
548  for (auto phi : bin.phis)
549  active.iphis.emplace_back(phi.first);
550  actives.emplace_back(active);
551  ++depth;
552 #ifdef EDM_ML_DEBUG
553  kount++;
554  edm::LogVerbatim("HcalGeom") << "getThickActive: [" << kount << "] eta:"
555  << active.ieta << ":" << active.eta
556  << " zside " << active.zside << " depth "
557  << active.depth << " type " << active.stype
558  << " thick " << active.thick;
559 #endif
560  }
561  }
562  return actives;
563 }
564 
565 std::vector<HcalCellType>
567 
568  if (subdet == HcalBarrel || subdet == HcalEndcap) {
569  std::vector<HcalCellType> cells;
570  int isub = (subdet == HcalBarrel) ? 0 : 1;
571  std::vector<HcalDDDRecConstants::HcalEtaBin> etabins = getEtaBins(isub);
572  std::vector<int> missPhi;
573  for (const auto& etabin : etabins) {
574  std::vector<HcalCellType> temp;
575  std::vector<int> count;
576  std::vector<double> dmin, dmax;
577  for (unsigned int il=0; il<etabin.layer.size(); ++il) {
578  HcalCellType cell(subdet, etabin.ieta, etabin.zside, 0,
580  temp.emplace_back(cell);
581  count.emplace_back(0);
582  dmin.emplace_back(0);
583  dmax.emplace_back(0);
584  }
585  int ieta = etabin.ieta;
586  for (int keta=etaSimValu[ieta-1].first; keta<=etaSimValu[ieta-1].second;
587  ++keta) {
588  std::vector<HcalCellType> cellsm = hcons.HcalCellTypes(subdet,keta,-1);
589  for (unsigned int il=0; il<etabin.layer.size(); ++il) {
590  for (auto & ic : cellsm) {
591  if (ic.depthSegment() >= etabin.layer[il].first &&
592  ic.depthSegment() <= etabin.layer[il].second &&
593  ic.etaBin() == temp[il].etaBin() &&
594  ic.zside() == temp[il].zside()) {
595  if (count[il] == 0) {
596  temp[il] = ic;
597  dmin[il] = ic.depthMin();
598  dmax[il] = ic.depthMax();
599  }
600  ++count[il];
601  if (ic.depthMin() < dmin[il])
602  dmin[il] = ic.depthMin();
603  if (ic.depthMax() > dmax[il])
604  dmax[il] = ic.depthMax();
605  }
606  }
607  }
608  }
609  for (unsigned int il=0; il<etabin.layer.size(); ++il) {
610  int depth = etabin.depthStart + (int)(il);
611  temp[il].setEta(ieta,etabin.etaMin,etabin.etaMax);
612  temp[il].setDepth(depth,dmin[il],dmax[il]);
613  double foff = (etabin.ieta <= iEtaMax[0]) ? hpar->phioff[0] : hpar->phioff[1];
614  int unit = hcons.unitPhi(etabin.dphi);
615  temp[il].setPhi(etabin.phis, missPhi, foff, etabin.dphi, unit);
616  cells.emplace_back(temp[il]);
617  }
618  }
619 #ifdef EDM_ML_DEBUG
620  edm::LogVerbatim("HcalGeom") << "HcalDDDRecConstants: found " << cells.size()
621  << " cells for sub-detector type " << isub;
622  for (unsigned int ic=0; ic<cells.size(); ++ic)
623  edm::LogVerbatim("HcalGeom") << "Cell[" << ic << "] " << cells[ic];
624 #endif
625  return cells;
626  } else {
627  return hcons.HcalCellTypes(subdet,-1,-1);
628  }
629 }
630 
631 bool HcalDDDRecConstants::mergedDepthList29(int ieta, int iphi, int depth) const {
632  int eta = std::abs(ieta);
633  int zside = (ieta > 0) ? 1 : -1;
634  int etamin= iEtaMax[1]-hcons.getDepthEta29(iphi,zside,1);
635  if ((eta >= etamin) && (eta <= iEtaMax[1])) {
636  int depthMax = getMaxDepth(1, etamin, iphi, zside);
637  int depthMin = hcons.getDepthEta29(iphi,zside,0) + 1;
638  if (depth >= depthMin && depth <= depthMax) return true;
639  }
640  return false;
641 }
642 
643 std::vector<int> HcalDDDRecConstants::mergedDepthList29(int ieta, int iphi) const {
644  std::vector<int> depths;
645  int eta = std::abs(ieta);
646  int zside = (ieta > 0) ? 1 : -1;
647  int etamin= iEtaMax[1]-hcons.getDepthEta29(iphi,zside,1);
648  if ((eta >= etamin) && (eta <= iEtaMax[1])) {
649  int depthMax = getMaxDepth(1, etamin, iphi, zside);
650  int depthMin = hcons.getDepthEta29(iphi,zside,0) + 1;
651  depths.reserve(depthMax-depthMin+1);
652  for (int depth=depthMin; depth <= depthMax; ++depth)
653  depths.emplace_back(depth);
654  }
655  return depths;
656 }
657 
658 
660 
661  if (subdet == HcalBarrel || subdet == HcalEndcap) {
662  unsigned int num = 0;
663  std::vector<HcalCellType> cellTypes = HcalCellTypes(subdet);
664  for (auto & cellType : cellTypes) {
665  num += (unsigned int)(cellType.nPhiBins());
666  }
667 #ifdef EDM_ML_DEBUG
668  edm::LogInfo ("HCalGeom") << "HcalDDDRecConstants:numberOfCells "
669  << cellTypes.size() << " " << num
670  << " for subdetector " << subdet;
671 #endif
672  return num;
673  } else {
674  return hcons.numberOfCells(subdet);
675  }
676 }
677 
678 unsigned int HcalDDDRecConstants::nCells(HcalSubdetector subdet) const {
679 
680  if (subdet == HcalBarrel || subdet == HcalEndcap) {
681  int isub = (subdet == HcalBarrel) ? 0 : 1;
682  std::vector<HcalDDDRecConstants::HcalEtaBin> etabins = getEtaBins(isub);
683  unsigned int ncell(0);
684  for (auto & etabin : etabins) {
685  ncell += ((etabin.phis.size())*(etabin.layer.size()));
686  }
687  return ncell;
688  } else if (subdet == HcalOuter) {
689  return kHOSizePreLS1;
690  } else if (subdet == HcalForward) {
691  return (unsigned int)(hcons.numberOfCells(subdet));
692  } else {
693  return 0;
694  }
695 }
696 
697 unsigned int HcalDDDRecConstants::nCells() const {
699 }
700 
702 
703  std::map<HcalDetId,HcalDetId>::const_iterator itr = detIdSp_.find(id);
704  if (itr == detIdSp_.end()) return id;
705  else return itr->second;
706 }
707 
709 
710  HcalDetId hid(id);
711  std::map<HcalDetId,std::vector<HcalDetId>>::const_iterator itr = detIdSpR_.find(id);
712  if (itr != detIdSpR_.end())
713  hid = HcalDetId(id.subdet(),id.ieta(),id.iphi(),(itr->second)[0].depth());
714  return hid;
715 }
716 
718 
719  HcalDetId hid(id);
720  std::map<HcalDetId,std::vector<HcalDetId>>::const_iterator itr = detIdSpR_.find(id);
721  if (itr != detIdSpR_.end())
722  hid = HcalDetId(id.subdet(),id.ieta(),id.iphi(),(itr->second).back().depth());
723  return hid;
724 }
725 
727  std::vector<HcalDetId>& ids) const {
728 
729  ids.clear();
730  std::map<HcalDetId,std::vector<HcalDetId>>::const_iterator itr = detIdSpR_.find(id);
731  if (itr == detIdSpR_.end()) {
732  ids.emplace_back(id);
733  } else {
734  for (auto k : itr->second) {
735  HcalDetId hid(id.subdet(),id.ieta(),id.iphi(),k.depth());
736  ids.emplace_back(hid);
737  }
738  }
739 }
740 
741 void HcalDDDRecConstants::specialRBXHBHE(const std::vector<HcalDetId>& idsOld,
742  std::vector<HcalDetId>& idsNew) const {
743  for (auto k : idsOld) {
744  std::map<HcalDetId,HcalDetId>::const_iterator itr = detIdSp_.find(k);
745  if (itr == detIdSp_.end()) idsNew.emplace_back(k);
746  else idsNew.emplace_back(itr->second);
747  }
748 }
749 
751  std::vector<HcalDetId>& ids) const {
752  if (tobemerged) {
753  std::map<HcalDetId,HcalDetId>::const_iterator itr;
754  for (itr = detIdSp_.begin(); itr != detIdSp_.end(); ++itr)
755  ids.emplace_back(itr->first);
756  } else{
757  std::map<HcalDetId,std::vector<HcalDetId>>::const_iterator itr;
758  for (itr = detIdSpR_.begin(); itr != detIdSpR_.end(); ++itr)
759  ids.emplace_back(itr->first);
760  }
761  return (!ids.empty());
762 }
763 
765  std::vector<std::pair<int,double> >& phis,
766  std::map<int,int>& layers, bool planOne,
767  std::vector<HcalDDDRecConstants::HcalEtaBin>& bins) const {
768 
769  unsigned int lymax = (subdet == HcalBarrel) ? maxLayerHB_+1 : maxLayer_+1;
770  int type = (subdet == HcalBarrel) ? 0 : 1;
771  double dphi = phibin[ieta-1];
773  etabin.phis.insert(etabin.phis.end(),phis.begin(),phis.end());
774  int n = (ieta == iEtaMax[type]) ? 0 : 1;
775  HcalDDDRecConstants::HcalEtaBin etabin0= HcalDDDRecConstants::HcalEtaBin(ieta,zside,dphi,etaTable[ieta-1],etaTable[ieta+n]);
776  etabin0.depthStart = hcons.getDepthEta29(phis[0].first,zside,0)+1;
777  int dstart = -1;
778  int lmin(0), lmax(0);
779 
780  std::map<int,int>::iterator itr=layers.begin();
781  if (!layers.empty()) {
782  int dep = itr->second;
783  if (subdet == HcalEndcap && ieta == iEtaMin[type])
784  dep = hcons.getDepthEta16(subdet,phis[0].first,zside);
785  unsigned lymx0 = (layers.size() > lymax) ? lymax : layers.size();
786 #ifdef EDM_ML_DEBUG
787  edm::LogVerbatim("HcalGeom") << "Eta " << ieta << ":" << hpar->noff[1]
788  << " zside " << zside << " lymax " << lymx0
789  << ":" << lymax << " Depth " << dep << ":"
790  << itr->second;
791  unsigned int l(0);
792  for (itr = layers.begin(); itr != layers.end(); ++itr,++l)
793  edm::LogVerbatim("HcalGeom") << "Layer [" << l << "] " << itr->first
794  << ":" << itr->second;
795  edm::LogVerbatim("HcalGeom") << "With " << phis.size() << " phis";
796  for (unsigned int l=0; l<phis.size(); ++l)
797  edm::LogVerbatim("HcalGeom") << "[" << l << "] " << phis[l].first << ":"
798  << convertRadToDeg(phis[l].second);
799 #endif
800  for (itr = layers.begin(); itr != layers.end(); ++itr) {
801  if (itr->first <= (int)(lymx0)) {
802  if (itr->second == dep) {
803  if (lmin == 0) lmin = itr->first;
804  lmax = itr->first;
805  } else if (itr->second > dep) {
806  if (dstart < 0) dstart = dep;
807  int lmax0 = (lmax >= lmin) ? lmax : lmin;
808  if (subdet == HcalEndcap && ieta+1 == hpar->noff[1] &&
809  dep > hcons.getDepthEta29(phis[0].first,zside,0)) {
810  etabin0.layer.emplace_back(std::pair<int,int>(lmin,lmax0));
811  } else {
812  etabin.layer.emplace_back(std::pair<int,int>(lmin,lmax0));
813  }
814  lmin = itr->first;
815  lmax = lmin-1;
816  dep = itr->second;
817  }
818  if (subdet == HcalBarrel && ieta == iEtaMax[type] &&
819  dep > hcons.getDepthEta16M(1)) break;
820  if (subdet == HcalEndcap && ieta == hpar->noff[1] &&
821  dep > hcons.getDepthEta29M(0,planOne)) {
822  lmax = lymx0;
823  break;
824  }
825  if (itr->first == (int)(lymx0)) lmax = lymx0;
826  }
827  }
828  if (lmax >= lmin) {
829  if (ieta+1 == hpar->noff[1]) {
830  etabin0.layer.emplace_back(std::pair<int,int>(lmin,lmax));
831  etabin0.phis.insert(etabin0.phis.end(),phis.begin(),phis.end());
832  bins.emplace_back(etabin0);
833 #ifdef EDM_ML_DEBUG
834  edm::LogVerbatim("HcalGeom") << "etabin0: dStatrt " << etabin0.depthStart
835  << " layers " << etabin0.layer.size() << ":"
836  << lmin << ":" << lmax << " phis "
837  << phis.size();
838  for (unsigned int k=0; k<etabin0.layer.size(); ++k)
839  edm::LogVerbatim("HcalGeom") << " [" << k << "] "
840  << etabin0.layer[k].first << ":"
841  << etabin0.layer[k].second;
842 #endif
843  } else if (ieta == hpar->noff[1]) {
844  } else {
845  etabin.layer.emplace_back(std::pair<int,int>(lmin,lmax));
846  if (dstart < 0) dstart = dep;
847  }
848  }
849  }
850  etabin.depthStart = dstart;
851  bins.emplace_back(etabin);
852 #ifdef EDM_ML_DEBUG
853  edm::LogVerbatim("HcalGeom") << "etabin: dStatrt " << etabin.depthStart
854  << " layers " << etabin.layer.size() << ":"
855  << lmin << ":" << lmax << " phis "
856  << etabin.phis.size();
857  for (unsigned int k=0; k<etabin.layer.size(); ++k)
858  edm::LogVerbatim("HcalGeom") << "[" << k << "] " << etabin.layer[k].first
859  << ":" << etabin.layer[k].second;
860 #endif
861 }
862 
864 
865  //Eta grouping
866  int nEta = (int)(hpar->etagroup.size());
867  if (nEta != (int)(hpar->phigroup.size())) {
868  edm::LogError("HCalGeom") << "HcalDDDRecConstants: sizes of the vectors "
869  << " etaGroup (" << nEta << ") and phiGroup ("
870  << hpar->phigroup.size() << ") do not match";
871  throw cms::Exception("DDException") << "HcalDDDRecConstants: inconsistent array sizes" << nEta << ":" << hpar->phigroup.size();
872  }
873 
874  // First eta table
875  iEtaMin = hpar->etaMin;
876  iEtaMax = hpar->etaMax;
877  etaTable.clear(); ietaMap.clear(); etaSimValu.clear();
878  int ieta(0), ietaHB(0), ietaHE(0), ietaHEM(0);
879  etaTable.emplace_back(hpar->etaTable[ieta]);
880  for (int i=0; i<nEta; ++i) {
881  int ef = ieta+1;
882  ieta += (hpar->etagroup[i]);
883  if (ieta >= (int)(hpar->etaTable.size())) {
884  edm::LogError("HCalGeom")
885  << "HcalDDDRecConstants: Going beyond the array boundary "
886  << hpar->etaTable.size() << " at index " << i
887  << " of etaTable from SimConstant";
888  throw cms::Exception("DDException")
889  << "HcalDDDRecConstants: Going beyond the array boundary "
890  << hpar->etaTable.size() << " at index " << i
891  << " of etaTable from SimConstant";
892  } else {
893  etaTable.emplace_back(hpar->etaTable[ieta]);
894  etaSimValu.emplace_back(std::pair<int,int>(ef,ieta));
895  }
896  for (int k=0; k<(hpar->etagroup[i]); ++k) ietaMap.emplace_back(i+1);
897  if (ieta <= hpar->etaMax[0]) ietaHB = i+1;
898  if (ieta <= hpar->etaMin[1]) ietaHE = i+1;
899  if (ieta <= hpar->etaMax[1]) ietaHEM= i+1;
900  }
901  iEtaMin[1] = ietaHE;
902  iEtaMax[0] = ietaHB;
903  iEtaMax[1] = ietaHEM;
904 
905  // Then Phi bins
906  nPhiBins.clear();
907  for (unsigned int k=0; k<4; ++k) nPhiBins.emplace_back(0);
908  ieta = 0;
909  phibin.clear(); phiUnitS.clear();
910  for (int i=0; i<nEta; ++i) {
911  double dphi = (hpar->phigroup[i])*(hpar->phibin[ieta]);
912  phibin.emplace_back(dphi);
913  int nphi = (int)((2._pi + 0.001)/dphi);
914  if (ieta <= iEtaMax[0]) {
915  if (nphi > nPhiBins[0]) nPhiBins[3] = nPhiBins[0] = nphi;
916  }
917  if (ieta >= iEtaMin[1]) {
918  if (nphi > nPhiBins[1]) nPhiBins[1] = nphi;
919  }
920  ieta += (hpar->etagroup[i]);
921  }
922  for (unsigned int i=1; i<hpar->etaTable.size(); ++i) {
923  int unit = hcons.unitPhi(hpar->phibin[i-1]);
924  phiUnitS.emplace_back(unit);
925  }
926  for (double i : hpar->phitable) {
927  int nphi = (int)((2._pi + 0.001)/i);
928  if (nphi > nPhiBins[2]) nPhiBins[2] = nphi;
929  }
930 #ifdef EDM_ML_DEBUG
931  edm::LogVerbatim("HcalGeom")
932  << "HcalDDDRecConstants: Modified eta/deltaphi table for " << nEta
933  << " bins";
934  for (int i=0; i<nEta; ++i)
935  edm::LogVerbatim("HcalGeom")
936  << "Eta[" << i << "] = " << etaTable[i] << ":" << etaTable[i+1] << ":"
937  << etaSimValu[i].first << ":" << etaSimValu[i].second << " PhiBin[" << i
938  << "] = " << convertRadToDeg(phibin[i]);
939  for (unsigned int i=0; i<phiUnitS.size(); ++i)
940  edm::LogVerbatim("HcalGeom") << " PhiUnitS[" << i << "] = " << phiUnitS[i];
941  for (unsigned int i=0; i<nPhiBins.size(); ++i)
942  edm::LogVerbatim("HcalGeom") << " nPhiBins[" << i << "] = " << nPhiBins[i];
943  for (unsigned int i=0; i<hpar->etaTableHF.size(); ++i)
944  edm::LogVerbatim("HcalGeom") << " EtaTableHF[" << i << "] = " << hpar->etaTableHF[i];
945  for (unsigned int i=0; i<hpar->phitable.size(); ++i)
946  edm::LogVerbatim("HcalGeom") << " PhiBinHF[" << i << "] = " << hpar->phitable[i];
947 #endif
948 
949  //Now the depths
951  maxDepth[0] = maxDepth[1] = 0;
952  for (int i=0; i<nEta; ++i) {
953  unsigned int imx = layerGroupSize(i);
954  int laymax = (imx > 0) ? layerGroup(i,imx-1) : 0;
955  if (i < iEtaMax[0]) {
956  int laymax0 = (imx > 16) ? layerGroup(i,16) : laymax;
957  if (i+1 == iEtaMax[0]) laymax0 = hcons.getDepthEta16M(1);
958 #ifdef EDM_ML_DEBUG
959  edm::LogVerbatim("HcalGeom")
960  << "HcalDDDRecConstants:HB " << i << " " << imx << " " << laymax
961  << " " << laymax0;
962 #endif
963  if (maxDepth[0] < laymax0) maxDepth[0] = laymax0;
964  }
965  if (i >= iEtaMin[1]-1 && i < iEtaMax[1]) {
966 #ifdef EDM_ML_DEBUG
967  edm::LogVerbatim("HcalGeom")
968  << "HcalDDDRecConstants:HE " << i << " " << imx << " " << laymax;
969 #endif
970  if (maxDepth[1] < laymax) maxDepth[1] = laymax;
971  }
972  }
973 #ifdef EDM_ML_DEBUG
974  for (int i=0; i<4; ++i)
975  edm::LogVerbatim("HcalGeom")
976  << "HcalDDDRecConstants:Detector Type[" << i << "] iEta "
977  << iEtaMin[i] << ":" << iEtaMax[i] << " MaxDepth " << maxDepth[i];
978 #endif
979 
980  //Now the geometry constants
981  nModule[0] = hpar->modHB[0];
982  nHalves[0] = hpar->modHB[1];
983  for (unsigned int i=0; i<hpar->rHB.size(); ++i) {
984  gconsHB.emplace_back(std::pair<double,double>(hpar->rHB[i]/CLHEP::cm,
985  hpar->drHB[i]/CLHEP::cm));
986  }
987 #ifdef EDM_ML_DEBUG
988  edm::LogVerbatim("HcalGeom")
989  << "HcalDDDRecConstants:HB with " << nModule[0] << " modules and "
990  << nHalves[0] <<" halves and " << gconsHB.size() << " layers";
991  for (unsigned int i=0; i<gconsHB.size(); ++i)
992  edm::LogVerbatim("HcalGeom") << "rHB[" << i << "] = " << gconsHB[i].first
993  << " +- " << gconsHB[i].second;
994 #endif
995  nModule[1] = hpar->modHE[0];
996  nHalves[1] = hpar->modHE[1];
997  for (unsigned int i=0; i<hpar->zHE.size(); ++i) {
998  gconsHE.emplace_back(std::pair<double,double>(hpar->zHE[i]/CLHEP::cm,
999  hpar->dzHE[i]/CLHEP::cm));
1000  }
1001 #ifdef EDM_ML_DEBUG
1002  edm::LogVerbatim("HcalGeom")
1003  << "HcalDDDRecConstants:HE with " << nModule[1] << " modules and "
1004  << nHalves[1] <<" halves and " << gconsHE.size()
1005  << " layers";
1006  for (unsigned int i=0; i<gconsHE.size(); ++i)
1007  edm::LogVerbatim("HcalGeom") << "zHE[" << i << "] = " << gconsHE[i].first
1008  << " +- " << gconsHE[i].second;
1009 #endif
1010 
1011  //Special RBX
1013  if (depthMaxSp_.first == 0) {
1014  depthMaxSp_ = depthMaxDf_ = std::pair<int,int>(2,maxDepth[1]);
1015  } else if (depthMaxSp_.first == 1) {
1016  depthMaxDf_ = std::pair<int,int>(1,maxDepth[0]);
1017  if (depthMaxSp_.second > maxDepth[0]) maxDepth[0] = depthMaxSp_.second;
1018  } else {
1019  depthMaxDf_ = std::pair<int,int>(2,maxDepth[1]);
1020  if (depthMaxSp_.second > maxDepth[1]) maxDepth[1] = depthMaxSp_.second;
1021  }
1022 #ifdef EDM_ML_DEBUG
1023  edm::LogVerbatim("HcalGeom")
1024  << "HcalDDDRecConstants:Detector type and maximum depth for all RBX "
1025  << depthMaxDf_.first << ":" << depthMaxDf_.second
1026  << " and for special RBX " << depthMaxSp_.first
1027  << ":" << depthMaxSp_.second;
1028 #endif
1029 
1030  //Map of special DetId's
1031  std::vector<int> phis;
1032  HcalSubdetector subdet = HcalSubdetector(hcons.ldMap()->validDet(phis));
1033  detIdSp_.clear(); detIdSpR_.clear();
1034  if ((subdet == HcalBarrel) || (subdet == HcalEndcap)) {
1035  int phi = (phis[0] > 0) ? phis[0] : -phis[0];
1036  int zside = (phis[0] > 0) ? 1 : -1;
1037  int lymax = (subdet == HcalBarrel) ? maxLayerHB_+1 : maxLayer_+1;
1038  std::pair<int,int>etas = hcons.ldMap()->validEta();
1039  for (int eta=etas.first; eta<=etas.second; ++eta) {
1040  std::map<int,std::pair<int,int> > oldDep;
1041  int depth(0);
1042  int lmin = layerGroup(eta-1,0);
1043  for (int lay=0; lay<lymax; ++lay) {
1044  int depc = layerGroup(eta-1,lay);
1045  if (depth != depc) {
1046  if (depth != 0) oldDep[depth] = std::pair<int,int>(lmin,lay-1);
1047  depth = depc;
1048  lmin = lay;
1049  }
1050  }
1051  if (depth != 0) oldDep[depth] = std::pair<int,int>(lmin,lymax-1);
1052 #ifdef EDM_ML_DEBUG
1053  edm::LogVerbatim("HcalGeom")
1054  << "HcalDDDRecConstants:Eta|Phi|Zside " << eta << ":" << phi
1055  << ":" << zside << " with " << oldDep.size() << " old Depths";
1056  unsigned int kk(0);
1057  for (std::map<int,std::pair<int,int> >::const_iterator itr=oldDep.begin(); itr != oldDep.end(); ++itr,++kk)
1058  edm::LogVerbatim("HcalGeom")
1059  << "[" << kk << "] " << itr->first <<" --> "
1060  << itr->second.first << ":" << itr->second.second;
1061 #endif
1062  std::pair<int,int> depths = hcons.ldMap()->getDepths(eta);
1063  for (int ndepth=depths.first; ndepth<=depths.second; ++ndepth) {
1064  bool flag = ((subdet == HcalBarrel && eta == iEtaMax[0] &&
1065  ndepth > hcons.getDepthEta16(subdet,phi,zside)) ||
1066  (subdet == HcalEndcap && eta == iEtaMin[1] &&
1067  ndepth < hcons.getDepthEta16(subdet,phi,zside)));
1068  if (!flag) {
1069  std::vector<int> count(oldDep.size(),0);
1070  int layFront = hcons.ldMap()->getLayerFront(subdet,eta,phi,zside,ndepth);
1071  int layBack = hcons.ldMap()->getLayerBack(subdet,eta,phi,zside,ndepth);
1072  for (int lay=layFront; lay<=layBack; ++lay) {
1073  unsigned int l(0);
1074  for (std::map<int,std::pair<int,int> >::iterator itr=oldDep.begin();
1075  itr != oldDep.end(); ++itr,++l) {
1076  if (lay >= (itr->second).first && lay <= (itr->second).second) {
1077  ++count[l]; break;
1078  }
1079  }
1080  }
1081  int odepth(0), maxlay(0);
1082  unsigned int l(0);
1083  for (std::map<int,std::pair<int,int> >::iterator itr=oldDep.begin();
1084  itr != oldDep.end(); ++itr,++l) {
1085  if (count[l] > maxlay) {
1086  odepth = itr->first;
1087  maxlay = count[l];
1088  }
1089  }
1090 #ifdef EDM_ML_DEBUG
1091  edm::LogVerbatim("HcalGeom")
1092  << "HcalDDDRecConstants:New Depth " << ndepth << " old Depth "
1093  << odepth << " max " << maxlay;
1094 #endif
1095  for (int k : phis) {
1096  zside = (k > 0) ? 1 : -1;
1097  phi = (k > 0) ? k : -k;
1098  if (subdet == HcalEndcap && eta == hpar->noff[1] &&
1099  ndepth > hcons.getDepthEta29M(0,true)) break;
1100  HcalDetId newId(subdet,zside*eta,phi,ndepth);
1101  HcalDetId oldId(subdet,zside*eta,phi,odepth);
1102  detIdSp_[newId] = oldId;
1103  std::vector<HcalDetId> ids;
1104  std::map<HcalDetId,std::vector<HcalDetId>>::iterator itr = detIdSpR_.find(oldId);
1105  if (itr != detIdSpR_.end()) ids = itr->second;
1106  ids.emplace_back(newId);
1107  detIdSpR_[oldId] = ids;
1108  }
1109  }
1110  }
1111  }
1112 #ifdef EDM_ML_DEBUG
1113  edm::LogVerbatim("HcalGeom")
1114  << "HcalDDDRecConstants:Map for merging new channels to old channel"
1115  << " IDs with " << detIdSp_.size() <<" entries";
1116  int l(0);
1117  for (auto itr : detIdSp_) {
1118  edm::LogVerbatim("HcalGeom") << "[" << l << "] Special " << itr.first
1119  << " Standard " << itr.second;
1120  ++l;
1121  }
1122  edm::LogVerbatim("HcalGeom")
1123  << "HcalDDDRecConstants:Reverse Map for mapping old to new IDs with "
1124  << detIdSpR_.size() << " entries";
1125  l = 0;
1126  for (auto itr : detIdSpR_) {
1127  edm::LogVerbatim("HcalGeom") << "[" << l << "] Standard " << itr.first
1128  << " Special";
1129  for (auto itr1 : itr.second)
1130  edm::LogVerbatim("HcalGeom") << "ID " << (itr1);
1131  ++l;
1132  }
1133 #endif
1134  }
1135 
1136 }
1137 
1138 unsigned int HcalDDDRecConstants::layerGroupSize(int eta) const {
1139  unsigned int k = 0;
1140  for (auto const & it : hpar->layerGroupEtaRec) {
1141  if (it.layer == (unsigned int)(eta + 1)) {
1142  return it.layerGroup.size();
1143  }
1144  if (it.layer > (unsigned int)(eta + 1)) break;
1145  k = it.layerGroup.size();
1146  }
1147  return k;
1148 }
1149 
1150 unsigned int HcalDDDRecConstants::layerGroup(int eta, int i) const {
1151  unsigned int k = 0;
1152  for (auto const & it : hpar->layerGroupEtaRec) {
1153  if (it.layer == (unsigned int)(eta + 1)) {
1154  return it.layerGroup.at(i);
1155  }
1156  if (it.layer > (unsigned int)(eta + 1)) break;
1157  k = it.layerGroup.at(i);
1158  }
1159  return k;
1160 }
type
Definition: HCALResponse.h:21
std::vector< int > getDepth(const int &det, const int &phi, const int &zside, const unsigned int &eta) const
std::vector< double > etaTable
std::vector< int > iEtaMin
std::vector< int > etagroup
std::pair< int, int > depthMaxSp_
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
std::map< HcalDetId, std::vector< HcalDetId > > detIdSpR_
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
int findDepth(const int &det, const int &eta, const int &phi, const int &zside, const int &lay) const
void getLayerDepth(const int subdet, const int ieta, const int iphi, const int zside, std::map< int, int > &layers) const
std::vector< double > rHB
std::vector< std::pair< int, int > > etaSimValu
HcalDetId mergedDepthDetId(const HcalDetId &id) const
int getFrontLayer(const int &det, const int &eta) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool mergedDepthList29(int ieta, int iphi, int depth) const
int getMinDepth(const int &det, const int &eta, const int &phi, const int &zside, const bool &partialOnly) const
Geom::Theta< T > theta() const
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
unsigned int layerGroup(int eta, int i) const
void getOneEtaBin(HcalSubdetector subdet, int ieta, int zside, std::vector< std::pair< int, double >> &phis, std::map< int, int > &layers, bool planOne, std::vector< HcalDDDRecConstants::HcalEtaBin > &bins) const
int phiNumber(const int &phi, const int &unit) const
static const int maxLayer_
int getSubdet() const
std::vector< int > maxDepth
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
std::vector< double > etaTableHF
int getLayerBack(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
std::vector< int > etaMax
std::vector< int > phiUnitS
std::vector< int > modHB
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)
const HcalParameters * hpar
std::pair< int, int > getDepths(const int eta) const
int validDet(std::vector< int > &phis) const
std::vector< std::pair< double, double > > gconsHE
std::vector< double > zHE
std::vector< HcalEtaBin > getEtaBins(const int &itype) const
std::vector< double > phibin
int getMaxDepth(const int &type) const
const std::vector< double > & getRTableHF() const
void specialRBXHBHE(const std::vector< HcalDetId > &, std::vector< HcalDetId > &) const
int getDepthEta29(const int &phi, const int &zside, const int &i) const
unsigned int numberOfCells(HcalSubdetector) const
HcalDetId idFront(const HcalDetId &id) const
int unitPhi(const int &det, const int &etaR) const
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
std::vector< double > dzHE
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
double getRZ(const int &subdet, const int &ieta, const int &depth) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const std::vector< double > & getPhiTableHF() const
std::vector< HFCellParameters > getHFCellParameters() const
const std::vector< int > & getPhis() const
std::vector< int > iEtaMax
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< HcalCellType > HcalCellTypes() const
std::map< HcalDetId, HcalDetId > detIdSp_
std::vector< int > ietaMap
std::vector< int > nPhiBins
std::vector< int > modHE
std::vector< std::pair< int, int > > layer
std::pair< int, int > validEta() const
T min(T a, T b)
Definition: MathUtil.h:58
void getLayerDepth(const int &ieta, std::map< int, int > &layers) const
int getLastLayer(const int &det, const int &eta) const
std::vector< HcalCellType > HcalCellTypes(HcalSubdetector) const
unsigned int numberOfCells(const HcalSubdetector &) const
int getLayerFront(const int &det, const int &eta, const int &phi, const int &depth) const
std::vector< std::pair< int, double > > getPhis(const int &subdet, const int &ieta) const
HcalDetId idBack(const HcalDetId &id) const
int getDepthEta16M(const int &det) const
#define M_PI
int getDepthEta29M(const int &i, const bool &planOne) const
int k[5][pyjets_maxn]
bin
set the eta bin as selection string.
std::vector< double > phioff
unsigned int layerGroupSize(int eta) const
std::vector< double > etaTable
HcalDDDRecConstants(const HcalParameters *hp, const HcalDDDSimConstants &hc)
int getMaxDepth(const int &type) const
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
std::vector< double > phitable
TString units(TString variable, Char_t axis)
std::vector< double > phibin
std::vector< LayerItem > layerGroupEtaRec
std::vector< double > drHB
const HcalDDDSimConstants & hcons
susybsm::HSCParticleCollection hc
Definition: classes.h:25
std::pair< int, int > depthMaxDf_
std::vector< int > noff
std::vector< HcalActiveLength > getThickActive(const int &type) const
std::pair< int, int > getMaxDepthDet(const int &i) const
const std::vector< HcalDetId > & getIdHF2QIE() const
std::vector< std::pair< double, double > > gconsHB
std::vector< int > maxDepth
std::vector< int > phigroup
int getLayerBack(const int &det, const int &eta, const int &phi, const int &depth) const
static const int maxLayerHB_
std::pair< double, double > getPhiCons(const int &det, const int &ieta) const
std::vector< std::pair< int, double > > phis
std::vector< int > etaMin
unsigned int nCells() const
int getPhiZOne(std::vector< std::pair< int, int > > &phiz) const
int getDepthEta16(const int &det, const int &phi, const int &zside) const
const HcalLayerDepthMap * ldMap() const