CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DetectorDescription/Algorithm/src/DDLinear.cc

Go to the documentation of this file.
00001 #include "DetectorDescription/Algorithm/interface/DDLinear.h"
00002 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00003 #include "DetectorDescription/Core/interface/DDSplit.h"
00004 #include "DetectorDescription/Base/interface/DDutils.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00007 
00008 DDLinear::DDLinear( void )
00009   : m_n( 1 ),
00010     m_startCopyNo( 1 ),
00011     m_incrCopyNo( 1 ),
00012     m_theta( 0. ),
00013     m_phi( 0. ),
00014     m_delta( 0. )
00015 {
00016   LogDebug( "DDAlgorithm" ) << "DDLinear: Creating an instance.";
00017 }
00018 
00019 DDLinear::~DDLinear( void ) 
00020 {}
00021 
00022 void
00023 DDLinear::initialize( const DDNumericArguments & nArgs,
00024                       const DDVectorArguments & vArgs,
00025                       const DDMapArguments & ,
00026                       const DDStringArguments & sArgs,
00027                       const DDStringVectorArguments &  )
00028 {
00029   m_n           = int(nArgs["N"]);
00030   m_startCopyNo = int(nArgs["StartCopyNo"]);
00031   m_incrCopyNo  = int(nArgs["IncrCopyNo"]);
00032   m_theta       = nArgs["Theta"];
00033   m_phi         = nArgs["Phi"];
00034   // FIXME: m_offset      = nArgs["Offset"];
00035   m_delta       = nArgs["Delta"];
00036   m_base        = vArgs["Base"];
00037 
00038   LogDebug( "DDAlgorithm" ) << "DDLinear: Parameters for position"
00039                             << "ing:: n " << m_n << " Direction Theta, Phi, Offset, Delta " 
00040                             << m_theta/CLHEP::deg << " " 
00041                             << m_phi/CLHEP::deg << " "
00042     // FIXME: << m_offset/CLHEP::deg
00043                             << " " << m_delta/CLHEP::deg
00044                             << " Base " << m_base[0] 
00045                             << ", " << m_base[1] << ", " << m_base[2];
00046   
00047   m_childNmNs   = DDSplit( sArgs["ChildName"] );
00048   if( m_childNmNs.second.empty())
00049     m_childNmNs.second = DDCurrentNamespace::ns();
00050   
00051   DDName parentName = parent().name();
00052   LogDebug( "DDAlgorithm" ) << "DDLinear: Parent " << parentName 
00053                             << "\tChild " << m_childNmNs.first << " NameSpace "
00054                             << m_childNmNs.second;
00055 }
00056 
00057 void
00058 DDLinear::execute( DDCompactView& cpv )
00059 {
00060   DDName mother = parent().name();
00061   DDName ddname( m_childNmNs.first, m_childNmNs.second );
00062   int    copy   = m_startCopyNo;
00063 
00064   DDTranslation direction( sin( m_theta ) * cos( m_phi ),
00065                            sin( m_theta ) * sin( m_phi ),
00066                            cos( m_theta ));
00067                  
00068   DDTranslation basetr( m_base[0],
00069                         m_base[1],
00070                         m_base[2] );                      
00071                             
00072   DDRotation rotation = DDRotation( "IdentityRotation" );
00073   if( !rotation )
00074   {
00075     LogDebug( "DDAlgorithm" ) << "DDLinear: Creating a new "
00076                               << "rotation: IdentityRotation for " << ddname;
00077         
00078     rotation = DDrot( "IdentityRotation", new DDRotationMatrix());
00079   }
00080   
00081   for( int i = 0; i < m_n; ++i )
00082   {
00083     DDTranslation tran = basetr + ( /*m_offset + */ double( copy ) * m_delta ) * direction;           
00084     cpv.position( ddname, mother, copy, tran, rotation );
00085     LogDebug( "DDAlgorithm" ) << "DDLinear: " << m_childNmNs.second << ":" << m_childNmNs.first << " number " 
00086                               << copy << " positioned in " << mother << " at "
00087                               << tran << " with " << rotation;
00088     copy += m_incrCopyNo;
00089   }
00090 }