Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/examples/DDCMS/src/plugins/DDTrackerXYZPosAlgo.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   int            startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0034   int            incrCopyNo  = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
0035   Volume         mother      = ns.volume(args.parentName());
0036   Volume         child       = ns.volume(args.value<string>("ChildName"));
0037   vector<double> xvec        = args.value<vector<double> >("XPositions");    // X positions
0038   vector<double> yvec        = args.value<vector<double> >("YPositions");    // Y positions
0039   vector<double> zvec        = args.value<vector<double> >("ZPositions");    // Z positions
0040   vector<string> rotMat      = args.value<vector<string> >("Rotations");   // Names of rotation matrices
0041 
0042   LogDebug("TrackerGeom") << "debug: Parent " << mother.name() 
0043                           << "\tChild " << child.name() << " NameSpace " 
0044                           << ns.name << "\tCopyNo (Start/Increment) " 
0045                           << startCopyNo << ", " << incrCopyNo << "\tNumber " 
0046                           << xvec.size() << ", " << yvec.size() << ", " << zvec.size();
0047   for (int i = 0; i < (int)(zvec.size()); i++) {
0048     LogDebug("TrackerGeom") << "\t[" << i << "]\tX = " << xvec[i]
0049                             << "\t[" << i << "]\tY = " << yvec[i] 
0050                             << "\t[" << i << "]\tZ = " << zvec[i] 
0051                             << ", Rot.Matrix = " << rotMat[i];
0052   }
0053 
0054   for (int i=0, copy = startCopyNo; i<(int)(zvec.size()); i++, copy += incrCopyNo) {
0055     Position tran(xvec[i], yvec[i], zvec[i]);
0056     Rotation3D rot;
0057     /* PlacedVolume pv = */ rotMat[i] != "NULL"
0058       ? mother.placeVolume(child,copy,Transform3D(ns.rotation(rotMat[i]),tran))
0059       : mother.placeVolume(child,tran);
0060     LogDebug("TrackerGeom") << "test: " << child.name() 
0061                             <<" number " << copy << " positioned in " 
0062                             << mother.name() << " at " << tran << " with " << rot;
0063   }
0064   return 1;
0065 }
0066 
0067 // first argument is the type from the xml file
0068 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerXYZPosAlgo,algorithm)