CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDHCalEndcapAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalEndcapAlgo.cc
3 // adapted from CCal(G4)HcalEndcap.cc
4 // Description: Geometry factory class for Hcal Endcap
6 
7 #include <cmath>
8 #include <algorithm>
9 
10 namespace std{} using namespace std;
19 #include "CLHEP/Units/GlobalPhysicalConstants.h"
20 #include "CLHEP/Units/GlobalSystemOfUnits.h"
21 
23  modMat(0),modType(0),sectionModule(0),layerN(0),layerN0(0),layerN1(0),
24  layerN2(0),layerN3(0),layerN4(0),layerN5(0),thick(0),trimLeft(0),
25  trimRight(0),zminBlock(0),zmaxBlock(0),rinBlock1(0),routBlock1(0),
26  rinBlock2(0),routBlock2(0),layerType(0),layerT(0),scintT(0) {
27  LogDebug("HCalGeom") << "DDHCalEndcapAlgo info: Creating an instance";
28 }
29 
31 
32 int DDHCalEndcapAlgo::getLayer(unsigned int i, unsigned int j) const {
33 
34  switch (i) {
35  case 0:
36  return layerN0[j];
37  break;
38 
39  case 1:
40  return layerN1[j];
41  break;
42 
43  case 2:
44  return layerN2[j];
45  break;
46 
47  case 3:
48  return layerN3[j];
49  break;
50 
51  case 4:
52  return layerN4[j];
53  break;
54 
55  case 5:
56  return layerN5[j];
57  break;
58 
59  default:
60  return 0;
61  }
62 }
63 
64 double DDHCalEndcapAlgo::getTrim(unsigned int i, unsigned int j) const {
65 
66  if (j == 0)
67  return trimLeft[i];
68  else
69  return trimRight[j];
70 }
71 
73  const DDVectorArguments & vArgs,
74  const DDMapArguments & ,
75  const DDStringArguments & sArgs,
76  const DDStringVectorArguments & vsArgs) {
77 
78  int i,j;
79  genMaterial = sArgs["MaterialName"];
80  rotation = sArgs["Rotation"];
81  nsectors = int (nArgs["Sector"]);
82  nsectortot = int (nArgs["SectorTot"]);
83  nEndcap = int (nArgs["Endcap"]);
84  rotHalf = sArgs["RotHalf"];
85  rotns = sArgs["RotNameSpace"];
86  zShift = nArgs["ZShift"];
87 
88  zFront = nArgs["ZFront"];
89  zEnd = nArgs["ZEnd"];
90  ziNose = nArgs["ZiNose"];
91  ziL0Nose = nArgs["ZiL0Nose"];
92  ziBody = nArgs["ZiBody"];
93  ziL0Body = nArgs["ZiL0Body"];
94  z0Beam = nArgs["Z0Beam"];
95  ziDip = nArgs["ZiDip"];
96  dzStep = nArgs["DzStep"];
97  zShiftHac2 = nArgs["ZShiftHac2"];
98  double gap = nArgs["Gap"];
99  double z1 = nArgs["Z1"];
100  double r1 = nArgs["R1"];
101  rout = nArgs["Rout"];
102  heboxDepth = nArgs["HEboxDepth"];
103  drEnd = nArgs["DrEnd"];
104  double etamin = nArgs["Etamin"];
105  angBot = nArgs["AngBot"];
106  angGap = nArgs["AngGap"];
107 
108  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: General material "
109  << genMaterial << "\tSectors " << nsectors << ", "
110  << nsectortot << "\tEndcaps " << nEndcap
111  << "\tRotation matrix for half " << rotns
112  << ":" << rotHalf << "\n\tzFront " << zFront << " zEnd "
113  << zEnd << " ziNose " << ziNose << " ziL0Nose "
114  << ziL0Nose << " ziBody " << ziBody << " ziL0Body "
115  << ziL0Body << " z0Beam " << z0Beam << " ziDip "
116  << ziDip << " dzStep " << dzStep << " Gap " << gap
117  << " z1 " << z1 << "\n\tr1 " << r1 << " rout " << rout
118  << " HeboxDepth " << heboxDepth << " drEnd " << drEnd
119  << "\tetamin " << etamin << " Bottom angle " << angBot
120  << " Gap angle " << angGap << " Z-Shift " << zShift
121  << " " << zShiftHac2;
122 
123  //Derived quantities
124  angTop = 2.0 * atan (exp(-etamin));
125  slope = tan(angGap);
126  z1Beam = z1 - r1/slope;
127  ziKink = z1Beam + rout/slope;
128  riKink = ziKink*tan(angBot);
129  riDip = ziDip*tan(angBot);
130  roDip = rout - heboxDepth;
131  dzShift = (z1Beam - z0Beam) - gap/sin(angGap);
132  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: angTop "
133  << angTop/CLHEP::deg <<"\tSlope " << slope
134  << "\tDzShift " << dzShift << "\n\tz1Beam " << z1Beam
135  << "\tziKink" << ziKink << "\triKink " << riKink
136  << "\triDip " << riDip << "\n\troDip " << roDip
137  << "\tRotation " << rotation;
138 
140  //Modules
141  absMat = sArgs["AbsMat"];
142  modules = int(nArgs["Modules"]);
143  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Number of modules "
144  << modules << " and absorber material " << absMat;
145 
146  modName = vsArgs["ModuleName"];
147  modMat = vsArgs["ModuleMat"];
148  modType = dbl_to_int(vArgs["ModuleType"]);
149  sectionModule = dbl_to_int(vArgs["SectionModule"]);
150  thick = vArgs["ModuleThick"];
151  trimLeft = vArgs["TrimLeft"];
152  trimRight = vArgs["TrimRight"];
153  eModule = dbl_to_int(vArgs["EquipModule"]);
154  layerN = dbl_to_int(vArgs["LayerN"]);
155  layerN0 = dbl_to_int(vArgs["LayerN0"]);
156  layerN1 = dbl_to_int(vArgs["LayerN1"]);
157  layerN2 = dbl_to_int(vArgs["LayerN2"]);
158  layerN3 = dbl_to_int(vArgs["LayerN3"]);
159  layerN4 = dbl_to_int(vArgs["LayerN4"]);
160  layerN5 = dbl_to_int(vArgs["LayerN5"]);
161  for (i = 0; i < modules; i++) {
162  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: " << modName[i] <<" type "
163  << modType[i] << " Sections " << sectionModule[i]
164  << " thickness of absorber/air " << thick[i]
165  << " trim " << trimLeft[i] << ", " << trimRight[i]
166  << " equip module " << eModule[i] << " with "
167  << layerN[i] << " layers";
168  if (i == 0) {
169  for (j = 0; j < layerN[i]; j++) {
170  LogDebug("HCalGeom") << "\t " << layerN0[j] << "/" << layerN0[j+1];
171  }
172  } else if (i == 1) {
173  for (j = 0; j < layerN[i]; j++) {
174  LogDebug("HCalGeom") << "\t " << layerN1[j] << "/" << layerN1[j+1];
175  }
176  } else if (i == 2) {
177  for (j = 0; j < layerN[i]; j++) {
178  LogDebug("HCalGeom") << "\t " << layerN2[j];
179  }
180  } else if (i == 3) {
181  for (j = 0; j < layerN[i]; j++) {
182  LogDebug("HCalGeom") << "\t " << layerN3[j];
183  }
184  } else if (i == 4) {
185  for (j = 0; j < layerN[i]; j++) {
186  LogDebug("HCalGeom") << "\t " << layerN4[j];
187  }
188  } else if (i == 5) {
189  for (j = 0; j < layerN[i]; j++) {
190  LogDebug("HCalGeom") << "\t " << layerN5[j];
191  }
192  }
193  }
194 
196  //Layers
197  phiSections = int(nArgs["PhiSections"]);
198  phiName = vsArgs["PhiName"];
199  layers = int(nArgs["Layers"]);
200  layerName = vsArgs["LayerName"];
201  layerType = dbl_to_int(vArgs["LayerType"]);
202  layerT = vArgs["LayerT"];
203  scintT = vArgs["ScintT"];
204  scintMat = sArgs["ScintMat"];
205  plastMat = sArgs["PlastMat"];
206  rotmat = sArgs["RotMat"];
207  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Phi Sections "
208  << phiSections;
209  for (i = 0; i < phiSections; i++)
210  LogDebug("HCalGeom") << "\tName[" << i << "] : " << phiName[i];
211  LogDebug("HCalGeom") << "\tPlastic: " << plastMat << "\tScintillator: "
212  << scintMat << "\tRotation matrix " << rotns << ":"
213  << rotmat << "\n\tNumber of layers " << layers;
214  for (i = 0; i < layers; i++) {
215  LogDebug("HCalGeom") << "\t" << layerName[i] << "\tType " << layerType[i]
216  << "\tThickness " << layerT[i] << "\tScint.Thick "
217  << scintT[i];
218  }
219 
221  // Derive bounding of the modules
222  int module = 0;
223  // Layer 0 (Nose)
224  if (modules > 0) {
225  zminBlock.push_back(ziL0Nose);
226  zmaxBlock.push_back(zminBlock[module] + layerT[0] + 0.5*dzStep);
227  rinBlock1.push_back(zminBlock[module] * tan(angTop));
228  rinBlock2.push_back(zmaxBlock[module] * tan(angTop));
229  routBlock1.push_back((zminBlock[module] - z1Beam) * slope);
230  routBlock2.push_back((zmaxBlock[module] - z1Beam) * slope);
231  module++;
232  }
233 
234  // Layer 0 (Body)
235  if (modules > 1) {
236  zminBlock.push_back(ziL0Body);
237  zmaxBlock.push_back(zminBlock[module] + layerT[0] + 0.5*dzStep);
238  rinBlock1.push_back(zminBlock[module] * tan(angBot));
239  rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
240  routBlock1.push_back(zminBlock[module] * tan(angTop));
241  routBlock2.push_back(zmaxBlock[module] * tan(angTop));
242  module++;
243  }
244 
245  // Hac1
246  if (modules > 2) {
247  zminBlock.push_back(ziNose);
248  zmaxBlock.push_back(ziBody);
249  rinBlock1.push_back(zminBlock[module] * tan(angTop));
250  rinBlock2.push_back(zmaxBlock[module] * tan(angTop));
251  routBlock1.push_back((zminBlock[module] - z1Beam) * slope);
252  routBlock2.push_back((zmaxBlock[module] - z1Beam) * slope);
253  module++;
254  }
255 
256  // Hac2
257  if (modules > 3) {
258  zminBlock.push_back(ziBody);
259  zmaxBlock.push_back(zminBlock[module] + layerN[3]*dzStep);
260  rinBlock1.push_back(zminBlock[module] * tan(angBot));
261  rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
262  routBlock1.push_back((zmaxBlock[module-1] - z1Beam) * slope);
263  routBlock2.push_back(rout);
264  module++;
265  }
266 
267  // Hac3
268  if (modules > 4) {
269  zminBlock.push_back(zmaxBlock[module-1]);
270  zmaxBlock.push_back(zminBlock[module] + layerN[4]*dzStep);
271  rinBlock1.push_back(zminBlock[module] * tan(angBot));
272  rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
273  routBlock1.push_back(rout);
274  routBlock2.push_back(rout);
275  module++;
276  }
277 
278  // Hac4
279  if (modules > 5) {
280  zminBlock.push_back(zmaxBlock[module-1]);
281  zmaxBlock.push_back(zminBlock[module] + layerN[5]*dzStep);
282  rinBlock1.push_back(zminBlock[module] * tan(angBot));
283  rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
284  routBlock1.push_back(rout);
285  routBlock2.push_back(roDip);
286  module++;
287  }
288 
289  for (i = 0; i < module; i++)
290  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Module " << i
291  << "\tZ/Rin/Rout " << zminBlock[i] << ", "
292  << zmaxBlock[i] << "/ " << rinBlock1[i] << ", "
293  << rinBlock2[i] << "/ " << routBlock1[i] << ", "
294  << routBlock2[i];
295 
296  idName = sArgs["MotherName"];
298  idOffset = int (nArgs["IdOffset"]);
299  DDName parentName = parent().name();
300  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Parent " << parentName
301  << " idName " << idName << " NameSpace " << idNameSpace
302  << " Offset " << idOffset;
303 
304  tolPos = nArgs["TolPos"];
305  tolAbs = nArgs["TolAbs"];
306  LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Tolerances - Positioning "
307  << tolPos << " Absorber " << tolAbs;
308 }
309 
311 // DDHCalEndcapAlgo methods...
313 
315 
316  LogDebug("HCalGeom") << "==>> Constructing DDHCalEndcapAlgo...";
318  LogDebug("HCalGeom") << "<<== End of DDHCalEndcapAlgo construction ...";
319 }
320 
321 //----------------------start here for DDD work!!! ---------------
322 
324 
325  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: General volume...";
326  bool proto = true;
327  for (int i=0; i<3; i++)
328  if (equipModule(i) > 0) proto = false;
329 
330  DDRotation rot;
331  if (DDSplit(getRotation()).first == "NULL") rot = DDRotation();
333  LogDebug("HCalGeom") << " First " << DDSplit(getRotation()).first
334  << " Second " << DDSplit(getRotation()).second
335  << " Rotation " << rot;
336  DDTranslation r0(0,0,getZShift());
337  double alpha = CLHEP::pi/getNsectors();
338  double dphi = getNsectortot()*CLHEP::twopi/getNsectors();
339 
341  //vertical walls are allowed in SolidPolyhedra
342  double delz = 0;
343 
344  vector<double> pgonZ, pgonRmin, pgonRmax;
345  if (proto) {
346  double zf = getZiBody() + getZShiftHac2();
347  pgonZ.push_back(zf - getDzShift());
348  pgonRmin.push_back(zf * tan(getAngBot()));
349  pgonRmax.push_back((zf - getZ1Beam())*getSlope());
350  } else {
351  pgonZ.push_back(getZFront() - getDzShift());
352  pgonRmin.push_back(getZFront() * tan(getAngTop()));
353  pgonRmax.push_back((getZFront() - getZ1Beam())*getSlope());
354  pgonZ.push_back(getZiL0Body() - getDzShift());
355  pgonRmin.push_back(getZiL0Body() * tan(getAngTop()));
356  pgonRmax.push_back((getZiL0Body() - getZ1Beam())*getSlope());
357  pgonZ.push_back(getZiL0Body() - getDzShift());
358  pgonRmin.push_back(getZiL0Body() * tan(getAngBot()));
359  pgonRmax.push_back((getZiL0Body() - getZ1Beam())*getSlope());
360  }
361  pgonZ.push_back(getZiKink() - getDzShift());
362  pgonRmin.push_back(getRinKink());
363  pgonRmax.push_back(getRout());
364  pgonZ.push_back(getZiDip() - getDzShift());
365  pgonRmin.push_back(getRinDip());
366  pgonRmax.push_back(getRout());
367  pgonZ.push_back(getZiDip() - getDzShift() + delz);
368  pgonRmin.push_back(getRinDip());
369  pgonRmax.push_back(getRoutDip());
370  pgonZ.push_back(getZEnd() - getDzShift());
371  pgonRmin.push_back(getZEnd() * tan(getAngBot()));
372  pgonRmax.push_back(getRoutDip());
373  pgonZ.push_back(getZEnd());
374  pgonRmin.push_back(getZEnd() * tan(getAngBot()));
375  pgonRmax.push_back(getRoutDip());
376 
377  string name("Null");
378  unsigned int i=0;
379  DDSolid solid;
381  getNsectortot(), -alpha, dphi, pgonZ,
382  pgonRmin, pgonRmax);
383  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: "
384  << DDName(idName, idNameSpace) << " Polyhedra made of "
385  << getGenMat() << " with " << getNsectortot()
386  << " sectors from " << -alpha/CLHEP::deg << " to "
387  << (-alpha+dphi)/CLHEP::deg << " and with "
388  << pgonZ.size() << " sections";
389  for (i = 0; i <pgonZ.size(); i++)
390  LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[i] << "\tRmin = " <<pgonRmin[i]
391  << "\tRmax = " << pgonRmax[i];
392 
394  DDMaterial matter(matname);
395  DDLogicalPart genlogic(DDName(idName, idNameSpace), matter, solid);
396 
397  DDName parentName = parent().name();
398  cpv.position(DDName(idName, idNameSpace), parentName, 1, r0, rot);
399  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: "
400  << DDName(idName, idNameSpace) << " number 1 positioned"
401  << " in " << parentName << " at " << r0 << " with "
402  << rot;
403  if (getEndcaps() != 1) {
404  rot = DDRotation(DDName(rotHalf,rotns));
405  cpv.position(DDName(idName, idNameSpace), parentName, 2, r0, rot);
406  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: "
407  << DDName(idName, idNameSpace) << " number 2 "
408  << "positioned in " << parentName << " at " << r0
409  << " with " << rot;
410  }
411 
412  //Forward half
413  name = idName + "Front";
414  vector<double> pgonZMod, pgonRminMod, pgonRmaxMod;
415  for (i=0; i < (pgonZ.size()-1); i++) {
416  pgonZMod.push_back(pgonZ[i] + getDzShift());
417  pgonRminMod.push_back(pgonRmin[i]);
418  pgonRmaxMod.push_back(pgonRmax[i]);
419  }
421  getNsectortot(), -alpha, dphi, pgonZMod,
422  pgonRminMod, pgonRmaxMod);
423  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
424  << " Polyhedra made of " << getGenMat() << " with "
425  << getNsectortot() << " sectors from "
426  << -alpha/CLHEP::deg << " to "
427  << (-alpha+dphi)/CLHEP::deg << " and with "
428  << pgonZMod.size() << " sections ";
429  for (i = 0; i < pgonZMod.size(); i++)
430  LogDebug("HCalGeom") << "\t\tZ = " << pgonZMod[i] << "\tRmin = "
431  << pgonRminMod[i] << "\tRmax = " << pgonRmaxMod[i];
432  DDLogicalPart genlogich(DDName(name, idNameSpace), matter, solid);
433 
434  cpv.position(genlogich, genlogic, 1, DDTranslation(0.0, 0.0, -getDzShift()),
435  DDRotation());
436  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << genlogich.name()
437  << " number 1 positioned in " << genlogic.name()
438  << " at (0,0," << -getDzShift() << ") with no rotation";
439 
440  //Construct sector (from -alpha to +alpha)
441  name = idName + "Module";
443  1, -alpha, 2*alpha, pgonZMod,
444  pgonRminMod, pgonRmaxMod);
445  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
446  << " Polyhedra made of " << getGenMat()
447  <<" with 1 sector from " << -alpha/CLHEP::deg << " to "
448  << alpha/CLHEP::deg << " and with " << pgonZMod.size()
449  << " sections";
450  for (i = 0; i < pgonZMod.size(); i++)
451  LogDebug("HCalGeom") << "\t\tZ = " << pgonZMod[i] << "\tRmin = "
452  << pgonRminMod[i] << "\tRmax = " << pgonRmaxMod[i];
453 
454  DDLogicalPart seclogic(DDName(name, idNameSpace), matter, solid);
455 
456  for (int ii=0; ii<getNsectortot(); ii++) {
457  double phi = ii*2*alpha;
458  double phideg = phi/CLHEP::deg;
459 
461  string rotstr("NULL");
462  if (phideg != 0) {
463  rotstr = "R";
464  if (phideg < 100) rotstr = "R0";
465  rotstr = rotstr + dbl_to_string(phideg);
466  rotation = DDRotation(DDName(rotstr, rotns));
467  if (!rotation) {
468  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Creating a new "
469  << "rotation " << rotstr << "\t" << 90 << ","
470  << phideg << "," << 90 << "," << (phideg+90)
471  << ", 0, 0";
472  rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg,
473  phideg*CLHEP::deg, 90*CLHEP::deg,
474  (90+phideg)*CLHEP::deg, 0*CLHEP::deg, 0*CLHEP::deg);
475  } //if !rotation
476  } //if phideg!=0
477 
478  cpv.position(seclogic, genlogich, ii+1, DDTranslation(0.0, 0.0, 0.0), rotation);
479  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << seclogic.name()
480  << " number " << ii+1 << " positioned in "
481  << genlogich.name() << " at (0,0,0) with " <<rotation;
482  }
483 
484  //Construct the things inside the sector
485  constructInsideSector(seclogic, cpv);
486 
487  //Backward half
488  name = idName + "Back";
489  vector<double> pgonZBack, pgonRminBack, pgonRmaxBack;
490  pgonZBack.push_back(getZEnd() - getDzShift());
491  pgonRminBack.push_back(pgonZBack[0]*tan(getAngBot()) + getDrEnd());
492  pgonRmaxBack.push_back(getRoutDip());
493  pgonZBack.push_back(getZEnd());
494  pgonRminBack.push_back(pgonZBack[1]*tan(getAngBot()) + getDrEnd());
495  pgonRmaxBack.push_back(getRoutDip());
497  getNsectortot(), -alpha, dphi, pgonZBack,
498  pgonRminBack, pgonRmaxBack);
499  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
500  << " Polyhedra made of " << getAbsMat() << " with "
501  << getNsectortot() << " sectors from "
502  << -alpha/CLHEP::deg << " to "
503  << (-alpha+dphi)/CLHEP::deg << " and with "
504  << pgonZBack.size() << " sections";
505  for (i = 0; i < pgonZBack.size(); i++)
506  LogDebug("HCalGeom") << "\t\tZ = " << pgonZBack[i] << "\tRmin = "
507  << pgonRminBack[i] << "\tRmax = " << pgonRmaxBack[i];
508  DDName absMatname(DDSplit(getAbsMat()).first, DDSplit(getAbsMat()).second);
509  DDMaterial absMatter(absMatname);
510  DDLogicalPart glog(DDName(name, idNameSpace), absMatter, solid);
511 
512  cpv.position(glog, genlogic, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
513  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name()
514  << " number 1 positioned in " << genlogic.name()
515  << " at (0,0,0) with no rotation";
516 }
517 
518 
520 
521  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Modules (" << getModules()
522  << ") ...";
523  double alpha = CLHEP::pi/getNsectors();
524 
525  for (int i = 0; i < getModules(); i++) {
526  string name = idName + getModName(i);
528  DDMaterial matter(matname);
529 
530  if (equipModule(i)>0) {
531  int nsec = getSectionModule(i);
532 
534  //vertical walls are allowed in SolidPolyhedra
535  double deltaz = 0;
536 
537  vector<double> pgonZ, pgonRmin, pgonRmax;
538  if (nsec == 3) {
539  double zf = getZminBlock(i) + getZShiftHac2();
540  pgonZ.push_back(zf);
541  pgonRmin.push_back(zf*tan(getAngBot()));
542  pgonRmax.push_back((zf-getZ1Beam())*getSlope());
543  pgonZ.push_back(getZiKink());
544  pgonRmin.push_back(getRinKink());
545  pgonRmax.push_back(getRout());
546  } else {
547  pgonZ.push_back(getZminBlock(i));
548  pgonRmin.push_back(getRinBlock1(i));
549  pgonRmax.push_back(getRoutBlock1(i));
550  }
551  if (nsec == 4) {
552  pgonZ.push_back(getZiDip());
553  pgonRmin.push_back(getRinDip());
554  pgonRmax.push_back(getRout());
555  pgonZ.push_back(pgonZ[1] + deltaz);
556  pgonRmin.push_back(pgonRmin[1]);
557  pgonRmax.push_back(getRoutDip());
558  }
559  pgonZ.push_back(getZmaxBlock(i));
560  pgonRmin.push_back(getRinBlock2(i));
561  pgonRmax.push_back(getRoutBlock2(i));
562 
563  //Solid & volume
564  DDSolid solid;
566  1, -alpha, 2*alpha,
567  pgonZ, pgonRmin, pgonRmax);
568  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: "
569  << DDName(name,idNameSpace) << " Polyhedra made of "
570  << getModMat(i) << " with 1 sector from "
571  << -alpha/CLHEP::deg << " to " << alpha/CLHEP::deg
572  << " and with " << nsec << " sections";
573  for (unsigned int k=0; k<pgonZ.size(); k++)
574  LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[k] << "\tRmin = "
575  << pgonRmin[k] << "\tRmax = " << pgonRmax[k];
576 
577  DDLogicalPart glog(DDName(name, idNameSpace), matter, solid);
578 
579  cpv.position(glog, sector, i+1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
580  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name()
581  << " number " << i+1 << " positioned in "
582  << sector.name() << " at (0,0,0) with no rotation";
583 
584  if (getModType(i) == 0)
585  constructInsideModule0 (glog, i, cpv);
586  else
587  constructInsideModule (glog, i, cpv);
588  }
589  }
590 
591 }
592 
593 void DDHCalEndcapAlgo::parameterLayer0(int mod, int layer, int iphi,
594  double& yh, double& bl, double& tl,
595  double& alp, double& xpos, double& ypos,
596  double& zpos) {
597 
598  //Given module and layer number compute parameters of trapezoid
599  //and positioning parameters
600  double alpha = CLHEP::pi/getNsectors();
601  LogDebug("HCalGeom") << "Input " << iphi << " " << layer << " " << iphi
602  << " Alpha " << alpha/CLHEP::deg;
603 
604  double zi, zo;
605  if (iphi == 0) {
606  zi = getZminBlock(mod);
607  zo = zi + getLayerT(layer);
608  } else {
609  zo = getZmaxBlock(mod);
610  zi = zo - getLayerT(layer);
611  }
612  double rin, rout;
613  if (mod == 0) {
614  rin = zo * tan(getAngTop());
615  rout = (zi - getZ1Beam()) * getSlope();
616  } else {
617  rin = zo * tan(getAngBot());
618  rout = zi * tan(getAngTop());
619  }
620  yh = 0.5 * (rout - rin);
621  bl = 0.5 * rin * tan (alpha);
622  tl = 0.5 * rout * tan(alpha);
623  xpos = 0.5 * (rin + rout);
624  ypos = 0.5 * (bl + tl);
625  zpos = 0.5 * (zi + zo);
626  yh -= getTrim(mod,iphi);
627  bl -= getTrim(mod,iphi);
628  tl -= getTrim(mod,iphi);
629  alp = atan(0.5 * tan(alpha));
630  if (iphi == 0) {
631  ypos = -ypos;
632  } else {
633  alp = -alp;
634  }
635  LogDebug("HCalGeom") << "Output Dimensions " << yh << " " << bl << " "
636  << tl << " " << alp/CLHEP::deg << " Position " << xpos
637  << " " << ypos << " " << zpos;
638 }
639 
640 
641 void DDHCalEndcapAlgo::parameterLayer(int iphi, double rinF, double routF,
642  double rinB, double routB, double zi,
643  double zo, double& yh1, double& bl1,
644  double& tl1, double& yh2, double& bl2,
645  double& tl2, double& alp, double& theta,
646  double& phi, double& xpos, double& ypos,
647  double& zpos) {
648 
649  //Given rin, rout compute parameters of the trapezoid and
650  //position of the trapezoid for a standrd layer
651  double alpha = CLHEP::pi/getNsectors();
652  LogDebug("HCalGeom") << "Input " << iphi << " Front " << rinF << " " << routF
653  << " " << zi << " Back " << rinB << " " << routB << " "
654  << zo << " Alpha " << alpha/CLHEP::deg;
655 
656  yh1 = 0.5 * (routF - rinB);
657  bl1 = 0.5 * rinB * tan(alpha);
658  tl1 = 0.5 * routF * tan(alpha);
659  yh2 = 0.5 * (routF - rinB);
660  bl2 = 0.5 * rinB * tan(alpha);
661  tl2 = 0.5 * routF * tan(alpha);
662  double dx = 0.25* (bl2+tl2-bl1-tl1);
663  double dy = 0.5 * (rinB+routF-rinB-routF);
664  xpos = 0.25*(rinB+routF+rinB+routF);
665  ypos = 0.25*(bl2+tl2+bl1+tl1);
666  zpos = 0.5*(zi+zo);
667  alp = atan(0.5 * tan(alpha));
668  // ypos-= getTolPos();
669  if (iphi == 0) {
670  ypos = -ypos;
671  } else {
672  alp = -alp;
673  dx = -dx;
674  }
675  double r = sqrt (dx*dx + dy*dy);
676  theta= atan (r/(zo-zi));
677  phi = atan2 (dy, dx);
678  LogDebug("HCalGeom") << "Output Dimensions " << yh1 << " " << bl1 << " "
679  << tl1 << " " << yh2 << " " << bl2 << " " << tl2
680  << " " << alp/CLHEP::deg << " " << theta/CLHEP::deg
681  << " " << phi/CLHEP::deg << " Position " << xpos << " "
682  << ypos << " " << zpos;
683 }
684 
685 
687 
688  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: \t\tInside module0 ..."<<mod;
689 
691  //Pointers to the Rotation Matrices and to the Materials
692  string rotstr = getRotMat();
693  DDRotation rot(DDName(rotstr, rotns));
695  DDMaterial matabsorbr(matName);
697  DDMaterial matplastic(plasName);
698 
699  int layer = getLayer(mod,0);
700  int layer0 = getLayer(mod,1);
701  string name;
702  double xpos, ypos, zpos;
703  DDSolid solid;
704  DDLogicalPart glog, plog;
705  for (int iphi = 0; iphi < getPhi(); iphi++) {
706  double yh, bl, tl, alp;
707  parameterLayer0(mod, layer, iphi, yh, bl, tl, alp, xpos, ypos, zpos);
708  name = module.name().name()+getLayerName(layer)+getPhiName(iphi);
709  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
710  0.5*getLayerT(layer), 0, 0, yh,
711  bl, tl, alp, yh, bl, tl, alp);
712  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name()
713  << " Trap made of " << getPlastMat()
714  << " of dimensions " << 0.5*getLayerT(layer)
715  << ", 0, 0, " << yh << ", " << bl << ", " << tl
716  << ", " << alp/CLHEP::deg << ", " << yh << ", " << bl
717  << ", " << tl << ", " << alp/CLHEP::deg;
718  glog = DDLogicalPart(solid.ddname(), matplastic, solid);
719 
720  DDTranslation r1(xpos, ypos, zpos);
721  cpv.position(glog, module, idOffset+layer+1, r1, rot);
722  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name()
723  << " number " << idOffset+layer+1 << " positioned in "
724  << module.name() << " at " << r1 << " with " << rot;
725  //Now construct the layer of scintillator inside this
726  int copyNo = layer0*10 + getLayerType(layer);
727  name = getModName(mod)+getLayerName(layer)+getPhiName(iphi);
728  constructScintLayer (glog, getScintT(layer), yh, bl, tl, alp, name, copyNo, cpv);
729  }
730 
731  //Now the absorber layer
732  double zi = getZminBlock(mod) + getLayerT(layer);
733  double zo = zi + 0.5*getDzStep();
734  double rinF, routF, rinB, routB;
735  if (mod == 0) {
736  rinF = zi * tan(getAngTop());
737  routF =(zi - getZ1Beam()) * getSlope();
738  rinB = zo * tan(getAngTop());
739  routB =(zo - getZ1Beam()) * getSlope();
740  } else {
741  rinF = zi * tan(getAngBot());
742  routF = zi * tan(getAngTop());
743  rinB = zo * tan(getAngBot());
744  routB = zo * tan(getAngTop());
745  }
746  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Module " << mod << " Front "
747  << zi << ", " << rinF << ", " << routF << " Back "
748  << zo << ", " << rinB << ", " << routB;
749  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
750  parameterLayer(0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2,
751  tl2, alp, theta, phi, xpos, ypos, zpos);
752  double fact = getTolAbs();
753  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Trim " << fact << " Param "
754  << yh1 << ", " << bl1 << ", " << tl1 << ", " << yh2
755  << ", " << bl2 << ", " << tl2;
756  bl1 -= fact;
757  tl1 -= fact;
758  bl2 -= fact;
759  tl2 -= fact;
760 
761  name = module.name().name()+"Absorber";
762  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
763  0.5*getThick(mod), theta, phi, yh1,
764  bl1, tl1, alp, yh2, bl2, tl2, alp);
765  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name()
766  << " Trap made of " << getAbsMat() << " of dimensions "
767  << 0.5*getThick(mod) << ", " << theta/CLHEP::deg << ", "
768  << phi/CLHEP::deg << ", " << yh1 << ", " << bl1 << ", "
769  << tl1 << ", " << alp/CLHEP::deg << ", " << yh2 << ", "
770  << bl2 << ", " << tl2 << ", " << alp/CLHEP::deg;
771  glog = DDLogicalPart(solid.ddname(), matabsorbr, solid);
772 
773  DDTranslation r2(xpos, ypos, zpos);
774  cpv.position(glog, module, 1, r2, rot);
775  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name()
776  << " number 1 positioned in " << module.name() << " at "
777  << r2 << " with " << rot;
778 }
779 
780 
782 
783  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: \t\tInside module ..." <<mod;
784 
786  //Pointers to the Rotation Matrices and to the Materials
787  string rotstr = getRotMat();
788  DDRotation rot(DDName(rotstr, rotns));
790  DDMaterial matter(matName);
792  DDMaterial matplastic(plasName);
793 
794  double alpha = CLHEP::pi/getNsectors();
795  double zi = getZminBlock(mod);
796 
797  for (int i = 0; i < getLayerN(mod); i++) {
798  string name;
799  DDSolid solid;
800  DDLogicalPart glog, plog;
801  int layer = getLayer(mod,i);
802  double zo = zi + 0.5*getDzStep();
803 
804  for (int iphi = 0; iphi < getPhi(); iphi++) {
805  double ziAir = zo - getThick(mod);
806  double rinF, rinB;
807  if (layer == 1) {
808  rinF = ziAir * tan(getAngTop());
809  rinB = zo * tan(getAngTop());
810  } else {
811  rinF = ziAir * tan(getAngBot());
812  rinB = zo * tan(getAngBot());
813  }
814  double routF = (ziAir - getZ1Beam()) * getSlope();
815  double routB = (zo - getZ1Beam()) * getSlope();
816  if (routF > getRoutBlock2(mod)) routF = getRoutBlock2(mod);
817  if (routB > getRoutBlock2(mod)) routB = getRoutBlock2(mod);
818  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Layer " << i << " Phi "
819  << iphi << " Front " << ziAir << ", " << rinF
820  << ", " << routF << " Back " << zo << ", " << rinB
821  << ", " << routB;
822  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
823  double xpos, ypos, zpos;
824  parameterLayer(iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1,
825  yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
826 
827  name = module.name().name()+getLayerName(layer)+getPhiName(iphi)+"Air";
828  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
829  0.5*getThick(mod), theta, phi, yh1,
830  bl1, tl1, alp, yh2, bl2, tl2, alp);
831  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name()
832  << " Trap made of " << getGenMat()
833  << " of dimensions " << 0.5*getThick(mod) << ", "
834  << theta/CLHEP::deg << ", " << phi/CLHEP::deg
835  << ", " << yh1 << ", " << bl1 << ", " << tl1 << ", "
836  << alp/CLHEP::deg << ", " << yh2 << ", " << bl2
837  << ", " << tl2 << ", " << alp/CLHEP::deg;
838  glog = DDLogicalPart(solid.ddname(), matter, solid);
839 
840  DDTranslation r1(xpos, ypos, zpos);
841  cpv.position(glog, module, layer+1, r1, rot);
842  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name()
843  << " number " << layer+1 << " positioned in "
844  << module.name() << " at " << r1 << " with " << rot;
845 
846  //Now the plastic with scintillators
847  double yh = 0.5 * (routF - rinB) - getTrim(mod,iphi);
848  double bl = 0.5 * rinB * tan(alpha) - getTrim(mod,iphi);
849  double tl = 0.5 * routF * tan(alpha) - getTrim(mod,iphi);
850  name = module.name().name()+getLayerName(layer)+getPhiName(iphi);
851  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
852  0.5*getLayerT(layer), 0, 0, yh,
853  bl, tl, alp, yh, bl, tl, alp);
854  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name()
855  << " Trap made of " << getPlastMat()
856  << " of dimensions " << 0.5*getLayerT(layer)
857  << ", 0, 0, " << yh << ", " << bl << ", " << tl
858  << ", " << alp/CLHEP::deg << ", " << yh << ", "
859  << bl << ", " << tl << ", " << alp/CLHEP::deg;
860  plog = DDLogicalPart(solid.ddname(), matplastic, solid);
861 
862  ypos = 0.5*(routF+rinB) - xpos;
863  DDTranslation r2(0., ypos, 0.);
864  cpv.position(plog, glog, idOffset+layer+1, r2, DDRotation());
865  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << plog.name()
866  << " number " << idOffset+layer+1
867  << " positioned in " << glog.name() << " at " << r2
868  << " with no rotation";
869 
870  //Constructin the scintillators inside
871  int copyNo = layer*10 + getLayerType(layer);
872  name = getModName(mod)+getLayerName(layer)+getPhiName(iphi);
873  constructScintLayer (plog, getScintT(layer), yh,bl,tl, alp,name,copyNo, cpv);
874  zo += 0.5*getDzStep();
875  } // End of loop over phi indices
876  zi = zo - 0.5*getDzStep();
877  } // End of loop on layers
878 }
879 
880 
882  double yh, double bl, double tl,
883  double alp, string nm, int id, DDCompactView& cpv) {
884 
886  DDMaterial matter(matname);
887  string name = idName+"Scintillator"+nm;
888 
889  DDSolid solid = DDSolidFactory::trap(DDName(name, idNameSpace), 0.5*dz, 0, 0,
890  yh, bl, tl, alp, yh, bl, tl, alp);
891  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
892  << " Trap made of " << getScintMat() <<" of dimensions "
893  << 0.5*dz << ", 0, 0, " << yh << ", " << bl << ", "
894  << tl << ", " << alp/CLHEP::deg << ", " << yh << ", "
895  << bl << ", " << tl << ", " << alp/CLHEP::deg;
896 
897  DDLogicalPart glog(solid.ddname(), matter, solid);
898 
899  cpv.position(glog, detector, id, DDTranslation(0,0,0), DDRotation());
900  LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name()
901  << " number " << id << " positioned in "
902  << detector.name() << " at (0,0,0) with no rotation";
903 
904 }
#define LogDebug(id)
double getTrim(unsigned int i, unsigned int j) const
void constructInsideModule0(DDLogicalPart module, int mod, DDCompactView &cpv)
std::string getModName(unsigned int i) const
int i
Definition: DBlmapReader.cc:9
double getZmaxBlock(unsigned i) const
double getDrEnd() const
float alpha
Definition: AMPTWrapper.h:95
std::vector< int > layerN2
double getSlope() const
const N & name() const
Definition: DDBase.h:82
std::vector< int > modType
list parent
Definition: dbtoconf.py:74
std::string idNameSpace
std::vector< double > zminBlock
double getRinBlock2(unsigned i) const
double getZiKink() const
double getZShift() const
int getNsectortot() const
std::vector< int > layerN0
std::vector< std::string > modMat
int getEndcaps() const
std::string getAbsMat() const
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
virtual ~DDHCalEndcapAlgo()
int getPhi() const
double getRoutBlock2(unsigned i) const
int getModType(unsigned int i) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int getNsectors() const
Geom::Theta< T > theta() const
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
void execute(DDCompactView &cpv)
std::vector< double > routBlock1
double getThick(unsigned int i) const
static std::string & ns()
std::string dbl_to_string(const double &in)
Converts only the integer part of a double to a string.
Definition: DDutils.cc:12
double getRinKink() const
std::vector< double > zmaxBlock
double getTolAbs() const
int ii
Definition: cuy.py:588
double getZEnd() const
type of data representation of DDCompactView
Definition: DDCompactView.h:77
int getSectionModule(unsigned i) const
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
std::string getModMat(unsigned int i) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
std::string getRotMat() const
std::string getRotation() const
const Double_t pi
std::vector< double > routBlock2
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
U second(std::pair< T, U > const &p)
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.cc:4
double getZ1Beam() const
std::vector< std::string > layerName
double getScintT(unsigned int i) const
void parameterLayer0(int mod, int layer, int iphi, double &yh, double &bl, double &tl, double &alp, double &xpos, double &ypos, double &zcpv)
std::vector< int > layerN1
double getAngTop() const
double getRout() const
double getRinBlock1(unsigned i) const
double getAngBot() const
std::string plastMat
std::vector< int > layerN4
T sqrt(T t)
Definition: SSEVec.h:48
std::string scintMat
void constructInsideModule(DDLogicalPart module, int mod, DDCompactView &cpv)
int equipModule(unsigned int i) const
std::vector< int > sectionModule
double getDzStep() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double getZiL0Body() const
std::string getPlastMat() const
int j
Definition: DBlmapReader.cc:9
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
std::vector< double > rinBlock1
std::vector< std::string > modName
std::vector< int > layerN5
static DDSolid trap(const DDName &name, double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: DDSolid.cc:723
int getLayerN(unsigned int i) const
std::vector< int > eModule
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
std::vector< int > layerType
std::vector< int > layerN
const double fact
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
void constructGeneralVolume(DDCompactView &cpv)
int getLayerType(unsigned int i) const
double getRinDip() const
std::vector< double > rinBlock2
double getLayerT(unsigned int i) const
double getRoutDip() const
std::vector< double > trimRight
double getDzShift() const
int getLayer(unsigned int i, unsigned int j) const
double getZiDip() const
std::string getPhiName(unsigned int i) const
double getZFront() const
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
std::vector< int > layerN3
double getZiBody() const
std::string getGenMat() const
std::string getScintMat() const
std::vector< std::string > phiName
void parameterLayer(int iphi, double rinF, double routF, double rinB, double routB, double zi, double zo, double &yh1, double &bl1, double &tl1, double &yh2, double &bl2, double &tl2, double &alp, double &theta, double &phi, double &xpos, double &ypos, double &zcpv)
std::string genMaterial
double getZminBlock(unsigned i) const
std::vector< double > thick
std::string rotation
std::string getLayerName(unsigned int i) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::vector< double > scintT
std::vector< double > layerT
Definition: vlib.h:208
void constructInsideSector(DDLogicalPart sector, DDCompactView &cpv)
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:673
void constructScintLayer(DDLogicalPart glog, double pDz, double yh, double bl, double tl, double alp, std::string name, int id, DDCompactView &cpv)
double getZShiftHac2() const
double getRoutBlock1(unsigned i) const
int getModules() const
const N & ddname() const
Definition: DDBase.h:84
Definition: DDAxes.h:10
std::vector< double > trimLeft