CMS 3D CMS Logo

DDPixBarLayerAlgo.cc
Go to the documentation of this file.
1 // File: DDPixBarLayerAlgo.cc
3 // Description: Make one layer of pixel barrel detector
5 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 #include <cmath>
19 #include <algorithm>
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 using namespace std;
25 
26 class DDPixBarLayerAlgo : public DDAlgorithm {
27 public:
28  //Constructor and Destructor
30  ~DDPixBarLayerAlgo() override;
31 
32  void initialize(const DDNumericArguments& nArgs,
33  const DDVectorArguments& vArgs,
34  const DDMapArguments& mArgs,
35  const DDStringArguments& sArgs,
36  const DDStringVectorArguments& vsArgs) override;
37 
38  void execute(DDCompactView& cpv) override;
39 
40 private:
41  string idNameSpace; //Namespace of this and ALL sub-parts
42  string genMat; //Name of general material
43  int number; //Number of ladders in phi
44  double layerDz; //Length of the layer
45  double sensorEdge; //Distance from edge for a half sensor
46  double coolDz; //Length of the cooling piece
47  double coolWidth; //Width
48  double coolSide; //Side length
49  double coolThick; //Thickness of the shell
50  double coolDist; //Radial distance between centres of 2
51  string coolMat; //Cooling fluid material name
52  string tubeMat; //Cooling piece material name
53  vector<string> ladder; //Names of ladders
54  vector<double> ladderWidth; //Widths ...
55  vector<double> ladderThick; //Thickness ...
56 };
57 
58 DDPixBarLayerAlgo::DDPixBarLayerAlgo() { LogDebug("PixelGeom") << "DDPixBarLayerAlgo info: Creating an instance"; }
59 
61 
63  const DDVectorArguments& vArgs,
64  const DDMapArguments&,
65  const DDStringArguments& sArgs,
66  const DDStringVectorArguments& vsArgs) {
67  idNameSpace = DDCurrentNamespace::ns();
68  DDName parentName = parent().name();
69 
70  genMat = sArgs["GeneralMaterial"];
71  number = int(nArgs["Ladders"]);
72  layerDz = nArgs["LayerDz"];
73  sensorEdge = nArgs["SensorEdge"];
74  coolDz = nArgs["CoolDz"];
75  coolWidth = nArgs["CoolWidth"];
76  coolSide = nArgs["CoolSide"];
77  coolThick = nArgs["CoolThick"];
78  coolDist = nArgs["CoolDist"];
79  coolMat = sArgs["CoolMaterial"];
80  tubeMat = sArgs["CoolTubeMaterial"];
81 
82  LogDebug("PixelGeom") << "DDPixBarLayerAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace << "\n"
83  << "\tLadders " << number << "\tGeneral Material " << genMat << "\tLength " << layerDz
84  << "\tSensorEdge " << sensorEdge << "\tSpecification of Cooling Pieces:\n"
85  << "\tLength " << coolDz << " Width " << coolWidth << " Side " << coolSide
86  << " Thickness of Shell " << coolThick << " Radial distance " << coolDist << " Materials "
87  << coolMat << ", " << tubeMat;
88 
89  ladder = vsArgs["LadderName"];
90  ladderWidth = vArgs["LadderWidth"];
91  ladderThick = vArgs["LadderThick"];
92 
93  LogDebug("PixelGeom") << "DDPixBarLayerAlgo debug: Full Ladder " << ladder[0] << " width/thickness " << ladderWidth[0]
94  << ", " << ladderThick[0] << "\tHalf Ladder " << ladder[1] << " width/thickness "
95  << ladderWidth[1] << ", " << ladderThick[1];
96 }
97 
99  DDName mother = parent().name();
100  const string& idName = mother.name();
101 
102  double dphi = CLHEP::twopi / number;
103  double d2 = 0.5 * coolWidth;
104  double d1 = d2 - coolSide * sin(0.5 * dphi);
105  double x1 = (d1 + d2) / (2. * sin(0.5 * dphi));
106  double x2 = coolDist * sin(0.5 * dphi);
107  double rmin = (coolDist - 0.5 * (d1 + d2)) * cos(0.5 * dphi) - 0.5 * ladderThick[0];
108  double rmax = (coolDist + 0.5 * (d1 + d2)) * cos(0.5 * dphi) + 0.5 * ladderThick[0];
109  double rmxh = rmax - 0.5 * ladderThick[0] + ladderThick[1];
110  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Rmin/Rmax " << rmin << ", " << rmax << " d1/d2 " << d1 << ", " << d2
111  << " x1/x2 " << x1 << ", " << x2;
112 
113  double rtmi = rmin + 0.5 * ladderThick[0] - ladderThick[1];
114  double rtmx = sqrt(rmxh * rmxh + ladderWidth[1] * ladderWidth[1]);
115  DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace), 0.5 * layerDz, rtmi, rtmx, 0, CLHEP::twopi);
116  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << DDName(idName, idNameSpace) << " Tubs made of " << genMat
117  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rtmi << " Rout " << rtmx
118  << " ZHalf " << 0.5 * layerDz;
119  DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
120  DDMaterial matter(matname);
121  DDLogicalPart layer(solid.ddname(), matter, solid);
122 
123  double rr = 0.5 * (rmax + rmin);
124  double dr = 0.5 * (rmax - rmin);
125  double h1 = 0.5 * coolSide * cos(0.5 * dphi);
126  string name = idName + "CoolTube";
127  solid = DDSolidFactory::trap(DDName(name, idNameSpace), 0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0);
128  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << solid.name() << " Trap made of " << tubeMat
129  << " of dimensions " << 0.5 * coolDz << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, "
130  << h1 << ", " << d2 << ", " << d1 << ", 0";
131  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
132  DDLogicalPart coolTube(solid.ddname(), matter, solid);
133 
134  name = idName + "Coolant";
135  h1 -= coolThick;
136  d1 -= coolThick;
137  d2 -= coolThick;
138  solid = DDSolidFactory::trap(DDName(name, idNameSpace), 0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0);
139  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << solid.name() << " Trap made of " << coolMat
140  << " of dimensions " << 0.5 * coolDz << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, "
141  << h1 << ", " << d2 << ", " << d1 << ", 0";
142  matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
143  DDLogicalPart cool(solid.ddname(), matter, solid);
144  cpv.position(cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
145  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << cool.name() << " number 1 positioned in " << coolTube.name()
146  << " at (0,0,0) with no rotation";
147 
148  DDName ladderFull(DDSplit(ladder[0]).first, DDSplit(ladder[0]).second);
149  DDName ladderHalf(DDSplit(ladder[1]).first, DDSplit(ladder[1]).second);
150 
151  int nphi = number / 2, copy = 1, iup = -1;
152  double phi0 = 90 * CLHEP::deg;
153  for (int i = 0; i < number; i++) {
154  double phi = phi0 + i * dphi;
155  double phix, phiy, rrr, xx;
156  string rots;
157  DDTranslation tran;
158  DDRotation rot;
159  if (i == 0 || i == nphi) {
160  rrr = rr + dr + 0.5 * (ladderThick[1] - ladderThick[0]);
161  xx = (0.5 * ladderWidth[1] - sensorEdge) * sin(phi);
162  tran = DDTranslation(xx, rrr * sin(phi), 0);
163  rots = idName + to_string(copy);
164  phix = phi - 90 * CLHEP::deg;
165  phiy = 90 * CLHEP::deg + phix;
166  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
167  << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
168  << ", 0, 0";
169  rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
170  cpv.position(ladderHalf, layer, copy, tran, rot);
171  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderHalf << " number " << copy << " positioned in "
172  << layer.name() << " at " << tran << " with " << rot;
173  copy++;
174  iup = -1;
175  rrr = rr - dr - 0.5 * (ladderThick[1] - ladderThick[0]);
176  tran = DDTranslation(-xx, rrr * sin(phi), 0);
177  rots = idName + to_string(copy);
178  phix = phi + 90 * CLHEP::deg;
179  phiy = 90 * CLHEP::deg + phix;
180  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
181  << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
182  << ", 0, 0";
183  rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
184  cpv.position(ladderHalf, layer, copy, tran, rot);
185  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderHalf << " number " << copy << " positioned in "
186  << layer.name() << " at " << tran << " with " << rot;
187  copy++;
188  } else {
189  iup = -iup;
190  rrr = rr + iup * dr;
191  tran = DDTranslation(rrr * cos(phi), rrr * sin(phi), 0);
192  rots = idName + to_string(copy);
193  if (iup > 0)
194  phix = phi - 90 * CLHEP::deg;
195  else
196  phix = phi + 90 * CLHEP::deg;
197  phiy = phix + 90. * CLHEP::deg;
198  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
199  << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
200  << ", 0, 0";
201  rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
202  cpv.position(ladderFull, layer, copy, tran, rot);
203  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderFull << " number " << copy << " positioned in "
204  << layer.name() << " at " << tran << " with " << rot;
205  copy++;
206  }
207  rrr = coolDist * cos(0.5 * dphi);
208  tran = DDTranslation(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0);
209  rots = idName + to_string(i + 100);
210  phix = phi + 0.5 * dphi;
211  if (iup > 0)
212  phix += 180 * CLHEP::deg;
213  phiy = phix + 90. * CLHEP::deg;
214  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
215  << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
216  << ", 0, 0";
217  rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
218  cpv.position(coolTube, layer, i + 1, tran, rot);
219  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << coolTube.name() << " number " << i + 1 << " positioned in "
220  << layer.name() << " at " << tran << " with " << rot;
221  }
222 }
223 
224 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixBarLayerAlgo, "track:DDPixBarLayerAlgo");
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
DDPixBarLayerAlgo::coolDz
double coolDz
Definition: DDPixBarLayerAlgo.cc:46
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
DDSplit.h
DDPixBarLayerAlgo::genMat
string genMat
Definition: DDPixBarLayerAlgo.cc:42
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
DDPixBarLayerAlgo::number
int number
Definition: DDPixBarLayerAlgo.cc:43
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDPixBarLayerAlgo::idNameSpace
string idNameSpace
Definition: DDPixBarLayerAlgo.cc:41
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
nphi
const int nphi
Definition: CMTRawAnalyzer.h:424
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDPixBarLayerAlgo::ladderWidth
vector< double > ladderWidth
Definition: DDPixBarLayerAlgo.cc:54
DDPixBarLayerAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDPixBarLayerAlgo.cc:98
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDSolidFactory::tubs
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:653
DDSolid.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDPixBarLayerAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDPixBarLayerAlgo.cc:62
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDPixBarLayerAlgo::coolMat
string coolMat
Definition: DDPixBarLayerAlgo.cc:51
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
createfilelist.int
int
Definition: createfilelist.py:10
DDPixBarLayerAlgo::ladder
vector< string > ladder
Definition: DDPixBarLayerAlgo.cc:53
DDPixBarLayerAlgo::tubeMat
string tubeMat
Definition: DDPixBarLayerAlgo.cc:52
DDPixBarLayerAlgo
Definition: DDPixBarLayerAlgo.cc:26
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDLogicalPart.h
DDPixBarLayerAlgo::~DDPixBarLayerAlgo
~DDPixBarLayerAlgo() override
Definition: DDPixBarLayerAlgo.cc:60
DDPixBarLayerAlgo::coolDist
double coolDist
Definition: DDPixBarLayerAlgo.cc:50
DDPixBarLayerAlgo::coolWidth
double coolWidth
Definition: DDPixBarLayerAlgo.cc:47
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDPixBarLayerAlgo::coolThick
double coolThick
Definition: DDPixBarLayerAlgo.cc:49
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDPixBarLayerAlgo::sensorEdge
double sensorEdge
Definition: DDPixBarLayerAlgo.cc:45
DDPixBarLayerAlgo::DDPixBarLayerAlgo
DDPixBarLayerAlgo()
Definition: DDPixBarLayerAlgo.cc:58
DDPixBarLayerAlgo::ladderThick
vector< double > ladderThick
Definition: DDPixBarLayerAlgo.cc:55
DDAlgorithmFactory.h
DDSolidFactory::trap
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:595
DDPixBarLayerAlgo::coolSide
double coolSide
Definition: DDPixBarLayerAlgo.cc:48
class-composition.parent
parent
Definition: class-composition.py:88
DDPixBarLayerAlgo::layerDz
double layerDz
Definition: DDPixBarLayerAlgo.cc:44
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:76
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18