CMS 3D CMS Logo

Functions
DDHCalTBCableAlgo.cc File Reference
#include "DataFormats/Math/interface/angle_units.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/DDutils.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DD4hep/DetFactoryHelper.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_hcal_DDHCalTBCableAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 10 of file DDHCalTBCableAlgo.cc.

References simBeamSpotPI::alpha, writedatasetfile::args, cms::convert2mm(), angle_units::operators::convertRadToDeg(), funct::cos(), PVValHelper::dy, PVValHelper::dz, MillePedeFileConverter_cfg::e, mps_fire::i, versionedElectronIDProducer_cfi::idName, cuy::ii, cms::makeRotation3D(), cms::DDNamespace::material(), g4SimHits_cfi::Material, Skims_PA_cff::name, cms::DDNamespace::name(), class-composition::parent, HGCalGeometryMode::Polyhedra, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), diffTwoXMLs::r2, makeMuonMisalignmentScenario::rot, idealTransformation::rotation, cms::s_executed, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), theta(), and cms::DDNamespace::volume().

10  {
11  cms::DDNamespace ns(ctxt, e, true);
13 
14  // Header section
15  // <---- Zout ---->
16  // | **************** |
17  // | * * Wstep
18  // W * ***** |
19  // | * *
20  // | ********************
21  // <------ Zin ------->
22  // <------ Zout ------> Zout = Full sector Z at position
23  // | ******************** Zin = Full sector Z at position
24  // | * *
25  // W * * Angle = Theta sector
26  // | * * )
27  // | ****************--------
28  // <------ Zin ------->
29  // <------ Zout ------> Zin(i)=Zout(i-1)
30  // | ******************** Zout(i)=Zin(i)+W(i)/tan(Theta(i))
31  // | * *
32  // W * * Theta
33  // | * *
34  // | ****************--------
35  // <--- Zin ------>
36  std::string genMat = args.value<std::string>("MaterialName"); //General material
37  int nsectors = args.value<int>("NSector"); //Number of potenital straight edges
38  int nsectortot = args.value<int>("NSectorTot"); //Number of straight edges (actual)
39  int nhalf = args.value<int>("NHalf"); //Number of half modules
40  double rin = args.value<double>("RIn"); //(see Figure of hcalbarrel)
41  std::vector<double> theta = args.value<std::vector<double> >("Theta"); // .... (in degrees)
42  std::vector<double> rmax = args.value<std::vector<double> >("RMax"); // ....
43  std::vector<double> zoff = args.value<std::vector<double> >("ZOff"); // ....
44  std::string absMat = args.value<std::string>("AbsMatName"); //Absorber material
45  double thick = args.value<double>("Thickness"); //Thickness of absorber
46  double width1 = args.value<double>("Width1"); //Width of absorber type 1
47  double length1 = args.value<double>("Length1"); //Length of absorber type 1
48  double width2 = args.value<double>("Width2"); //Width of absorber type 2
49  double length2 = args.value<double>("Length2"); //Length of absorber type 2
50  double gap2 = args.value<double>("Gap2"); //Gap between abosrbers of type 2
51  std::string idName = args.value<std::string>("MotherName"); //Name of the "parent" volume.
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: General material " << genMat << "\tSectors " << nsectors << ", "
54  << nsectortot << "\tHalves " << nhalf << "\tRin " << cms::convert2mm(rin);
55  for (unsigned int i = 0; i < theta.size(); i++)
56  edm::LogVerbatim("HCalGeom") << "\t" << i << " Theta " << convertRadToDeg(theta[i]) << " rmax "
57  << cms::convert2mm(rmax[i]) << " zoff " << cms::convert2mm(zoff[i]);
58  edm::LogVerbatim("HCalGeom") << "\tCable mockup made of " << absMat << "\tThick " << cms::convert2mm(thick)
59  << "\tLength and width " << cms::convert2mm(length1) << ", " << cms::convert2mm(width1)
60  << " and " << cms::convert2mm(length2) << ", " << cms::convert2mm(width2) << " Gap "
61  << cms::convert2mm(gap2);
62  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: Parent " << args.parentName() << " idName " << idName
63  << " NameSpace " << ns.name() << " for solids";
64 #endif
65 
66  double alpha = 1._pi / nsectors;
67  double dphi = nsectortot * 2._pi / nsectors;
68  double zstep0 = zoff[1] + rmax[1] * tan(theta[1]) + (rin - rmax[1]) * tan(theta[2]);
69  double zstep1 = zstep0 + thick / cos(theta[2]);
70  double zstep2 = zoff[3];
71  double rstep0 = rin + (zstep2 - zstep1) / tan(theta[2]);
72  double rstep1 = rin + (zstep1 - zstep0) / tan(theta[2]);
73 
74  std::vector<double> pgonZ = {zstep0, zstep1, zstep2, zstep2 + thick / cos(theta[2])};
75  std::vector<double> pgonRmin = {rin, rin, rstep0, rmax[2]};
76  std::vector<double> pgonRmax = {rin, rstep1, rmax[2], rmax[2]};
77 
78  dd4hep::Solid solid = dd4hep::Polyhedra(ns.prepend(idName), nsectortot, -alpha, dphi, pgonZ, pgonRmin, pgonRmax);
79  dd4hep::Material matter = ns.material(genMat);
80  dd4hep::Volume genlogic(solid.name(), solid, matter);
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << solid.name() << " Polyhedra made of " << genMat << " with "
83  << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
84  << convertRadToDeg(-alpha + dphi) << " and with " << pgonZ.size() << " sections";
85  for (unsigned int i = 0; i < pgonZ.size(); i++)
86  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[i])
87  << "\tRmin = " << cms::convert2mm(pgonRmin[i])
88  << "\tRmax = " << cms::convert2mm(pgonRmax[i]);
89 #endif
90 
91  dd4hep::Volume parent = ns.volume(args.parentName());
92  dd4hep::Rotation3D rot;
93  parent.placeVolume(genlogic, 1);
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << genlogic.name() << " number 1 positioned in "
96  << parent.name() << " at (0, 0, 0) with no rotation";
97 #endif
98  if (nhalf != 1) {
99  rot = cms::makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0);
100  parent.placeVolume(genlogic, 2, rot);
101 #ifdef EDM_ML_DEBUG
102  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << genlogic.name() << " number 2 positioned in "
103  << parent.name() << " at (0, 0, 0) with rotation: " << rot;
104 #endif
105  }
106 
107  //Construct sector (from -alpha to +alpha)
108  std::string name = idName + "Module";
109  solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha, 2 * alpha, pgonZ, pgonRmin, pgonRmax);
110  dd4hep::Volume seclogic(solid.name(), solid, matter);
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << solid.name() << " Polyhedra made of " << genMat
113  << " with 1 sector from " << convertRadToDeg(-alpha) << " to " << convertRadToDeg(alpha)
114  << " and with " << pgonZ.size() << " sections";
115  for (unsigned int i = 0; i < pgonZ.size(); i++)
116  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[i])
117  << "\tRmin = " << cms::convert2mm(pgonRmin[i])
118  << "\tRmax = " << cms::convert2mm(pgonRmax[i]);
119 #endif
120 
121  for (int ii = 0; ii < nsectortot; ++ii) {
122  double phi = ii * 2 * alpha;
123  dd4hep::Rotation3D rotation;
124  if (phi != 0) {
125  rotation = dd4hep::RotationZ(phi);
126 #ifdef EDM_ML_DEBUG
127  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: Creating a new rotation "
128  << "\t90," << convertRadToDeg(phi) << ",90," << (90 + convertRadToDeg(phi))
129  << ", 0, 0";
130 #endif
131  }
132  genlogic.placeVolume(seclogic, ii + 1, rotation);
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << seclogic.name() << " number " << ii + 1
135  << " positioned in " << genlogic.name() << " at (0, 0, 0) with rotation: " << rotation;
136 #endif
137  }
138 
139  //Now a trapezoid of air
140  double rinl = pgonRmin[0] + thick * sin(theta[2]);
141  double routl = pgonRmax[2] - thick * sin(theta[2]);
142  double dx1 = rinl * tan(alpha);
143  double dx2 = 0.90 * routl * tan(alpha);
144  double dy = 0.50 * thick;
145  double dz = 0.50 * (routl - rinl);
146  name = idName + "Trap";
147  solid = dd4hep::Trap(ns.prepend(name), dz, 0, 0, dy, dx1, dx1, 0, dy, dx2, dx2, 0);
148  dd4hep::Volume glog(solid.name(), solid, matter);
149 #ifdef EDM_ML_DEBUG
150  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << solid.name() << " Trap made of " << genMat
151  << " of dimensions " << cms::convert2mm(dz) << ", 0, 0, " << cms::convert2mm(dy) << ", "
152  << cms::convert2mm(dx1) << ", " << cms::convert2mm(dx1) << ", 0, " << cms::convert2mm(dy)
153  << ", " << cms::convert2mm(dx2) << ", " << cms::convert2mm(dx2) << ", 0";
154 #endif
155 
156  rot = cms::makeRotation3D(90._deg, 270._deg, (180._deg - theta[2]), 0, (90._deg - theta[2]), 0);
157 #ifdef EDM_ML_DEBUG
158  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: Creating a rotation: \t90, 270, "
159  << (180 - convertRadToDeg(theta[2])) << ", 0, " << (90 - convertRadToDeg(theta[2]))
160  << ", 0";
161 #endif
162  dd4hep::Position r1(0.5 * (rinl + routl), 0, 0.5 * (pgonZ[1] + pgonZ[2]));
163  seclogic.placeVolume(glog, 1, dd4hep::Transform3D(rot, r1));
164 #ifdef EDM_ML_DEBUG
165  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << glog.name() << " number 1 positioned in " << seclogic.name()
166  << " at (" << cms::convert2mm(0.5 * (rinl + routl)) << ", 0, "
167  << cms::convert2mm(0.5 * (pgonZ[1] + pgonZ[2])) << " with rotation: " << rot;
168 #endif
169  //Now the cable of type 1
170  name = idName + "Cable1";
171  double phi = atan((dx2 - dx1) / (2 * dz));
172  double xmid = 0.5 * (dx1 + dx2) - 1.0;
173  solid = dd4hep::Box(ns.prepend(name), 0.5 * width1, 0.5 * thick, 0.5 * length1);
174  dd4hep::Material absmatter = ns.material(absMat);
175  dd4hep::Volume cablog1(solid.name(), solid, absmatter);
176 #ifdef EDM_ML_DEBUG
177  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << solid.name() << " Box made of " << absMat << " of dimension "
178  << cms::convert2mm(0.5 * width1) << ", " << cms::convert2mm(0.5 * thick) << ", "
179  << cms::convert2mm(0.5 * length1);
180 #endif
181 
182  dd4hep::Rotation3D rot2 = cms::makeRotation3D((90._deg + phi), 0.0, 90._deg, 90._deg, phi, 0.0);
183 #ifdef EDM_ML_DEBUG
184  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: Creating a rotation \t" << (90 + convertRadToDeg(phi))
185  << ", 0, 90, 90, " << convertRadToDeg(phi) << ", 0";
186 #endif
187  dd4hep::Position r2((xmid - 0.5 * width1 * cos(phi)), 0, 0);
188  glog.placeVolume(cablog1, 1, dd4hep::Transform3D(rot2, r2));
189 #ifdef EDM_ML_DEBUG
190  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << cablog1.name() << " number 1 positioned in " << glog.name()
191  << " at (" << cms::convert2mm(xmid - 0.5 * width1 * cos(phi))
192  << ", 0, 0) with rotation: " << rot2;
193 #endif
194  dd4hep::Rotation3D rot3 = cms::makeRotation3D((90._deg - phi), 0, 90._deg, 90._deg, -phi, 0);
195 #ifdef EDM_ML_DEBUG
196  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: Creating a rotation \t" << (90 - convertRadToDeg(phi))
197  << ", 0, 90, 90, " << convertRadToDeg(-phi) << ", 0";
198 #endif
199  dd4hep::Position r3(-(xmid - 0.5 * width1 * cos(phi)), 0, 0);
200  glog.placeVolume(cablog1, 2, dd4hep::Transform3D(rot3, r3));
201 #ifdef EDM_ML_DEBUG
202  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << cablog1.name() << " number 2 positioned in " << glog.name()
203  << " at (" << cms::convert2mm(xmid - 0.5 * width1 * cos(phi))
204  << ", 0, 0) with rotation: " << rot3;
205 #endif
206  //Now the cable of type 2
207  name = idName + "Cable2";
208  solid = dd4hep::Box(ns.prepend(name), 0.5 * width2, 0.5 * thick, 0.5 * length2);
209  dd4hep::Volume cablog2(solid.name(), solid, absmatter);
210 #ifdef EDM_ML_DEBUG
211  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << solid.name() << " Box made of " << absMat << " of dimension "
212  << cms::convert2mm(0.5 * width2) << ", " << cms::convert2mm(0.5 * thick) << ", "
213  << cms::convert2mm(0.5 * length2);
214 #endif
215 
216  glog.placeVolume(cablog2, 1, dd4hep::Position(0.5 * (width2 + gap2), 0, 0));
217 #ifdef EDM_ML_DEBUG
218  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << cablog2.name() << " number 1 positioned in " << glog.name()
219  << " at (" << cms::convert2mm(0.5 * (width2 + gap2)) << ", 0, 0) with no rotation";
220 #endif
221  glog.placeVolume(cablog2, 2, dd4hep::Position(-0.5 * (width2 + gap2), 0, 0));
222 #ifdef EDM_ML_DEBUG
223  edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: " << cablog2.name() << " number 2 positioned in " << glog.name()
224  << " at " << cms::convert2mm(-0.5 * (width2 + gap2)) << ", 0, 0) with no rotation";
225 
226  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalTBCableAlgo construction";
227 #endif
228 
229  return cms::s_executed;
230 }
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static constexpr long s_executed
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
dd4hep::Volume Volume
ii
Definition: cuy.py:589
Geom::Theta< T > theta() const

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalTBCableAlgo   
)

Definition at line 233 of file DDHCalTBCableAlgo.cc.