Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:55

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTOBRadCableAlgo.cc
0003 // Description: Equipping the side disks of TOB with cables etc
0004 ///////////////////////////////////////////////////////////////////////////////
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0008 #include "DetectorDescription/Core/interface/DDSolid.h"
0009 #include "DetectorDescription/Core/interface/DDMaterial.h"
0010 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0011 #include "DetectorDescription/Core/interface/DDSplit.h"
0012 #include "DetectorDescription/Core/interface/DDTypes.h"
0013 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0015 #include <CLHEP/Units/GlobalPhysicalConstants.h>
0016 #include <CLHEP/Units/SystemOfUnits.h>
0017 
0018 #include <string>
0019 #include <vector>
0020 
0021 using namespace std;
0022 
0023 class DDTOBRadCableAlgo : public DDAlgorithm {
0024 public:
0025   //Constructor and Destructor
0026   DDTOBRadCableAlgo();
0027   ~DDTOBRadCableAlgo() override;
0028 
0029   void initialize(const DDNumericArguments& nArgs,
0030                   const DDVectorArguments& vArgs,
0031                   const DDMapArguments& mArgs,
0032                   const DDStringArguments& sArgs,
0033                   const DDStringVectorArguments& vsArgs) override;
0034 
0035   void execute(DDCompactView& cpv) override;
0036 
0037 private:
0038   string idNameSpace;  // Namespace of this and ALL sub-parts
0039 
0040   double diskDz;           // Disk  thickness
0041   double rMax;             // Maximum radius
0042   double cableT;           // Cable thickness
0043   vector<double> rodRin;   // Radii for inner rods
0044   vector<double> rodRout;  // Radii for outer rods
0045   vector<string> cableM;   // Materials for cables
0046   double connW;            // Connector width
0047   double connT;            // Connector thickness
0048   vector<string> connM;    // Materials for connectors
0049   vector<double> coolR1;   // Radii for cooling manifold
0050   vector<double> coolR2;   // Radii for return cooling manifold
0051   double coolRin;          // Inner radius of cooling manifold
0052   double coolRout1;        // Outer radius of cooling manifold
0053   double coolRout2;        // Outer radius of cooling fluid in cooling manifold
0054   double coolStartPhi1;    // Starting Phi of cooling manifold
0055   double coolDeltaPhi1;    // Phi Range of cooling manifold
0056   double coolStartPhi2;    // Starting Phi of cooling fluid in of cooling manifold
0057   double coolDeltaPhi2;    // Phi Range of of cooling fluid in cooling manifold
0058   string coolM1;           // Material for cooling manifold
0059   string coolM2;           // Material for cooling fluid
0060   vector<string> names;    // Names of layers
0061 };
0062 
0063 DDTOBRadCableAlgo::DDTOBRadCableAlgo()
0064     : rodRin(0),
0065       rodRout(0),
0066       cableM(0),
0067       connM(0),
0068       coolR1(0),
0069       coolR2(0),
0070       coolRin(0),
0071       coolRout1(0),
0072       coolRout2(0),
0073       coolStartPhi1(0),
0074       coolDeltaPhi1(0),
0075       coolStartPhi2(0),
0076       coolDeltaPhi2(0),
0077       names(0) {
0078   LogDebug("TOBGeom") << "DDTOBRadCableAlgo info: Creating an instance";
0079 }
0080 
0081 DDTOBRadCableAlgo::~DDTOBRadCableAlgo() {}
0082 
0083 void DDTOBRadCableAlgo::initialize(const DDNumericArguments& nArgs,
0084                                    const DDVectorArguments& vArgs,
0085                                    const DDMapArguments&,
0086                                    const DDStringArguments& sArgs,
0087                                    const DDStringVectorArguments& vsArgs) {
0088   idNameSpace = DDCurrentNamespace::ns();
0089   DDName parentName = parent().name();
0090   LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace;
0091 
0092   diskDz = nArgs["DiskDz"];
0093   rMax = nArgs["RMax"];
0094   cableT = nArgs["CableT"];
0095   rodRin = vArgs["RodRin"];
0096   rodRout = vArgs["RodRout"];
0097   cableM = vsArgs["CableMaterial"];
0098   LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Disk Half width " << diskDz << "\tRMax " << rMax
0099                       << "\tCable Thickness " << cableT << "\tRadii of disk position and cable materials:";
0100   for (int i = 0; i < (int)(rodRin.size()); i++)
0101     LogDebug("TOBGeom") << "\t[" << i << "]\tRin = " << rodRin[i] << "\tRout = " << rodRout[i] << "  " << cableM[i];
0102 
0103   connW = nArgs["ConnW"];
0104   connT = nArgs["ConnT"];
0105   connM = vsArgs["ConnMaterial"];
0106   LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Connector Width = " << connW << "\tThickness = " << connT
0107                       << "\tMaterials: ";
0108   for (int i = 0; i < (int)(connM.size()); i++)
0109     LogDebug("TOBGeom") << "\tconnM[" << i << "] = " << connM[i];
0110 
0111   coolR1 = vArgs["CoolR1"];
0112   coolR2 = vArgs["CoolR2"];
0113   coolRin = nArgs["CoolRin"];
0114   coolRout1 = nArgs["CoolRout1"];
0115   coolRout2 = nArgs["CoolRout2"];
0116   coolStartPhi1 = nArgs["CoolStartPhi1"];
0117   coolDeltaPhi1 = nArgs["CoolDeltaPhi1"];
0118   coolStartPhi2 = nArgs["CoolStartPhi2"];
0119   coolDeltaPhi2 = nArgs["CoolDeltaPhi2"];
0120   coolM1 = sArgs["CoolMaterial1"];
0121   coolM2 = sArgs["CoolMaterial2"];
0122   LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Cool Manifold Torus Rin = " << coolRin << " Rout = " << coolRout1
0123                       << "\t Phi start = " << coolStartPhi1 << " Phi Range = " << coolDeltaPhi1
0124                       << "\t Material = " << coolM1 << "\t Radial positions:";
0125   for (int i = 0; i < (int)(coolR1.size()); i++)
0126     LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
0127   for (int i = 0; i < (int)(coolR2.size()); i++)
0128     LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
0129   LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Cooling Fluid Torus Rin = " << coolRin << " Rout = " << coolRout2
0130                       << "\t Phi start = " << coolStartPhi2 << " Phi Range = " << coolDeltaPhi2
0131                       << "\t Material = " << coolM2 << "\t Radial positions:";
0132   for (int i = 0; i < (int)(coolR1.size()); i++)
0133     LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
0134   for (int i = 0; i < (int)(coolR2.size()); i++)
0135     LogDebug("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
0136 
0137   names = vsArgs["RingName"];
0138   for (int i = 0; i < (int)(names.size()); i++)
0139     LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: names[" << i << "] = " << names[i];
0140 }
0141 
0142 void DDTOBRadCableAlgo::execute(DDCompactView& cpv) {
0143   LogDebug("TOBGeom") << "==>> Constructing DDTOBRadCableAlgo...";
0144   DDName diskName = parent().name();
0145 
0146   // Loop over sub disks
0147   for (int i = 0; i < (int)(names.size()); i++) {
0148     DDSolid solid;
0149     string name;
0150     double dz, rin, rout;
0151 
0152     // Cooling Manifolds
0153     name = "TOBCoolingManifold" + names[i] + "a";
0154     dz = coolRout1;
0155     DDName manifoldName_a(name, idNameSpace);
0156     solid = DDSolidFactory::torus(manifoldName_a, coolRin, coolRout1, coolR1[i], coolStartPhi1, coolDeltaPhi1);
0157     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " Torus made of " << coolM1
0158                         << " from " << coolStartPhi1 / CLHEP::deg << " to "
0159                         << (coolStartPhi1 + coolDeltaPhi1) / CLHEP::deg << " with Rin " << coolRin << " Rout "
0160                         << coolRout1 << " R torus " << coolR1[i];
0161     DDName coolManifoldName_a(DDSplit(coolM1).first, DDSplit(coolM1).second);
0162     DDMaterial coolManifoldMatter_a(coolManifoldName_a);
0163     DDLogicalPart coolManifoldLogic_a(DDName(name, idNameSpace), coolManifoldMatter_a, solid);
0164 
0165     DDTranslation r1(0, 0, (dz - diskDz));
0166     cpv.position(DDName(name, idNameSpace), diskName, i + 1, r1, DDRotation());
0167     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0168                         << " positioned in " << diskName << " at " << r1 << " with no rotation";
0169     // Cooling Fluid (in Cooling Manifold)
0170     name = "TOBCoolingManifoldFluid" + names[i] + "a";
0171     solid =
0172         DDSolidFactory::torus(DDName(name, idNameSpace), coolRin, coolRout2, coolR1[i], coolStartPhi2, coolDeltaPhi2);
0173     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " Torus made of " << coolM2
0174                         << " from " << coolStartPhi2 / CLHEP::deg << " to "
0175                         << (coolStartPhi2 + coolDeltaPhi2) / CLHEP::deg << " with Rin " << coolRin << " Rout "
0176                         << coolRout2 << " R torus " << coolR1[i];
0177     DDName coolManifoldFluidName_a(DDSplit(coolM2).first, DDSplit(coolM2).second);
0178     DDMaterial coolManifoldFluidMatter_a(coolManifoldFluidName_a);
0179     DDLogicalPart coolManifoldFluidLogic_a(DDName(name, idNameSpace), coolManifoldFluidMatter_a, solid);
0180     cpv.position(DDName(name, idNameSpace), manifoldName_a, i + 1, DDTranslation(), DDRotation());
0181     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0182                         << " positioned in " << coolManifoldName_a << " with no translation and no rotation";
0183     //
0184     name = "TOBCoolingManifold" + names[i] + "r";
0185     dz = coolRout1;
0186     DDName manifoldName_r(name, idNameSpace);
0187     solid = DDSolidFactory::torus(manifoldName_r, coolRin, coolRout1, coolR2[i], coolStartPhi1, coolDeltaPhi1);
0188     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " Torus made of " << coolM1
0189                         << " from " << coolStartPhi1 / CLHEP::deg << " to "
0190                         << (coolStartPhi1 + coolDeltaPhi1) / CLHEP::deg << " with Rin " << coolRin << " Rout "
0191                         << coolRout1 << " R torus " << coolR2[i];
0192     DDName coolManifoldName_r(DDSplit(coolM1).first, DDSplit(coolM1).second);
0193     DDMaterial coolManifoldMatter_r(coolManifoldName_r);
0194     DDLogicalPart coolManifoldLogic_r(DDName(name, idNameSpace), coolManifoldMatter_r, solid);
0195 
0196     r1 = DDTranslation(0, 0, (dz - diskDz));
0197     cpv.position(DDName(name, idNameSpace), diskName, i + 1, r1, DDRotation());
0198     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0199                         << " positioned in " << diskName << " at " << r1 << " with no rotation";
0200     // Cooling Fluid (in Cooling Manifold)
0201     name = "TOBCoolingManifoldFluid" + names[i] + "r";
0202     solid =
0203         DDSolidFactory::torus(DDName(name, idNameSpace), coolRin, coolRout2, coolR2[i], coolStartPhi2, coolDeltaPhi2);
0204     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " Torus made of " << coolM2
0205                         << " from " << coolStartPhi2 / CLHEP::deg << " to "
0206                         << (coolStartPhi2 + coolDeltaPhi2) / CLHEP::deg << " with Rin " << coolRin << " Rout "
0207                         << coolRout2 << " R torus " << coolR2[i];
0208     DDName coolManifoldFluidName_r(DDSplit(coolM2).first, DDSplit(coolM2).second);
0209     DDMaterial coolManifoldFluidMatter_r(coolManifoldFluidName_r);
0210     DDLogicalPart coolManifoldFluidLogic_r(DDName(name, idNameSpace), coolManifoldFluidMatter_r, solid);
0211     cpv.position(DDName(name, idNameSpace), manifoldName_r, i + 1, DDTranslation(), DDRotation());
0212     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0213                         << " positioned in " << coolManifoldName_r << " with no translation and no rotation";
0214 
0215     // Connectors
0216     name = "TOBConn" + names[i];
0217     dz = 0.5 * connT;
0218     rin = 0.5 * (rodRin[i] + rodRout[i]) - 0.5 * connW;
0219     rout = 0.5 * (rodRin[i] + rodRout[i]) + 0.5 * connW;
0220     solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, 0, CLHEP::twopi);
0221     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << connM[i]
0222                         << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0223                         << " ZHalf " << dz;
0224     DDName connName(DDSplit(connM[i]).first, DDSplit(connM[i]).second);
0225     DDMaterial connMatter(connName);
0226     DDLogicalPart connLogic(DDName(name, idNameSpace), connMatter, solid);
0227 
0228     DDTranslation r2(0, 0, (dz - diskDz));
0229     cpv.position(DDName(name, idNameSpace), diskName, i + 1, r2, DDRotation());
0230     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0231                         << " positioned in " << diskName << " at " << r2 << " with no rotation";
0232 
0233     // Now the radial cable
0234     name = "TOBRadServices" + names[i];
0235     rin = 0.5 * (rodRin[i] + rodRout[i]);
0236     rout = (i + 1 == (int)(names.size()) ? rMax : 0.5 * (rodRin[i + 1] + rodRout[i + 1]));
0237     vector<double> pgonZ;
0238     pgonZ.emplace_back(-0.5 * cableT);
0239     pgonZ.emplace_back(cableT * (rin / rMax - 0.5));
0240     pgonZ.emplace_back(0.5 * cableT);
0241     vector<double> pgonRmin;
0242     pgonRmin.emplace_back(rin);
0243     pgonRmin.emplace_back(rin);
0244     pgonRmin.emplace_back(rin);
0245     vector<double> pgonRmax;
0246     pgonRmax.emplace_back(rout);
0247     pgonRmax.emplace_back(rout);
0248     pgonRmax.emplace_back(rout);
0249     solid = DDSolidFactory::polycone(DDName(name, idNameSpace), 0, CLHEP::twopi, pgonZ, pgonRmin, pgonRmax);
0250     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " Polycone made of " << cableM[i]
0251                         << " from 0 to " << CLHEP::twopi / CLHEP::deg << " and with " << pgonZ.size() << " sections";
0252     for (int ii = 0; ii < (int)(pgonZ.size()); ii++)
0253       LogDebug("TOBGeom") << "\t[" << ii << "]\tZ = " << pgonZ[ii] << "\tRmin = " << pgonRmin[ii]
0254                           << "\tRmax = " << pgonRmax[ii];
0255     DDName cableName(DDSplit(cableM[i]).first, DDSplit(cableM[i]).second);
0256     DDMaterial cableMatter(cableName);
0257     DDLogicalPart cableLogic(DDName(name, idNameSpace), cableMatter, solid);
0258 
0259     DDTranslation r3(0, 0, (diskDz - (i + 0.5) * cableT));
0260     cpv.position(DDName(name, idNameSpace), diskName, i + 1, r3, DDRotation());
0261     LogDebug("TOBGeom") << "DDTOBRadCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0262                         << " positioned in " << diskName << " at " << r3 << " with no rotation";
0263   }
0264 
0265   LogDebug("TOBGeom") << "<<== End of DDTOBRadCableAlgo construction ...";
0266 }
0267 
0268 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTOBRadCableAlgo, "track:DDTOBRadCableAlgo");