CMS 3D CMS Logo

Functions
DDPixBarLayerAlgo.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 (Detector &description, cms::DDParsingContext &ctxt, xml_h e)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_track_DDPixBarLayerAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 11 of file DDPixBarLayerAlgo.cc.

References cms::DDNamespace::addSolid(), cms::DDNamespace::addVolume(), writedatasetfile::args, angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), d1, edmLumisInFiles::description, l1ctLayer1_cff::dr, MillePedeFileConverter_cfg::e, mps_fire::i, versionedElectronIDProducer_cfi::idName, PVValHelper::ladder, phase1PixelTopology::layer, cms::makeRotation3D(), cms::DDNamespace::material(), Skims_PA_cff::name, cms::DDNamespace::name(), nphi, contentValuesFiles::number, cms::DDNamespace::objName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), MetAnalyzer::pv(), makeMuonMisalignmentScenario::rot, findQualityFiles::rr, funct::sin(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), cms::DDNamespace::volume(), testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and geometryCSVtoXML::xx.

11  {
13  cms::DDNamespace ns(ctxt, e, true);
14  DDAlgoArguments args(ctxt, e);
15  string parentName = args.parentName();
16 
17  edm::LogVerbatim("PixelGeom") << "+++ Parsing arguments for Algorithm:" << args.name << " rParent:" << parentName;
18  string genMat = args.value<string>("GeneralMaterial");
19  int number = args.value<int>("Ladders");
20  double layerDz = args.value<double>("LayerDz");
21  double sensorEdge = args.value<double>("SensorEdge");
22  double coolDz = args.value<double>("CoolDz");
23  double coolWidth = args.value<double>("CoolWidth");
24  double coolSide = args.value<double>("CoolSide");
25  double coolThick = args.value<double>("CoolThick");
26  double coolDist = args.value<double>("CoolDist");
27  string coolMat = args.value<string>("CoolMaterial");
28  string tubeMat = args.value<string>("CoolTubeMaterial");
29  edm::LogVerbatim("PixelGeom") << "Parent " << parentName << " NameSpace " << ns.name() << "\n"
30  << "\tLadders " << number << "\tGeneral Material " << genMat << "\tLength " << layerDz
31  << "\tSensorEdge " << sensorEdge << "\tSpecification of Cooling Pieces:\n"
32  << "\tLength " << coolDz << " Width " << coolWidth << " Side " << coolSide
33  << " Thickness of Shell " << coolThick << " Radial distance " << coolDist
34  << " Materials " << coolMat << ", " << tubeMat;
35  vector<string> ladder = args.value<vector<string> >("LadderName");
36  vector<double> ladderWidth = args.value<vector<double> >("LadderWidth");
37  vector<double> ladderThick = args.value<vector<double> >("LadderThick");
38  edm::LogVerbatim("PixelGeom") << "Full Ladder " << ladder[0] << " width/thickness " << ladderWidth[0] << ", "
39  << ladderThick[0] << "\tHalf Ladder " << ladder[1] << " width/thickness "
40  << ladderWidth[1] << ", " << ladderThick[1];
41 
42  const std::string idName = ns.objName(parentName);
43  double dphi = 2_pi / number;
44  double d2 = 0.5 * coolWidth;
45  double d1 = d2 - coolSide * sin(0.5 * dphi);
46  double x1 = (d1 + d2) / (2. * sin(0.5 * dphi));
47  double x2 = coolDist * sin(0.5 * dphi);
48  double rmin = (coolDist - 0.5 * (d1 + d2)) * cos(0.5 * dphi) - 0.5 * ladderThick[0];
49  double rmax = (coolDist + 0.5 * (d1 + d2)) * cos(0.5 * dphi) + 0.5 * ladderThick[0];
50  double rmxh = rmax - 0.5 * ladderThick[0] + ladderThick[1];
51  edm::LogVerbatim("PixelGeom") << "Rmin/Rmax " << rmin << ", " << rmax << " d1/d2 " << d1 << ", " << d2 << " x1/x2 "
52  << x1 << ", " << x2;
53 
54  double rtmi = rmin + 0.5 * ladderThick[0] - ladderThick[1];
55  double rtmx = sqrt(rmxh * rmxh + ladderWidth[1] * ladderWidth[1]);
56  Solid solid = ns.addSolid(ns.prepend(idName), Tube(rtmi, rtmx, 0.5 * layerDz, 0, 2_pi));
57  edm::LogVerbatim("PixelGeom") << "IDname " << solid.name() << " Tubs made of " << genMat << " from 0 to "
58  << convertRadToDeg(2_pi) << " with Rin " << rtmi << " Rout " << rtmx << " ZHalf "
59  << 0.5 * layerDz;
60 
61  Volume layer = ns.addVolume(Volume(solid.name(), solid, ns.material(genMat)));
62  double rr = 0.5 * (rmax + rmin);
63  double dr = 0.5 * (rmax - rmin);
64  double h1 = 0.5 * coolSide * cos(0.5 * dphi);
65  std::string name = idName + "CoolTube";
66  solid = ns.addSolid(ns.prepend(name), Trap(0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
67  edm::LogVerbatim("PixelGeom") << "Solid " << solid.name() << " Trap made of " << tubeMat << " of dimensions "
68  << 0.5 * coolDz << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, " << h1 << ", "
69  << d2 << ", " << d1 << ", 0";
70 
71  Volume coolTube = ns.addVolume(Volume(solid.name(), solid, description.material(tubeMat)));
72  h1 -= coolThick;
73  d1 -= coolThick;
74  d2 -= coolThick;
75  name = idName + "Coolant";
76  solid = ns.addSolid(ns.prepend(name), Trap(0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
77  edm::LogVerbatim("PixelGeom") << "Solid " << solid.name() << " Trap made of " << coolMat << " of dimensions "
78  << 0.5 * coolDz << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, " << h1 << ", "
79  << d2 << ", " << d1 << ", 0";
80 
81  Volume cool = ns.addVolume(Volume(solid.name(), solid, description.material(coolMat)));
82  pv = coolTube.placeVolume(cool, 1);
83  edm::LogVerbatim("PixelGeom") << "Cool " << cool.name() << " number 1 positioned in " << coolTube.name()
84  << " at (0,0,0) with no rotation";
85 
86  string ladderFull = ladder[0];
87  string ladderHalf = ladder[1];
88  int nphi = number / 2, copy = 1, iup = -1;
89  double phi0 = 90_deg;
90  Volume ladderHalfVol = ns.volume(ladderHalf);
91  Volume ladderFullVol = ns.volume(ladderFull);
92 
93  for (int i = 0; i < number; i++) {
94  double phi = phi0 + i * dphi;
95  double phix, phiy, rrr, xx;
96  std::string rots;
97  Position tran;
98  Rotation3D rot;
99  if (i == 0 || i == nphi) {
100  rrr = rr + dr + 0.5 * (ladderThick[1] - ladderThick[0]);
101  xx = (0.5 * ladderWidth[1] - sensorEdge) * sin(phi);
102  tran = Position(xx, rrr * sin(phi), 0);
103  rots = idName + std::to_string(copy);
104  phix = phi - 90_deg;
105  phiy = 90_deg + phix;
106  edm::LogVerbatim("PixelGeom") << "Creating a new "
107  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
108  << convertRadToDeg(phiy) << ", 0, 0";
109  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
110 
111  //cpv.position(ladderHalf, layer, copy, tran, rot);
112  pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot, tran));
113  if (!pv.isValid()) {
114  }
115  edm::LogVerbatim("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name() << " number " << copy
116  << " positioned in " << layer.name() << " at " << tran << " with " << rot;
117  copy++;
118  iup = -1;
119  rrr = rr - dr - 0.5 * (ladderThick[1] - ladderThick[0]);
120  tran = Position(-xx, rrr * sin(phi), 0);
121  rots = idName + std::to_string(copy);
122  phix = phi + 90_deg;
123  phiy = 90_deg + phix;
124  edm::LogVerbatim("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " << convertRadToDeg(phix)
125  << ", 90.," << convertRadToDeg(phiy) << ", 0, 0";
126  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
127  //cpv.position(ladderHalf, layer, copy, tran, rot);
128  pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot, tran));
129  if (!pv.isValid()) {
130  }
131  edm::LogVerbatim("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name() << " number " << copy
132  << " positioned in " << layer.name() << " at " << tran << " with " << rot;
133  copy++;
134  } else {
135  iup = -iup;
136  rrr = rr + iup * dr;
137  tran = Position(rrr * cos(phi), rrr * sin(phi), 0);
138  rots = idName + std::to_string(copy);
139  if (iup > 0)
140  phix = phi - 90_deg;
141  else
142  phix = phi + 90_deg;
143  phiy = phix + 90._deg;
144  edm::LogVerbatim("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
145  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
146  << convertRadToDeg(phiy) << ", 0, 0";
147  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
148 
149  //cpv.position(ladderFull, layer, copy, tran, rot);
150  pv = layer.placeVolume(ladderFullVol, copy, Transform3D(rot, tran));
151  if (!pv.isValid()) {
152  }
153  edm::LogVerbatim("PixelGeom") << "test: " << ladderFullVol.name() << " number " << copy << " positioned in "
154  << layer.name() << " at " << tran << " with " << rot;
155  copy++;
156  }
157  rrr = coolDist * cos(0.5 * dphi);
158  tran = Position(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0);
159  rots = idName + std::to_string(i + 100);
160  phix = phi + 0.5 * dphi;
161  if (iup > 0)
162  phix += 180_deg;
163  phiy = phix + 90._deg;
164  edm::LogVerbatim("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " << convertRadToDeg(phix)
165  << ", 90.," << convertRadToDeg(phiy) << ", 0, 0";
166 
167  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
168  pv = layer.placeVolume(coolTube, i + 1, Transform3D(rot, tran));
169  if (!pv.isValid()) {
170  }
171  edm::LogVerbatim("PixelGeom") << "coolTube: " << coolTube.name() << " number " << i + 1 << " positioned in "
172  << layer.name() << " at " << tran << " with " << rot;
173  }
174  edm::LogVerbatim("PixelGeom") << "Layer: " << layer.name();
175  return 1;
176 }
Log< level::Info, true > LogVerbatim
const int nphi
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
T sqrt(T t)
Definition: SSEVec.h:19
dd4hep::PlacedVolume PlacedVolume
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def pv(vc)
Definition: MetAnalyzer.py:7
dd4hep::Volume Volume
static constexpr float d1

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_track_DDPixBarLayerAlgo   
)

Definition at line 179 of file DDPixBarLayerAlgo.cc.