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