CMS 3D CMS Logo

DDPixBarLayerUpgradeAlgo.cc
Go to the documentation of this file.
1 // File: DDPixBarLayerUpgradeAlgo.cc
3 // Description: Make one layer of pixel barrel detector for Upgrading.
5 
6 #include <cmath>
7 #include <algorithm>
8 
16 #include "CLHEP/Units/PhysicalConstants.h"
17 #include "CLHEP/Units/SystemOfUnits.h"
18 
19 
21  LogDebug("PixelGeom") <<"DDPixBarLayerUpgradeAlgo 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  coolDz = nArgs["CoolDz"];
39  coolThick = nArgs["CoolThick"];
40  coolRadius= nArgs["CoolRadius"];
41  coolDist = nArgs["CoolDist"];
42  cool1Offset = nArgs["Cool1Offset"];
43  cool2Offset = nArgs["Cool2Offset"];
44  coolMat = sArgs["CoolMaterial"];
45  tubeMat = sArgs["CoolTubeMaterial"];
46  coolMatHalf = sArgs["CoolMaterialHalf"];
47  tubeMatHalf = sArgs["CoolTubeMaterialHalf"];
48  phiFineTune = nArgs["PitchFineTune"];
49  rOuterFineTune = nArgs["OuterOffsetFineTune"];
50  rInnerFineTune = nArgs["InnerOffsetFineTune"];
51 
52 
53  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Parent " << parentName
54  << " NameSpace " << idNameSpace << "\n"
55  << "\tLadders " << number << "\tGeneral Material "
56  << genMat << "\tLength " << layerDz << "\tSpecification of Cooling Pieces:\n"
57  << "\tLength " << coolDz << " Thickness of Shell "
58  << coolThick << " Radial distance " << coolDist
59  << " Materials " << coolMat << ", " << tubeMat;
60 
61  ladder = sArgs["LadderName"];
62  ladderWidth = nArgs["LadderWidth"];
63  ladderThick = nArgs["LadderThick"];
64  ladderOffset = nArgs["LadderOffset"];
65  outerFirst = int(nArgs["OuterFirst"]);
66 
67  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Full Ladder "
68  << ladder << " width/thickness " << ladderWidth
69  << ", " << ladderThick;
70 }
71 
73 
74  DDName mother = parent().name();
75  std::string idName = DDSplit(mother).first;
76 
77  double dphi = CLHEP::twopi/number;
78  double x2 = coolDist*sin(0.5*dphi);
79  double rtmi = coolDist*cos(0.5*dphi)-(coolRadius+ladderThick)+rInnerFineTune;
81  double rtmx = sqrt(rmxh*rmxh+ladderWidth*ladderWidth/4);
83  rtmi, rtmx, 0, CLHEP::twopi);
84  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: "
85  << DDName(idName, idNameSpace) << " Tubs made of "
86  << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg
87  << " with Rin " << rtmi << " Rout " << rtmx
88  << " ZHalf " << 0.5*layerDz;
90  DDMaterial matter(matname);
91  DDLogicalPart layer(solid.ddname(), matter, solid);
92 
93  // Full Tubes
94  std::string name = idName + "CoolTube";
95  solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
96  0, coolRadius, 0, CLHEP::twopi);
97  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name()
98  << " Tubs made of " << tubeMat << " from 0 to " <<
99  CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius <<
100  " ZHalf " << 0.5*coolDz;
101  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
102  DDLogicalPart coolTube(solid.ddname(), matter, solid);
103 
104  // Half Tubes
105  name = idName + "CoolTubeHalf";
106  solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
107  0, coolRadius, 0, CLHEP::pi);
108  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name()
109  << " Tubs made of " << tubeMatHalf << " from 0 to " <<
110  CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius <<
111  " ZHalf " << 0.5*coolDz;
112  matter = DDMaterial(DDName(DDSplit(tubeMatHalf).first, DDSplit(tubeMatHalf).second));
113  DDLogicalPart coolTubeHalf(solid.ddname(), matter, solid);
114 
115  // Full Coolant
116  name = idName + "Coolant";
117  solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
118  0, coolRadius-coolThick, 0, CLHEP::twopi);
119  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name()
120  << " Tubs made of " << tubeMat << " from 0 to " <<
121  CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius-coolThick <<
122  " ZHalf " << 0.5*coolDz;
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") << "DDPixBarLayerUpgradeAlgo test: " << cool.name()
127  << " number 1 positioned in " << coolTube.name()
128  << " at (0,0,0) with no rotation";
129 
130  // Half Coolant
131  name = idName + "CoolantHalf";
132  solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
134  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name()
135  << " Tubs made of " << tubeMatHalf << " from 0 to " <<
136  CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius-coolThick <<
137  " ZHalf " << 0.5*coolDz;
138  matter = DDMaterial(DDName(DDSplit(coolMatHalf).first, DDSplit(coolMatHalf).second));
139  DDLogicalPart coolHalf(solid.ddname(), matter, solid);
140  cpv.position (coolHalf, coolTubeHalf, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
141  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name()
142  << " number 1 positioned in " << coolTube.name()
143  << " at (0,0,0) with no rotation";
144 
145  DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
146  int copy=1, iup=(-1)*outerFirst;
147  int copyoffset=number+2;
148  for (int i=1; i<number+1; i++) {
149  double phi = i*dphi+90*CLHEP::deg-0.5*dphi+phiFineTune; //to start with the interface ladder
150  double phix, phiy, rrr, rrroffset;
151  std::string rots;
152  DDTranslation tran;
153  DDRotation rot;
154  iup =-iup;
155  double dr;
156  if ((i==1)||(i==number/2+1)) {
157  dr=coolRadius+0.5*ladderThick+ladderOffset; //interface ladder offset
158  } else {
159  dr=coolRadius+0.5*ladderThick;
160  }
161  if(i % 2 == 1) {
162  rrr = coolDist*cos(0.5*dphi)+iup*dr+rOuterFineTune;
163  } else {
164  rrr = coolDist*cos(0.5*dphi)+iup*dr+rInnerFineTune;
165  }
166  tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
167  rots = idName + std::to_string(copy);
168  if (iup > 0) phix = phi-90*CLHEP::deg;
169  else phix = phi+90*CLHEP::deg;
170  phiy = phix+90.*CLHEP::deg;
171  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
172  << "rotation: " << rots << "\t90., " << phix/CLHEP::deg
173  << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
174  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
175  cpv.position (ladderFull, layer, copy, tran, rot);
176  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladderFull
177  << " number " << copy << " positioned in "
178  << layer.name() << " at " << tran << " with "
179  << rot;
180  copy++;
181  rrr = coolDist*cos(0.5*dphi) + coolRadius/2.;
182  rots = idName + std::to_string(i+100);
183  phix = phi + 90.*CLHEP::deg;
184  if(iup < 0) phix += dphi;
185  phiy = phix+90.*CLHEP::deg;
186  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
187  << "rotation: " << rots << "\t90., " << phix/CLHEP::deg
188  << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
189  tran = DDTranslation(rrr*cos(phi)-x2*sin(phi), rrr*sin(phi)+x2*cos(phi), 0);
190  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
191  cpv.position (coolTubeHalf, layer, i+1, tran, rot);
192  if ((i==1)||(i==number/2+1)){
193  rrroffset = coolDist*cos(0.5*dphi)+iup*ladderOffset + rOuterFineTune;
194  tran = DDTranslation(rrroffset*cos(phi)-cool1Offset*sin(phi),
195  rrroffset*sin(phi)+cool1Offset*cos(phi), 0);
196  cpv.position (coolTube, layer, copyoffset, tran, DDRotation());
197  copyoffset++;
198  tran = DDTranslation(rrroffset*cos(phi)-cool2Offset*sin(phi),
199  rrroffset*sin(phi)+cool2Offset*cos(phi), 0);
200  cpv.position (coolTube, layer, copyoffset, tran, DDRotation());
201  copyoffset++;
202  }
203  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name()
204  << " number " << i+1 << " positioned in "
205  << layer.name() << " at " << tran << " with "<< rot;
206  }
207 }
#define LogDebug(id)
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
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
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)
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
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:986
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) override
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