CMS 3D CMS Logo

DDPixBarLayerAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace std;
7 using namespace dd4hep;
8 using namespace cms;
9 using namespace cms_units::operators;
10 
11 static long algorithm(Detector& description, cms::DDParsingContext& ctxt, xml_h e) {
13  cms::DDNamespace ns(ctxt, e, true);
14  DDAlgoArguments args(ctxt, e);
15  string parentName = args.parentName();
16 
17  LogDebug("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  LogDebug("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 << " Materials "
34  << 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  LogDebug("PixelGeom") << "Full Ladder " << ladder[0] << " width/thickness " << ladderWidth[0] << ", "
39  << ladderThick[0] << "\tHalf Ladder " << ladder[1] << " width/thickness " << ladderWidth[1]
40  << ", " << 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  LogDebug("PixelGeom") << "Rmin/Rmax " << rmin << ", " << rmax << " d1/d2 " << d1 << ", " << d2 << " x1/x2 " << x1
52  << ", " << 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(idName, Tube(rtmi, rtmx, 0.5 * layerDz, 0, 2_pi));
57  LogDebug("PixelGeom") << "IDname " << idName << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
58  << " with Rin " << rtmi << " Rout " << rtmx << " ZHalf " << 0.5 * layerDz;
59 
60  Volume layer = ns.addVolume(Volume(idName, solid, ns.material(genMat)));
61  double rr = 0.5 * (rmax + rmin);
62  double dr = 0.5 * (rmax - rmin);
63  double h1 = 0.5 * coolSide * cos(0.5 * dphi);
64  std::string name = idName + "CoolTube";
65  solid = ns.addSolid(name, Trap(0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
66  LogDebug("PixelGeom") << "Solid " << solid.name() << " Trap made of " << tubeMat << " of dimensions " << 0.5 * coolDz
67  << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " << d1
68  << ", 0";
69 
70  Volume coolTube = ns.addVolume(Volume(name, solid, description.material(tubeMat)));
71  h1 -= coolThick;
72  d1 -= coolThick;
73  d2 -= coolThick;
74  name = idName + "Coolant";
75  solid = ns.addSolid(name, Trap(0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
76  LogDebug("PixelGeom") << "Solid " << solid.name() << " Trap made of " << coolMat << " of dimensions " << 0.5 * coolDz
77  << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " << d1
78  << ", 0";
79 
80  Volume cool = ns.addVolume(Volume(name, solid, description.material(coolMat)));
81  pv = coolTube.placeVolume(cool, 1);
82  LogDebug("PixelGeom") << "Cool " << cool.name() << " number 1 positioned in " << coolTube.name()
83  << " at (0,0,0) with no rotation";
84 
85  string ladderFull = ladder[0];
86  string ladderHalf = ladder[1];
87  int nphi = number / 2, copy = 1, iup = -1;
88  double phi0 = 90_deg;
89  Volume ladderHalfVol = ns.volume(ladderHalf);
90  Volume ladderFullVol = ns.volume(ladderFull);
91 
92  for (int i = 0; i < number; i++) {
93  double phi = phi0 + i * dphi;
94  double phix, phiy, rrr, xx;
95  std::string rots;
96  Position tran;
97  Rotation3D rot;
98  if (i == 0 || i == nphi) {
99  rrr = rr + dr + 0.5 * (ladderThick[1] - ladderThick[0]);
100  xx = (0.5 * ladderWidth[1] - sensorEdge) * sin(phi);
101  tran = Position(xx, rrr * sin(phi), 0);
102  rots = idName + std::to_string(copy);
103  phix = phi - 90_deg;
104  phiy = 90_deg + phix;
105  LogDebug("PixelGeom") << "Creating a new "
106  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
107  << convertRadToDeg(phiy) << ", 0, 0";
108  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
109 
110  //cpv.position(ladderHalf, layer, copy, tran, rot);
111  pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot, tran));
112  if (!pv.isValid()) {
113  }
114  LogDebug("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name() << " number " << copy << " positioned in "
115  << layer.name() << " at " << tran << " with " << rot;
116  copy++;
117  iup = -1;
118  rrr = rr - dr - 0.5 * (ladderThick[1] - ladderThick[0]);
119  tran = Position(-xx, rrr * sin(phi), 0);
120  rots = idName + std::to_string(copy);
121  phix = phi + 90_deg;
122  phiy = 90_deg + phix;
123  LogDebug("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
124  << convertRadToDeg(phiy) << ", 0, 0";
125  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
126  //cpv.position(ladderHalf, layer, copy, tran, rot);
127  pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot, tran));
128  if (!pv.isValid()) {
129  }
130  LogDebug("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name() << " number " << copy << " positioned in "
131  << layer.name() << " at " << tran << " with " << rot;
132  copy++;
133  } else {
134  iup = -iup;
135  rrr = rr + iup * dr;
136  tran = Position(rrr * cos(phi), rrr * sin(phi), 0);
137  rots = idName + std::to_string(copy);
138  if (iup > 0)
139  phix = phi - 90_deg;
140  else
141  phix = phi + 90_deg;
142  phiy = phix + 90._deg;
143  LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
144  << "rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
145  << convertRadToDeg(phiy) << ", 0, 0";
146  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
147 
148  //cpv.position(ladderFull, layer, copy, tran, rot);
149  pv = layer.placeVolume(ladderFullVol, copy, Transform3D(rot, tran));
150  if (!pv.isValid()) {
151  }
152  LogDebug("PixelGeom") << "test: " << ladderFullVol.name() << " number " << copy << " positioned in "
153  << layer.name() << " at " << tran << " with " << rot;
154  copy++;
155  }
156  rrr = coolDist * cos(0.5 * dphi);
157  tran = Position(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0);
158  rots = idName + std::to_string(i + 100);
159  phix = phi + 0.5 * dphi;
160  if (iup > 0)
161  phix += 180_deg;
162  phiy = phix + 90._deg;
163  LogDebug("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " << convertRadToDeg(phix) << ", 90.,"
164  << convertRadToDeg(phiy) << ", 0, 0";
165 
166  rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.);
167  pv = layer.placeVolume(coolTube, i + 1, Transform3D(rot, tran));
168  if (!pv.isValid()) {
169  }
170  LogDebug("PixelGeom") << "coolTube: " << coolTube.name() << " number " << i + 1 << " positioned in " << layer.name()
171  << " at " << tran << " with " << rot;
172  }
173  LogDebug("PixelGeom") << "Layer: " << layer.name();
174  return 1;
175 }
176 
177 // first argument is the type from the xml file
178 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixBarLayerAlgo, 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
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
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
edmLumisInFiles.description
description
Definition: edmLumisInFiles.py:11
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
cms::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition: DDFilteredView.h:48
cms::DDNamespace::objName
static std::string objName(const std::string &)
Definition: DDNamespace.cc:90
algorithm
static long algorithm(Detector &description, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDPixBarLayerAlgo.cc:11
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
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
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
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
align::Detector
Definition: StructureType.h:86
std
Definition: JetResolutionObject.h:76
dd4hep
Definition: DDPlugins.h:8
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
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37