CMS 3D CMS Logo

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