CMS 3D CMS Logo

Functions
DDHCalTBCableAlgo.cc File Reference
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.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::SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hcal_DDHCalTBCableAlgo)
 

Function Documentation

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

Definition at line 10 of file DDHCalTBCableAlgo.cc.

References zMuMuMuonUserData::alpha, writedatasetfile::args, geant_units::operators::convertCmToMm(), angle_units::operators::convertRadToDeg(), funct::cos(), PVValHelper::dy, PVValHelper::dz, 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, cms::DDAlgoArguments::parentName(), HGCalGeometryMode::Polyhedra, cms::DDNamespace::prepend(), diffTwoXMLs::r1, diffTwoXMLs::r2, makeMuonMisalignmentScenario::rot, idealTransformation::rotation, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), theta(), cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

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

Definition at line 235 of file DDHCalTBCableAlgo.cc.