CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDDDGeometryLoader.cc
Go to the documentation of this file.
9 
10 #include<string>
11 
13 
14 //#define DebugLog
15 
17  : hcalConstants(hcons) { }
18 
20 }
21 
24 
25  HcalSubdetector hsub = static_cast<HcalSubdetector>(subdet);
26 
27 
28  HcalDDDGeometry* gDDD ( new HcalDDDGeometry(topo) );
29  ReturnType geom ( gDDD );
30 
31  if ( geom->cornersMgr() == 0 ) {
32  const unsigned int count (hcalConstants->numberOfCells(HcalBarrel ) +
36  geom->allocateCorners( count ) ;
37  }
38 
39  // if( geom->cornersMgr() == 0 ) geom->allocateCorners( 2592 ) ;
40 
41  if ( geom->parMgr() == 0 ) geom->allocatePar( 500, 3 ) ;
42 
43  fill (hsub, gDDD, geom );
44  return geom ;
45 }
46 
49 
50  HcalDDDGeometry* gDDD ( new HcalDDDGeometry(topo) );
51  ReturnType geom ( gDDD );
52 
53  if( geom->cornersMgr() == 0 ) {
54  const unsigned int count (hcalConstants->numberOfCells(HcalBarrel ) +
58  geom->allocateCorners( count ) ;
59  }
60  if( geom->parMgr() == 0 ) geom->allocatePar( 500, 3 ) ;
61 
62  fill(HcalBarrel, gDDD, geom);
63  fill(HcalEndcap, gDDD, geom);
64  fill(HcalForward, gDDD, geom);
65  fill(HcalOuter, gDDD, geom);
66  return geom ;
67 }
68 
70  HcalDDDGeometry* geometryDDD,
72 
73  // start by making the new HcalDetIds
74  std::vector<HcalCellType> hcalCells = hcalConstants->HcalCellTypes(subdet);
75  geometryDDD->insertCell(hcalCells);
76 #ifdef DebugLog
77  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill gets "
78  << hcalCells.size() << " cells for subdetector "
79  << subdet;
80 #endif
81  // Make the new HcalDetIds and the cells
82 
83  double deg = M_PI/180.;
84  std::vector<HcalDetId> hcalIds;
85  for (unsigned int i=0; i<hcalCells.size(); i++) {
86  int etaRing = hcalCells[i].etaBin();
87  int depthBin = hcalCells[i].depthSegment();
88  int phiInc = 4/hcalCells[i].nPhiModule();
89  unsigned int iphi = 1;
90  if (hcalCells[i].unitPhi() == 4) iphi = 3;
91  double dphi = (hcalCells[i].phiBinWidth())*deg;
92  double phi =-(hcalCells[i].phiOffset())*deg + 0.5*dphi;
93  std::vector<int>missPlus = hcalCells[i].missingPhiPlus();
94  std::vector<int>missMinus = hcalCells[i].missingPhiMinus();
95 #ifdef DebugLog
96  LogDebug("HCalGeom") << "HcalDDDGeometryLoader: Subdet " << subdet
97  << " eta " << etaRing << " depth " << depthBin
98  << " modules " << hcalCells[i].nPhiModule() << " "
99  << phiInc << " phi " << phi/deg << " " << dphi/deg
100  << " Missing " << missPlus.size() << "/"
101  << missMinus.size();
102 #endif
103  for (int k = 0; k < hcalCells[i].nPhiBins(); k++) {
104  bool ok = true;
105  for (unsigned int kk = 0; kk < missPlus.size(); kk++)
106  if (iphi == (unsigned int)(missPlus[kk])) ok = false;
107  if (ok) {
108 #ifdef DebugLog
109  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i
110  << " eta " << etaRing << " phi " << iphi << "("
111  << phi/deg << ", " << dphi/deg << ") depth "
112  << depthBin;
113 #endif
114  HcalDetId id(subdet, etaRing, iphi, depthBin);
115  hcalIds.push_back(id);
116  makeCell(id,hcalCells[i],phi,dphi,geom) ;
117  }
118  if (hcalCells[i].nHalves() > 1) {
119  ok = true;
120  for (unsigned int kk = 0; kk < missMinus.size(); kk++)
121  if (iphi == (unsigned int)(missMinus[kk])) ok = false;
122  if (ok) {
123 #ifdef DebugLog
124  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i
125  << " eta " << -etaRing << " phi " << iphi <<" ("
126  << phi/deg << ", " << dphi/deg << ") depth "
127  << depthBin;
128 #endif
129  HcalDetId id(subdet, -etaRing, iphi, depthBin);
130  hcalIds.push_back(id);
131  makeCell(id,hcalCells[i],phi,dphi,geom) ;
132  }
133  }
134  iphi += phiInc;
135  phi += dphi;
136  }
137  }
138 
139  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet
140  << " is " << hcalIds.size();
141 }
142 
143 void
145  const HcalCellType& hcalCell,
146  double phi,
147  double dphi,
148  CaloSubdetectorGeometry* geom) const {
149 
150  // the two eta boundaries of the cell
151  double eta1 = hcalCell.etaMin();
152  double eta2 = hcalCell.etaMax();
153  HcalSubdetector subdet = detId.subdet();
154  double eta = 0.5*(eta1+eta2) * detId.zside();
155  double deta = (eta2-eta1);
156  double theta = 2.0*atan(exp(-eta));
157 
158  // barrel vs forward
159  bool rzType = hcalCell.depthType();
160  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
161 
162  double z, r, thickness;
163 #ifdef DebugLog
164  double r0, r1, r2;
165 #endif
166  if (rzType) {
167  r = hcalCell.depthMin();
168  if (isBarrel) {
169  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
170  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
171 #ifdef DebugLog
172  r1 = r;
173  r2 = hcalCell.depthMax();
174  r0 = 0.5*(r1+r2);
175 #endif
176  } else {
177  z = r * sinh(eta2);
178  thickness = 2. * hcalCell.halfSize();
179  r = z/sinh(std::abs(eta));
180 #ifdef DebugLog
181  r0 = z/sinh(std::abs(eta));
182  r1 = z/sinh(std::abs(eta)+0.5*deta);
183  r2 = z/sinh(std::abs(eta)-0.5*deta);
184 #endif
185  }
186 #ifdef DebugLog
187  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
188  << " eta = " << eta << " theta = " << theta
189  << " r = " << r << " thickness = " << thickness
190  << " r0-r2 (" << r0 << ":" << r1 << ":" << r2 << ")";
191 #endif
192  } else {
193  z = hcalCell.depthMin();
194  thickness = hcalCell.depthMax() - z;
195  z *= detId.zside(); // get the sign right.
196  r = z * tan(theta);
197  thickness /= std::abs(cos(theta));
198 #ifdef DebugLog
199  r0 = z/sinh(std::abs(eta));
200  r1 = z/sinh(std::abs(eta)+0.5*deta);
201  r2 = z/sinh(std::abs(eta)-0.5*deta);
202  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
203  << " eta = " << eta << " theta = " << theta
204  << " z = " << z << " r = " << r << " thickness = "
205  << thickness << " r0-r2 (" << r0 << ":" << r1 << ":"
206  << r2 << ")";
207 #endif
208  }
209 
210  double x = r * cos(phi);
211  double y = r * sin(phi);
212  GlobalPoint point(x,y,z);
213 
214 #ifdef DebugLog
215  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell for " << detId
216  << " Point " << point << " deta = " << deta
217  << " dphi = " << dphi << " thickness = " << thickness
218  << " isBarrel = " << isBarrel << " " << rzType;
219 #endif
220 
221  std::vector<CCGFloat> hp ;
222  hp.reserve(3) ;
223 
224  if (subdet==HcalForward) {
225  hp.push_back(deta/2.) ;
226  hp.push_back(dphi/2.) ;
227  hp.push_back(thickness/2.) ;
228  } else {
229  const double sign ( isBarrel ? 1 : -1 ) ;
230  hp.push_back(deta/2.) ;
231  hp.push_back(dphi/2.) ;
232  hp.push_back(sign*thickness/2.) ;
233  }
234  geom->newCell( point, point, point,
236  geom->parMgr(),
237  geom->parVecVec() ),
238  detId ) ;
239 }
#define LogDebug(id)
double depthMax() const
Definition: HcalCellType.h:79
int i
Definition: DBlmapReader.cc:9
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:114
virtual void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)=0
bool isBarrel(GeomDetEnumerators::SubDetector m)
double sign(double x)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
void allocatePar(ParVec::size_type n, unsigned int m)
void fill(HcalSubdetector, HcalDDDGeometry *, CaloSubdetectorGeometry *)
double halfSize() const
Definition: HcalCellType.h:81
unsigned int numberOfCells(HcalSubdetector) const
int insertCell(std::vector< HcalCellType > const &)
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
CaloCellGeometry::CCGFloat CCGFloat
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
void makeCell(const HcalDetId &, const HcalCellType &, double, double, CaloSubdetectorGeometry *geom) const
#define M_PI
double etaMax() const
cell edge, always positive &amp; greater than etaMin
Definition: HcalCellType.h:74
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:24
double etaMin() const
lower cell edge. Always positive
Definition: HcalCellType.h:71
Geom::Phi< T > phi() const
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