CMS 3D CMS Logo

HcalDDDGeometryLoader.cc
Go to the documentation of this file.
9 
10 #include<string>
11 
13 
14 //#define EDM_ML_DEBUG
15 
17  : hcalConstants(hcons) {
19 }
20 
22 }
23 
26 
27  HcalSubdetector hsub = static_cast<HcalSubdetector>(subdet);
28 
29 
30  HcalDDDGeometry* geom ( new HcalDDDGeometry(topo) );
31 
32  if ( geom->cornersMgr() == 0 ) {
33  const unsigned int count (hcalConstants->numberOfCells(HcalBarrel ) +
37  geom->allocateCorners( count ) ;
38  }
39 
40  // if( geom->cornersMgr() == 0 ) geom->allocateCorners( 2592 ) ;
41 
42  if ( geom->parMgr() == 0 ) geom->allocatePar( 500, 3 ) ;
43 
44  fill (hsub, geom );
45  //fast insertion of valid ids requires sort at end
46  geom->sortValidIds();
47  return geom ;
48 }
49 
52 
53  HcalDDDGeometry* geom ( new HcalDDDGeometry(topo) );
54 
55  if( geom->cornersMgr() == 0 ) {
56  const unsigned int count (hcalConstants->numberOfCells(HcalBarrel ) +
60  geom->allocateCorners( count ) ;
61  }
62  if( geom->parMgr() == 0 ) geom->allocatePar( 500, 3 ) ;
63 
64  fill(HcalBarrel, geom);
65  fill(HcalEndcap, geom);
66  fill(HcalForward, geom);
67  fill(HcalOuter, geom);
68  //fast insertion of valid ids requires sort at end
69  geom->sortValidIds();
70  return geom ;
71 }
72 
75 
76  // start by making the new HcalDetIds
77  std::vector<HcalCellType> hcalCells = hcalConstants->HcalCellTypes(subdet);
78  geom->insertCell(hcalCells);
79 #ifdef EDM_ML_DEBUG
80  std::cout << "HcalDDDGeometryLoader::fill gets " << hcalCells.size()
81  << " cells for subdetector " << subdet << std::endl;
82 #endif
83  // Make the new HcalDetIds and the cells
84 
85  std::vector<HcalDetId> hcalIds;
86  for (unsigned int i=0; i<hcalCells.size(); i++) {
87  int etaRing = hcalCells[i].etaBin();
88  int iside = hcalCells[i].zside();
89  int depthBin = hcalCells[i].depthSegment();
90  double dphi = hcalCells[i].phiBinWidth();
91  std::vector<std::pair<int,double> > phis = hcalCells[i].phis();
92 #ifdef EDM_ML_DEBUG
93  std::cout << "HcalDDDGeometryLoader: Subdet " << subdet << " side "
94  << iside << " eta " << etaRing << " depth " << depthBin
95  << " with " << phis.size() << "modules:" << std::endl;
96 #endif
97  geom->increaseReserve(phis.size());
98  for (unsigned int k = 0; k < phis.size(); k++) {
99 #ifdef EDM_ML_DEBUG
100  std::cout << "HcalDDDGeometryLoader::fill Cell " << i << " eta "
101  << iside*etaRing << " phi " << phis[k].first << "("
102  << phis[k].second/CLHEP::deg << ", " << dphi/CLHEP::deg
103  << ") depth " << depthBin << std::endl;
104 #endif
105  HcalDetId id(subdet, iside*etaRing, phis[k].first, depthBin);
106  hcalIds.push_back(id);
107  makeCell(id,hcalCells[i],phis[k].second,dphi,geom) ;
108  }
109  }
110 
111  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet
112  << " is " << hcalIds.size();
113 }
114 
116  const HcalCellType& hcalCell,
117  double phi, double dphi,
118  HcalDDDGeometry* geom) const {
119 
120  // the two eta boundaries of the cell
121  double eta1 = hcalCell.etaMin();
122  double eta2 = hcalCell.etaMax();
123  HcalSubdetector subdet = detId.subdet();
124  double eta = 0.5*(eta1+eta2) * detId.zside();
125  double deta = (eta2-eta1);
126  double theta = 2.0*atan(exp(-eta));
127 
128  // barrel vs forward
129  bool rzType = hcalCell.depthType();
130  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
131 
132  double z, r, thickness;
133 #ifdef EDM_ML_DEBUG
134  double r0, r1, r2;
135 #endif
136  if (rzType) {
137  r = hcalCell.depthMin();
138  if (isBarrel) {
139  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
140  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
141 #ifdef EDM_ML_DEBUG
142  r1 = r;
143  r2 = hcalCell.depthMax();
144  r0 = 0.5*(r1+r2);
145 #endif
146  } else {
147  z = r * sinh(eta2);
148  thickness = 2. * hcalCell.halfSize();
149  r = z/sinh(std::abs(eta));
150 #ifdef EDM_ML_DEBUG
151  r0 = z/sinh(std::abs(eta));
152  r1 = z/sinh(std::abs(eta)+0.5*deta);
153  r2 = z/sinh(std::abs(eta)-0.5*deta);
154 #endif
155  }
156 #ifdef EDM_ML_DEBUG
157  std::cout << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
158  << " eta = " << eta << " theta = " << theta << " r = " << r
159  << " thickness = " << thickness << " r0-r2 (" << r0 << ":"
160  << r1 << ":" << r2 << ")" << std::endl;
161 #endif
162  } else {
163  z = hcalCell.depthMin();
164  thickness = hcalCell.depthMax() - z;
165  if (isBH_) z += (0.5*thickness);
166  z *= detId.zside(); // get the sign right.
167  r = z * tan(theta);
168  thickness /= std::abs(cos(theta));
169 #ifdef EDM_ML_DEBUG
170  r0 = z/sinh(std::abs(eta));
171  r1 = z/sinh(std::abs(eta)+0.5*deta);
172  r2 = z/sinh(std::abs(eta)-0.5*deta);
173  std::cout << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
174  << " eta = " << eta << " theta = " << theta << " z = " << z
175  << " r = " << r << " thickness = " << thickness << " r0-r2 ("
176  << r0 << ":" << r1 << ":" << r2 << ")" << std::endl;
177 #endif
178  }
179 
180  double x = r * cos(phi);
181  double y = r * sin(phi);
182  GlobalPoint point(x,y,z);
183 
184 #ifdef EDM_ML_DEBUG
185  std::cout << "HcalDDDGeometryLoader::makeCell for " << detId << " Point "
186  << point << " deta = " << deta << " dphi = " << dphi
187  << " thickness = " << thickness << " isBarrel = " << isBarrel
188  << " " << rzType << std::endl;
189 #endif
190 
191  std::vector<CCGFloat> hp ;
192  hp.reserve(3) ;
193 
194  if (subdet==HcalForward) {
195  hp.push_back(deta/2.) ;
196  hp.push_back(dphi/2.) ;
197  hp.push_back(thickness/2.) ;
198  } else {
199  const double sign ( isBarrel ? 1 : -1 ) ;
200  hp.push_back(deta/2.) ;
201  hp.push_back(dphi/2.) ;
202  hp.push_back(sign*thickness/2.) ;
203  }
204  geom->newCellFast( point, point, point,
206  geom->parMgr(),
207  geom->parVecVec() ),
208  detId ) ;
209 }
double depthMax() const
Definition: HcalCellType.h:77
double depthMin() const
Definition: HcalCellType.h:76
bool depthType() const
Definition: HcalCellType.h:78
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.cc:93
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
CaloCellGeometry::CCGFloat CCGFloat
void allocatePar(ParVec::size_type n, unsigned int m)
void fill(HcalSubdetector, HcalDDDGeometry *)
void newCellFast(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
U second(std::pair< T, U > const &p)
double halfSize() const
Definition: HcalCellType.h:79
unsigned int numberOfCells(HcalSubdetector) const
int insertCell(std::vector< HcalCellType > const &)
void increaseReserve(unsigned int extra)
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
ReturnType load(const HcalTopology &topo, DetId::Detector, int)
std::vector< HcalCellType > HcalCellTypes(HcalSubdetector) const
int k[5][pyjets_maxn]
void makeCell(const HcalDetId &, const HcalCellType &, double, double, HcalDDDGeometry *geom) const
double etaMax() const
cell edge, always positive & greater than etaMin
Definition: HcalCellType.h:69
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:24
double etaMin() const
lower cell edge. Always positive
Definition: HcalCellType.h:66
const HcalDDDRecConstants * hcalConstants
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5