Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/examples/DDCMS/src/plugins/DDTrackerPhiAltAlgo.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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   Volume        child       = ns.volume(args.childName());
0035   double        tilt        = args.value<double>("Tilt");        //Tilt of the module
0036   double        startAngle  = args.value<double>("StartAngle");  //offset in phi
0037   double        rangeAngle  = args.value<double>("RangeAngle");  //Maximum range in phi
0038   double        radiusIn    = args.value<double>("RadiusIn");    //Inner radius
0039   double        radiusOut   = args.value<double>("RadiusOut");   //Outer radius
0040   double        zpos        = args.value<double>("ZPosition");   //z position
0041   int           number      = args.value<int>("Number");         //Number of copies
0042   int           startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number
0043   int           incrCopyNo  = args.find("IncrCopyNo")  ? args.value<int>("IncrCopyNo")  : 1; //Increment in copy number
0044 
0045   LogDebug("TrackerGeom") << "Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name;
0046   LogDebug("TrackerGeom") << "Parameters for positioning-- Tilt " << tilt 
0047                           << "\tStartAngle " << startAngle/CLHEP::deg 
0048                           << "\tRangeAngle " << rangeAngle/CLHEP::deg 
0049                           << "\tRin " << radiusIn << "\tRout " << radiusOut 
0050                           << "\t ZPos " << zpos << "\tCopy Numbers " << number 
0051                           << " Start/Increment " << startCopyNo << ", " 
0052                           << incrCopyNo;
0053 
0054   if (number > 0) {
0055     double theta  = 90.*CLHEP::deg;
0056     double dphi;
0057     if (number == 1 || fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) 
0058       dphi = rangeAngle/number;
0059     else
0060       dphi = rangeAngle/(number-1);
0061     int copyNo = startCopyNo;
0062 
0063     for (int i=0; i<number; i++) {
0064       double phi  = startAngle + i*dphi;
0065       double phix = phi - tilt + 90.*CLHEP::deg;
0066       double phiy = phix + 90.*CLHEP::deg;
0067       double phideg = phix/CLHEP::deg;
0068   
0069       Rotation3D rotation;
0070       if (phideg != 0) {
0071         rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0072       }
0073     
0074       double xpos, ypos;
0075       if (i%2 == 0) {
0076         xpos = radiusIn*cos(phi);
0077         ypos = radiusIn*sin(phi);
0078       } else {
0079         xpos = radiusOut*cos(phi);
0080         ypos = radiusOut*sin(phi);
0081       }
0082       Position tran(xpos, ypos, zpos);  
0083       /* PlacedVolume pv = */ mother.placeVolume(child,copyNo,Transform3D(rotation,tran));
0084       LogDebug("TrackerGeom") << "" << child.name() 
0085                               << " number " << copyNo << " positioned in " 
0086                               << mother.name() << " at " << tran << " with " 
0087                               << rotation;
0088       copyNo += incrCopyNo;
0089     }
0090   }
0091   return 1;
0092 }
0093 
0094 // first argument is the type from the xml file
0095 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAltAlgo,algorithm)
0096