Back to home page

EIC code displayed by LXR

 
 

    


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

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   int            startCopyNo = args.value<int>("StartCopyNo");
0034   double         rpos        = args.value<double>("Rpos");
0035   double         zpos        = args.value<double>("Zpos");
0036   double         optoHeight  = args.value<double>("OptoHeight");
0037   double         optoWidth   = args.value<double>("OptoWidth");
0038   vector<double> angles      = args.value<vector<double> >("Angles");
0039   Volume         child       = ns.volume(args.value<string>("ChildName"));
0040   Volume         mother      = ns.volume(args.parentName());
0041 
0042   LogDebug("TECGeom") << "Parent " << mother.name()
0043                       << " Child " << child.name() << " NameSpace " << ns.name;
0044   LogDebug("TECGeom") << "Height of the Hybrid "
0045                       << optoHeight << " and Width " << optoWidth
0046                       <<"Rpos " << rpos << " Zpos " << zpos 
0047                       << " StartCopyNo " << startCopyNo << " Number " 
0048                       << angles.size();
0049 
0050   // given r positions are for the lower left corner
0051   rpos += optoHeight/2;
0052   int    copyNo = startCopyNo;
0053   for (double angle : angles) {
0054     double phix = -angle;
0055     // given phi positions are for the lower left corner
0056     phix += asin(optoWidth/2/rpos);
0057     double xpos = rpos * cos(phix);
0058     double ypos = rpos * sin(phix);
0059     Position tran(xpos, ypos, zpos);
0060 
0061     Rotation3D rotation;
0062     double phiy = phix + 90.*CLHEP::deg;
0063     double phideg = phix/CLHEP::deg;
0064     if (phideg != 0) {
0065       string rotstr= ns.ns_name(child.name()) + std::to_string(phideg*1000.);
0066       auto irot = ctxt.rotations.find(ns.prepend(rotstr));
0067       if ( irot != ctxt.rotations.end() )   {
0068         rotation = ns.rotation(ns.prepend(rotstr));
0069       }
0070       else  {
0071         double theta = 90.*CLHEP::deg;
0072         LogDebug("TECGeom") << "test: Creating a new "
0073                             << "rotation: " << rotstr << "\t90., " 
0074                             << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
0075                             << ", 0, 0";
0076         rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0077       }
0078     }
0079     mother.placeVolume(child, copyNo, Transform3D(rotation,tran));
0080     LogDebug("TECGeom") << "test " << child.name() << " number " 
0081                         << copyNo << " positioned in " << mother.name() << " at "
0082                         << tran  << " with " << rotation;
0083     copyNo++;
0084   }
0085   LogDebug("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ...";
0086   return 1;
0087 }
0088 
0089 // first argument is the type from the xml file
0090 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECOptoHybAlgo,algorithm)