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 
16 #include "CLHEP/Units/PhysicalConstants.h"
17 #include "CLHEP/Units/SystemOfUnits.h"
18 
19 
21  LogDebug("PixelGeom") <<"DDPixBarLayerUpgradeAlgoCoverage 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 
48  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage 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 = sArgs["LadderName"];
59  ladderWidth = nArgs["LadderWidth"];
60  ladderThick = nArgs["LadderThick"];
61  activeWidth = nArgs["ActiveWidth"];
62  outerFirst = int(nArgs["OuterFirst"]);
63 
64  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage debug: Full Ladder "
65  << ladder << " width/thickness " << ladderWidth
66  << ", " << ladderThick;
67  std::cout << " LadderThick = " << ladderThick << std::endl;
68  std::cout << " LadderWidth = " << ladderWidth << std::endl;
69  std::cout << " ActiveWidth = " << activeWidth << std::endl;
70 }
71 
73 
74  DDName mother = parent().name();
75  std::string idName = DDSplit(mother).first;
76 
77  // Keep a running tally to check that there are no phi gaps.
78  double phi_coverage = 0.0; // Running total of Phi coverage
79  double dphi = CLHEP::twopi/number;
80  double d2 = 0.5*coolWidth;
81  double d1 = d2 - coolSide*sin(0.5*dphi);
82  double x1 = (d1+d2)/(2.*sin(0.5*dphi));
83  double x2 = coolDist*sin(0.5*dphi);
84  double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick;
85  double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick;
86  double rmxh = rmax + 0.5*ladderThick;
87  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: Rmin/Rmax " << rmin
88  << ", " << rmax << " d1/d2 " << d1 << ", " << d2
89  << " x1/x2 " << x1 << ", " << x2;
90 
91  double rtmi = rmin - 0.5*ladderThick;
92  double rtmx = sqrt(rmxh*rmxh+ladderWidth*ladderWidth);
94  rtmi, rtmx, 0, CLHEP::twopi);
95  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: "
96  << DDName(idName, idNameSpace) << " Tubs made of "
97  << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg
98  << " with Rin " << rtmi << " Rout " << rtmx
99  << " ZHalf " << 0.5*layerDz;
101  DDMaterial matter(matname);
102  DDLogicalPart layer(solid.ddname(), matter, solid);
103 
104  double rr = 0.5*(rmax+rmin);
105  double dr = 0.5*(rmax-rmin);
106  double h1 = 0.5*coolSide*cos(0.5*dphi);
107  std::string name = idName + "CoolTube";
108  solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
109  h1, d2, d1, 0, h1, d2, d1, 0);
110  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " <<solid.name()
111  << " Trap made of " << tubeMat << " of dimensions "
112  << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
113  << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", "
114  << d1 << ", 0";
115  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
116  DDLogicalPart coolTube(solid.ddname(), matter, solid);
117 
118  name = idName + "Coolant";
119  h1 -= coolThick;
120  d1 -= coolThick;
121  d2 -= coolThick;
122  solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
123  h1, d2, d1, 0, h1, d2, d1, 0);
124  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " <<solid.name()
125  << " Trap made of " << coolMat << " of dimensions "
126  << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
127  << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", "
128  << d1 << ", 0";
129  matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
130  DDLogicalPart cool(solid.ddname(), matter, solid);
131  cpv.position (cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
132  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << cool.name()
133  << " number 1 positioned in " << coolTube.name()
134  << " at (0,0,0) with no rotation";
135 
136  DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
137  int copy=1, iup=(-1)*outerFirst;
138  for (int i=1; i<number+1; i++) {
139  double phi = i*dphi;
140  double phix, phiy, rrr;
141  std::string rots;
142  DDTranslation tran;
143  DDRotation rot;
144  iup =-iup;
145  rrr = rr + iup*dr;
146  tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
147  rots = idName + std::to_string(copy);
148  if (iup > 0) phix = phi-90*CLHEP::deg;
149  else phix = phi+90*CLHEP::deg;
150  phiy = phix+90.*CLHEP::deg;
151  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: Creating a new "
152  << "rotation: " << rots << "\t90., " << phix/CLHEP::deg
153  << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
154  rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
155  cpv.position (ladderFull, layer, copy, tran, rot);
156  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << ladderFull
157  << " number " << copy << " positioned in "
158  << layer.name() << " at " << tran << " with "
159  << rot;
160  double phi_coverage_i=2*atan2((activeWidth/2.0),(rrr+(ladderThick/2.0)));
161  //std::cout << " radius = " << rrr << " phi value " << phi_coverage_i << std::endl;
162  phi_coverage += phi_coverage_i;
163  copy++;
164  rrr = coolDist*cos(0.5*dphi);
165  tran = DDTranslation(rrr*cos(phi)-x2*sin(phi),
166  rrr*sin(phi)+x2*cos(phi), 0);
167  rots = idName + std::to_string(i+100);
168  phix = phi+0.5*dphi;
169  if (iup > 0) phix += 180*CLHEP::deg;
170  phiy = phix+90.*CLHEP::deg;
171  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage 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 (coolTube, layer, i+1, tran, rot);
176  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << coolTube.name()
177  << " number " << i+1 << " positioned in "
178  << layer.name() << " at " << tran << " with "<< rot;
179  }
180  std::cout<<"\nLayer covered "<<phi_coverage<<" radians in phi. (2Pi="<<CLHEP::twopi<<")" << std::endl;
181  if (phi_coverage>CLHEP::twopi) std::cout<<"\nPhi coverage is achieved"<< std::endl;
182 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:78
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:16
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:37
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: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:823
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:758
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:145
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:90
const N & ddname() const
Definition: DDBase.h:80