CMS 3D CMS Logo

DDTOBRadCableAlgo.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) {
12  cms::DDNamespace ns(ctxt, e, true);
13  DDAlgoArguments args(ctxt, e);
14  double diskDz = args.dble("DiskDz"); // Disk thickness
15  double rMax = args.dble("RMax"); // Maximum radius
16  double cableT = args.dble("CableT"); // Cable thickness
17  vector<double> rodRin = args.vecDble("RodRin"); // Radii for inner rods
18  vector<double> rodRout = args.vecDble("RodRout"); // Radii for outer rods
19  vector<string> cableM = args.vecStr("CableMaterial"); // Materials for cables
20  double connW = args.dble("ConnW"); // Connector width
21  double connT = args.dble("ConnT"); // Connector thickness
22  vector<string> connM = args.vecStr("ConnMaterial"); // Materials for connectors
23  vector<double> coolR1 = args.vecDble("CoolR1"); // Radii for cooling manifold
24  vector<double> coolR2 = args.vecDble("CoolR2"); // Radii for return cooling manifold
25  double coolRin = args.dble("CoolRin"); // Inner radius of cooling manifold
26  double coolRout1 = args.dble("CoolRout1"); // Outer radius of cooling manifold
27  double coolRout2 = args.dble("CoolRout2"); // Outer radius of cooling fluid in cooling manifold
28  double coolStartPhi1 = args.dble("CoolStartPhi1"); // Starting Phi of cooling manifold
29  double coolDeltaPhi1 = args.dble("CoolDeltaPhi1"); // Phi Range of cooling manifold
30  double coolStartPhi2 = args.dble("CoolStartPhi2"); // Starting Phi of cooling fluid in of cooling manifold
31  double coolDeltaPhi2 = args.dble("CoolDeltaPhi2"); // Phi Range of of cooling fluid in cooling manifold
32  string coolM1 = args.str("CoolMaterial1"); // Material for cooling manifold
33  string coolM2 = args.str("CoolMaterial2"); // Material for cooling fluid
34  vector<string> names = args.vecStr("RingName"); // Names of layers
35 
36  string parentName = args.parentName();
37  edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Parent " << parentName << " NameSpace " << ns.name();
38  edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Disk Half width " << diskDz << "\tRMax " << rMax
39  << "\tCable Thickness " << cableT << "\tRadii of disk position and cable materials:";
40  for (int i = 0; i < (int)(rodRin.size()); i++)
41  edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tRin = " << rodRin[i] << "\tRout = " << rodRout[i] << " "
42  << cableM[i];
43  edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Connector Width = " << connW << "\tThickness = " << connT
44  << "\tMaterials: ";
45  for (int i = 0; i < (int)(connM.size()); i++)
46  edm::LogVerbatim("TOBGeom") << "\tconnM[" << i << "] = " << connM[i];
47  edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Cool Manifold Torus Rin = " << coolRin
48  << " Rout = " << coolRout1 << "\t Phi start = " << coolStartPhi1
49  << " Phi Range = " << coolDeltaPhi1 << "\t Material = " << coolM1
50  << "\t Radial positions:";
51  for (int i = 0; i < (int)(coolR1.size()); i++)
52  edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
53  for (int i = 0; i < (int)(coolR2.size()); i++)
54  edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
55  edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Cooling Fluid Torus Rin = " << coolRin
56  << " Rout = " << coolRout2 << "\t Phi start = " << coolStartPhi2
57  << " Phi Range = " << coolDeltaPhi2 << "\t Material = " << coolM2
58  << "\t Radial positions:";
59  for (int i = 0; i < (int)(coolR1.size()); i++)
60  edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
61  for (int i = 0; i < (int)(coolR2.size()); i++)
62  edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
63  for (int i = 0; i < (int)(names.size()); i++)
64  edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: names[" << i << "] = " << names[i];
65 
66  Volume disk = ns.volume(parentName);
67  // Loop over sub disks
68  for (int i = 0; i < (int)(names.size()); i++) {
69  Solid solid;
70  string name;
71  double dz, rin, rout;
72 
73  // Cooling Manifolds
74  name = "TOBCoolingManifold" + names[i] + "a";
75  dz = coolRout1;
76  solid = ns.addSolid(ns.prepend(name), Torus(coolR1[i], coolRin, coolRout1, coolStartPhi1, coolDeltaPhi1));
77  edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM1 << " from "
78  << convertRadToDeg(coolStartPhi1) << " to "
79  << convertRadToDeg((coolStartPhi1 + coolDeltaPhi1)) << " with Rin " << coolRin
80  << " Rout " << coolRout1 << " R torus " << coolR1[i];
81  Volume coolManifoldLogic_a = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM1)));
82  Position r1(0, 0, (dz - diskDz));
83  disk.placeVolume(coolManifoldLogic_a, i + 1, r1); // i+1
84  edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
85  << r1 << " with no rotation";
86 
87  // Cooling Fluid (in Cooling Manifold)
88  name = "TOBCoolingManifoldFluid" + names[i] + "a";
89  solid = ns.addSolid(ns.prepend(name), Torus(coolR1[i], coolRin, coolRout2, coolStartPhi2, coolDeltaPhi2));
90  edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM2 << " from "
91  << convertRadToDeg(coolStartPhi2) << " to "
92  << convertRadToDeg((coolStartPhi2 + coolDeltaPhi2)) << " with Rin " << coolRin
93  << " Rout " << coolRout2 << " R torus " << coolR1[i];
94  Volume coolManifoldFluidLogic_a = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM2)));
95  coolManifoldLogic_a.placeVolume(coolManifoldFluidLogic_a, i + 1); // i+1
96  edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << coolM2
97  << " with no translation and no rotation";
98 
99  name = "TOBCoolingManifold" + names[i] + "r";
100  dz = coolRout1;
101  solid = ns.addSolid(ns.prepend(name), Torus(coolR2[i], coolRin, coolRout1, coolStartPhi1, coolDeltaPhi1));
102  edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM1 << " from "
103  << convertRadToDeg(coolStartPhi1) << " to "
104  << convertRadToDeg((coolStartPhi1 + coolDeltaPhi1)) << " with Rin " << coolRin
105  << " Rout " << coolRout1 << " R torus " << coolR2[i];
106  Volume coolManifoldLogic_r = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM1)));
107  r1 = Position(0, 0, (dz - diskDz));
108  disk.placeVolume(coolManifoldLogic_r, i + 1, r1); // i+1
109  edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
110  << r1 << " with no rotation";
111 
112  // Cooling Fluid (in Cooling Manifold)
113  name = "TOBCoolingManifoldFluid" + names[i] + "r";
114  solid = ns.addSolid(ns.prepend(name), Torus(coolR2[i], coolRin, coolRout2, coolStartPhi2, coolDeltaPhi2));
115  edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM2 << " from "
116  << convertRadToDeg(coolStartPhi2) << " to "
117  << convertRadToDeg((coolStartPhi2 + coolDeltaPhi2)) << " with Rin " << coolRin
118  << " Rout " << coolRout2 << " R torus " << coolR2[i];
119  Volume coolManifoldFluidLogic_r = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM2)));
120  coolManifoldLogic_r.placeVolume(coolManifoldFluidLogic_r, i + 1); // i+1
121  edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << coolM2
122  << " with no translation and no rotation";
123 
124  // Connectors
125  name = "TOBConn" + names[i];
126  dz = 0.5 * connT;
127  rin = 0.5 * (rodRin[i] + rodRout[i]) - 0.5 * connW;
128  rout = 0.5 * (rodRin[i] + rodRout[i]) + 0.5 * connW;
129  solid = ns.addSolid(ns.prepend(name), Tube(rin, rout, dz));
130  edm::LogVerbatim("TOBGeom") << solid.name() << " Tubs made of " << connM[i] << " from 0 to "
131  << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf " << dz;
132  Volume connLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(connM[i])));
133  Position r2(0, 0, (dz - diskDz));
134  disk.placeVolume(connLogic, i + 1, r2); // i+1
135  edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
136  << r2 << " with no rotation";
137 
138  // Now the radial cable
139  name = "TOBRadServices" + names[i];
140  rin = 0.5 * (rodRin[i] + rodRout[i]);
141  rout = (i + 1 == (int)(names.size()) ? rMax : 0.5 * (rodRin[i + 1] + rodRout[i + 1]));
142  vector<double> pgonZ;
143  pgonZ.emplace_back(-0.5 * cableT);
144  pgonZ.emplace_back(cableT * (rin / rMax - 0.5));
145  pgonZ.emplace_back(0.5 * cableT);
146  vector<double> pgonRmin;
147  pgonRmin.emplace_back(rin);
148  pgonRmin.emplace_back(rin);
149  pgonRmin.emplace_back(rin);
150  vector<double> pgonRmax;
151  pgonRmax.emplace_back(rout);
152  pgonRmax.emplace_back(rout);
153  pgonRmax.emplace_back(rout);
154  solid = ns.addSolid(ns.prepend(name), Polycone(0, 2_pi, pgonRmin, pgonRmax, pgonZ));
155  edm::LogVerbatim("TOBGeom") << solid.name() << " Polycone made of " << cableM[i] << " from 0 to "
156  << convertRadToDeg(2_pi) << " and with " << pgonZ.size() << " sections";
157  for (int ii = 0; ii < (int)(pgonZ.size()); ii++)
158  edm::LogVerbatim("TOBGeom") << "\t[" << ii << "]\tZ = " << pgonZ[ii] << "\tRmin = " << pgonRmin[ii]
159  << "\tRmax = " << pgonRmax[ii];
160  Volume cableLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(cableM[i])));
161  Position r3(0, 0, (diskDz - (i + 0.5) * cableT));
162  disk.placeVolume(cableLogic, i + 1, r3); // i+1
163  edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
164  << r3 << " with no rotation";
165  }
166  edm::LogVerbatim("TOBGeom") << "<<== End of DDTOBRadCableAlgo construction ...";
167  return 1;
168 }
169 
170 // first argument is the type from the xml file
171 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRadCableAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
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:154
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:98
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
DDPlugins.h
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
createfilelist.int
int
Definition: createfilelist.py:10
cms::DDNamespace::addVolume
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Definition: DDNamespace.cc:209
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:295
align::Detector
Definition: StructureType.h:92
std
Definition: JetResolutionObject.h:76
PVValHelper::dz
Definition: PVValidationHelpers.h:51
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dd4hep
Definition: DDPlugins.h:8
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDTOBRadCableAlgo.cc:11
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
edm::Log
Definition: MessageLogger.h:70
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:79
cuy.ii
ii
Definition: cuy.py:589
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:264
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37