Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-24 09:25:08

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   Volume         mother     = ns.volume(args.parentName());
0034   vector<string> moduleName = args.value<vector<string> >("ModuleName"); //Name of the module
0035   string         iccName    = args.value<string>("ICCName");             //Name of the ICC
0036   int            number     = args.value<int>("Number");                 //Number of copies
0037   double         startAngle = args.value<double>("StartAngle");          //Phi offset
0038   double         rModule    = args.value<double>("ModuleR");             //Location of module in R 
0039   vector<double> zModule    = args.value<vector<double> >("ModuleZ");     //                   in Z
0040   double         rICC       = args.value<double>("ICCR");                //Location of ICC    in R 
0041   double         sICC       = args.value<double>("ICCShift");            //Shift of ICC       per to R
0042   vector<double> zICC       = args.value<vector<double> >("ICCZ");        //                   in Z
0043 
0044   LogDebug("TIDGeom") << "Parent " << mother.name() 
0045                       << "\tModule " << moduleName[0] << ", "
0046                       << moduleName[1] << "\tICC " << iccName 
0047                       << "\tNameSpace " << ns.name;
0048   LogDebug("TIDGeom") << "Parameters for positioning--"
0049                       << " StartAngle " << startAngle/CLHEP::deg
0050                       << " Copy Numbers " << number << " Modules at R " 
0051                       << rModule << " Z " << zModule[0] << ", " << zModule[1] 
0052                       << " ICCs at R " << rICC << " Z " << zICC[0] << ", " 
0053                       << zICC[1]; 
0054   double theta = 90.*CLHEP::deg;
0055   double phiy  = 0.*CLHEP::deg;
0056   double dphi  = CLHEP::twopi/number;
0057 
0058   //Loop over modules
0059   Volume icc  = ns.volume(iccName);
0060   Volume mod0 = ns.volume(moduleName[0]);
0061   Volume mod1 = ns.volume(moduleName[1]);
0062   for (int i=0; i<number; i++) {
0063     //First the module
0064     double phiz = startAngle + i*dphi;
0065     double xpos = rModule*cos(phiz);
0066     double ypos = rModule*sin(phiz);
0067     double zpos, thetay, phix;
0068     Volume module;
0069     if (i%2 == 0) {
0070       phix   = phiz + 90.*CLHEP::deg;
0071       thetay = 0*CLHEP::deg;
0072       zpos   = zModule[0];
0073       module = mod0;
0074     } else {
0075       phix   = phiz - 90.*CLHEP::deg;
0076       thetay = 180*CLHEP::deg;
0077       zpos   = zModule[1];
0078       module = mod1;
0079     }
0080     
0081     // stereo face inside toward structure, rphi face outside
0082     phix   = phix   - 180.*CLHEP::deg;
0083     thetay = thetay + 180.*CLHEP::deg;
0084     //
0085     Position    trmod(xpos, ypos, zpos);
0086     Rotation3D  rotation = make_rotation3D(theta, phix, thetay, phiy, theta, phiz);
0087     // int copyNr = i+1;
0088     /* PlacedVolume pv = */ mother.placeVolume(module, i+1, Transform3D(rotation,trmod));
0089     LogDebug("TIDGeom") << module.name() << " number "
0090                         << i+1 << " positioned in " << mother.name() << " at "
0091                         << trmod << " with " << rotation;
0092     //Now the ICC
0093     if (i%2 == 0 ) {
0094       zpos = zICC[0];
0095       xpos = rICC*cos(phiz) + sICC*sin(phiz);
0096       ypos = rICC*sin(phiz) - sICC*cos(phiz);
0097     } else {
0098       zpos = zICC[1];
0099       xpos = rICC*cos(phiz) - sICC*sin(phiz);
0100       ypos = rICC*sin(phiz) + sICC*cos(phiz);
0101     }
0102     // int copyNr = i+1;
0103     Position tricc(xpos, ypos, zpos);
0104     /* PlacedVolume pv = */ mother.placeVolume(icc, i+1, Transform3D(rotation,tricc));
0105     LogDebug("TIDGeom") << iccName << " number " 
0106                         << i+1 << " positioned in " << mother.name() << " at "
0107                         << tricc << " with " << rotation;
0108   }
0109   return 1;
0110 }
0111 
0112 // first argument is the type from the xml file
0113 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDRingAlgo,algorithm)