CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17 #include "CLHEP/Units/PhysicalConstants.h"
18 #include "CLHEP/Units/SystemOfUnits.h"
19 
20 
22  LogDebug("PixelGeom") <<"DDPixBarLayerUpgradeAlgo 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  coolDz = nArgs["CoolDz"];
40  coolThick = nArgs["CoolThick"];
41  coolRadius= nArgs["CoolRadius"];
42  coolDist = nArgs["CoolDist"];
43  cool1Offset = nArgs["Cool1Offset"];
44  cool2Offset = nArgs["Cool2Offset"];
45  coolMat = sArgs["CoolMaterial"];
46  tubeMat = sArgs["CoolTubeMaterial"];
47 
48 
49  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Parent " << parentName
50  << " NameSpace " << idNameSpace << "\n"
51  << "\tLadders " << number << "\tGeneral Material "
52  << genMat << "\tLength " << layerDz << "\tSpecification of Cooling Pieces:\n"
53  << "\tLength " << coolDz << " Thickness of Shell "
54  << coolThick << " Radial distance " << coolDist
55  << " Materials " << coolMat << ", " << tubeMat;
56 
57  ladder = sArgs["LadderName"];
58  ladderWidth = nArgs["LadderWidth"];
59  ladderThick = nArgs["LadderThick"];
60  ladderOffset = nArgs["LadderOffset"];
61  outerFirst = int(nArgs["OuterFirst"]);
62 
63  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Full Ladder "
64  << ladder << " width/thickness " << ladderWidth
65  << ", " << ladderThick;
66 }
67 
69 
70  DDName mother = parent().name();
71  std::string idName = DDSplit(mother).first;
72 
73  double dphi = CLHEP::twopi/number;
74  double x2 = coolDist*sin(0.5*dphi);
75  double rtmi = coolDist*cos(0.5*dphi)-(coolRadius+ladderThick);
76  double rmxh = coolDist*cos(0.5*dphi)+(coolRadius+ladderThick+ladderOffset);
77  double rtmx = sqrt(rmxh*rmxh+ladderWidth*ladderWidth/4);
79  rtmi, rtmx, 0, CLHEP::twopi);
80  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: "
81  << DDName(idName, idNameSpace) << " Tubs made of "
82  << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg
83  << " with Rin " << rtmi << " Rout " << rtmx
84  << " ZHalf " << 0.5*layerDz;
86  DDMaterial matter(matname);
87  DDLogicalPart layer(solid.ddname(), matter, solid);
88 
89  double dr = coolRadius+0.5*ladderThick;
90  std::string name = idName + "CoolTube";
91  solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
92  0, coolRadius, 0, CLHEP::twopi);
93  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name()
94  << " Tubs made of " << tubeMat << " from 0 to " <<
95  CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius <<
96  " ZHalf " << 0.5*coolDz;
97  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
98  DDLogicalPart coolTube(solid.ddname(), matter, solid);
99 
100  name = idName + "Coolant";
101  solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
102  0, coolRadius-coolThick, 0, CLHEP::twopi);
103  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name()
104  << " Tubs made of " << tubeMat << " from 0 to " <<
105  CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius-coolThick <<
106  " ZHalf " << 0.5*coolDz;
107  matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
108  DDLogicalPart cool(solid.ddname(), matter, solid);
109  cpv.position (cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
110  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name()
111  << " number 1 positioned in " << coolTube.name()
112  << " at (0,0,0) with no rotation";
113 
114  DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
115  int copy=1, iup=(-1)*outerFirst;
116  int copyoffset=number+2;
117  for (int i=1; i<number+1; i++) {
118  double phi = i*dphi+90*CLHEP::deg-0.5*dphi; //to start with the interface ladder
119  double phix, phiy, rrr, rrroffset;
120  std::string rots;
121  DDTranslation tran;
122  DDRotation rot;
123  iup =-iup;
124  if ((i==1)||(i==number/2+1)){
125  dr=coolRadius+0.5*ladderThick+ladderOffset; //interface ladder offset
126  }else{
127  dr=coolRadius+0.5*ladderThick;
128  }
129  rrr = coolDist*cos(0.5*dphi)+iup*dr;
130  tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
131  rots = idName + dbl_to_string(copy);
132  if (iup > 0) phix = phi-90*CLHEP::deg;
133  else phix = phi+90*CLHEP::deg;
134  phiy = phix+90.*CLHEP::deg;
135  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
136  << "rotation: " << rots << "\t90., " << phix/CLHEP::deg
137  << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
138  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
139  cpv.position (ladderFull, layer, copy, tran, rot);
140  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladderFull
141  << " number " << copy << " positioned in "
142  << layer.name() << " at " << tran << " with "
143  << rot;
144  copy++;
145  rrr = coolDist*cos(0.5*dphi);
146  tran = DDTranslation(rrr*cos(phi)-x2*sin(phi),
147  rrr*sin(phi)+x2*cos(phi), 0);
148  rots = idName + dbl_to_string(i+100);
149  phix = phi+0.5*dphi;
150  if (iup > 0) phix += 180*CLHEP::deg;
151  phiy = phix+90.*CLHEP::deg;
152  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
153  << "rotation: " << rots << "\t90., " << phix/CLHEP::deg
154  << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
155  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
156  cpv.position (coolTube, layer, i+1, tran, rot);
157  if ((i==1)||(i==number/2+1)){
158  rrroffset = coolDist*cos(0.5*dphi)+iup*ladderOffset;
159  tran = DDTranslation(rrroffset*cos(phi)-cool1Offset*sin(phi),
160  rrroffset*sin(phi)+cool1Offset*cos(phi), 0);
161  cpv.position (coolTube, layer, copyoffset, tran, DDRotation());
162  copyoffset++;
163  tran = DDTranslation(rrroffset*cos(phi)-cool2Offset*sin(phi),
164  rrroffset*sin(phi)+cool2Offset*cos(phi), 0);
165  cpv.position (coolTube, layer, copyoffset, tran, DDRotation());
166  copyoffset++;
167  }
168  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name()
169  << " number " << i+1 << " positioned in "
170  << layer.name() << " at " << tran << " with "<< rot;
171  }
172 }
#define LogDebug(id)
void execute(DDCompactView &cpv)
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:78
list parent
Definition: dbtoconf.py:74
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
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
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
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)
T sqrt(T t)
Definition: SSEVec.h:48
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
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
const N & ddname() const
Definition: DDBase.h:80