CMS 3D CMS Logo

DDPixBarLayerUpgradeAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace cms_units::operators;
7 
8 static long algorithm(dd4hep::Detector&, cms::DDParsingContext& ctxt, xml_h e) {
9  cms::DDNamespace ns(ctxt, e, true);
11  std::string parentName = args.parentName();
12 
13  std::string genMat = args.value<std::string>("GeneralMaterial");
14  int number = args.value<int>("Ladders");
15  double layerDz = args.value<double>("LayerDz");
16  double coolDz = args.value<double>("CoolDz");
17  double coolThick = args.value<double>("CoolThick");
18  double coolRadius = args.value<double>("CoolRadius");
19  double coolDist = args.value<double>("CoolDist");
20  double cool1Offset = args.value<double>("Cool1Offset");
21  double cool2Offset = args.value<double>("Cool2Offset");
22  std::string coolMat = args.value<std::string>("CoolMaterial");
23  std::string tubeMat = args.value<std::string>("CoolTubeMaterial");
24  std::string coolMatHalf = args.value<std::string>("CoolMaterialHalf");
25  std::string tubeMatHalf = args.value<std::string>("CoolTubeMaterial");
26  double phiFineTune = args.value<double>("PitchFineTune");
27  double rOuterFineTune = args.value<double>("OuterOffsetFineTune");
28  double rInnerFineTune = args.value<double>("InnerOffsetFineTune");
29 
30  // FixMe : Would need ns.vecStr
31  std::string ladder = args.value<std::string>("LadderName");
32 
33  double ladderWidth = args.value<double>("LadderWidth");
34  double ladderThick = args.value<double>("LadderThick");
35  double ladderOffset = args.value<double>("LadderOffset");
36  int outerFirst = args.value<int>("OuterFirst");
37 
38  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Parent " << parentName << " NameSpace "
39  << ns.objName(parentName) << "\n\tLadders " << number << "\tGeneral Material " << genMat
40  << "\tLength " << layerDz << "\tSpecification of Cooling Pieces:\n"
41  << "\tLength " << coolDz << "\tThickness of Shell " << coolThick << "\tRadial distance "
42  << coolDist << "\tMaterials " << coolMat << ", " << tubeMat << std::endl;
43 
44  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Full Ladder " << ladder << " width/thickness "
45  << ladderWidth << ", " << ladderThick;
46 
47  double dphi = 2_pi / (double)number;
48  double x2 = coolDist * sin(0.5 * dphi);
49  double rtmi = coolDist * cos(0.5 * dphi) - (coolRadius + ladderThick) + rInnerFineTune;
50  double rmxh = coolDist * cos(0.5 * dphi) + (coolRadius + ladderThick + ladderOffset) + rOuterFineTune;
51  double rtmx = sqrt(rmxh * rmxh + ladderWidth * ladderWidth / 4.);
52 
53  std::string name = ns.objName(parentName);
54 
55  dd4hep::Solid solid = ns.addSolid(name, dd4hep::Tube(rtmi, rtmx, 0.5 * layerDz, 0., 2._pi));
56 
57  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ns.name() << " Tubs made of " << genMat
58  << " from 0. to " << convertRadToDeg(2_pi) << " with Rin " << rtmi << " Rout " << rtmx
59  << " ZHalf " << 0.5 * layerDz;
60 
61  dd4hep::Volume layer = ns.addVolume(dd4hep::Volume(solid.name(), solid, ns.material(genMat)));
62 
63  // Full Tubes
64  solid = ns.addSolid(name + "CoolTube", dd4hep::Tube(0., coolRadius, 0.5 * coolDz, 0., 2_pi));
65 
66  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMat
67  << " from 0 to " << convertRadToDeg(2_pi) << " with Rout " << coolRadius << " ZHalf "
68  << 0.5 * coolDz;
69 
70  dd4hep::Volume coolTube = ns.addVolume(dd4hep::Volume(solid.name(), solid, ns.material(tubeMat)));
71 
72  // Half Tubes
73  solid = ns.addSolid(name + "CoolTubeHalf", dd4hep::Tube(0., coolRadius, 0.5 * coolDz, 0, 1_pi));
74 
75  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
76  << " from 0 to " << convertRadToDeg(2_pi) << " with Rout " << coolRadius << " ZHalf "
77  << 0.5 * coolDz;
78 
79  dd4hep::Volume coolTubeHalf = ns.addVolume(dd4hep::Volume(solid.name(), solid, ns.material(tubeMatHalf)));
80 
81  // Full Coolant
82  name = ns.objName(parentName);
83 
84  solid = ns.addSolid(name + "Coolant", dd4hep::Tube(0., coolRadius - coolThick, 0.5 * coolDz, 0., 2_pi));
85 
86  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMat
87  << " from 0 to " << convertRadToDeg(2._pi) << " with Rout " << coolRadius - coolThick
88  << " ZHalf " << 0.5 * coolDz;
89 
90  dd4hep::Volume cool = ns.addVolume(dd4hep::Volume(solid.name(), solid, ns.material(coolMat)));
91 
92  coolTube.placeVolume(cool, 1, dd4hep::Transform3D(dd4hep::Rotation3D(), dd4hep::Position(0., 0., 0.)));
93 
94  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
95  << coolTube.name() << " at (0,0,0) with no rotation";
96 
97  // Half Coolant
98 
99  solid = ns.addSolid(name + "CoolantHalf", dd4hep::Tube(0., coolRadius - coolThick, 0.5 * coolDz, 0., 1._pi));
100 
101  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
102  << " from 0 to " << convertRadToDeg(2._pi) << " with Rout " << coolRadius - coolThick
103  << " ZHalf " << 0.5 * coolDz;
104 
105  dd4hep::Volume coolHalf = ns.addVolume(dd4hep::Volume(solid.name(), solid, ns.material(coolMatHalf)));
106 
107  coolTubeHalf.placeVolume(coolHalf, 1, dd4hep::Transform3D(dd4hep::Rotation3D(), dd4hep::Position(0., 0., 0.)));
108 
109  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
110  << coolTube.name() << " at (0,0,0) with no rotation";
111  int copy = 1, iup = (-1) * outerFirst;
112  int copyoffset = number + 2;
113 
114  for (int i = 1; i < number + 1; i++) {
115  double phi = i * dphi + 90._deg - 0.5 * dphi + phiFineTune; //to start with the interface ladder
116  double phix, phiy, rrr, rrroffset;
117  std::string rots;
118 
119  auto tran = dd4hep::Position();
120  auto rot = dd4hep::Rotation3D();
121 
122  iup = -iup;
123 
124  double dr;
125 
126  if ((i == 1) || (i == number / 2 + 1)) {
127  dr = coolRadius + 0.5 * ladderThick + ladderOffset; //interface ladder offset
128  } else {
129  dr = coolRadius + 0.5 * ladderThick;
130  }
131 
132  if (i % 2 == 1) {
133  rrr = coolDist * cos(0.5 * dphi) + iup * dr + rOuterFineTune;
134  } else {
135  rrr = coolDist * cos(0.5 * dphi) + iup * dr + rInnerFineTune;
136  }
137 
138  tran = dd4hep::Position(rrr * cos(phi), rrr * sin(phi), 0);
139  rots = name + std::to_string(copy);
140 
141  if (iup > 0) {
142  phix = phi - 90._deg;
143  } else {
144  phix = phi + 90._deg;
145  }
146 
147  phiy = phix + 90._deg;
148 
149  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
150  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
151  << convertRadToDeg(phiy) << ", 0, 0";
152 
153  rot = cms::makeRotation3D(90._deg, phix, 90._deg, phiy, 0., 0.);
154 
155  // FixMe : Would need ns.vecStr
156  layer.placeVolume(ns.volume(ladder), copy, dd4hep::Transform3D(rot, tran));
157 
158  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladder << " number " << copy << " positioned in "
159  << layer.name() << " at " << tran << " with " << rot;
160 
161  copy++;
162 
163  rrr = coolDist * cos(0.5 * dphi) + coolRadius / 2.;
164 
165  rots = name + std::to_string(i + 100);
166  phix = phi + 90._deg;
167 
168  if (iup < 0)
169  phix += dphi;
170 
171  phiy = phix + 90._deg;
172 
173  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
174  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
175  << convertRadToDeg(phiy) << ", 0, 0";
176 
177  tran = dd4hep::Position(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0.);
178 
179  rot = cms::makeRotation3D(90._deg, phix, 90._deg, phiy, 0., 0.);
180 
181  layer.placeVolume(coolTubeHalf, i + 1, dd4hep::Transform3D(rot, tran));
182 
183  if ((i == 1) || (i == number / 2 + 1)) {
184  rrroffset = coolDist * cos(0.5 * dphi) + iup * ladderOffset + rOuterFineTune;
185  tran = dd4hep::Position(
186  rrroffset * cos(phi) - cool1Offset * sin(phi), rrroffset * sin(phi) + cool1Offset * cos(phi), 0.);
187 
188  layer.placeVolume(coolTube, copyoffset, dd4hep::Transform3D(dd4hep::Rotation3D(), tran));
189  ;
190 
191  copyoffset++;
192  tran = dd4hep::Position(
193  rrroffset * cos(phi) - cool2Offset * sin(phi), rrroffset * sin(phi) + cool2Offset * cos(phi), 0.);
194 
195  layer.placeVolume(coolTube, copyoffset, dd4hep::Transform3D(dd4hep::Rotation3D(), tran));
196  copyoffset++;
197  }
198 
199  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name() << " number " << i + 1
200  << " positioned in " << layer.name() << " at " << tran << " with " << rot;
201  }
202 
203  return cms::s_executed;
204 }
205 
206 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixBarLayerUpgradeAlgo, algorithm);
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
cms_units::operators
Definition: CMSUnits.h:13
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:116
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:13
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDPixBarLayerUpgradeAlgo.cc:8
cms::DDNamespace::objName
static std::string objName(const std::string &)
Definition: DDNamespace.cc:90
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
DDPlugins.h
cms::DDNamespace::addVolume
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
Definition: DDNamespace.cc:165
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:236
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:86
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
CMSUnits.h
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37