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) {
19 }
20 
22 }
23 
26 
27  HcalSubdetector hsub = static_cast<HcalSubdetector>(subdet);
28 
29 
30  HcalDDDGeometry* gDDD ( new HcalDDDGeometry(topo) );
31  ReturnType geom ( gDDD );
32 
33  if ( geom->cornersMgr() == 0 ) {
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() == 0 ) geom->allocatePar( 500, 3 ) ;
44 
45  fill (hsub, gDDD, geom );
46  return geom ;
47 }
48 
51 
52  HcalDDDGeometry* gDDD ( new HcalDDDGeometry(topo) );
53  ReturnType geom ( gDDD );
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, gDDD, geom);
65  fill(HcalEndcap, gDDD, geom);
66  fill(HcalForward, gDDD, geom);
67  fill(HcalOuter, gDDD, geom);
68  return geom ;
69 }
70 
72  HcalDDDGeometry* geometryDDD,
74 
75  // start by making the new HcalDetIds
76  std::vector<HcalCellType> hcalCells = hcalConstants->HcalCellTypes(subdet);
77  geometryDDD->insertCell(hcalCells);
78 #ifdef DebugLog
79  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill gets "
80  << hcalCells.size() << " cells for subdetector "
81  << subdet;
82 #endif
83  // Make the new HcalDetIds and the cells
84 
85  double deg = M_PI/180.;
86  std::vector<HcalDetId> hcalIds;
87  for (unsigned int i=0; i<hcalCells.size(); i++) {
88  int etaRing = hcalCells[i].etaBin();
89  int depthBin = hcalCells[i].depthSegment();
90  int phiInc = 4/hcalCells[i].nPhiModule();
91  unsigned int iphi = 1;
92  if (hcalCells[i].unitPhi() == 4) iphi = 3;
93  double dphi = (hcalCells[i].phiBinWidth())*deg;
94  double phi =-(hcalCells[i].phiOffset())*deg + 0.5*dphi;
95  std::vector<int>missPlus = hcalCells[i].missingPhiPlus();
96  std::vector<int>missMinus = hcalCells[i].missingPhiMinus();
97 #ifdef DebugLog
98  LogDebug("HCalGeom") << "HcalDDDGeometryLoader: Subdet " << subdet
99  << " eta " << etaRing << " depth " << depthBin
100  << " modules " << hcalCells[i].nPhiModule() << " "
101  << phiInc << " phi " << phi/deg << " " << dphi/deg
102  << " Missing " << missPlus.size() << "/"
103  << missMinus.size();
104 #endif
105  for (int k = 0; k < hcalCells[i].nPhiBins(); k++) {
106  bool ok = true;
107  for (unsigned int kk = 0; kk < missPlus.size(); kk++)
108  if (iphi == (unsigned int)(missPlus[kk])) ok = false;
109  if (ok) {
110 #ifdef DebugLog
111  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i
112  << " eta " << etaRing << " phi " << iphi << "("
113  << phi/deg << ", " << dphi/deg << ") depth "
114  << depthBin;
115 #endif
116  HcalDetId id(subdet, etaRing, iphi, depthBin);
117  hcalIds.push_back(id);
118  makeCell(id,hcalCells[i],phi,dphi,geom) ;
119  }
120  if (hcalCells[i].nHalves() > 1) {
121  ok = true;
122  for (unsigned int kk = 0; kk < missMinus.size(); kk++)
123  if (iphi == (unsigned int)(missMinus[kk])) ok = false;
124  if (ok) {
125 #ifdef DebugLog
126  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i
127  << " eta " << -etaRing << " phi " << iphi <<" ("
128  << phi/deg << ", " << dphi/deg << ") depth "
129  << depthBin;
130 #endif
131  HcalDetId id(subdet, -etaRing, iphi, depthBin);
132  hcalIds.push_back(id);
133  makeCell(id,hcalCells[i],phi,dphi,geom) ;
134  }
135  }
136  iphi += phiInc;
137  phi += dphi;
138  }
139  }
140 
141  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet
142  << " is " << hcalIds.size();
143 }
144 
145 void
147  const HcalCellType& hcalCell,
148  double phi,
149  double dphi,
150  CaloSubdetectorGeometry* geom) const {
151 
152  // the two eta boundaries of the cell
153  double eta1 = hcalCell.etaMin();
154  double eta2 = hcalCell.etaMax();
155  HcalSubdetector subdet = detId.subdet();
156  double eta = 0.5*(eta1+eta2) * detId.zside();
157  double deta = (eta2-eta1);
158  double theta = 2.0*atan(exp(-eta));
159 
160  // barrel vs forward
161  bool rzType = hcalCell.depthType();
162  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
163 
164  double z, r, thickness;
165 #ifdef DebugLog
166  double r0, r1, r2;
167 #endif
168  if (rzType) {
169  r = hcalCell.depthMin();
170  if (isBarrel) {
171  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
172  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
173 #ifdef DebugLog
174  r1 = r;
175  r2 = hcalCell.depthMax();
176  r0 = 0.5*(r1+r2);
177 #endif
178  } else {
179  z = r * sinh(eta2);
180  thickness = 2. * hcalCell.halfSize();
181  r = z/sinh(std::abs(eta));
182 #ifdef DebugLog
183  r0 = z/sinh(std::abs(eta));
184  r1 = z/sinh(std::abs(eta)+0.5*deta);
185  r2 = z/sinh(std::abs(eta)-0.5*deta);
186 #endif
187  }
188 #ifdef DebugLog
189  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
190  << " eta = " << eta << " theta = " << theta
191  << " r = " << r << " thickness = " << thickness
192  << " r0-r2 (" << r0 << ":" << r1 << ":" << r2 << ")";
193 #endif
194  } else {
195  z = hcalCell.depthMin();
196  thickness = hcalCell.depthMax() - z;
197  if (isBH_) z += (0.5*thickness);
198  z *= detId.zside(); // get the sign right.
199  r = z * tan(theta);
200  thickness /= std::abs(cos(theta));
201 #ifdef DebugLog
202  r0 = z/sinh(std::abs(eta));
203  r1 = z/sinh(std::abs(eta)+0.5*deta);
204  r2 = z/sinh(std::abs(eta)-0.5*deta);
205  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
206  << " eta = " << eta << " theta = " << theta
207  << " z = " << z << " r = " << r << " thickness = "
208  << thickness << " r0-r2 (" << r0 << ":" << r1 << ":"
209  << r2 << ")";
210 #endif
211  }
212 
213  double x = r * cos(phi);
214  double y = r * sin(phi);
215  GlobalPoint point(x,y,z);
216 
217 #ifdef DebugLog
218  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell for " << detId
219  << " Point " << point << " deta = " << deta
220  << " dphi = " << dphi << " thickness = " << thickness
221  << " isBarrel = " << isBarrel << " " << rzType;
222 #endif
223 
224  std::vector<CCGFloat> hp ;
225  hp.reserve(3) ;
226 
227  if (subdet==HcalForward) {
228  hp.push_back(deta/2.) ;
229  hp.push_back(dphi/2.) ;
230  hp.push_back(thickness/2.) ;
231  } else {
232  const double sign ( isBarrel ? 1 : -1 ) ;
233  hp.push_back(deta/2.) ;
234  hp.push_back(dphi/2.) ;
235  hp.push_back(sign*thickness/2.) ;
236  }
237  geom->newCell( point, point, point,
239  geom->parMgr(),
240  geom->parVecVec() ),
241  detId ) ;
242 }
#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:93
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