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>("CoolTubeMaterialHalf");
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  edm::LogVerbatim("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  edm::LogVerbatim("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(ns.prepend(name), dd4hep::Tube(rtmi, rtmx, 0.5 * layerDz, 0., 2._pi));
56 
57  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.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(ns.prepend(name + "CoolTube"), dd4hep::Tube(0., coolRadius, 0.5 * coolDz, 0., 2_pi));
65 
66  edm::LogVerbatim("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(ns.prepend(name + "CoolTubeHalf"), dd4hep::Tube(0., coolRadius, 0.5 * coolDz, 0, 1_pi));
74 
75  edm::LogVerbatim("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(ns.prepend(name + "Coolant"), dd4hep::Tube(0., coolRadius - coolThick, 0.5 * coolDz, 0., 2_pi));
85 
86  edm::LogVerbatim("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  edm::LogVerbatim("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 =
100  ns.addSolid(ns.prepend(name + "CoolantHalf"), dd4hep::Tube(0., coolRadius - coolThick, 0.5 * coolDz, 0., 1._pi));
101 
102  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
103  << " from 0 to " << convertRadToDeg(2._pi) << " with Rout " << coolRadius - coolThick
104  << " ZHalf " << 0.5 * coolDz;
105 
106  dd4hep::Volume coolHalf = ns.addVolume(dd4hep::Volume(solid.name(), solid, ns.material(coolMatHalf)));
107 
108  coolTubeHalf.placeVolume(coolHalf, 1, dd4hep::Transform3D(dd4hep::Rotation3D(), dd4hep::Position(0., 0., 0.)));
109 
110  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
111  << coolTube.name() << " at (0,0,0) with no rotation";
112  int copy = 1, iup = (-1) * outerFirst;
113  int copyoffset = number + 2;
114 
115  for (int i = 1; i < number + 1; i++) {
116  double phi = i * dphi + 90._deg - 0.5 * dphi + phiFineTune; //to start with the interface ladder
117  double phix, phiy, rrr, rrroffset;
118  std::string rots;
119 
120  auto tran = dd4hep::Position();
121  auto rot = dd4hep::Rotation3D();
122 
123  iup = -iup;
124 
125  double dr;
126 
127  if ((i == 1) || (i == number / 2 + 1)) {
128  dr = coolRadius + 0.5 * ladderThick + ladderOffset; //interface ladder offset
129  } else {
130  dr = coolRadius + 0.5 * ladderThick;
131  }
132 
133  if (i % 2 == 1) {
134  rrr = coolDist * cos(0.5 * dphi) + iup * dr + rOuterFineTune;
135  } else {
136  rrr = coolDist * cos(0.5 * dphi) + iup * dr + rInnerFineTune;
137  }
138 
139  tran = dd4hep::Position(rrr * cos(phi), rrr * sin(phi), 0);
140  rots = name + std::to_string(copy);
141 
142  if (iup > 0) {
143  phix = phi - 90._deg;
144  } else {
145  phix = phi + 90._deg;
146  }
147 
148  phiy = phix + 90._deg;
149 
150  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
151  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
152  << convertRadToDeg(phiy) << ", 0, 0";
153 
154  rot = cms::makeRotation3D(90._deg, phix, 90._deg, phiy, 0., 0.);
155 
156  // FixMe : Would need ns.vecStr
157  layer.placeVolume(ns.volume(ladder), copy, dd4hep::Transform3D(rot, tran));
158 
159  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladder << " number " << copy
160  << " positioned in " << layer.name() << " at " << tran << " with " << rot;
161 
162  copy++;
163 
164  rrr = coolDist * cos(0.5 * dphi) + coolRadius / 2.;
165 
166  rots = name + std::to_string(i + 100);
167  phix = phi + 90._deg;
168 
169  if (iup < 0)
170  phix += dphi;
171 
172  phiy = phix + 90._deg;
173 
174  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
175  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
176  << convertRadToDeg(phiy) << ", 0, 0";
177 
178  tran = dd4hep::Position(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0.);
179 
180  rot = cms::makeRotation3D(90._deg, phix, 90._deg, phiy, 0., 0.);
181 
182  layer.placeVolume(coolTubeHalf, i + 1, dd4hep::Transform3D(rot, tran));
183 
184  if ((i == 1) || (i == number / 2 + 1)) {
185  rrroffset = coolDist * cos(0.5 * dphi) + iup * ladderOffset + rOuterFineTune;
186  tran = dd4hep::Position(
187  rrroffset * cos(phi) - cool1Offset * sin(phi), rrroffset * sin(phi) + cool1Offset * cos(phi), 0.);
188 
189  layer.placeVolume(coolTube, copyoffset, dd4hep::Transform3D(dd4hep::Rotation3D(), tran));
190  ;
191 
192  copyoffset++;
193  tran = dd4hep::Position(
194  rrroffset * cos(phi) - cool2Offset * sin(phi), rrroffset * sin(phi) + cool2Offset * cos(phi), 0.);
195 
196  layer.placeVolume(coolTube, copyoffset, dd4hep::Transform3D(dd4hep::Rotation3D(), tran));
197  copyoffset++;
198  }
199 
200  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name() << " number " << i + 1
201  << " positioned in " << layer.name() << " at " << tran << " with " << rot;
202  }
203 
204  return cms::s_executed;
205 }
206 
207 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:154
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
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:128
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
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:98
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
DDPlugins.h
cms::DDNamespace::addVolume
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Definition: DDNamespace.cc:209
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:295
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
PVValHelper::ladder
Definition: PVValidationHelpers.h:73
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:264
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37