CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalGeomParameters.cc
Go to the documentation of this file.
2 
5 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 //#define DebugLog
19 
21 #ifdef DebugLog
22  std::cout << "HcalGeomParameters::HcalGeomParameters ( const DDCompactView& cpv ) constructor" << std::endl;
23 #endif
24 }
25 
27 #ifdef DebugLog
28  std::cout << "HcalGeomParameters::destructed!!!" << std::endl;
29 #endif
30 }
31 
32 void HcalGeomParameters::getConstRHO( std::vector<double>& rHO ) const {
33 
34  rHO.push_back(rminHO);
35  for (int i=0; i<4; ++i) rHO.push_back(etaHO[i]);
36 }
37 
38 std::vector<int> HcalGeomParameters::getModHalfHBHE(const int type) const {
39 
40  std::vector<int> modHalf;
41  if (type == 0) {
42  modHalf.push_back(nmodHB); modHalf.push_back(nzHB);
43  } else {
44  modHalf.push_back(nmodHE); modHalf.push_back(nzHE);
45  }
46  return modHalf;
47 }
48 
49 unsigned int HcalGeomParameters::find(int element,
50  std::vector<int>& array) const {
51  unsigned int id = array.size();
52  for (unsigned int i = 0; i < array.size(); i++) {
53  if (element == array[i]) {
54  id = i;
55  break;
56  }
57  }
58  return id;
59 }
60 
61 double HcalGeomParameters::getEta(double r, double z) const {
62 
63  double tmp = 0;
64  if (z != 0) tmp = -log(tan(0.5*atan(r/z)));
65 #ifdef DebugLog
66  std::cout << "HcalGeomParameters::getEta " << r << " " << z << " ==> "
67  << tmp << std::endl;
68 #endif
69  return tmp;
70 }
71 
73  HcalParameters& php) {
74 
75  DDFilteredView fv = _fv;
76  bool dodet=true, hf=false;
77  std::vector<double> rb(20,0.0), ze(20,0.0), thkb(20,-1.0), thke(20,-1.0);
78  std::vector<int> ib(20,0), ie(20,0);
79  std::vector<int> izb, phib, ize, phie, izf, phif;
80  std::vector<double> rxb;
81  php.rhoxHB.clear(); php.zxHB.clear(); php.dyHB.clear(); php.dxHB.clear();
82  php.layHB.clear(); php.layHE.clear();
83  php.zxHE.clear(); php.rhoxHE.clear(); php.dyHE.clear(); php.dx1HE.clear(); php.dx2HE.clear();
84  double zf = 0;
85  dzVcal = -1.;
86 
87  while (dodet) {
89  std::vector<int> copy = fv.copyNumbers();
90  const DDSolid & sol = fv.logicalPart().solid();
91  int idet = 0, lay = -1;
92  int nsiz = (int)(copy.size());
93  if (nsiz>0) lay = copy[nsiz-1]/10;
94  if (nsiz>1) idet = copy[nsiz-2]/1000;
95  double dx=0, dy=0, dz=0, dx1=0, dx2=0;
96  if (sol.shape() == 1) {
97  const DDBox & box = static_cast<DDBox>(fv.logicalPart().solid());
98  dx = box.halfX();
99  dy = box.halfY();
100  dz = box.halfZ();
101  } else if (sol.shape() == 3) {
102  const DDTrap & trp = static_cast<DDTrap>(fv.logicalPart().solid());
103  dx1= trp.x1();
104  dx2= trp.x2();
105  dx = 0.25*(trp.x1()+trp.x2()+trp.x3()+trp.x4());
106  dy = 0.5*(trp.y1()+trp.y2());
107  dz = trp.halfZ();
108  } else if (sol.shape() == 2) {
109  const DDTubs & tub = static_cast<DDTubs>(fv.logicalPart().solid());
110  dx = tub.rIn();
111  dy = tub.rOut();
112  dz = tub.zhalf();
113  }
114  if (idet == 3) {
115  // HB
116 #ifdef DebugLog
117  std::cout << "HB " << sol.name() << " Shape " << sol.shape()
118  << " Layer " << lay << " R " << t.Rho() << std::endl;
119 #endif
120  if (lay >=0 && lay < 20) {
121  ib[lay]++;
122  rb[lay] += t.Rho();
123  if (thkb[lay] <= 0) {
124  if (lay < 17) thkb[lay] = dx;
125  else thkb[lay] = std::min(dx,dy);
126  }
127  if (lay < 17) {
128  bool found = false;
129  for (unsigned int k=0; k<rxb.size(); k++) {
130  if (std::abs(rxb[k]-t.Rho()) < 0.01) {
131  found = true;
132  break;
133  }
134  }
135  if (!found) {
136  rxb.push_back(t.Rho());
137  php.rhoxHB.push_back(t.Rho()*std::cos(t.phi()));
138  php.zxHB.push_back(std::abs(t.z()));
139  php.dyHB.push_back(2.*dy);
140  php.dxHB.push_back(2.*dz);
141  php.layHB.push_back(lay);
142  }
143  }
144  }
145  if (lay == 2) {
146  int iz = copy[nsiz-5];
147  int fi = copy[nsiz-4];
148  unsigned int it1 = find(iz, izb);
149  if (it1 == izb.size()) izb.push_back(iz);
150  unsigned int it2 = find(fi, phib);
151  if (it2 == phib.size()) phib.push_back(fi);
152  }
153  if (lay == 18) {
154  int ifi=-1, ich=-1;
155  if (nsiz>2) ifi = copy[nsiz-3];
156  if (nsiz>3) ich = copy[nsiz-4];
157  double z1 = std::abs((t.z()) + dz);
158  double z2 = std::abs((t.z()) - dz);
159  if (std::abs(z1-z2) < 0.01) z1 = 0;
160  if (ifi == 1 && ich == 4) {
161  if (z1 > z2) {
162  double tmp = z1;
163  z1 = z2;
164  z2 = tmp;
165  }
166  bool sok = true;
167  for (unsigned int kk=0; kk<php.zHO.size(); kk++) {
168  if (std::abs(z2-php.zHO[kk]) < 0.01) {
169  sok = false;
170  break;
171  } else if (z2 < php.zHO[kk]) {
172  php.zHO.resize(php.zHO.size()+2);
173  for (unsigned int kz=php.zHO.size()-1; kz>kk+1; kz=kz-2) {
174  php.zHO[kz] = php.zHO[kz-2];
175  php.zHO[kz-1] = php.zHO[kz-3];
176  }
177  php.zHO[kk+1] = z2;
178  php.zHO[kk] = z1;
179  sok = false;
180  break;
181  }
182  }
183  if (sok) {
184  php.zHO.push_back(z1);
185  php.zHO.push_back(z2);
186  }
187 #ifdef DebugLog
188  std::cout << "Detector " << idet << " Lay " << lay << " fi " << ifi
189  << " " << ich << " z " << z1 << " " << z2 << std::endl;
190 #endif
191  }
192  }
193  } else if (idet == 4) {
194  // HE
195 #ifdef DebugLog
196  std::cout << "HE " << sol.name() << " Shape " << sol.shape()
197  << " Layer " << lay << " Z " << t.z() << std::endl;
198 #endif
199  if (lay >=0 && lay < 20) {
200  ie[lay]++;
201  ze[lay] += std::abs(t.z());
202  if (thke[lay] <= 0) thke[lay] = dz;
203  bool found = false;
204  for (unsigned int k=0; k<php.zxHE.size(); k++) {
205  if (std::abs(php.zxHE[k]-std::abs(t.z())) < 0.01) {
206  found = true;
207  break;
208  }
209  }
210  if (!found) {
211  php.zxHE.push_back(std::abs(t.z()));
212  php.rhoxHE.push_back(t.Rho()*std::cos(t.phi()));
213  php.dyHE.push_back(dy*std::cos(t.phi()));
214  dx1 -= 0.5*(t.rho()-dy)*std::cos(t.phi())*std::tan(10*CLHEP::deg);
215  dx2 -= 0.5*(t.rho()+dy)*std::cos(t.phi())*std::tan(10*CLHEP::deg);
216  php.dx1HE.push_back(-dx1);
217  php.dx2HE.push_back(-dx2);
218  php.layHE.push_back(lay);
219  }
220  }
221  if (copy[nsiz-1] == 21 || copy[nsiz-1] == 71) {
222  int iz = copy[nsiz-7];
223  int fi = copy[nsiz-5];
224  unsigned int it1 = find(iz, ize);
225  if (it1 == ize.size()) ize.push_back(iz);
226  unsigned int it2 = find(fi, phie);
227  if (it2 == phie.size()) phie.push_back(fi);
228  }
229  } else if (idet == 5) {
230  // HF
231  if (!hf) {
232  const std::vector<double> & paras = sol.parameters();
233 #ifdef DebugLog
234  std::cout << "HF " << sol.name() << " Shape " << sol.shape()
235  << " Z " << t.z() << " with " << paras.size()
236  << " Parameters" << std::endl;
237  for (unsigned j=0; j<paras.size(); j++)
238  std::cout << "HF Parameter[" << j << "] = " << paras[j] << std::endl;
239 #endif
240  zf = fabs(t.z());
241  if (sol.shape() == ddpolycone_rrz) {
242  int nz = (int)(paras.size())-3;
243  zf += paras[3];
244  dzVcal = 0.5*(paras[nz]-paras[3]);
245  hf = true;
246  } else if (sol.shape() == ddtubs || sol.shape() == ddcons) {
247  dzVcal = paras[0];
248  zf -= paras[0];
249  hf = true;
250  }
251  }
252 #ifdef DebugLog
253  } else {
254  std::cout << "Unknown Detector " << idet << " for " << sol.name()
255  << " Shape " << sol.shape() << " R " << t.Rho() << " Z "
256  << t.z() << std::endl;
257 #endif
258  }
259  dodet = fv.next();
260  }
261 
262  int ibmx = 0, iemx = 0;
263  for (int i = 0; i < 20; i++) {
264  if (ib[i]>0) {
265  rb[i] /= (double)(ib[i]);
266  ibmx = i+1;
267  }
268  if (ie[i]>0) {
269  ze[i] /= (double)(ie[i]);
270  iemx = i+1;
271  }
272 #ifdef DebugLog
273  std::cout << "Index " << i << " Barrel " << ib[i] << " "
274  << rb[i] << " Endcap " << ie[i] << " " << ze[i] << std::endl;
275 #endif
276  }
277  for (int i = 4; i >= 0; i--) {
278  if (ib[i] == 0) {rb[i] = rb[i+1]; thkb[i] = thkb[i+1];}
279  if (ie[i] == 0) {ze[i] = ze[i+1]; thke[i] = thke[i+1];}
280 #ifdef DebugLog
281  if (ib[i] == 0 || ie[i] == 0)
282  std::cout << "Index " << i << " Barrel " << ib[i] << " "
283  << rb[i] << " Endcap " << ie[i] << " " << ze[i] << std::endl;
284 #endif
285  }
286 
287 #ifdef DebugLog
288  for (unsigned int k=0; k<php.layHB.size(); ++k)
289  std::cout << "HB: " << php.layHB[k] << " R " << rxb[k] << " " << php.rhoxHB[k] << " Z " << php.zxHB[k] << " DY " << php.dyHB[k] << " DZ " << php.dxHB[k] << "\n";
290  for (unsigned int k=0; k<php.layHE.size(); ++k)
291  std::cout << "HE: " << php.layHE[k] << " R " << php.rhoxHE[k] << " Z " << php.zxHE[k] << " X1|X2 " << php.dx1HE[k] << "|" << php.dx2HE[k] << " DY " << php.dyHE[k] << "\n";
292  std::cout << "HcalGeomParameters: Maximum Layer for HB " << ibmx << " for HE "
293  << iemx << " Z for HF " << zf << " extent " << dzVcal << std::endl;
294 #endif
295 
296  if (ibmx > 0) {
297  php.rHB.resize(ibmx);
298  php.drHB.resize(ibmx);
299  for (int i=0; i<ibmx; i++) {
300  php.rHB[i] = rb[i];
301  php.drHB[i] = thkb[i];
302 #ifdef DebugLog
303  std::cout << "HcalGeomParameters: php.rHB[" << i << "] = " << php.rHB[i]
304  << " php.drHB[" << i << "] = " << php.drHB[i] << std::endl;
305 #endif
306  }
307  }
308  if (iemx > 0) {
309  php.zHE.resize(iemx);
310  php.dzHE.resize(iemx);
311  for (int i=0; i<iemx; i++) {
312  php.zHE[i] = ze[i];
313  php.dzHE[i] = thke[i];
314 #ifdef DebugLog
315  std::cout << "HcalGeomParameters: php.zHE[" << i << "] = " << php.zHE[i]
316  << " php.dzHE[" << i << "] = " << php.dzHE[i] << std::endl;
317 #endif
318  }
319  }
320 
321  nzHB = (int)(izb.size());
322  nmodHB = (int)(phib.size());
323 #ifdef DebugLog
324  std::cout << "HcalGeomParameters::loadGeometry: " << nzHB
325  << " barrel half-sectors" << std::endl;
326  for (int i=0; i<nzHB; i++)
327  std::cout << "Section " << i << " Copy number " << izb[i] << std::endl;
328  std::cout << "HcalGeomParameters::loadGeometry: " << nmodHB
329  << " barrel modules" << std::endl;
330  for (int i=0; i<nmodHB; i++)
331  std::cout << "Module " << i << " Copy number " << phib[i] << std::endl;
332 #endif
333 
334  nzHE = (int)(ize.size());
335  nmodHE = (int)(phie.size());
336 #ifdef DebugLog
337  std::cout << "HcalGeomParameters::loadGeometry: " << nzHE
338  << " endcap half-sectors" << std::endl;
339  for (int i=0; i<nzHE; i++)
340  std::cout << "Section " << i << " Copy number " << ize[i] << std::endl;
341  std::cout << "HcalGeomParameters::loadGeometry: " << nmodHE
342  << " endcap modules" << std::endl;
343  for (int i=0; i<nmodHE; i++)
344  std::cout << "Module " << i << " Copy number " << phie[i] << std::endl;
345 #endif
346 
347 #ifdef DebugLog
348  std::cout << "HO has Z of size " << php.zHO.size() << std::endl;
349  for (unsigned int kk=0; kk<php.zHO.size(); kk++)
350  std::cout << "ZHO[" << kk << "] = " << php.zHO[kk] << std::endl;
351 #endif
352  if (ibmx > 17 && php.zHO.size() > 4) {
353  rminHO = php.rHB[17]-100.0;
354  etaHO[0] = getEta(0.5*(php.rHB[17]+php.rHB[18]), php.zHO[1]);
355  etaHO[1] = getEta(php.rHB[18]+php.drHB[18], php.zHO[2]);
356  etaHO[2] = getEta(php.rHB[18]-php.drHB[18], php.zHO[3]);
357  etaHO[3] = getEta(php.rHB[18]+php.drHB[18], php.zHO[4]);
358  } else {
359  rminHO =-1.0;
360  etaHO[0] = etaHO[1] = etaHO[2] = etaHO[3] = 0;
361  }
362 #ifdef DebugLog
363  std::cout << "HO Eta boundaries " << etaHO[0] << " " << etaHO[1]
364  << " " << etaHO[2] << " " << etaHO[3] << std::endl;
365  std::cout << "HO Parameters " << rminHO << " " << php.zHO.size();
366  for (int i=0; i<4; ++i) std::cout << " eta[" << i << "] = " << etaHO[i];
367  for (unsigned int i=0; i<php.zHO.size(); ++i) std::cout << " zho[" << i << "] = " << php.zHO[i];
368  std::cout << std::endl;
369 #endif
370 }
type
Definition: HCALResponse.h:21
std::vector< double > zHO
int i
Definition: DBlmapReader.cc:9
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:167
void loadGeometry(const DDFilteredView &_fv, HcalParameters &php)
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
double halfZ(void) const
Definition: DDSolid.cc:258
std::vector< int > layHE
double x1(void) const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
Definition: DDSolid.cc:175
const N & name() const
Definition: DDBase.h:78
int ib
Definition: cuy.py:660
double halfY(void) const
Definition: DDSolid.cc:256
std::vector< double > rHB
nav_type copyNumbers() const
return the stack of copy numbers
unsigned find(int element, std::vector< int > &array) const
std::vector< double > rhoxHB
std::vector< int > getModHalfHBHE(const int type) const
std::vector< double > dx2HE
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
float float float z
void getConstRHO(std::vector< double > &) const
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
std::vector< double > rhoxHE
std::vector< double > zxHE
std::vector< double > zHE
std::vector< double > dyHE
std::vector< double > zxHB
double x4(void) const
Half-length along x of the side at y=+pDy2 of the face at +pDz.
Definition: DDSolid.cc:185
bool next()
set current node to the next node in the filtered tree
std::vector< double > dx1HE
std::vector< double > dzHE
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Interface to a Trapezoid.
Definition: DDSolid.h:77
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double y1(void) const
Half-length along y of the face at -pDz.
Definition: DDSolid.cc:173
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
T min(T a, T b)
Definition: MathUtil.h:58
double rOut(void) const
Definition: DDSolid.cc:509
std::vector< double > dyHB
double halfX(void) const
Definition: DDSolid.cc:254
Interface to a Box.
Definition: DDSolid.h:162
std::vector< double > dxHB
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:177
double zhalf(void) const
Definition: DDSolid.cc:505
double getEta(double r, double z) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< double > drHB
double y2(void) const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:181
tuple cout
Definition: gather_cfg.py:121
const DDTranslation & translation() const
The absolute translation of the current node.
double rIn(void) const
Definition: DDSolid.cc:507
for(const auto &isodef:isoDefs)
std::vector< int > layHB
double x3(void) const
Half-length along x of the side at y=-pDy2 of the face at +pDz.
Definition: DDSolid.cc:183
tuple log
Definition: cmsBatch.py:341