File indexing completed on 2024-04-06 12:15:22
0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include "DataFormats/Math/interface/CMSUnits.h"
0003 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005
0006 using namespace std;
0007 using namespace dd4hep;
0008 using namespace cms;
0009 using namespace cms_units::operators;
0010
0011 static long algorithm(Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0012 cms::DDNamespace ns(ctxt, e, true);
0013 DDAlgoArguments args(ctxt, e);
0014 vector<string> sectorNumber = args.vecStr("SectorNumber");
0015 double sectorRin = args.dble("SectorRin");
0016 double sectorRout = args.dble("SectorRout");
0017 double sectorDz = args.dble("SectorDz");
0018 double sectorDeltaPhi_B = args.dble("SectorDeltaPhi_B");
0019 vector<double> sectorStartPhi = args.vecDble("SectorStartPhi");
0020 vector<string> sectorMaterial_A = args.vecStr("SectorMaterial_A");
0021 vector<string> sectorMaterial_B = args.vecStr("SectorMaterial_B");
0022 vector<string> sectorMaterial_C = args.vecStr("SectorMaterial_C");
0023
0024 for (int i = 0; i < (int)(sectorNumber.size()); i++)
0025 edm::LogVerbatim("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i << "] = " << sectorNumber[i];
0026
0027 edm::LogVerbatim("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz << "\tRin "
0028 << sectorRin << "\tRout = " << sectorRout << "\tPhi of sectors position:";
0029 for (int i = 0; i < (int)(sectorNumber.size()); i++)
0030 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i];
0031 edm::LogVerbatim("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts";
0032
0033 edm::LogVerbatim("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A";
0034 for (int i = 0; i < (int)(sectorNumber.size()); i++)
0035 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i];
0036
0037 edm::LogVerbatim("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B";
0038 for (int i = 0; i < (int)(sectorNumber.size()); i++)
0039 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i];
0040
0041 edm::LogVerbatim("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C";
0042 for (int i = 0; i < (int)(sectorNumber.size()); i++)
0043 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i];
0044
0045 string tubsName = args.parentName();
0046 Volume tubsVol = ns.volume(tubsName);
0047
0048 for (int i = 0; i < (int)(sectorNumber.size()); i++) {
0049 Solid solid;
0050 string name;
0051 double dz, rin, rout, startphi, widthphi, deltaphi;
0052
0053
0054
0055
0056 widthphi = ((i + 1 == (int)(sectorStartPhi.size())) ? (sectorStartPhi[0] + 2_pi) - sectorStartPhi[i]
0057 : (sectorStartPhi[i + 1] - sectorStartPhi[i]));
0058
0059 name = "TOBAxService_" + sectorNumber[i] + "A";
0060 dz = sectorDz;
0061 rin = sectorRin;
0062 rout = sectorRout;
0063 startphi = sectorStartPhi[i];
0064 deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
0065 solid = ns.addSolid(ns.prepend(name), Tube(rin, rout, dz, startphi, startphi + deltaphi));
0066 edm::LogVerbatim("TOBGeom") << solid.name() << " Tubs made of " << sectorMaterial_A[i] << " from "
0067 << convertRadToDeg(startphi) << " to " << convertRadToDeg((startphi + deltaphi))
0068 << " with Rin " << rin << " Rout " << rout << " ZHalf " << dz;
0069 Volume sectorLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(sectorMaterial_A[i])));
0070 tubsVol.placeVolume(sectorLogic, i + 1);
0071 edm::LogVerbatim("TOBGeom") << sectorLogic.name() << " number " << i + 1 << " positioned in " << tubsName
0072 << " with no translation and no rotation";
0073
0074
0075 name = "TOBAxService_" + sectorNumber[i] + "B";
0076 startphi += deltaphi;
0077 deltaphi = sectorDeltaPhi_B;
0078 solid = ns.addSolid(ns.prepend(name), Tube(rin, rout, dz, startphi, startphi + deltaphi));
0079 edm::LogVerbatim("TOBGeom") << solid.name() << " Tubs made of " << sectorMaterial_B[i] << " from "
0080 << convertRadToDeg(startphi) << " to " << convertRadToDeg((startphi + deltaphi))
0081 << " with Rin " << rin << " Rout " << rout << " ZHalf " << dz;
0082
0083 sectorLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(sectorMaterial_B[i])));
0084 tubsVol.placeVolume(sectorLogic, i + 1);
0085 edm::LogVerbatim("TOBGeom") << sectorLogic.name() << " number " << i + 1 << " positioned in " << tubsName
0086 << " with no translation and no rotation";
0087
0088
0089 name = "TOBAxService_" + sectorNumber[i] + "C";
0090 startphi += deltaphi;
0091 deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
0092 solid = ns.addSolid(ns.prepend(name), Tube(rin, rout, dz, startphi, startphi + deltaphi));
0093 edm::LogVerbatim("TOBGeom") << solid.name() << " Tubs made of " << sectorMaterial_C[i] << " from "
0094 << convertRadToDeg(startphi) << " to " << convertRadToDeg((startphi + deltaphi))
0095 << " with Rin " << rin << " Rout " << rout << " ZHalf " << dz;
0096 sectorLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(sectorMaterial_C[i])));
0097 tubsVol.placeVolume(sectorLogic, i + 1);
0098 edm::LogVerbatim("TOBGeom") << sectorLogic.name() << " number " << i + 1 << " positioned in " << tubsName
0099 << " with no translation and no rotation";
0100 }
0101 edm::LogVerbatim("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ...";
0102 return 1;
0103 }
0104
0105
0106 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBAxCableAlgo, algorithm)