Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:06

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 //
0014 // Specialized generic detector constructor
0015 // 
0016 //==========================================================================
0017 
0018 // Framework include files
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DDCMS/DDCMSPlugins.h"
0021 
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::cms;
0025 
0026 static long algorithm(Detector& /* description */,
0027                       ParsingContext& ctxt,
0028                       xml_h e,
0029                       SensitiveDetector& /* sens */)
0030 {
0031   Namespace      ns(ctxt, e, true);
0032   AlgoArguments  args(ctxt, e);
0033   vector<string> sectorNumber = args.vecStr("SectorNumber");         // Id. Number of the sectors
0034   double sectorRin = args.dble("SectorRin");                         // Inner radius of service sectors  
0035   double sectorRout = args.dble("SectorRout");                       // Outer radius of service sectors  
0036   double sectorDz = args.dble("SectorDz");                           // Sector half-length
0037   double sectorDeltaPhi_B = args.dble("SectorDeltaPhi_B");           // Sector B phi width [A=C=0.5*(360/sectors)]
0038   vector<double> sectorStartPhi = args.vecDble("SectorStartPhi");    // Starting phi for the service sectors
0039   vector<string> sectorMaterial_A = args.vecStr("SectorMaterial_A"); // Material for the A sectors
0040   vector<string> sectorMaterial_B = args.vecStr("SectorMaterial_B"); // Material for the B sectors
0041   vector<string> sectorMaterial_C = args.vecStr("SectorMaterial_C"); // Material for the C sectors
0042 
0043 
0044   for (int i=0; i<(int)(sectorNumber.size()); i++)
0045     LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i
0046                         << "] = " << sectorNumber[i];
0047   
0048   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz
0049                       << "\tRin " << sectorRin << "\tRout = " << sectorRout
0050                       << "\tPhi of sectors position:";
0051   for (int i=0; i<(int)(sectorNumber.size()); i++)
0052     LogDebug("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i];
0053   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts";
0054   //
0055   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A";
0056   for (int i=0; i<(int)(sectorNumber.size()); i++)
0057     LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i];
0058   //
0059   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B";
0060   for (int i=0; i<(int)(sectorNumber.size()); i++)
0061     LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i];
0062   //
0063   LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C";
0064   for (int i=0; i<(int)(sectorNumber.size()); i++)
0065     LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i];
0066 
0067   string tubsName = args.parentName();
0068   Volume tubsVol = ns.volume(tubsName);
0069   // Loop over sectors (sectorNumber vector)
0070   for (int i=0; i<(int)(sectorNumber.size()); i++) {    
0071     Solid solid;
0072     string  name;
0073     double  dz, rin, rout, startphi, widthphi, deltaphi;
0074     
0075     // Axial Services
0076     // Each sector is divided in 3 parts from phi[i] to phi[i+1]
0077     
0078     widthphi = ( (i+1 == (int)(sectorStartPhi.size())) ?
0079                  (sectorStartPhi[0]+CLHEP::twopi)-sectorStartPhi[i] :
0080                  (sectorStartPhi[i+1]-sectorStartPhi[i]) );
0081     // First Part: A
0082     name  = "TOBAxService_" + sectorNumber[i] + "A";
0083     dz   = sectorDz;
0084     rin  = sectorRin;
0085     rout = sectorRout;
0086     startphi = sectorStartPhi[i];
0087     deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);    
0088     solid = ns.addSolid(name,Tube(rin, rout, dz, startphi, deltaphi));
0089     LogDebug("TOBGeom") << solid.name() << " Tubs made of " 
0090                         << sectorMaterial_A[i] << " from " 
0091                         << startphi/CLHEP::deg << " to "
0092                         << (startphi+deltaphi)/CLHEP::deg << " with Rin " 
0093                         << rin << " Rout " << rout << " ZHalf " << dz;
0094     Volume sectorLogic = ns.addVolume(Volume(name,solid, ns.material(sectorMaterial_A[i])));
0095     tubsVol.placeVolume(sectorLogic,i+1); // copyNr: i+1
0096     LogDebug("TOBGeom") << sectorLogic.name() << " number " << i+1 
0097                         << " positioned in " << tubsName 
0098                         << " with no translation and no rotation";
0099 
0100     // Second Part: B
0101     name  = "TOBAxService_" + sectorNumber[i] + "B";
0102     startphi += deltaphi;
0103     deltaphi = sectorDeltaPhi_B;
0104     solid = ns.addSolid(name, Tube(rin, rout, dz, startphi, deltaphi));
0105     LogDebug("TOBGeom") << solid.name() << " Tubs made of " 
0106                         << sectorMaterial_B[i] << " from " << startphi/CLHEP::deg
0107                         << " to " << (startphi+deltaphi)/CLHEP::deg
0108                         << " with Rin " << rin << " Rout " << rout 
0109                         << " ZHalf " << dz;
0110     
0111     sectorLogic = ns.addVolume(Volume(name, solid, ns.material(sectorMaterial_B[i])));
0112     tubsVol.placeVolume(sectorLogic,i+1); // copyNr: i+1
0113     LogDebug("TOBGeom") << sectorLogic.name() << " number " << i+1 
0114                         << " positioned in " << tubsName 
0115                         << " with no translation and no rotation";
0116     
0117     // Third Part: C
0118     name  = "TOBAxService_" + sectorNumber[i] + "C";
0119     startphi += deltaphi;
0120     deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);    
0121     solid = ns.addSolid(name,Tube(rin, rout, dz, startphi, deltaphi));
0122     LogDebug("TOBGeom") << solid.name() << " Tubs made of " 
0123                         << sectorMaterial_C[i] << " from " 
0124                         << startphi/CLHEP::deg << " to " 
0125                         << (startphi+deltaphi)/CLHEP::deg << " with Rin " 
0126                         << rin << " Rout " << rout << " ZHalf " << dz;
0127     sectorLogic = ns.addVolume(Volume(name, solid, ns.material(sectorMaterial_C[i])));
0128     tubsVol.placeVolume(sectorLogic,i+1); // copyNr: i+1
0129     LogDebug("TOBGeom") << sectorLogic.name() << " number " << i+1 
0130                         << " positioned in " << tubsName 
0131                         << " with no translation and no rotation";
0132   }
0133   LogDebug("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ...";
0134   return 1;
0135 }
0136 
0137 // first argument is the type from the xml file
0138 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBAxCableAlgo,algorithm)
0139