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