CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  std::cout << "HcalDDDRecConstants::HcalDDDRecConstants (const HcalParameters* hp) constructor" << std::endl;
19 #endif
20  initialize();
21 }
22 
24 #ifdef EDM_ML_DEBUG
25  std::cout << "HcalDDDRecConstants::destructed!!!" << std::endl;
26 #endif
27 }
28 
29 std::vector<HcalDDDRecConstants::HcalEtaBin>
30 HcalDDDRecConstants::getEtaBins(const int itype) const {
31 
32  std::vector<HcalDDDRecConstants::HcalEtaBin> bins;
33  unsigned int type = (itype == 0) ? 0 : 1;
34  unsigned int lymax = (type == 0) ? 17 : 19;
35  for (int ieta = iEtaMin[type]; ieta <= iEtaMax[type]; ++ieta) {
36  int nfi = (int)((20.001*nModule[itype]*CLHEP::deg)/phibin[ieta-1]);
37  HcalDDDRecConstants::HcalEtaBin etabin = HcalDDDRecConstants::HcalEtaBin(ieta, etaTable[ieta-1], etaTable[ieta], nfi, hpar->phioff[type], phibin[ieta-1]);
38  int n = (ieta == iEtaMax[type]) ? 0 : 1;
39  HcalDDDRecConstants::HcalEtaBin etabin0= HcalDDDRecConstants::HcalEtaBin(ieta, etaTable[ieta-1], etaTable[ieta+n], nfi, hpar->phioff[type], phibin[ieta-1]);
40  etabin0.depthStart = hcons.getDepthEta29(0)+1;
41  int dstart = -1;
42  if (layerGroupSize(ieta-1) > 0) {
43  int lmin(0), lmax(0);
44  int dep = layerGroup(ieta-1, 0);
45  if (type == 1 && ieta == iEtaMin[1]) dep = hcons.getDepthEta16(1);
46  unsigned lymx0 = (layerGroupSize(ieta-1) > lymax) ? lymax : layerGroupSize(ieta-1);
47 #ifdef EDM_ML_DEBUG
48  std::cout << "Eta " << ieta << ":" << hpar->noff[1] << " lymax " << lymx0
49  << ":" << lymax << " Depth " << dep;
50  for (unsigned int l=0; l<lymax; ++l)
51  std::cout << " [" << l << "] " << layerGroup(ieta-1, l);
52  std::cout << std::endl;
53 #endif
54  for (unsigned int l=0; l<lymx0; ++l) {
55  if ((int)layerGroup(ieta-1, l) == dep) {
56  if (lmin == 0) lmin = l + 1;
57  lmax = l + 1;
58  } else if ((int)layerGroup(ieta-1, l) > dep) {
59  if (dstart < 0) dstart = dep;
60  int lmax0 = (lmax >= lmin) ? lmax : lmin;
61  if (type == 1 && ieta+1 == hpar->noff[1] && dep > hcons.getDepthEta29(0)) {
62  etabin0.layer.push_back(std::pair<int,int>(lmin,lmax0));
63  } else {
64  etabin.layer.push_back(std::pair<int,int>(lmin,lmax0));
65  }
66  lmin = (l + 1);
67  lmax = l;
68  dep = layerGroup(ieta-1, l);
69  }
70  if (type == 0 && ieta == iEtaMax[type] && dep > hcons.getDepthEta16(0)) break;
71  if (type == 1 && ieta == hpar->noff[1] && dep > hcons.getDepthEta29(0)){
72  lmax = lymx0;
73  break;
74  }
75  if (l+1 == lymx0) lmax = lymx0;
76  }
77  if (lmax >= lmin) {
78  if (ieta+1 == hpar->noff[1]) {
79  etabin0.layer.push_back(std::pair<int,int>(lmin,lmax));
80  bins.push_back(etabin0);
81  } else if (ieta == hpar->noff[1]) {
82  } else {
83  etabin.layer.push_back(std::pair<int,int>(lmin,lmax));
84  if (dstart < 0) dstart = dep;
85  }
86  }
87  }
88  etabin.depthStart = dstart;
89  bins.push_back(etabin);
90  }
91 #ifdef EDM_ML_DEBUG
92  std::cout << "Prepares " << bins.size() << " eta bins for type " << type
93  << std::endl;
94  for (unsigned int i=0; i<bins.size(); ++i) {
95  std::cout << "Bin[" << i << "]: Eta = (" << bins[i].ieta << ":"
96  << bins[i].etaMin << ":" << bins[i].etaMax << ") Phi = ("
97  << bins[i].nPhi << ":" << bins[i].phi0 << ":" << bins[i].dphi
98  << ") and " << bins[i].layer.size() << " depths (start) "
99  << bins[i].depthStart << " :";
100  for (unsigned int k=0; k<bins[i].layer.size(); ++k)
101  std::cout << " [" << k << "] " << bins[i].layer[k].first << ":"
102  << bins[i].layer[k].second;
103  std::cout << std::endl;
104  }
105 #endif
106  return bins;
107 }
108 
109 std::pair<double,double>
110 HcalDDDRecConstants::getEtaPhi(int subdet, int ieta, int iphi) const {
111  int ietaAbs = (ieta > 0) ? ieta : -ieta;
112  double eta(0), phi(0);
113  if ((subdet == static_cast<int>(HcalBarrel)) ||
114  (subdet == static_cast<int>(HcalEndcap)) ||
115  (subdet == static_cast<int>(HcalOuter))) { // Use Eta Table
116  int unit = hcons.unitPhi(phibin[ietaAbs-1]);
117  int kphi = (unit == 2) ? ((iphi-1)/2 + 1) : iphi;
118  double foff = (ietaAbs <= iEtaMax[0]) ? hpar->phioff[0] : hpar->phioff[1];
119  eta = 0.5*(etaTable[ietaAbs-1]+etaTable[ietaAbs]);
120  phi = foff + (kphi-0.5)*phibin[ietaAbs-1];
121  } else {
122  ietaAbs -= iEtaMin[2];
123  int unit = hcons.unitPhi(hpar->phitable[ietaAbs-1]);
124  int kphi = (unit == 4) ? ((iphi-3)/4 + 1) : ((iphi-1)/2 + 1);
125  double foff = (unit > 2) ? hpar->phioff[4] : hpar->phioff[2];
126  eta = 0.5*(hpar->etaTableHF[ietaAbs-1]+hpar->etaTableHF[ietaAbs]);
127  phi = foff + (kphi-0.5)*hpar->phitable[ietaAbs-1];
128  }
129  if (ieta < 0) eta = -eta;
130  if (phi > M_PI) phi -= (2*M_PI);
131 #ifdef EDM_ML_DEBUG
132  std::cout << "getEtaPhi: subdet|ieta|iphi " << subdet << "|" << ieta << "|"
133  << iphi << " eta|phi " << eta << "|" << phi << std::endl;
134 #endif
135  return std::pair<double,double>(eta,phi);
136 }
137 
139 HcalDDDRecConstants::getHCID(int subdet, int ieta, int iphi, int lay,
140  int idepth) const {
141 
142  int eta(ieta), phi(iphi), depth(idepth);
143  if ((subdet == static_cast<int>(HcalOuter)) ||
144  ((subdet == static_cast<int>(HcalBarrel)) && (lay > 17))) {
145  subdet= static_cast<int>(HcalOuter);
146  depth = 4;
147  } else if (subdet == static_cast<int>(HcalBarrel) ||
148  subdet == static_cast<int>(HcalEndcap)) {
149  eta = ietaMap[ieta-1];
150  int unit = phiUnitS[ieta-1];
151  int phi0 = (iphi-1)/(hpar->phigroup[eta-1]);
152  if (unit == 2) {
153  phi0 = (iphi+1)/2;
154  phi0 = (phi0-1)/(hpar->phigroup[eta-1]);
155  } else if (unit == 4) {
156  phi0 = (iphi+1)/4;
157  phi0 = (phi0-1)/(hpar->phigroup[eta-1]);
158  }
159  ++phi0;
160  unit = hcons.unitPhi(phibin[eta-1]);
161  phi = hcons.phiNumber(phi0,unit);
162  depth = layerGroup(eta-1, lay-1);
163  if (eta == iEtaMin[1]) {
164  if (subdet == static_cast<int>(HcalBarrel)) {
165  if (depth > hcons.getDepthEta16(0)) depth = hcons.getDepthEta16(0);
166  } else {
167  if (depth < hcons.getDepthEta16(1)) depth = hcons.getDepthEta16(1);
168  }
169  } else if (eta == hpar->noff[0] && lay > 1) {
170  int kphi = phi + int((hpar->phioff[3]+0.1)/phibin[eta-1]);
171  kphi = (kphi-1)%4 + 1;
172  if (kphi == 2 || kphi == 3) depth = layerGroup(eta-1, lay-2);
173  } else if (eta == hpar->noff[1] && depth > 2) {
174  eta = hpar->noff[1]-1;
175  }
176  }
177 #ifdef EDM_ML_DEBUG
178  std::cout << "getHCID: input " << subdet << ":" << ieta << ":" << iphi
179  << ":" << idepth << ":" << lay << " output " << eta << ":" << phi
180  << ":" << depth << std::endl;
181 #endif
182  return HcalDDDRecConstants::HcalID(subdet,eta,phi,depth);
183 }
184 
185 std::vector<HcalDDDRecConstants::HFCellParameters>
187 
188  std::vector<HcalDDDRecConstants::HFCellParameters> cells;
189  unsigned int nEta = hcons.getPhiTableHF().size();
190  if (maxDepth[2] > 0) {
191  for (unsigned int k=0; k<nEta; ++k) {
192  int ieta = iEtaMin[2] + k;
193  int dphi = (int)(0.001 + hcons.getPhiTableHF()[k]/(5.0*CLHEP::deg));
194  int iphi = (dphi == 4) ? 3 : 1;
195  int nphi = 72/dphi;
196  double rMin = hcons.getRTableHF()[nEta-k-1]/CLHEP::cm;
197  double rMax = hcons.getRTableHF()[nEta-k]/CLHEP::cm;
198  HcalDDDRecConstants::HFCellParameters cell1( ieta,1,iphi,dphi,nphi,rMin,rMax);
199  cells.push_back(cell1);
200  HcalDDDRecConstants::HFCellParameters cell2(-ieta,1,iphi,dphi,nphi,rMin,rMax);
201  cells.push_back(cell2);
202  }
203  }
204  if (maxDepth[2] > 2) {
205  if (hcons.getIdHF2QIE().size() > 0) {
206  for (unsigned int k=0; k<hcons.getIdHF2QIE().size(); ++k) {
207  int ieta = hcons.getIdHF2QIE()[k].ieta();
208  int ind = std::abs(ieta) - iEtaMin[2];
209  int dphi = (int)(0.001 + hcons.getPhiTableHF()[ind]/(5.0*CLHEP::deg));
210  int iphi = hcons.getIdHF2QIE()[k].iphi();
211  double rMin = hcons.getRTableHF()[nEta-ind-1]/CLHEP::cm;
212  double rMax = hcons.getRTableHF()[nEta-ind]/CLHEP::cm;
213  HcalDDDRecConstants::HFCellParameters cell1( ieta,3,iphi,dphi,1,rMin,rMax);
214  cells.push_back(cell1);
215  }
216  } else {
217  for (unsigned int k=0; k<nEta; ++k) {
218  int ieta = iEtaMin[2] + k;
219  int dphi = (int)(0.001 + hcons.getPhiTableHF()[k]/(5.0*CLHEP::deg));
220  int iphi = (dphi == 4) ? 3 : 1;
221  int nphi = 72/dphi;
222  double rMin = hcons.getRTableHF()[nEta-k-1]/CLHEP::cm;
223  double rMax = hcons.getRTableHF()[nEta-k]/CLHEP::cm;
224  HcalDDDRecConstants::HFCellParameters cell1( ieta,3,iphi,dphi,nphi,rMin,rMax);
225  cells.push_back(cell1);
226  HcalDDDRecConstants::HFCellParameters cell2(-ieta,3,iphi,dphi,nphi,rMin,rMax);
227  cells.push_back(cell2);
228  }
229  }
230  }
231 #ifdef EDM_ML_DEBUG
232  std::cout << "HcalDDDRecConstants returns " << cells.size()
233  << " HF cell parameters" << std::endl;
234  for (unsigned int k=0; k<cells.size(); ++k)
235  std::cout << "Cell[" << k <<"] : (" << cells[k].ieta <<", "<< cells[k].depth
236  << ", " << cells[k].firstPhi << ", " << cells[k].stepPhi << ", "
237  << cells[k].nPhi << ", " << cells[k].rMin << ", "
238  << cells[k].rMax << ")" << std::endl;
239 #endif
240  return cells;
241 }
242 
243 int HcalDDDRecConstants::getMaxDepth (const int itype, const int ieta) const {
244 
245  int lmax(0);
246  unsigned int type = (itype == 0) ? 0 : 1;
247  unsigned int lymax = (type == 0) ? 17 : 19;
248  if (layerGroupSize(ieta-1) > 0) {
249  if (layerGroupSize(ieta-1) < lymax) lymax = layerGroupSize(ieta-1);
250  lmax = (int)(layerGroup(ieta-1, lymax-1));
251  if (type == 0 && ieta == iEtaMax[type]) lmax = hcons.getDepthEta16(0);
252  if (type == 1 && ieta >= hpar->noff[1]) lmax = hcons.getDepthEta29(0);
253  }
254  return lmax;
255 }
256 
257 int HcalDDDRecConstants::getMinDepth (const int itype, const int ieta) const {
258 
259  int lmin(1);
260  if (itype == 2) { // HF
261  } else if (itype == 3) { //HO
262  lmin = maxDepth[3];
263  } else {
264  unsigned int type = (itype == 0) ? 0 : 1;
265  if (layerGroupSize(ieta-1) > 0) {
266  lmin = (int)(layerGroup(ieta-1, 0));
267  if (type == 1 && ieta == iEtaMin[type]) lmin = hcons.getDepthEta16(1);
268  }
269  }
270  return lmin;
271 }
272 
273 double HcalDDDRecConstants::getRZ(int subdet, int ieta, int depth) const {
274 
275  int ietaAbs = (ieta > 0) ? ieta : -ieta;
276  double rz(0);
277 #ifdef EDM_ML_DEBUG
278  int lay(0);
279 #endif
280  if (ietaAbs < hpar->etaMax[1]) {
281  for (unsigned int k=0; k< layerGroupSize(ietaAbs-1); ++k) {
282  if (depth == (int)layerGroup(ietaAbs-1, k)) {
283  rz = ((subdet == static_cast<int>(HcalBarrel)) ? (gconsHB[k].first) :
284  (gconsHE[k].first));
285  if (rz > 10.) {
286 #ifdef EDM_ML_DEBUG
287  lay = k;
288 #endif
289  break;
290  }
291  }
292  }
293  }
294 #ifdef EDM_ML_DEBUG
295  std::cout << "getRZ: subdet|ieta|depth " << subdet << "|" << ieta << "|"
296  << depth << " lay|rz " << lay << "|" << rz << std::endl;
297 #endif
298  return rz;
299 }
300 
301 std::vector<HcalDDDRecConstants::HcalActiveLength>
303 
304  std::vector<HcalDDDRecConstants::HcalActiveLength> actives;
305  std::vector<HcalDDDRecConstants::HcalEtaBin> bins = getEtaBins(type);
306 #ifdef EDM_ML_DEBUG
307  unsigned int kount(0);
308 #endif
309  for (unsigned int k=0; k<bins.size(); ++k) {
310  int ieta = bins[k].ieta;
311  double eta = 0.5*(bins[k].etaMin+bins[k].etaMax);
312  double theta = 2*atan(exp(-eta));
313  double scale = 1.0/((type == 0) ? sin(theta) : cos(theta));
314  int depth = bins[k].depthStart;
315  for (unsigned int i = 0; i < bins[k].layer.size(); ++i) {
316  double thick(0);
317  for (int j = bins[k].layer[i].first; j <= bins[k].layer[i].second; ++j) {
318  if (type == 0 || j > 1) {
319  double t = ((type == 0) ? gconsHB[j-1].second : gconsHE[j-1].second);
320  if (t > 0) thick += t;
321  }
322  }
323  thick *= (2.*scale);
324  HcalDDDRecConstants::HcalActiveLength active(ieta,depth,eta,thick);
325  actives.push_back(active);
326  ++depth;
327 #ifdef EDM_ML_DEBUG
328  kount++;
329  std::cout << "getThickActive: [" << kount << "] eta:" << active.ieta
330  << ":" << active.eta << " depth " << active.depth << " thick "
331  << active.thick << std::endl;
332 #endif
333  }
334  }
335  return actives;
336 }
337 
338 std::vector<HcalCellType>
340 
341  if (subdet == HcalBarrel || subdet == HcalEndcap) {
342  std::vector<HcalCellType> cells;
343  int isub = (subdet == HcalBarrel) ? 0 : 1;
344  std::vector<HcalDDDRecConstants::HcalEtaBin> etabins = getEtaBins(isub);
345  for (unsigned int bin=0; bin<etabins.size(); ++bin) {
346  std::vector<HcalCellType> temp;
347  std::vector<int> count;
348  std::vector<double> dmin, dmax;
349  for (unsigned int il=0; il<etabins[bin].layer.size(); ++il) {
350  HcalCellType cell(subdet, 0, 0, 0, HcalCellType::HcalCell());
351  temp.push_back(cell);
352  count.push_back(0);
353  dmin.push_back(0);
354  dmax.push_back(0);
355  }
356  int ieta = etabins[bin].ieta;
357  for (int keta=etaSimValu[ieta-1].first; keta<=etaSimValu[ieta-1].second;
358  ++keta) {
359  std::vector<HcalCellType> cells = hcons.HcalCellTypes(subdet,keta,-1);
360  for (unsigned int ic=0; ic<cells.size(); ++ic) {
361  for (unsigned int il=0; il<etabins[bin].layer.size(); ++il) {
362  if (cells[ic].depthSegment() >= etabins[bin].layer[il].first &&
363  cells[ic].depthSegment() <= etabins[bin].layer[il].second) {
364  if (count[il] == 0) {
365  temp[il] = cells[ic];
366  dmin[il] = cells[ic].depthMin();
367  dmax[il] = cells[ic].depthMax();
368  }
369  ++count[il];
370  if (cells[ic].depthMin() < dmin[il]) dmin[il] = cells[ic].depthMin();
371  if (cells[ic].depthMax() > dmax[il]) dmax[il] = cells[ic].depthMax();
372  break;
373  }
374  }
375  }
376  }
377  int unit = hcons.unitPhi(etabins[bin].dphi);
378  for (unsigned int il=0; il<etabins[bin].layer.size(); ++il) {
379  int depth = etabins[bin].depthStart + (int)(il);
380  temp[il].setEta(ieta,etabins[bin].etaMin,etabins[bin].etaMax);
381  temp[il].setPhi(etabins[bin].nPhi,unit,etabins[bin].dphi/CLHEP::deg,
382  hpar->phioff[isub]/CLHEP::deg);
383  temp[il].setDepth(depth,dmin[il],dmax[il]);
384  cells.push_back(temp[il]);
385  }
386  }
387 #ifdef EDM_ML_DEBUG
388  std::cout << "HcalDDDRecConstants: found " << cells.size() << " cells for sub-detector type " << isub << std::endl;
389  for (unsigned int ic=0; ic<cells.size(); ++ic)
390  std::cout << "Cell[" << ic << "] " << cells[ic] << std::endl;
391 #endif
392  return cells;
393  } else {
394  return hcons.HcalCellTypes(subdet,-1,-1);
395  }
396 }
397 
399 
400  if (subdet == HcalBarrel || subdet == HcalEndcap) {
401  unsigned int num = 0;
402  std::vector<HcalCellType> cellTypes = HcalCellTypes(subdet);
403  for (unsigned int i=0; i<cellTypes.size(); i++) {
404  num += (unsigned int)(cellTypes[i].nPhiBins());
405  if (cellTypes[i].nHalves() > 1)
406  num += (unsigned int)(cellTypes[i].nPhiBins());
407  num -= (unsigned int)(cellTypes[i].nPhiMissingBins());
408  }
409 #ifdef EDM_ML_DEBUG
410  edm::LogInfo ("HCalGeom") << "HcalDDDRecConstants:numberOfCells "
411  << cellTypes.size() << " " << num
412  << " for subdetector " << subdet;
413 #endif
414  return num;
415  } else {
416  return hcons.numberOfCells(subdet);
417  }
418 }
419 
420 unsigned int HcalDDDRecConstants::nCells(HcalSubdetector subdet) const {
421 
422  if (subdet == HcalBarrel || subdet == HcalEndcap) {
423  int isub = (subdet == HcalBarrel) ? 0 : 1;
424  std::vector<HcalDDDRecConstants::HcalEtaBin> etabins = getEtaBins(isub);
425  unsigned int ncell(0);
426  for (unsigned int i=0; i<etabins.size(); ++i) {
427  ncell += (((unsigned int)(etabins[i].nPhi))*(etabins[i].layer.size()));
428  }
429  return ncell;
430  } else if (subdet == HcalOuter) {
431  return kHOSizePreLS1;
432  } else if (subdet == HcalForward) {
433  return (unsigned int)(hcons.numberOfCells(subdet));
434  } else {
435  return 0;
436  }
437 }
438 
439 unsigned int HcalDDDRecConstants::nCells() const {
441 }
442 
444 
445  //Eta grouping
446  int nEta = (int)(hpar->etagroup.size());
447  if (nEta != (int)(hpar->phigroup.size())) {
448  edm::LogError("HCalGeom") << "HcalDDDRecConstants: sizes of the vectors "
449  << " etaGroup (" << nEta << ") and phiGroup ("
450  << hpar->phigroup.size() << ") do not match";
451  throw cms::Exception("DDException") << "HcalDDDRecConstants: inconsistent array sizes" << nEta << ":" << hpar->phigroup.size();
452  }
453 
454  // First eta table
455  iEtaMin = hpar->etaMin;
456  iEtaMax = hpar->etaMax;
457  etaTable.clear(); ietaMap.clear(); etaSimValu.clear();
458  int ieta(0), ietaHB(0), ietaHE(0), ietaHEM(0);
459  etaTable.push_back(hpar->etaTable[ieta]);
460  for (int i=0; i<nEta; ++i) {
461  int ef = ieta+1;
462  ieta += (hpar->etagroup[i]);
463  if (ieta >= (int)(hpar->etaTable.size())) {
464  edm::LogError("HCalGeom") << "Going beyond the array boundary "
465  << hpar->etaTable.size() << " at index " << i
466  << " of etaTable from SimConstant";
467  throw cms::Exception("DDException") << "Going beyond the array boundary "
468  << hpar->etaTable.size()
469  << " at index " << i
470  << " of etaTable from SimConstant";
471  } else {
472  etaTable.push_back(hpar->etaTable[ieta]);
473  etaSimValu.push_back(std::pair<int,int>(ef,ieta));
474  }
475  for (int k=0; k<(hpar->etagroup[i]); ++k) ietaMap.push_back(i+1);
476  if (ieta <= hpar->etaMax[0]) ietaHB = i+1;
477  if (ieta <= hpar->etaMin[1]) ietaHE = i+1;
478  if (ieta <= hpar->etaMax[1]) ietaHEM= i+1;
479  }
480  iEtaMin[1] = ietaHE;
481  iEtaMax[0] = ietaHB;
482  iEtaMax[1] = ietaHEM;
483 
484  // Then Phi bins
485  nPhiBins.clear();
486  for (unsigned int k=0; k<4; ++k) nPhiBins.push_back(0);
487  ieta = 0;
488  phibin.clear(); phiUnitS.clear();
489  for (int i=0; i<nEta; ++i) {
490  double dphi = (hpar->phigroup[i])*(hpar->phibin[ieta]);
491  phibin.push_back(dphi);
492  int nphi = (int)((CLHEP::twopi + 0.001)/dphi);
493  if (ieta <= iEtaMax[0]) {
494  if (nphi > nPhiBins[0]) nPhiBins[3] = nPhiBins[0] = nphi;
495  }
496  if (ieta >= iEtaMin[1]) {
497  if (nphi > nPhiBins[1]) nPhiBins[1] = nphi;
498  }
499  ieta += (hpar->etagroup[i]);
500  }
501  for (unsigned int i=1; i<hpar->etaTable.size(); ++i) {
502  int unit = hcons.unitPhi(hpar->phibin[i-1]);
503  phiUnitS.push_back(unit);
504  }
505  for (unsigned int i=0; i<hpar->phitable.size(); ++i) {
506  int nphi = (int)((CLHEP::twopi + 0.001)/hpar->phitable[i]);
507  if (nphi > nPhiBins[2]) nPhiBins[2] = nphi;
508  }
509 #ifdef EDM_ML_DEBUG
510  std::cout << "Modified eta/deltaphi table for " << nEta << " bins" << std::endl;
511  for (int i=0; i<nEta; ++i)
512  std::cout << "Eta[" << i << "] = " << etaTable[i] << ":" << etaTable[i+1]
513  << ":" << etaSimValu[i].first << ":" << etaSimValu[i].second
514  << " PhiBin[" << i << "] = " << phibin[i]/CLHEP::deg <<std::endl;
515  std::cout << "PhiUnitS";
516  for (unsigned int i=0; i<phiUnitS.size(); ++i)
517  std::cout << " [" << i << "] = " << phiUnitS[i];
518  std::cout << std::endl;
519  std::cout << "nPhiBins";
520  for (unsigned int i=0; i<nPhiBins.size(); ++i)
521  std::cout << " [" << i << "] = " << nPhiBins[i];
522  std::cout << std::endl;
523  std::cout << "EtaTableHF";
524  for (unsigned int i=0; i<hpar->etaTableHF.size(); ++i)
525  std::cout << " [" << i << "] = " << hpar->etaTableHF[i];
526  std::cout << std::endl;
527  std::cout << "PhiBinHF";
528  for (unsigned int i=0; i<hpar->phitable.size(); ++i)
529  std::cout << " [" << i << "] = " << hpar->phitable[i];
530  std::cout << std::endl;
531 #endif
532 
533  //Now the depths
535  maxDepth[0] = maxDepth[1] = 0;
536  for (int i=0; i<nEta; ++i) {
537  unsigned int imx = layerGroupSize(i);
538  int laymax = (imx > 0) ? layerGroup(i,imx-1) : 0;
539  if (i < iEtaMax[0]) {
540  int laymax0 = (imx > 16) ? layerGroup(i,16) : laymax;
541  if (i+1 == iEtaMax[0]) laymax0 = hcons.getDepthEta16(0);
542 #ifdef EDM_ML_DEBUG
543  std::cout << "HB " << i << " " << imx << " " << laymax << " " << laymax0 << std::endl;
544 #endif
545  if (maxDepth[0] < laymax0) maxDepth[0] = laymax0;
546  }
547  if (i >= iEtaMin[1]-1 && i < iEtaMax[1]) {
548 #ifdef EDM_ML_DEBUG
549  std::cout << "HE " << i << " " << imx << " " << laymax << std::endl;
550 #endif
551  if (maxDepth[1] < laymax) maxDepth[1] = laymax;
552  }
553  }
554 #ifdef EDM_ML_DEBUG
555  for (int i=0; i<4; ++i)
556  std::cout << "Detector Type[" << i << "] iEta " << iEtaMin[i] << ":"
557  << iEtaMax[i] << " MaxDepth " << maxDepth[i] << std::endl;
558 #endif
559 
560  //Now the geometry constants
561  nModule[0] = hpar->modHB[0];
562  nHalves[0] = hpar->modHB[1];
563  for (unsigned int i=0; i<hpar->rHB.size(); ++i) {
564  gconsHB.push_back(std::pair<double,double>(hpar->rHB[i]/CLHEP::cm,
565  hpar->drHB[i]/CLHEP::cm));
566  }
567 #ifdef EDM_ML_DEBUG
568  std::cout << "HB with " << nModule[0] << " modules and " << nHalves[0]
569  <<" halves and " << gconsHB.size() << " layers" << std::endl;
570  for (unsigned int i=0; i<gconsHB.size(); ++i)
571  std::cout << "rHB[" << i << "] = " << gconsHB[i].first << " +- "
572  << gconsHB[i].second << std::endl;
573 #endif
574  nModule[1] = hpar->modHE[0];
575  nHalves[1] = hpar->modHE[1];
576  for (unsigned int i=0; i<hpar->zHE.size(); ++i) {
577  gconsHE.push_back(std::pair<double,double>(hpar->zHE[i]/CLHEP::cm,
578  hpar->dzHE[i]/CLHEP::cm));
579  }
580 #ifdef EDM_ML_DEBUG
581  std::cout << "HE with " << nModule[1] << " modules and " << nHalves[1]
582  <<" halves and " << gconsHE.size() << " layers" << std::endl;
583  for (unsigned int i=0; i<gconsHE.size(); ++i)
584  std::cout << "zHE[" << i << "] = " << gconsHE[i].first << " +- "
585  << gconsHE[i].second << std::endl;
586 #endif
587 }
588 
589 unsigned int HcalDDDRecConstants::layerGroupSize(unsigned int eta) const {
590  unsigned int k = 0;
591  for( auto const & it : hpar->layerGroupEtaRec ) {
592  if( it.layer == eta + 1 ) {
593  return it.layerGroup.size();
594  }
595  if( it.layer > eta + 1 ) break;
596  k = it.layerGroup.size();
597  }
598  return k;
599 }
600 
601 unsigned int HcalDDDRecConstants::layerGroup(unsigned int eta,
602  unsigned int i) const {
603  unsigned int k = 0;
604  for( auto const & it : hpar->layerGroupEtaRec ) {
605  if( it.layer == eta + 1 ) {
606  return it.layerGroup.at( i );
607  }
608  if( it.layer > eta + 1 ) break;
609  k = it.layerGroup.at( i );
610  }
611  return k;
612 }
613 
614 const std::vector<int> & HcalDDDRecConstants::getDepth(const unsigned int i) const {
615  std::vector<HcalParameters::LayerItem>::const_iterator last = hpar->layerGroupEtaRec.begin();
616  for( std::vector<HcalParameters::LayerItem>::const_iterator it = hpar->layerGroupEtaRec.begin(); it != hpar->layerGroupEtaRec.end(); ++it ) {
617  if( it->layer == i + 1 )
618  return it->layerGroup;
619  if( it->layer > i + 1 )
620  return last->layerGroup;
621  last = it;
622  }
623  return last->layerGroup;
624 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
std::vector< double > etaTable
std::vector< int > iEtaMin
std::vector< int > etagroup
int unitPhi(int det, int etaR) const
double getRZ(int subdet, int ieta, int depth) const
std::vector< double > rHB
std::vector< std::pair< int, int > > etaSimValu
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
std::vector< int > maxDepth
int getMinDepth(const int itype, const int ieta) const
std::vector< double > etaTableHF
unsigned int numberOfCells(HcalSubdetector) const
std::vector< int > etaMax
int getDepthEta16(int i) const
std::vector< int > phiUnitS
std::vector< int > modHB
U second(std::pair< T, U > const &p)
const HcalParameters * hpar
int getMaxDepth(const int type) const
std::vector< std::pair< double, double > > gconsHE
std::vector< double > zHE
std::vector< double > phibin
const std::vector< double > & getRTableHF() const
unsigned int numberOfCells(HcalSubdetector) const
unsigned int layerGroup(unsigned int eta, unsigned int i) const
string unit
Definition: csvLumiCalc.py:46
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
std::vector< double > dzHE
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const std::vector< double > & getPhiTableHF() const
std::vector< HFCellParameters > getHFCellParameters() const
std::vector< int > iEtaMax
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
std::vector< HcalCellType > HcalCellTypes() const
std::vector< int > ietaMap
std::vector< int > nPhiBins
std::vector< int > modHE
std::vector< std::pair< int, int > > layer
unsigned int layerGroupSize(unsigned int eta) const
std::vector< HcalCellType > HcalCellTypes(HcalSubdetector) const
std::vector< HcalActiveLength > getThickActive(const int type) const
#define M_PI
std::vector< double > phioff
int getDepthEta29(int i) const
std::vector< double > etaTable
HcalDDDRecConstants(const HcalParameters *hp, const HcalDDDSimConstants &hc)
const std::vector< int > & getDepth(const unsigned int i) const
std::vector< double > phitable
std::vector< double > phibin
std::vector< LayerItem > layerGroupEtaRec
int phiNumber(int phi, int unit) const
std::vector< double > drHB
const HcalDDDSimConstants & hcons
susybsm::HSCParticleCollection hc
Definition: classes.h:25
std::vector< int > noff
tuple cout
Definition: gather_cfg.py:145
const std::vector< HcalDetId > & getIdHF2QIE() const
std::vector< std::pair< double, double > > gconsHB
std::vector< int > maxDepth
std::vector< int > phigroup
for(const auto &isodef:isoDefs)
std::pair< double, double > getEtaPhi(int subdet, int ieta, int iphi) const
std::vector< int > etaMin
unsigned int nCells() const
std::vector< HcalEtaBin > getEtaBins(const int itype) const