Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTOBAxCableAlgo.cc
0003 // Description: Equipping the axial cylinder 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 DDTOBAxCableAlgo : public DDAlgorithm {
0024 public:
0025   //Constructor and Destructor
0026   DDTOBAxCableAlgo();
0027   ~DDTOBAxCableAlgo() 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   vector<string> sectorNumber;  // Id. Number of the sectors
0041 
0042   double sectorRin;                 // Inner radius of service sectors
0043   double sectorRout;                // Outer radius of service sectors
0044   double sectorDz;                  // Sector half-length
0045   double sectorDeltaPhi_B;          // Sector B phi width [A=C=0.5*(360/sectors)]
0046   vector<double> sectorStartPhi;    // Starting phi for the service sectors
0047   vector<string> sectorMaterial_A;  // Material for the A sectors
0048   vector<string> sectorMaterial_B;  // Material for the B sectors
0049   vector<string> sectorMaterial_C;  // Material for the C sectors
0050 };
0051 
0052 DDTOBAxCableAlgo::DDTOBAxCableAlgo() : sectorRin(0), sectorRout(0), sectorDeltaPhi_B(0) {
0053   LogDebug("TOBGeom") << "DDTOBAxCableAlgo info: Creating an instance";
0054 }
0055 
0056 DDTOBAxCableAlgo::~DDTOBAxCableAlgo() {}
0057 
0058 void DDTOBAxCableAlgo::initialize(const DDNumericArguments& nArgs,
0059                                   const DDVectorArguments& vArgs,
0060                                   const DDMapArguments&,
0061                                   const DDStringArguments& sArgs,
0062                                   const DDStringVectorArguments& vsArgs) {
0063   idNameSpace = DDCurrentNamespace::ns();
0064   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Parent " << parent().name() << " NameSpace " << idNameSpace;
0065 
0066   sectorNumber = vsArgs["SectorNumber"];
0067   sectorRin = nArgs["SectorRin"];
0068   sectorRout = nArgs["SectorRout"];
0069   sectorDz = nArgs["SectorDz"];
0070   sectorDeltaPhi_B = nArgs["SectorDeltaPhi_B"];
0071   sectorStartPhi = vArgs["SectorStartPhi"];
0072   sectorMaterial_A = vsArgs["SectorMaterial_A"];
0073   sectorMaterial_B = vsArgs["SectorMaterial_B"];
0074   sectorMaterial_C = vsArgs["SectorMaterial_C"];
0075 
0076   for (int i = 0; i < (int)(sectorNumber.size()); i++)
0077     LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i << "] = " << sectorNumber[i];
0078 
0079   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz << "\tRin "
0080                       << sectorRin << "\tRout = " << sectorRout << "\tPhi of sectors position:";
0081   for (int i = 0; i < (int)(sectorNumber.size()); i++)
0082     LogDebug("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i];
0083   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts";
0084   //
0085   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A";
0086   for (int i = 0; i < (int)(sectorNumber.size()); i++)
0087     LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i];
0088   //
0089   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B";
0090   for (int i = 0; i < (int)(sectorNumber.size()); i++)
0091     LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i];
0092   //
0093   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C";
0094   for (int i = 0; i < (int)(sectorNumber.size()); i++)
0095     LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i];
0096 }
0097 
0098 void DDTOBAxCableAlgo::execute(DDCompactView& cpv) {
0099   LogDebug("TOBGeom") << "==>> Constructing DDTOBAxCableAlgo...";
0100   DDName tubsName(parent().name());
0101 
0102   // Loop over sectors (sectorNumber vector)
0103   for (int i = 0; i < (int)(sectorNumber.size()); i++) {
0104     DDSolid solid;
0105     string name;
0106     double dz, rin, rout, startphi, widthphi, deltaphi;
0107 
0108     // Axial Services
0109     // Each sector is divided in 3 parts from phi[i] to phi[i+1]
0110 
0111     widthphi = ((i + 1 == (int)(sectorStartPhi.size())) ? (sectorStartPhi[0] + CLHEP::twopi) - sectorStartPhi[i]
0112                                                         : (sectorStartPhi[i + 1] - sectorStartPhi[i]));
0113 
0114     // First Part: A
0115     name = "TOBAxService_" + sectorNumber[i] + "A";
0116     dz = sectorDz;
0117     rin = sectorRin;
0118     rout = sectorRout;
0119     startphi = sectorStartPhi[i];
0120     deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
0121 
0122     solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, startphi, deltaphi);
0123 
0124     LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of "
0125                         << sectorMaterial_A[i] << " from " << startphi / CLHEP::deg << " to "
0126                         << (startphi + deltaphi) / CLHEP::deg << " with Rin " << rin << " Rout " << rout << " ZHalf "
0127                         << dz;
0128 
0129     DDName sectorMatName(DDSplit(sectorMaterial_A[i]).first, DDSplit(sectorMaterial_A[i]).second);
0130     DDMaterial sectorMatter(sectorMatName);
0131     DDLogicalPart sectorLogic(DDName(name, idNameSpace), sectorMatter, solid);
0132 
0133     cpv.position(DDName(name, idNameSpace), tubsName, i + 1, DDTranslation(), DDRotation());
0134     LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0135                         << " positioned in " << tubsName << " with no translation and no rotation";
0136 
0137     // Second Part: B
0138     name = "TOBAxService_" + sectorNumber[i] + "B";
0139     startphi += deltaphi;
0140     deltaphi = sectorDeltaPhi_B;
0141 
0142     solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, startphi, deltaphi);
0143 
0144     LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of "
0145                         << sectorMaterial_B[i] << " from " << startphi / CLHEP::deg << " to "
0146                         << (startphi + deltaphi) / CLHEP::deg << " with Rin " << rin << " Rout " << rout << " ZHalf "
0147                         << dz;
0148 
0149     sectorMatName = DDName(DDSplit(sectorMaterial_B[i]).first, DDSplit(sectorMaterial_B[i]).second);
0150     sectorMatter = DDMaterial(sectorMatName);
0151     sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter, solid);
0152 
0153     cpv.position(DDName(name, idNameSpace), tubsName, i + 1, DDTranslation(), DDRotation());
0154     LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0155                         << " positioned in " << tubsName << " with no translation and no rotation";
0156 
0157     // Third Part: C
0158     name = "TOBAxService_" + sectorNumber[i] + "C";
0159     startphi += deltaphi;
0160     deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
0161 
0162     solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, startphi, deltaphi);
0163 
0164     LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of "
0165                         << sectorMaterial_C[i] << " from " << startphi / CLHEP::deg << " to "
0166                         << (startphi + deltaphi) / CLHEP::deg << " with Rin " << rin << " Rout " << rout << " ZHalf "
0167                         << dz;
0168 
0169     sectorMatName = DDName(DDSplit(sectorMaterial_C[i]).first, DDSplit(sectorMaterial_C[i]).second);
0170     sectorMatter = DDMaterial(sectorMatName);
0171     sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter, solid);
0172 
0173     cpv.position(DDName(name, idNameSpace), tubsName, i + 1, DDTranslation(), DDRotation());
0174     LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
0175                         << " positioned in " << tubsName << " with no translation and no rotation";
0176   }
0177 
0178   LogDebug("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ...";
0179 }
0180 
0181 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTOBAxCableAlgo, "track:DDTOBAxCableAlgo");