CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDPixBarLayerUpgradeAlgoCoverage.cc
Go to the documentation of this file.
1 // File: DDPixBarLayerUpgradeAlgoCoverage.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") <<"DDPixBarLayerUpgradeAlgoCoverage 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 
49  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage debug: Parent " << parentName
50  << " NameSpace " << idNameSpace << "\n"
51  << "\tLadders " << number << "\tGeneral Material "
52  << genMat << "\tLength " << layerDz << "\tSensorEdge "
53  << sensorEdge << "\tSpecification of Cooling Pieces:\n"
54  << "\tLength " << coolDz << " Width " << coolWidth
55  << " Side " << coolSide << " Thickness of Shell "
56  << coolThick << " Radial distance " << coolDist
57  << " Materials " << coolMat << ", " << tubeMat;
58 
59  ladder = sArgs["LadderName"];
60  ladderWidth = nArgs["LadderWidth"];
61  ladderThick = nArgs["LadderThick"];
62  activeWidth = nArgs["ActiveWidth"];
63  outerFirst = int(nArgs["OuterFirst"]);
64 
65  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage debug: Full Ladder "
66  << ladder << " width/thickness " << ladderWidth
67  << ", " << ladderThick;
68  std::cout << " LadderThick = " << ladderThick << std::endl;
69  std::cout << " LadderWidth = " << ladderWidth << std::endl;
70  std::cout << " ActiveWidth = " << activeWidth << std::endl;
71 }
72 
74 
75  DDName mother = parent().name();
76  std::string idName = DDSplit(mother).first;
77 
78  // Keep a running tally to check that there are no phi gaps.
79  double phi_coverage = 0.0; // Running total of Phi coverage
80  double dphi = CLHEP::twopi/number;
81  double d2 = 0.5*coolWidth;
82  double d1 = d2 - coolSide*sin(0.5*dphi);
83  double x1 = (d1+d2)/(2.*sin(0.5*dphi));
84  double x2 = coolDist*sin(0.5*dphi);
85  double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick;
86  double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick;
87  double rmxh = rmax + 0.5*ladderThick;
88  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: Rmin/Rmax " << rmin
89  << ", " << rmax << " d1/d2 " << d1 << ", " << d2
90  << " x1/x2 " << x1 << ", " << x2;
91 
92  double rtmi = rmin - 0.5*ladderThick;
93  double rtmx = sqrt(rmxh*rmxh+ladderWidth*ladderWidth);
95  rtmi, rtmx, 0, CLHEP::twopi);
96  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: "
97  << DDName(idName, idNameSpace) << " Tubs made of "
98  << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg
99  << " with Rin " << rtmi << " Rout " << rtmx
100  << " ZHalf " << 0.5*layerDz;
102  DDMaterial matter(matname);
103  DDLogicalPart layer(solid.ddname(), matter, solid);
104 
105  double rr = 0.5*(rmax+rmin);
106  double dr = 0.5*(rmax-rmin);
107  double h1 = 0.5*coolSide*cos(0.5*dphi);
108  std::string name = idName + "CoolTube";
109  solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
110  h1, d2, d1, 0, h1, d2, d1, 0);
111  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " <<solid.name()
112  << " Trap made of " << tubeMat << " of dimensions "
113  << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
114  << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", "
115  << d1 << ", 0";
116  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
117  DDLogicalPart coolTube(solid.ddname(), matter, solid);
118 
119  name = idName + "Coolant";
120  h1 -= coolThick;
121  d1 -= coolThick;
122  d2 -= coolThick;
123  solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
124  h1, d2, d1, 0, h1, d2, d1, 0);
125  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " <<solid.name()
126  << " Trap made of " << coolMat << " of dimensions "
127  << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
128  << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", "
129  << d1 << ", 0";
130  matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
131  DDLogicalPart cool(solid.ddname(), matter, solid);
132  cpv.position (cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
133  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << cool.name()
134  << " number 1 positioned in " << coolTube.name()
135  << " at (0,0,0) with no rotation";
136 
137  DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
138  int copy=1, iup=(-1)*outerFirst;
139  for (int i=1; i<number+1; i++) {
140  double phi = i*dphi;
141  double phix, phiy, rrr;
142  std::string rots;
143  DDTranslation tran;
144  DDRotation rot;
145  iup =-iup;
146  rrr = rr + iup*dr;
147  tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
148  rots = idName + dbl_to_string(copy);
149  if (iup > 0) phix = phi-90*CLHEP::deg;
150  else phix = phi+90*CLHEP::deg;
151  phiy = phix+90.*CLHEP::deg;
152  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage 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 (ladderFull, layer, copy, tran, rot);
157  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << ladderFull
158  << " number " << copy << " positioned in "
159  << layer.name() << " at " << tran << " with "
160  << rot;
161  double phi_coverage_i=2*atan2((activeWidth/2.0),(rrr+(ladderThick/2.0)));
162  //std::cout << " radius = " << rrr << " phi value " << phi_coverage_i << std::endl;
163  phi_coverage += phi_coverage_i;
164  copy++;
165  rrr = coolDist*cos(0.5*dphi);
166  tran = DDTranslation(rrr*cos(phi)-x2*sin(phi),
167  rrr*sin(phi)+x2*cos(phi), 0);
168  rots = idName + dbl_to_string(i+100);
169  phix = phi+0.5*dphi;
170  if (iup > 0) phix += 180*CLHEP::deg;
171  phiy = phix+90.*CLHEP::deg;
172  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: Creating a new "
173  << "rotation: " << rots << "\t90., " << phix/CLHEP::deg
174  << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
175  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
176  cpv.position (coolTube, layer, i+1, tran, rot);
177  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << coolTube.name()
178  << " number " << i+1 << " positioned in "
179  << layer.name() << " at " << tran << " with "<< rot;
180  }
181  std::cout<<"\nLayer covered "<<phi_coverage<<" radians in phi. (2Pi="<<CLHEP::twopi<<")" << std::endl;
182  if (phi_coverage>CLHEP::twopi) std::cout<<"\nPhi coverage is achieved"<< std::endl;
183 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:82
list parent
Definition: dbtoconf.py:74
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
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:18
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
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
bool first
Definition: L1TdeRCT.cc:79
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
tuple cout
Definition: gather_cfg.py:121
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:84
Definition: DDAxes.h:10