CMS 3D CMS Logo

DDHGCalEEAlgo.cc
Go to the documentation of this file.
1 // File: DDHGCalEEAlgo.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") << "DDHGCalEEAlgo 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  rotstr = sArgs["Rotation"];
36  layerType = dbl_to_int(vArgs["LayerType"]);
37  heightType = dbl_to_int(vArgs["HeightType"]);
38  thickBlock = vArgs["LayerThick"];
39  zMinBlock = nArgs["zMinBlock"];
40  for (unsigned int i=0; i<materials.size(); ++i) {
41  copyNumber.emplace_back(1);
42  }
43  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo: " << materials.size()
44  << " volumes to be put with rotation " << rotstr
45  << " starting at " << zMinBlock;
46  for (unsigned int i=0; i<names.size(); ++i)
47  edm::LogInfo("HGCalGeom") << "Volume [" << i << "] " << names[i]
48  << " of thickness " << thick[i]
49  << " filled with " << materials[i]
50  << " first copy number " << copyNumber[i];
51  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo: " << layerType.size()
52  << " layers";
53  for (unsigned int i=0; i<layerType.size(); ++i)
54  edm::LogInfo("HGCalGeom") << "Layer [" << i << "] with material type "
55  << layerType[i] << " height type "
56  << heightType[i] << " block thickness "
57  << thickBlock[i];
58 
59  sectors = (int)(nArgs["Sectors"]);
60  slopeB = nArgs["SlopeBottom"];
61  slopeT = vArgs["SlopeTop"];
62  zFront = vArgs["ZFront"];
63  rMaxFront = vArgs["RMaxFront"];
64  idName = parent().name().name();
66  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo: Bottom slope " << slopeB
67  << " " << slopeT.size() << " slopes for top";
68  for (unsigned int i=0; i<slopeT.size(); ++i)
69  edm::LogInfo("HGCalGeom") << "Block [" << i << "] Zmin " << zFront[i]
70  << " Rmax " << rMaxFront[i] << " Slope "
71  << slopeT[i];
72  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo: Sectors " << sectors
73  << "\tNameSpace:Name " << idNameSpace
74  << ":" << idName;
75 
76 }
77 
79 // DDHGCalEEAlgo methods...
81 
83 
84  edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalEEAlgo...";
85  constructLayers (parent(), cpv);
86  edm::LogInfo("HGCalGeom") << "<<== End of DDHGCalEEAlgo construction ...";
87 }
88 
90 
91  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo test: \t\tInside Layers";
92 
94  //Pointers to the Rotation Matrices and to the Materials
96 
97  double zi(zMinBlock), zz(zMinBlock);
98  for (unsigned int i=0; i<layerType.size(); i++) {
99  int ii = layerType[i];
100  int copy = copyNumber[ii];
101  ++copyNumber[ii];
102  double layer_thick = thickBlock[i];
103 
104  if (heightType[i] == 0) zz = zi;
105  double zlayer = zz + layer_thick;
106  double zo = zi + thick[ii];
107  double rinF = zi * slopeB;
108  double rinB = zlayer * slopeB;
109  double routF = (heightType[i] == 0) ? rMax(zi) : rMax(zz);
110  double routB = rMax(zo);
111 
112  std::string name = "HGCal"+names[ii]+std::to_string(copy);
113  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo test: Layer " << i << ":"
114  << ii << " Front " << zi << ", " << rinF << ", "
115  << routF << " Back " << zo << ", " << rinB
116  << ", " << routB << " superlayer thickness "
117  << layer_thick;
118  DDHGCalEEAlgo::HGCalEEPar parm = parameterLayer(rinF, routF, rinB,
119  routB, zi, zo);
121  0.5*thick[ii], parm.theta,
122  parm.phi, parm.yh1, parm.bl1,
123  parm.tl1, parm.alp, parm.yh2,
124  parm.bl2, parm.tl2, parm.alp);
125 
126  DDName matName(DDSplit(materials[ii]).first,
127  DDSplit(materials[ii]).second);
128  DDMaterial matter(matName);
129  DDLogicalPart glog = DDLogicalPart(solid.ddname(), matter, solid);
130  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo test: "
131  << solid.name() << " Trap made of " << matName
132  << " of dimensions " << 0.5*thick[ii] << ", "
133  << parm.theta/CLHEP::deg << ", "
134  << parm.phi/CLHEP::deg << ", " << parm.yh1
135  << ", " << parm.bl1 << ", " << parm.tl1
136  << ", " << parm.alp/CLHEP::deg << ", "
137  << parm.yh2 << ", " << parm.bl2 << ", "
138  << parm.tl2 << ", " << parm.alp/CLHEP::deg;
139  DDTranslation r1(parm.xpos, parm.ypos, parm.zpos);
140  cpv.position(glog, module, copy, r1, rot);
141  edm::LogInfo("HGCalGeom") << "DDHGCalEEAlgo test: " << glog.name()
142  << " number " << copy << " positioned in "
143  << module.name() << " at " << r1 << " with "
144  << rot;
145  zi = zo;
146  } // End of loop on layers
147 }
148 
149 
151 DDHGCalEEAlgo::parameterLayer(double rinF, double routF, double rinB,
152  double routB, double zi, double zo) {
153 
155  //Given rin, rout compute parameters of the trapezoid and
156  //position of the trapezoid for a standrd layer
157  double alpha = CLHEP::pi/sectors;
158  edm::LogInfo("HGCalGeom") << "Input: Front " << rinF << " " << routF << " "
159  << zi << " Back " << rinB << " " << routB << " "
160  << zo << " Alpha " << alpha/CLHEP::deg;
161 
162  parm.yh2 = parm.yh1 = 0.5 * (routF*cos(alpha) - rinB);
163  parm.bl2 = parm.bl1 = rinB * tan(alpha);
164  parm.tl2 = parm.tl1 = routF * sin(alpha);
165  parm.xpos = 0.5*(routF*cos(alpha)+rinB);
166  parm.ypos = 0.0;
167  parm.zpos = 0.5*(zi+zo);
168  parm.alp = parm.theta = parm.phi = 0;
169  edm::LogInfo("HGCalGeom") << "Output Dimensions " << parm.yh1 << " "
170  << parm.bl1 << " " << parm.tl1 << " " << parm.yh2
171  << " " << parm.bl2 << " " << parm.tl2 << " "
172  << parm.alp/CLHEP::deg <<" "<<parm.theta/CLHEP::deg
173  << " " << parm.phi/CLHEP::deg << " Position "
174  << parm.xpos << " " << parm.ypos <<" " <<parm.zpos;
175  return parm;
176 }
177 
178 double DDHGCalEEAlgo::rMax(double z) {
179 
180  double r(0);
181  unsigned int ik(0);
182  for (unsigned int k=0; k<slopeT.size(); ++k) {
183  if (z < zFront[k]) break;
184  r = rMaxFront[k] + (z - zFront[k]) * slopeT[k];
185  ik = k;
186  }
187  edm::LogInfo("HGCalGeom") << "rMax : " << z << ":" << ik << ":" << r ;
188  return r;
189 }
void execute(DDCompactView &cpv) override
std::vector< double > thick
Definition: DDHGCalEEAlgo.h:47
~DDHGCalEEAlgo() override
float alpha
Definition: AMPTWrapper.h:95
const N & name() const
Definition: DDBase.h:78
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
std::vector< std::string > names
Definition: DDHGCalEEAlgo.h:42
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::vector< std::string > materials
Definition: DDHGCalEEAlgo.h:41
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
double rMax(double z)
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
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:67
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
std::string idNameSpace
Definition: DDHGCalEEAlgo.h:56
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double zMinBlock
Definition: DDHGCalEEAlgo.h:49
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
std::vector< double > thickBlock
Definition: DDHGCalEEAlgo.h:48
std::vector< int > layerType
Definition: DDHGCalEEAlgo.h:44
std::vector< int > heightType
Definition: DDHGCalEEAlgo.h:45
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:917
ii
Definition: cuy.py:588
int k[5][pyjets_maxn]
std::string rotstr
Definition: DDHGCalEEAlgo.h:43
std::vector< double > rMaxFront
Definition: DDHGCalEEAlgo.h:54
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< double > slopeT
Definition: DDHGCalEEAlgo.h:52
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
Definition: vlib.h:208
HGCalEEPar parameterLayer(double rinF, double routF, double rinB, double routB, double zi, double zo)
std::vector< double > zFront
Definition: DDHGCalEEAlgo.h:53
std::string idName
Definition: DDHGCalEEAlgo.h:55
const N & ddname() const
Definition: DDBase.h:80
std::vector< int > copyNumber
Definition: DDHGCalEEAlgo.h:46
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)