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, SensitiveDetector& /* sens */) {
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  LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Parent " << parentName << " NameSpace " << ns.name();
38  LogDebug("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  LogDebug("TOBGeom") << "\t[" << i << "]\tRin = " << rodRin[i] << "\tRout = " << rodRout[i] << " " << cableM[i];
42  LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Connector Width = " << connW << "\tThickness = " << connT
43  << "\tMaterials: ";
44  for (int i = 0; i < (int)(connM.size()); i++)
45  LogDebug("TOBGeom") << "\tconnM[" << i << "] = " << connM[i];
46  LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Cool Manifold Torus Rin = " << coolRin << " Rout = " << coolRout1
47  << "\t Phi start = " << coolStartPhi1 << " Phi Range = " << coolDeltaPhi1
48  << "\t Material = " << coolM1 << "\t Radial positions:";
49  for (int i = 0; i < (int)(coolR1.size()); i++)
50  LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
51  for (int i = 0; i < (int)(coolR2.size()); i++)
52  LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
53  LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Cooling Fluid Torus Rin = " << coolRin << " Rout = " << coolRout2
54  << "\t Phi start = " << coolStartPhi2 << " Phi Range = " << coolDeltaPhi2
55  << "\t Material = " << coolM2 << "\t Radial positions:";
56  for (int i = 0; i < (int)(coolR1.size()); i++)
57  LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
58  for (int i = 0; i < (int)(coolR2.size()); i++)
59  LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
60  for (int i = 0; i < (int)(names.size()); i++)
61  LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: names[" << i << "] = " << names[i];
62 
63  Volume disk = ns.volume(parentName);
64  // Loop over sub disks
65  for (int i = 0; i < (int)(names.size()); i++) {
66  Solid solid;
67  string name;
68  double dz, rin, rout;
69 
70  // Cooling Manifolds
71  name = "TOBCoolingManifold" + names[i] + "a";
72  dz = coolRout1;
73  solid = ns.addSolid(name, Torus(coolR1[i], coolRin, coolRout1, coolStartPhi1, coolDeltaPhi1));
74  LogDebug("TOBGeom") << name << " Torus made of " << coolM1 << " from " << convertRadToDeg(coolStartPhi1) << " to "
75  << convertRadToDeg((coolStartPhi1 + coolDeltaPhi1)) << " with Rin " << coolRin << " Rout "
76  << coolRout1 << " R torus " << coolR1[i];
77  Volume coolManifoldLogic_a = ns.addVolume(Volume(name, solid, ns.material(coolM1)));
78  Position r1(0, 0, (dz - diskDz));
79  disk.placeVolume(coolManifoldLogic_a, i + 1, r1); // i+1
80  LogDebug("TOBGeom") << name << " number " << i + 1 << " positioned in " << disk.name() << " at " << r1
81  << " with no rotation";
82 
83  // Cooling Fluid (in Cooling Manifold)
84  name = "TOBCoolingManifoldFluid" + names[i] + "a";
85  solid = ns.addSolid(name, Torus(coolR1[i], coolRin, coolRout2, coolStartPhi2, coolDeltaPhi2));
86  LogDebug("TOBGeom") << name << " Torus made of " << coolM2 << " from " << convertRadToDeg(coolStartPhi2) << " to "
87  << convertRadToDeg((coolStartPhi2 + coolDeltaPhi2)) << " with Rin " << coolRin << " Rout "
88  << coolRout2 << " R torus " << coolR1[i];
89  Volume coolManifoldFluidLogic_a = ns.addVolume(Volume(name, solid, ns.material(coolM2)));
90  coolManifoldLogic_a.placeVolume(coolManifoldFluidLogic_a, i + 1); // i+1
91  LogDebug("TOBGeom") << name << " number " << i + 1 << " positioned in " << coolM2
92  << " with no translation and no rotation";
93 
94  name = "TOBCoolingManifold" + names[i] + "r";
95  dz = coolRout1;
96  solid = ns.addSolid(name, Torus(coolR2[i], coolRin, coolRout1, coolStartPhi1, coolDeltaPhi1));
97  LogDebug("TOBGeom") << name << " Torus made of " << coolM1 << " from " << convertRadToDeg(coolStartPhi1) << " to "
98  << convertRadToDeg((coolStartPhi1 + coolDeltaPhi1)) << " with Rin " << coolRin << " Rout "
99  << coolRout1 << " R torus " << coolR2[i];
100  Volume coolManifoldLogic_r = ns.addVolume(Volume(name, solid, ns.material(coolM1)));
101  r1 = Position(0, 0, (dz - diskDz));
102  disk.placeVolume(coolManifoldLogic_r, i + 1, r1); // i+1
103  LogDebug("TOBGeom") << name << " number " << i + 1 << " positioned in " << disk.name() << " at " << r1
104  << " with no rotation";
105 
106  // Cooling Fluid (in Cooling Manifold)
107  name = "TOBCoolingManifoldFluid" + names[i] + "r";
108  solid = ns.addSolid(name, Torus(coolR2[i], coolRin, coolRout2, coolStartPhi2, coolDeltaPhi2));
109  LogDebug("TOBGeom") << name << " Torus made of " << coolM2 << " from " << convertRadToDeg(coolStartPhi2) << " to "
110  << convertRadToDeg((coolStartPhi2 + coolDeltaPhi2)) << " with Rin " << coolRin << " Rout "
111  << coolRout2 << " R torus " << coolR2[i];
112  Volume coolManifoldFluidLogic_r = ns.addVolume(Volume(name, solid, ns.material(coolM2)));
113  coolManifoldLogic_r.placeVolume(coolManifoldFluidLogic_r, i + 1); // i+1
114  LogDebug("TOBGeom") << name << " number " << i + 1 << " positioned in " << coolM2
115  << " with no translation and no rotation";
116 
117  // Connectors
118  name = "TOBConn" + names[i];
119  dz = 0.5 * connT;
120  rin = 0.5 * (rodRin[i] + rodRout[i]) - 0.5 * connW;
121  rout = 0.5 * (rodRin[i] + rodRout[i]) + 0.5 * connW;
122  solid = ns.addSolid(name, Tube(rin, rout, dz));
123  LogDebug("TOBGeom") << name << " Tubs made of " << connM[i] << " from 0 to " << convertRadToDeg(2_pi)
124  << " with Rin " << rin << " Rout " << rout << " ZHalf " << dz;
125  Volume connLogic = ns.addVolume(Volume(name, solid, ns.material(connM[i])));
126  Position r2(0, 0, (dz - diskDz));
127  disk.placeVolume(connLogic, i + 1, r2); // i+1
128  LogDebug("TOBGeom") << name << " number " << i + 1 << " positioned in " << disk.name() << " at " << r2
129  << " with no rotation";
130 
131  // Now the radial cable
132  name = "TOBRadServices" + names[i];
133  rin = 0.5 * (rodRin[i] + rodRout[i]);
134  rout = (i + 1 == (int)(names.size()) ? rMax : 0.5 * (rodRin[i + 1] + rodRout[i + 1]));
135  vector<double> pgonZ;
136  pgonZ.emplace_back(-0.5 * cableT);
137  pgonZ.emplace_back(cableT * (rin / rMax - 0.5));
138  pgonZ.emplace_back(0.5 * cableT);
139  vector<double> pgonRmin;
140  pgonRmin.emplace_back(rin);
141  pgonRmin.emplace_back(rin);
142  pgonRmin.emplace_back(rin);
143  vector<double> pgonRmax;
144  pgonRmax.emplace_back(rout);
145  pgonRmax.emplace_back(rout);
146  pgonRmax.emplace_back(rout);
147  solid = ns.addSolid(name, Polycone(0, 2_pi, pgonRmin, pgonRmax, pgonZ));
148  LogDebug("TOBGeom") << name << " Polycone made of " << cableM[i] << " from 0 to " << convertRadToDeg(2_pi)
149  << " and with " << pgonZ.size() << " sections";
150  for (int ii = 0; ii < (int)(pgonZ.size()); ii++)
151  LogDebug("TOBGeom") << "\t[" << ii << "]\tZ = " << pgonZ[ii] << "\tRmin = " << pgonRmin[ii]
152  << "\tRmax = " << pgonRmax[ii];
153  Volume cableLogic = ns.addVolume(Volume(name, solid, ns.material(cableM[i])));
154  Position r3(0, 0, (diskDz - (i + 0.5) * cableT));
155  disk.placeVolume(cableLogic, i + 1, r3); // i+1
156  LogDebug("TOBGeom") << name << " number " << i + 1 << " positioned in " << disk.name() << " at " << r3
157  << " with no rotation";
158  }
159  LogDebug("TOBGeom") << "<<== End of DDTOBRadCableAlgo construction ...";
160  return 1;
161 }
162 
163 // first argument is the type from the xml file
164 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:355
cms_units::operators
Definition: CMSUnits.h:13
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
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
SensitiveDetector
Definition: SensitiveDetector.h:25
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Definition: DDTOBRadCableAlgo.cc:11
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
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
Add rotation matrix to current namespace.
Definition: DDNamespace.cc:170
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
align::Detector
Definition: StructureType.h:86
std
Definition: JetResolutionObject.h:76
PVValHelper::dz
Definition: PVValidationHelpers.h:50
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
dd4hep
Definition: DDPlugins.h:8
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
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
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37