test
CMS 3D CMS Logo

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