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.
8 
9 #include<string>
10 
12 
13 //#define DebugLog
14 
16  std::string name = "HcalHits";
17  numberingFromDDD = new HcalNumberingFromDDD(name, cpv);
18 }
19 
21  delete numberingFromDDD;
22 }
23 
24 
27 
28  HcalSubdetector hsub = static_cast<HcalSubdetector>(subdet);
29 
30 
31  HcalDDDGeometry* gDDD ( new HcalDDDGeometry(topo) );
32  ReturnType geom ( gDDD );
33 
34  if ( geom->cornersMgr() == 0 ) {
35  const unsigned int count (numberingFromDDD->numberOfCells(HcalBarrel ) +
39  geom->allocateCorners( count ) ;
40  }
41 
42  // if( geom->cornersMgr() == 0 ) geom->allocateCorners( 2592 ) ;
43 
44  if ( geom->parMgr() == 0 ) geom->allocatePar( 500, 3 ) ;
45 
46  fill (hsub, gDDD, geom );
47  return geom ;
48 }
49 
52 
53  HcalDDDGeometry* gDDD ( new HcalDDDGeometry(topo) );
54  ReturnType geom ( gDDD );
55 
56  if( geom->cornersMgr() == 0 ) {
57  const unsigned int count (numberingFromDDD->numberOfCells(HcalBarrel ) +
61  geom->allocateCorners( count ) ;
62  }
63  if( geom->parMgr() == 0 ) geom->allocatePar( 500, 3 ) ;
64 
65  fill(HcalBarrel, gDDD, geom);
66  fill(HcalEndcap, gDDD, geom);
67  fill(HcalForward, gDDD, geom);
68  fill(HcalOuter, gDDD, geom);
69  return geom ;
70 }
71 
73  HcalDDDGeometry* geometryDDD,
75 
76  // start by making the new HcalDetIds
77  std::vector<HcalCellType> hcalCells = numberingFromDDD->HcalCellTypes(subdet);
78  geometryDDD->insertCell(hcalCells);
79 #ifdef DebugLog
80  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill gets "
81  << hcalCells.size() << " cells for subdetector "
82  << subdet;
83 #endif
84  // Make the new HcalDetIds and the cells
85 
86  double deg = M_PI/180.;
87  std::vector<HcalDetId> hcalIds;
88  for (unsigned int i=0; i<hcalCells.size(); i++) {
89  int etaRing = hcalCells[i].etaBin();
90  int depthBin = hcalCells[i].depthSegment();
91  int phiInc = 4/hcalCells[i].nPhiModule();
92  unsigned int iphi = 1;
93  if (hcalCells[i].unitPhi() == 4) iphi = 3;
94  double dphi = (hcalCells[i].phiBinWidth())*deg;
95  double phi =-(hcalCells[i].phiOffset())*deg + 0.5*dphi;
96  std::vector<int>missPlus = hcalCells[i].missingPhiPlus();
97  std::vector<int>missMinus = hcalCells[i].missingPhiMinus();
98 #ifdef DebugLog
99  LogDebug("HCalGeom") << "HcalDDDGeometryLoader: Subdet " << subdet
100  << " eta " << etaRing << " depth " << depthBin
101  << " modules " << hcalCells[i].nPhiModule() << " "
102  << phiInc << " phi " << phi/deg << " " << dphi/deg
103  << " Missing " << missPlus.size() << "/"
104  << missMinus.size();
105 #endif
106  for (int k = 0; k < hcalCells[i].nPhiBins(); k++) {
107  bool ok = true;
108  for (unsigned int kk = 0; kk < missPlus.size(); kk++)
109  if (iphi == (unsigned int)(missPlus[kk])) ok = false;
110  if (ok) {
111 #ifdef DebugLog
112  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i
113  << " eta " << etaRing << " phi " << iphi << "("
114  << phi/deg << ", " << dphi/deg << ") depth "
115  << depthBin;
116 #endif
117  HcalDetId id(subdet, etaRing, iphi, depthBin);
118  hcalIds.push_back(id);
119  makeCell(id,hcalCells[i],phi,dphi,geom) ;
120  }
121  if (hcalCells[i].nHalves() > 1) {
122  ok = true;
123  for (unsigned int kk = 0; kk < missMinus.size(); kk++)
124  if (iphi == (unsigned int)(missMinus[kk])) ok = false;
125  if (ok) {
126 #ifdef DebugLog
127  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i
128  << " eta " << -etaRing << " phi " << iphi <<" ("
129  << phi/deg << ", " << dphi/deg << ") depth "
130  << depthBin;
131 #endif
132  HcalDetId id(subdet, -etaRing, iphi, depthBin);
133  hcalIds.push_back(id);
134  makeCell(id,hcalCells[i],phi,dphi,geom) ;
135  }
136  }
137  iphi += phiInc;
138  phi += dphi;
139  }
140  }
141 
142  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet
143  << " is " << hcalIds.size();
144 }
145 
146 void
148  const HcalCellType& hcalCell,
149  double phi,
150  double dphi,
151  CaloSubdetectorGeometry* geom) const {
152 
153  // the two eta boundaries of the cell
154  double eta1 = hcalCell.etaMin();
155  double eta2 = hcalCell.etaMax();
156  HcalSubdetector subdet = detId.subdet();
157  double eta = 0.5*(eta1+eta2) * detId.zside();
158  double deta = (eta2-eta1);
159  double theta = 2.0*atan(exp(-eta));
160 
161  // barrel vs forward
162  bool rzType = hcalCell.depthType();
163  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
164 
165  double z, r, thickness;
166 #ifdef DebugLog
167  double r0, r1, r2;
168 #endif
169  if (rzType) {
170  r = hcalCell.depthMin();
171  if (isBarrel) {
172  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
173  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
174 #ifdef DebugLog
175  r1 = r;
176  r2 = hcalCell.depthMax();
177  r0 = 0.5*(r1+r2);
178 #endif
179  } else {
180  z = r * sinh(eta2);
181  thickness = 2. * hcalCell.halfSize();
182  r = z/sinh(std::abs(eta));
183 #ifdef DebugLog
184  r0 = z/sinh(std::abs(eta));
185  r1 = z/sinh(std::abs(eta)+0.5*deta);
186  r2 = z/sinh(std::abs(eta)-0.5*deta);
187 #endif
188  }
189 #ifdef DebugLog
190  LogDebug("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet
191  << " eta = " << eta << " theta = " << theta
192  << " r = " << r << " thickness = " << thickness
193  << " r0-r2 (" << r0 << ":" << r1 << ":" << r2 << ")";
194 #endif
195  } else {
196  z = hcalCell.depthMin();
197  thickness = hcalCell.depthMax() - z;
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  {
229  hp.push_back(deta/2.) ;
230  hp.push_back(dphi/2.) ;
231  hp.push_back(thickness/2.) ;
232  }
233  else
234  {
235  const double sign ( isBarrel ? 1 : -1 ) ;
236  hp.push_back(deta/2.) ;
237  hp.push_back(dphi/2.) ;
238  hp.push_back(sign*thickness/2.) ;
239  }
240  geom->newCell( point, point, point,
242  geom->parMgr(),
243  geom->parVecVec() ),
244  detId ) ;
245 }
#define LogDebug(id)
double depthMax() const
Definition: HcalCellType.h:75
int i
Definition: DBlmapReader.cc:9
double depthMin() const
Definition: HcalCellType.h:74
bool depthType() const
Definition: HcalCellType.h:76
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:32
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
std::vector< HcalCellType > HcalCellTypes() const
T eta() const
type of data representation of DDCompactView
Definition: DDCompactView.h:77
void allocatePar(ParVec::size_type n, unsigned int m)
void fill(HcalSubdetector, HcalDDDGeometry *, CaloSubdetectorGeometry *)
float float float z
unsigned int numberOfCells(HcalSubdetector) const
double halfSize() const
Definition: HcalCellType.h:77
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)
HcalNumberingFromDDD * numberingFromDDD
ReturnType load(const HcalTopology &topo, DetId::Detector, int)
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:70
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:24
double etaMin() const
lower cell edge. Always positive
Definition: HcalCellType.h:67
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
Definition: DDAxes.h:10
*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
Definition: DDAxes.h:10