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)
18 {
20 }
21 
23 }
24 
27 
28  HcalSubdetector hsub = static_cast<HcalSubdetector>(subdet);
29 
30 
31  HcalDDDGeometry* geom ( new HcalDDDGeometry(topo) );
32 
33  if ( geom->cornersMgr() == nullptr ) {
34  const unsigned int count (hcalConstants_->numberOfCells(HcalBarrel ) +
38  geom->allocateCorners( count ) ;
39  }
40 
41  // if( geom->cornersMgr() == 0 ) geom->allocateCorners( 2592 ) ;
42 
43  if ( geom->parMgr() == nullptr ) geom->allocatePar( 500, 3 ) ;
44 
45  fill (hsub, geom );
46  //fast insertion of valid ids requires sort at end
47  geom->sortValidIds();
48  return geom ;
49 }
50 
53 
54  HcalDDDGeometry* geom ( new HcalDDDGeometry(topo) );
55 
56  if( geom->cornersMgr() == nullptr ) {
57  const unsigned int count (hcalConstants_->numberOfCells(HcalBarrel ) +
61  geom->allocateCorners( count ) ;
62  }
63  if( geom->parMgr() == nullptr ) geom->allocatePar( 500, 3 ) ;
64 
65  fill(HcalBarrel, geom);
66  fill(HcalEndcap, geom);
67  fill(HcalForward, geom);
68  fill(HcalOuter, geom);
69  //fast insertion of valid ids requires sort at end
70  geom->sortValidIds();
71  return geom ;
72 }
73 
76 
77  // start by making the new HcalDetIds
78  std::vector<HcalCellType> hcalCells = hcalConstants_->HcalCellTypes(subdet);
79  geom->insertCell(hcalCells);
80 #ifdef EDM_ML_DEBUG
81  std::cout << "HcalDDDGeometryLoader::fill gets " << hcalCells.size()
82  << " cells for subdetector " << subdet << std::endl;
83 #endif
84  // Make the new HcalDetIds and the cells
85 
86  std::vector<HcalDetId> hcalIds;
87  for (auto & hcalCell : hcalCells) {
88  int etaRing = hcalCell.etaBin();
89  int iside = hcalCell.zside();
90  int depthBin = hcalCell.depthSegment();
91  double dphi = hcalCell.phiBinWidth();
92  std::vector<std::pair<int,double> > phis = hcalCell.phis();
93 #ifdef EDM_ML_DEBUG
94  std::cout << "HcalDDDGeometryLoader: Subdet " << subdet << " side "
95  << iside << " eta " << etaRing << " depth " << depthBin
96  << " with " << phis.size() << "modules:" << std::endl;
97 #endif
98  geom->increaseReserve(phis.size());
99  for (auto & phi : phis) {
100 #ifdef EDM_ML_DEBUG
101  std::cout << "HcalDDDGeometryLoader::fill Cell " << i << " eta "
102  << iside*etaRing << " phi " << phis[k].first << "("
103  << phis[k].second/CLHEP::deg << ", " << dphi/CLHEP::deg
104  << ") depth " << depthBin << std::endl;
105 #endif
106  HcalDetId id(subdet, iside*etaRing, phi.first, depthBin);
107  hcalIds.emplace_back(id);
108  makeCell(id,hcalCell,phi.second,dphi,geom) ;
109  }
110  }
111 
112  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet
113  << " is " << hcalIds.size();
114 }
115 
117  const HcalCellType& hcalCell,
118  double phi, double dphi,
119  HcalDDDGeometry* geom) const {
120 
121  // the two eta boundaries of the cell
122  double eta1 = hcalCell.etaMin();
123  double eta2 = hcalCell.etaMax();
124  HcalSubdetector subdet = detId.subdet();
125  double eta = 0.5*(eta1+eta2) * detId.zside();
126  double deta = (eta2-eta1);
127  double theta = 2.0*atan(exp(-eta));
128 
129  // barrel vs forward
130  bool rzType = hcalCell.depthType();
131  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
132 
133  double z, r, thickness;
134 #ifdef EDM_ML_DEBUG
135  double r0, r1, r2;
136 #endif
137  if (rzType) {
138  r = hcalCell.depthMin();
139  if (isBarrel) {
140  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
141  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
142 #ifdef EDM_ML_DEBUG
143  r1 = r;
144  r2 = hcalCell.depthMax();
145  r0 = 0.5*(r1+r2);
146 #endif
147  } else {
148  z = r * sinh(eta2);
149  thickness = 2. * hcalCell.halfSize();
150  r = z/sinh(std::abs(eta));
151 #ifdef EDM_ML_DEBUG
152  r0 = z/sinh(std::abs(eta));
153  r1 = z/sinh(std::abs(eta)+0.5*deta);
154  r2 = z/sinh(std::abs(eta)-0.5*deta);
155 #endif
156  }
157 #ifdef EDM_ML_DEBUG
158  std::cout << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
159  << " eta = " << eta << " theta = " << theta << " r = " << r
160  << " thickness = " << thickness << " r0-r2 (" << r0 << ":"
161  << r1 << ":" << r2 << ")" << std::endl;
162 #endif
163  } else {
164  z = hcalCell.depthMin();
165  thickness = hcalCell.depthMax() - z;
166  if (isBH_) z += (0.5*thickness);
167  z *= detId.zside(); // get the sign right.
168  r = z * tan(theta);
169  thickness /= std::abs(cos(theta));
170 #ifdef EDM_ML_DEBUG
171  r0 = z/sinh(std::abs(eta));
172  r1 = z/sinh(std::abs(eta)+0.5*deta);
173  r2 = z/sinh(std::abs(eta)-0.5*deta);
174  std::cout << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
175  << " eta = " << eta << " theta = " << theta << " z = " << z
176  << " r = " << r << " thickness = " << thickness << " r0-r2 ("
177  << r0 << ":" << r1 << ":" << r2 << ")" << std::endl;
178 #endif
179  }
180 
181  double x = r * cos(phi);
182  double y = r * sin(phi);
183  GlobalPoint point(x,y,z);
184 
185 #ifdef EDM_ML_DEBUG
186  std::cout << "HcalDDDGeometryLoader::makeCell for " << detId << " Point "
187  << point << " deta = " << deta << " dphi = " << dphi
188  << " thickness = " << thickness << " isBarrel = " << isBarrel
189  << " " << rzType << std::endl;
190 #endif
191 
192  std::vector<CCGFloat> hp ;
193  hp.reserve(3) ;
194 
195  if (subdet==HcalForward) {
196  hp.emplace_back(deta/2.) ;
197  hp.emplace_back(dphi/2.) ;
198  hp.emplace_back(thickness/2.) ;
199  } else {
200  const double sign ( isBarrel ? 1 : -1 ) ;
201  hp.emplace_back(deta/2.) ;
202  hp.emplace_back(dphi/2.) ;
203  hp.emplace_back(sign*thickness/2.) ;
204  }
205  geom->newCellFast( point, point, point,
207  geom->parMgr(),
208  geom->parVecVec() ),
209  detId ) ;
210 }
double depthMax() const
Definition: HcalCellType.h:79
double depthMin() const
Definition: HcalCellType.h:78
bool depthType() const
Definition: HcalCellType.h:80
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
#define nullptr
void allocatePar(ParVec::size_type n, unsigned int m)
void fill(HcalSubdetector, HcalDDDGeometry *)
HcalDDDGeometryLoader()=delete
void newCellFast(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
double halfSize() const
Definition: HcalCellType.h:81
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
const HcalDDDRecConstants * hcalConstants_
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:71
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:24
double etaMin() const
lower cell edge. Always positive
Definition: HcalCellType.h:68
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