CMS 3D CMS Logo

DDHGCalHEAlgo.cc
Go to the documentation of this file.
1 // File: DDHGCalHEAlgo.cc
3 // Description: Geometry factory class for HGCal (EE)
5 
6 #include <cmath>
7 #include <algorithm>
8 
17 #include "CLHEP/Units/GlobalPhysicalConstants.h"
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
19 
21  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo info: Creating an instance";
22 }
23 
25 
27  const DDVectorArguments & vArgs,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments &vsArgs){
31 
32  materials = vsArgs["MaterialNames"];
33  names = vsArgs["VolumeNames"];
34  thick = vArgs["Thickness"];
35  type = dbl_to_int(vArgs["Type"]);
36  copyNumber = dbl_to_int(vArgs["Offsets"]);
37  zMinBlock = vArgs["ZMinType"];
38  rotstr = sArgs["Rotation"];
39  layerType = dbl_to_int(vArgs["LayerType"]);
40  heightType = dbl_to_int(vArgs["HeightType"]);
41  thickModule = nArgs["ThickModule"];
42  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo: " << materials.size()
43  << " volumes to be put with rotation " << rotstr
44  << " in " << layerType.size() << " layers and "
45  << "module thickness " << thickModule;
46  for (unsigned int i=0; i<names.size(); ++i)
47  edm::LogInfo("HGCalGeom") << "Volume [" << i << "] " << names[i]
48  << " filled with " << materials[i] << " of type "
49  << type[i] << " thickness " << thick[i]
50  << " first copy number " << copyNumber[i]
51  << " starting at " << zMinBlock[i];
52  for (unsigned int i=0; i<layerType.size(); ++i)
53  edm::LogInfo("HGCalGeom") << "Layer [" << i << "] with material type "
54  << layerType[i] << " height type "
55  << heightType[i];
56 
57  sectors = (int)(nArgs["Sectors"]);
58  slopeB = nArgs["SlopeBottom"];
59  slopeT = vArgs["SlopeTop"];
60  zFront = vArgs["ZFront"];
61  rMaxFront = vArgs["RMaxFront"];
62  idName = parent().name().name();
64  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo: Bottom slope " << slopeB
65  << " " << slopeT.size() << " slopes for top";
66  for (unsigned int i=0; i<slopeT.size(); ++i)
67  edm::LogInfo("HGCalGeom") << "Block [" << i << "] Zmin " << zFront[i]
68  << " Rmax " << rMaxFront[i] << " Slope "
69  << slopeT[i];
70  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo: Sectors " << sectors
71  << "\tNameSpace:Name " << idNameSpace
72  << ":" << idName;
73 
74 }
75 
77 // DDHGCalHEAlgo methods...
79 
81 
82  edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalHEAlgo...";
83  constructLayers (parent(), cpv);
84  edm::LogInfo("HGCalGeom") << "<<== End of DDHGCalHEAlgo construction ...";
85 }
86 
88 
89  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo test: \t\tInside Layers";
90 
92  //Pointers to the Rotation Matrices and to the Materials
94 
95  double zz(zMinBlock[0]);
96  for (unsigned int i=0; i<layerType.size(); i++) {
97  int ii = layerType[i];
98  int copy = copyNumber[ii];
99  ++copyNumber[ii];
100  int ityp = type[ii];
101  type[ii] =-ityp;
102  double zi = zMinBlock[ii];
104  if (heightType[i] == 0) zz = zi;
105 
106  double zlayer = zz + 2*thickModule;
107  if((i % 6)>2) zlayer = zz + thickModule;
108 
109  double zo = zi + thick[ii];
110  double rinF = zi * slopeB;
111  double rinB = zlayer * slopeB;
112 
113  double routF = (heightType[i] == 0) ? rMax(zi) : rMax(zz);
114  if((i % 6)>2) routF = (heightType[i] == 0) ? rMax(zi-thickModule) : rMax(zz-thickModule);
115 
116  double routB = rMax(zo);
117  std::string name = "HGCal"+names[ii]+std::to_string(copy);
118  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo test: Layer " << i << ":"
119  << ii << ":" << ityp << " Front " << zi << ", "
120  << rinF << ", " << routF << " Back " << zo
121  << ", " << rinB << ", " << routB;
122  DDHGCalHEAlgo::HGCalHEPar parm = (ityp == 0) ?
123  parameterLayer(rinF, routF, rinB, routB, zi, zo) :
124  parameterLayer(ityp, rinF, routF, rinB, routB, zi, zo);
126  0.5*thick[ii], parm.theta,
127  parm.phi, parm.yh1, parm.bl1,
128  parm.tl1, parm.alp, parm.yh2,
129  parm.bl2, parm.tl2, parm.alp);
130 
131  DDName matName(DDSplit(materials[ii]).first,
132  DDSplit(materials[ii]).second);
133  DDMaterial matter(matName);
134  DDLogicalPart glog = DDLogicalPart(solid.ddname(), matter, solid);
135  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo test: "
136  << solid.name() << " Trap made of " << matName
137  << " of dimensions " << 0.5*thick[ii] << ", "
138  << parm.theta/CLHEP::deg << ", "
139  << parm.phi/CLHEP::deg << ", " << parm.yh1
140  << ", " << parm.bl1 << ", " << parm.tl1
141  << ", " << parm.alp/CLHEP::deg << ", "
142  << parm.yh2 << ", " << parm.bl2 << ", "
143  << parm.tl2 << ", " << parm.alp/CLHEP::deg;
144  DDTranslation r1(parm.xpos, parm.ypos, parm.zpos);
145  cpv.position(glog, module, copy, r1, rot);
146  edm::LogInfo("HGCalGeom") << "DDHGCalHEAlgo test: " << glog.name()
147  << " number " << copy << " positioned in "
148  << module.name() << " at " << r1 << " with "
149  << rot;
150  } // End of loop on layers
151 }
152 
153 
155 DDHGCalHEAlgo::parameterLayer(double rinF, double routF, double rinB,
156  double routB, double zi, double zo) {
157 
159  //Given rin, rout compute parameters of the trapezoid and
160  //position of the trapezoid for a standrd layer
161  double alpha = CLHEP::pi/sectors;
162  double rout = routF;
163  edm::LogInfo("HGCalGeom") << "Input: Front " << rinF << " " << routF << " "
164  << zi << " Back " << rinB << " " << routB << " "
165  << zo << " Alpha " << alpha/CLHEP::deg << " Rout "
166  << rout;
167 
168  parm.yh2 = parm.yh1 = 0.5 * (rout*cos(alpha) - rinB);
169  parm.bl2 = parm.bl1 = rinB * tan(alpha);
170  parm.tl2 = parm.tl1 = rout * sin(alpha);
171  parm.xpos = 0.5*(rout*cos(alpha)+rinB);
172  parm.ypos = 0.0;
173  parm.zpos = 0.5*(zi+zo);
174  parm.alp = parm.theta = parm.phi = 0;
175  edm::LogInfo("HGCalGeom") << "Output Dimensions " << parm.yh1 << " "
176  << parm.bl1 << " " << parm.tl1 << " " << parm.yh2
177  << " " << parm.bl2 << " " << parm.tl2 << " "
178  << parm.alp/CLHEP::deg <<" "<<parm.theta/CLHEP::deg
179  << " " << parm.phi/CLHEP::deg << " Position "
180  << parm.xpos << " " << parm.ypos <<" " <<parm.zpos;
181  return parm;
182 }
183 
185 DDHGCalHEAlgo::parameterLayer(int type, double rinF, double routF, double rinB,
186  double routB, double zi, double zo) {
187 
189  //Given rin, rout compute parameters of the trapezoid and
190  //position of the trapezoid for a standrd layer
191  double alpha = CLHEP::pi/sectors;
192  double rout = routF;
193  edm::LogInfo("HGCalGeom") << "Input " << type << " Front " << rinF << " "
194  << routF << " " << zi << " Back " << rinB << " "
195  << routB << " " << zo <<" Alpha "
196  << alpha/CLHEP::deg << " rout " << rout;
197 
198  parm.yh2 = parm.yh1 = 0.5 * (rout*cos(alpha) - rinB);
199  parm.bl2 = parm.bl1 = 0.5 * rinB * tan(alpha);
200  parm.tl2 = parm.tl1 = 0.5 * rout * sin(alpha);
201  double dx = 0.25* (parm.bl2+parm.tl2-parm.bl1-parm.tl1);
202  double dy = 0.0;
203  parm.xpos = 0.5*(rout*cos(alpha)+rinB);
204  parm.ypos = 0.25*(parm.bl2+parm.tl2+parm.bl1+parm.tl1);
205  parm.zpos = 0.5*(zi+zo);
206  parm.alp = atan(0.5 * tan(alpha));
207  if (type > 0) {
208  parm.ypos = -parm.ypos;
209  } else {
210  parm.alp = -parm.alp;
211  dx = -dx;
212  }
213  double r = sqrt (dx*dx + dy*dy);
214  edm::LogInfo("HGCalGeom") << "dx|dy|r " << dx << ":" << dy << ":" << r;
215  if (r > 1.0e-8) {
216  parm.theta = atan (r/(zo-zi));
217  parm.phi = atan2 (dy, dx);
218  } else {
219  parm.theta = parm.phi = 0;
220  }
221  edm::LogInfo("HGCalGeom") << "Output Dimensions " << parm.yh1 << " "
222  << parm.bl1 << " " << parm.tl1 << " " << parm.yh2
223  << " " << parm.bl2 << " " << parm.tl2 << " "
224  << parm.alp/CLHEP::deg <<" " <<parm.theta/CLHEP::deg
225  << " " << parm.phi/CLHEP::deg << " Position "
226  << parm.xpos << " " << parm.ypos << " " <<parm.zpos;
227  return parm;
228 }
229 
230 double DDHGCalHEAlgo::rMax(double z) {
231 
232  double r(0);
233  unsigned int ik(0);
234  for (unsigned int k=0; k<slopeT.size(); ++k) {
235  if (z < zFront[k]) break;
236  r = rMaxFront[k] + (z - zFront[k]) * slopeT[k];
237  ik = k;
238  }
239  edm::LogInfo("HGCalGeom") << "rMax : " << z << ":" << ik << ":" << r ;
240  return r;
241 }
type
Definition: HCALResponse.h:21
std::vector< double > zMinBlock
Definition: DDHGCalHEAlgo.h:49
float alpha
Definition: AMPTWrapper.h:95
const N & name() const
Definition: DDBase.h:78
std::vector< double > zFront
Definition: DDHGCalHEAlgo.h:56
double rMax(double z)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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:16
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
std::vector< int > layerType
Definition: DDHGCalHEAlgo.h:50
A DDSolid represents the shape of a part.
Definition: DDSolid.h:37
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const Double_t pi
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
double thickModule
Definition: DDHGCalHEAlgo.h:52
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.h:7
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
std::vector< std::string > names
Definition: DDHGCalHEAlgo.h:44
std::vector< int > heightType
Definition: DDHGCalHEAlgo.h:51
std::vector< std::string > materials
Definition: DDHGCalHEAlgo.h:43
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:794
ii
Definition: cuy.py:588
int k[5][pyjets_maxn]
virtual ~DDHGCalHEAlgo()
void execute(DDCompactView &cpv)
HGCalHEPar parameterLayer(double rinF, double routF, double rinB, double routB, double zi, double zo)
std::string rotstr
Definition: DDHGCalHEAlgo.h:45
std::string idNameSpace
Definition: DDHGCalHEAlgo.h:60
void constructLayers(DDLogicalPart, DDCompactView &cpv)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
std::vector< double > thick
Definition: DDHGCalHEAlgo.h:47
std::string idName
Definition: DDHGCalHEAlgo.h:59
Definition: vlib.h:208
std::vector< double > slopeT
Definition: DDHGCalHEAlgo.h:55
std::vector< double > rMaxFront
Definition: DDHGCalHEAlgo.h:57
std::vector< int > copyNumber
Definition: DDHGCalHEAlgo.h:46
const N & ddname() const
Definition: DDBase.h:80