CMS 3D CMS Logo

Functions
DDPixBarLayerUpgradeAlgo.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DataFormats/Math/interface/CMSUnits.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_track_DDPixBarLayerUpgradeAlgo)
 

Function Documentation

◆ algorithm()

static long algorithm ( dd4hep::Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e 
)
static

Definition at line 8 of file DDPixBarLayerUpgradeAlgo.cc.

References cms::DDNamespace::addSolid(), cms::DDNamespace::addVolume(), writedatasetfile::args, angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), flavorHistoryFilter_cfi::dr, MillePedeFileConverter_cfg::e, mps_fire::i, PVValHelper::ladder, phase1PixelTopology::layer, cms::makeRotation3D(), cms::DDNamespace::material(), Skims_PA_cff::name, contentValuesFiles::number, cms::DDNamespace::objName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), makeMuonMisalignmentScenario::rot, cms::s_executed, funct::sin(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), cms::DDNamespace::volume(), and testProducerWithPsetDescEmpty_cfi::x2.

8  {
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 }
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::string to_string(const V &value)
Definition: OMSAccess.h:71
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
constexpr std::array< uint8_t, layerIndexSize > layer
static constexpr long s_executed
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
dd4hep::Volume Volume

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_track_DDPixBarLayerUpgradeAlgo   
)

Definition at line 207 of file DDPixBarLayerUpgradeAlgo.cc.