CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDHCalTBCableAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalTBCableAlgo.cc
3 // Description: Cable mockup between barrel and endcap gap
5 
6 #include <cmath>
7 #include <algorithm>
8 
9 namespace std{} using namespace std;
10 
18 #include "CLHEP/Units/GlobalPhysicalConstants.h"
19 #include "CLHEP/Units/GlobalSystemOfUnits.h"
20 
22  LogDebug("HCalGeom") << "DDHCalTBCableAlgo info: Creating an instance";
23 }
24 
26 
27 
29  const DDVectorArguments & vArgs,
30  const DDMapArguments & ,
31  const DDStringArguments & sArgs,
32  const DDStringVectorArguments & ) {
33 
34  genMat = sArgs["MaterialName"];
35  nsectors = int (nArgs["NSector"]);
36  nsectortot = int (nArgs["NSectorTot"]);
37  nhalf = int (nArgs["NHalf"]);
38  rin = nArgs["RIn"];
39  theta = vArgs["Theta"];
40  rmax = vArgs["RMax"];
41  zoff = vArgs["ZOff"];
42 
43  absMat = sArgs["AbsMatName"];
44  thick = nArgs["Thickness"];
45  width1 = nArgs["Width1"];
46  length1 = nArgs["Length1"];
47  width2 = nArgs["Width2"];
48  length2 = nArgs["Length2"];
49  gap2 = nArgs["Gap2"];
50 
51  LogDebug("HCalGeom") << "DDHCalTBCableAlgo debug: General material "
52  << genMat << "\tSectors " << nsectors << ", "
53  << nsectortot << "\tHalves " << nhalf << "\tRin " <<rin;
54  for (unsigned int i = 0; i < theta.size(); i++)
55  LogDebug("HCalGeom") << "\t" << i << " Theta " << theta[i] << " rmax "
56  << rmax[i] << " zoff " << zoff[i];
57  LogDebug("HCalGeom") << "\tCable mockup made of " << absMat << "\tThick "
58  << thick << "\tLength and width " << length1 << ", "
59  << width1 <<" and " << length2 << ", " << width2
60  << " Gap " << gap2;
61 
62  idName = sArgs["MotherName"];
64  rotns = sArgs["RotNameSpace"];
65  DDName parentName = parent().name();
66  LogDebug("HCalGeom") << "DDHCalTBCableAlgo debug: Parent " << parentName
67  << " idName " << idName << " NameSpace " << idNameSpace
68  << " for solids etc. and " << rotns << " for rotations";
69 }
70 
72 
73  LogDebug("HCalGeom") << "==>> Constructing DDHCalTBCableAlgo...";
74  unsigned int i=0;
75 
76  double alpha = CLHEP::pi/nsectors;
77  double dphi = nsectortot*CLHEP::twopi/nsectors;
78 
79  double zstep0 = zoff[1]+rmax[1]*tan(theta[1])+(rin-rmax[1])*tan(theta[2]);
80  double zstep1 = zstep0+thick/cos(theta[2]);
81  double zstep2 = zoff[3];
82 
83  double rstep0 = rin + (zstep2-zstep1)/tan(theta[2]);
84  double rstep1 = rin + (zstep1-zstep0)/tan(theta[2]);
85 
86  vector<double> pgonZ;
87  pgonZ.push_back(zstep0);
88  pgonZ.push_back(zstep1);
89  pgonZ.push_back(zstep2);
90  pgonZ.push_back(zstep2+thick/cos(theta[2]));
91 
92  vector<double> pgonRmin;
93  pgonRmin.push_back(rin);
94  pgonRmin.push_back(rin);
95  pgonRmin.push_back(rstep0);
96  pgonRmin.push_back(rmax[2]);
97 
98  vector<double> pgonRmax;
99  pgonRmax.push_back(rin);
100  pgonRmax.push_back(rstep1);
101  pgonRmax.push_back(rmax[2]);
102  pgonRmax.push_back(rmax[2]);
103 
104  string name("Null");
105  DDSolid solid;
107  nsectortot, -alpha, dphi, pgonZ,
108  pgonRmin, pgonRmax);
109  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: "
110  << DDName(idName,idNameSpace) << " Polyhedra made of "
111  << genMat << " with " << nsectortot << " sectors from "
112  << -alpha/CLHEP::deg << " to "
113  << (-alpha+dphi)/CLHEP::deg << " and with "
114  << pgonZ.size() << " sections";
115  for (i = 0; i <pgonZ.size(); i++)
116  LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[i] << "\tRmin = "
117  << pgonRmin[i] << "\tRmax = " << pgonRmax[i];
118 
120  DDMaterial matter(matname);
121  DDLogicalPart genlogic(solid.ddname(), matter, solid);
122 
123  DDName parentName = parent().name();
124  DDTranslation r0(0.0, 0.0, 0.0);
125  DDRotation rot;
126  cpv.position(DDName(idName, idNameSpace), parentName, 1, r0, rot);
127  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: "
128  << DDName(idName,idNameSpace) << " number 1 positioned "
129  << "in " << parentName << " at " << r0 << " with "<<rot;
130 
131  if (nhalf != 1) {
132  rot = DDRotation(DDName("180D", rotns));
133  cpv.position(DDName(idName, idNameSpace), parentName, 2, r0, rot);
134  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: "
135  << DDName(idName,idNameSpace) <<" number 2 positioned"
136  << "in " << parentName << " at " << r0 << " with "
137  << rot;
138  }
139 
140  //Construct sector (from -alpha to +alpha)
141  name = idName + "Module";
142  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: "
143  << DDName(name,idNameSpace) << " Polyhedra made of "
144  << genMat << " with 1 sector from " <<-alpha/CLHEP::deg
145  << " to " << alpha/CLHEP::deg << " and with "
146  << pgonZ.size() << " sections";
147  for (i = 0; i < pgonZ.size(); i++)
148  LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[i] << "\tRmin = "
149  << pgonRmin[i] << "\tRmax = " << pgonRmax[i];
151  1, -alpha, 2*alpha, pgonZ,
152  pgonRmin, pgonRmax);
153  DDLogicalPart seclogic(solid.ddname(), matter, solid);
154 
155  for (int ii=0; ii<nsectortot; ii++) {
156  double phi = ii*2*alpha;
157  double phideg = phi/CLHEP::deg;
158 
160  string rotstr("NULL");
161  if (phideg != 0) {
162  rotstr = "R";
163  if (phideg < 100) rotstr = "R0";
164  rotstr = rotstr + std::to_string(phideg);
165  rotation = DDRotation(DDName(rotstr, rotns));
166  if (!rotation) {
167  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: Creating a new "
168  << "rotation " << rotstr << "\t90," << phideg
169  << ", 90, " << (phideg+90) << ", 0, 0";
170  rotation = DDrot(DDName(rotstr, idNameSpace), 90*CLHEP::deg,
171  phideg*CLHEP::deg, 90*CLHEP::deg,
172  (90+phideg)*CLHEP::deg, 0*CLHEP::deg, 0*CLHEP::deg);
173  }
174  }
175 
176  cpv.position(seclogic, genlogic, ii+1, DDTranslation(0.0, 0.0, 0.0), rotation);
177  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << seclogic.name()
178  << " number " << ii+1 << " positioned in "
179  << genlogic.name() << " at (0,0,0) with " << rotation;
180  }
181 
182  //Now a trapezoid of air
183  double rinl = pgonRmin[0] + thick * sin(theta[2]);
184  double routl = pgonRmax[2] - thick * sin(theta[2]);
185  double dx1 = rinl * tan(alpha);
186  double dx2 = 0.90 * routl * tan(alpha);
187  double dy = 0.50 * thick;
188  double dz = 0.50 * (routl -rinl);
189  name = idName + "Trap";
190  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, dy, dx1,
191  dx1, 0, dy, dx2, dx2, 0);
192  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << solid.name()
193  <<" Trap made of " << genMat << " of dimensions " << dz
194  << ", 0, 0, " << dy << ", " << dx1 << ", " << dx1
195  << ", 0, " << dy << ", " << dx2 << ", " << dx2 <<", 0";
196  DDLogicalPart glog(solid.ddname(), matter, solid);
197 
198  string rotstr = name;
199  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: Creating a new rotation: "
200  << rotstr << "\t90, 270, " << (180-theta[2]/CLHEP::deg)
201  << ", 0, " << (90-theta[2]/CLHEP::deg) << ", 0";
202  rot = DDrot(DDName(rotstr, idNameSpace), 90*CLHEP::deg, 270*CLHEP::deg,
203  180*CLHEP::deg-theta[2], 0, 90*CLHEP::deg-theta[2], 0);
204  DDTranslation r1(0.5*(rinl+routl), 0, 0.5*(pgonZ[1]+pgonZ[2]));
205  cpv.position(glog, seclogic, 1, r1, rot);
206  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << glog.name()
207  << " number 1 positioned in " << seclogic.name()
208  << " at " << r1 << " with " << rot;
209 
210  //Now the cable of type 1
211  name = idName + "Cable1";
212  double phi = atan((dx2-dx1)/(2*dz));
213  double xmid = 0.5*(dx1+dx2)-1.0;
214  solid = DDSolidFactory::box(DDName(name, idNameSpace), 0.5*width1,
215  0.5*thick, 0.5*length1);
216  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << solid.name()
217  << " Box made of " << absMat << " of dimension "
218  << 0.5*width1 << ", " << 0.5*thick << ", "
219  << 0.5*length1;
220  DDName absname(DDSplit(absMat).first, DDSplit(absMat).second);
221  DDMaterial absmatter(absname);
222  DDLogicalPart cablog1(solid.ddname(), absmatter, solid);
223 
224  rotstr = idName + "Left";
225  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: Creating a new rotation "
226  << rotstr << "\t" << (90+phi/CLHEP::deg) << "," << 0
227  << "," << 90 << "," << 90 << "," << phi/CLHEP::deg
228  << "," << 0;
229  DDRotation rot2 = DDrot(DDName(rotstr, idNameSpace), 90*CLHEP::deg+phi, 0.0,
230  90*CLHEP::deg, 90*CLHEP::deg, phi, 0.0);
231  DDTranslation r2((xmid-0.5*width1*cos(phi)), 0, 0);
232  cpv.position(cablog1, glog, 1, r2, rot2);
233  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << cablog1.name()
234  << " number 1 positioned in " << glog.name() << " at "
235  << r2 << " with " << rot2;
236 
237  rotstr = idName + "Right";
238  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: Creating a new rotation "
239  << rotstr << "\t" << (90-phi/CLHEP::deg)
240  << ", 0, 90, 90, " << -phi/CLHEP::deg << ", 0";
241  DDRotation rot3 = DDrot(DDName(rotstr, idNameSpace), 90*CLHEP::deg-phi,
242  0*CLHEP::deg, 90*CLHEP::deg, 90*CLHEP::deg,
243  -phi, 0*CLHEP::deg);
244  DDTranslation r3(-(xmid-0.5*width1*cos(phi)), 0, 0);
245  cpv.position(cablog1, glog, 2, r3, rot3);
246  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << cablog1.name()
247  << " number 2 positioned in " << glog.name() << " at "
248  << r3 << " with " << rot3;
249 
250  //Now the cable of type 2
251  name = idName + "Cable2";
252  solid = DDSolidFactory::box(DDName(name, idNameSpace), 0.5*width2,
253  0.5*thick, 0.5*length2);
254  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << solid.name()
255  << " Box made of " << absMat << " of dimension "
256  << 0.5*width2 << ", " << 0.5*thick << ", "<<0.5*length2;
257  DDLogicalPart cablog2(solid.ddname(), absmatter, solid);
258 
259  double xpos = 0.5*(width2+gap2);
260  cpv.position(cablog2, glog, 1, DDTranslation(xpos, 0.0, 0.0), DDRotation());
261  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << cablog2.name()
262  << " number 1 positioned in " << glog.name() << " at ("
263  << xpos << ", 0, 0) with no rotation";
264  cpv.position(cablog2, glog, 2, DDTranslation(-xpos, 0.0, 0.0), DDRotation());
265  LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " << cablog2.name()
266  << " number 2 positioned in " << glog.name() << " at ("
267  <<-xpos << ", 0, 0) with no rotation";
268 
269  LogDebug("HCalGeom") << "<<== End of DDHCalTBCableAlgo construction ...";
270 }
#define LogDebug(id)
std::vector< double > theta
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< double > rmax
const N & name() const
Definition: DDBase.h:78
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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:16
static std::string & ns()
int ii
Definition: cuy.py:588
type of data representation of DDCompactView
Definition: DDCompactView.h:90
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:66
U second(std::pair< T, U > const &p)
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
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:758
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:526
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void execute(DDCompactView &cpv)
virtual ~DDHCalTBCableAlgo()
std::vector< double > zoff
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
std::string idNameSpace
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:708
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
const N & ddname() const
Definition: DDBase.h:80