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