CMS 3D CMS Logo

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