CMS 3D CMS Logo

DDPixBarLayerAlgo.cc
Go to the documentation of this file.
1 // File: DDPixBarLayerAlgo.cc
3 // Description: Make one layer of pixel barrel detector
5 
6 #include <cmath>
7 #include <algorithm>
8 
16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
19 
21  LogDebug("PixelGeom") <<"DDPixBarLayerAlgo info: Creating an instance";
22 }
23 
25 
27  const DDVectorArguments & vArgs,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments & vsArgs) {
31 
33  DDName parentName = parent().name();
34 
35  genMat = sArgs["GeneralMaterial"];
36  number = int(nArgs["Ladders"]);
37  layerDz = nArgs["LayerDz"];
38  sensorEdge= nArgs["SensorEdge"];
39  coolDz = nArgs["CoolDz"];
40  coolWidth = nArgs["CoolWidth"];
41  coolSide = nArgs["CoolSide"];
42  coolThick = nArgs["CoolThick"];
43  coolDist = nArgs["CoolDist"];
44  coolMat = sArgs["CoolMaterial"];
45  tubeMat = sArgs["CoolTubeMaterial"];
46 
47  LogDebug("PixelGeom") << "DDPixBarLayerAlgo debug: Parent " << parentName
48  << " NameSpace " << idNameSpace << "\n"
49  << "\tLadders " << number << "\tGeneral Material "
50  << genMat << "\tLength " << layerDz << "\tSensorEdge "
51  << sensorEdge << "\tSpecification of Cooling Pieces:\n"
52  << "\tLength " << coolDz << " Width " << coolWidth
53  << " Side " << coolSide << " Thickness of Shell "
54  << coolThick << " Radial distance " << coolDist
55  << " Materials " << coolMat << ", " << tubeMat;
56 
57  ladder = vsArgs["LadderName"];
58  ladderWidth = vArgs["LadderWidth"];
59  ladderThick = vArgs["LadderThick"];
60 
61  LogDebug("PixelGeom") << "DDPixBarLayerAlgo debug: Full Ladder "
62  << ladder[0] << " width/thickness " << ladderWidth[0]
63  << ", " << ladderThick[0] << "\tHalf Ladder "
64  << ladder[1] << " width/thickness " << ladderWidth[1]
65  << ", " << ladderThick[1];
66 }
67 
69 
70  DDName mother = parent().name();
71  const std::string &idName = mother.name();
72 
73  double dphi = CLHEP::twopi/number;
74  double d2 = 0.5*coolWidth;
75  double d1 = d2 - coolSide*sin(0.5*dphi);
76  double x1 = (d1+d2)/(2.*sin(0.5*dphi));
77  double x2 = coolDist*sin(0.5*dphi);
78  double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick[0];
79  double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick[0];
80  double rmxh = rmax - 0.5*ladderThick[0] + ladderThick[1];
81  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Rmin/Rmax " << rmin
82  << ", " << rmax << " d1/d2 " << d1 << ", " << d2
83  << " x1/x2 " << x1 << ", " << x2;
84 
85  double rtmi = rmin + 0.5*ladderThick[0] - ladderThick[1];
86  double rtmx = sqrt(rmxh*rmxh+ladderWidth[1]*ladderWidth[1]);
88  rtmi, rtmx, 0, CLHEP::twopi);
89  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: "
90  << DDName(idName, idNameSpace) << " Tubs made of "
91  << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg
92  << " with Rin " << rtmi << " Rout " << rtmx
93  << " ZHalf " << 0.5*layerDz;
95  DDMaterial matter(matname);
96  DDLogicalPart layer(solid.ddname(), matter, solid);
97 
98  double rr = 0.5*(rmax+rmin);
99  double dr = 0.5*(rmax-rmin);
100  double h1 = 0.5*coolSide*cos(0.5*dphi);
101  std::string name = idName + "CoolTube";
102  solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
103  h1, d2, d1, 0, h1, d2, d1, 0);
104  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " <<solid.name()
105  << " Trap made of " << tubeMat << " of dimensions "
106  << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
107  << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", "
108  << d1 << ", 0";
109  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
110  DDLogicalPart coolTube(solid.ddname(), matter, solid);
111 
112  name = idName + "Coolant";
113  h1 -= coolThick;
114  d1 -= coolThick;
115  d2 -= coolThick;
116  solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
117  h1, d2, d1, 0, h1, d2, d1, 0);
118  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " <<solid.name()
119  << " Trap made of " << coolMat << " of dimensions "
120  << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
121  << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", "
122  << d1 << ", 0";
123  matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
124  DDLogicalPart cool(solid.ddname(), matter, solid);
125  cpv.position(cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
126  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << cool.name()
127  << " number 1 positioned in " << coolTube.name()
128  << " at (0,0,0) with no rotation";
129 
130  DDName ladderFull(DDSplit(ladder[0]).first, DDSplit(ladder[0]).second);
131  DDName ladderHalf(DDSplit(ladder[1]).first, DDSplit(ladder[1]).second);
132 
133  int nphi=number/2, copy=1, iup=-1;
134  double phi0 = 90*CLHEP::deg;
135  for (int i=0; i<number; i++) {
136 
137  double phi = phi0 + i*dphi;
138  double phix, phiy, rrr, xx;
139  std::string rots;
140  DDTranslation tran;
141  DDRotation rot;
142  if (i == 0 || i == nphi) {
143  rrr = rr + dr + 0.5*(ladderThick[1]-ladderThick[0]);
144  xx = (0.5*ladderWidth[1] - sensorEdge) * sin(phi);
145  tran = DDTranslation(xx, rrr*sin(phi), 0);
146  rots = idName + std::to_string(copy);
147  phix = phi-90*CLHEP::deg;
148  phiy = 90*CLHEP::deg+phix;
149  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
150  << "rotation: " << rots << "\t90., "
151  << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
152  << ", 0, 0";
153  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg,
154  phiy, 0.,0.);
155  cpv.position(ladderHalf, layer, copy, tran, rot);
156  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderHalf
157  << " number " << copy << " positioned in "
158  << layer.name() << " at " << tran << " with "
159  << rot;
160  copy++;
161  iup = -1;
162  rrr = rr - dr - 0.5*(ladderThick[1]-ladderThick[0]);
163  tran = DDTranslation(-xx, rrr*sin(phi), 0);
164  rots = idName + std::to_string(copy);
165  phix = phi+90*CLHEP::deg;
166  phiy = 90*CLHEP::deg+phix;
167  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
168  << "rotation: " << rots << "\t90., "
169  << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
170  << ", 0, 0";
171  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg,
172  phiy, 0.,0.);
173  cpv.position(ladderHalf, layer, copy, tran, rot);
174  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderHalf
175  << " number " << copy << " positioned in "
176  << layer.name() << " at " << tran << " with "
177  << rot;
178  copy++;
179  } else {
180  iup =-iup;
181  rrr = rr + iup*dr;
182  tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
183  rots = idName + std::to_string(copy);
184  if (iup > 0) phix = phi-90*CLHEP::deg;
185  else phix = phi+90*CLHEP::deg;
186  phiy = phix+90.*CLHEP::deg;
187  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
188  << "rotation: " << rots << "\t90., "
189  << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
190  << ", 0, 0";
191  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg,
192  phiy, 0.,0.);
193  cpv.position(ladderFull, layer, copy, tran, rot);
194  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderFull
195  << " number " << copy << " positioned in "
196  << layer.name() << " at " << tran << " with "
197  << rot;
198  copy++;
199  }
200  rrr = coolDist*cos(0.5*dphi);
201  tran = DDTranslation(rrr*cos(phi)-x2*sin(phi),
202  rrr*sin(phi)+x2*cos(phi), 0);
203  rots = idName + std::to_string(i+100);
204  phix = phi+0.5*dphi;
205  if (iup > 0) phix += 180*CLHEP::deg;
206  phiy = phix+90.*CLHEP::deg;
207  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
208  << "rotation: " << rots << "\t90., "
209  << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
210  << ", 0, 0";
211  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg,
212  phiy, 0.,0.);
213  cpv.position(coolTube, layer, i+1, tran, rot);
214  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << coolTube.name()
215  << " number " << i+1 << " positioned in "
216  << layer.name() << " at " << tran << " with "<< rot;
217  }
218 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
def copy(args, dbName)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::string idNameSpace
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
void execute(DDCompactView &cpv) override
std::vector< std::string > ladder
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:986
~DDPixBarLayerAlgo() override
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
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< double > ladderWidth
std::vector< double > ladderThick
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
const N & ddname() const
Definition: DDBase.h:80