CMS 3D CMS Logo

DDLinear.cc
Go to the documentation of this file.
1 #include "DDLinear.h"
2 
3 #include <cmath>
4 
5 #include "CLHEP/Units/GlobalSystemOfUnits.h"
6 #include "CLHEP/Units/SystemOfUnits.h"
16 #include "Math/GenVector/Cartesian3D.h"
17 #include "Math/GenVector/DisplacementVector3D.h"
18 
20  : m_n( 1 ),
21  m_startCopyNo( 1 ),
22  m_incrCopyNo( 1 ),
23  m_theta( 0. ),
24  m_phi( 0. ),
25  m_delta( 0. )
26 {
27  LogDebug( "DDAlgorithm" ) << "DDLinear: Creating an instance.";
28 }
29 
31 {}
32 
33 void
35  const DDVectorArguments & vArgs,
36  const DDMapArguments & ,
37  const DDStringArguments & sArgs,
38  const DDStringVectorArguments & )
39 {
40  m_n = int(nArgs["N"]);
41  m_startCopyNo = int(nArgs["StartCopyNo"]);
42  m_incrCopyNo = int(nArgs["IncrCopyNo"]);
43  m_theta = nArgs["Theta"];
44  m_phi = nArgs["Phi"];
45  // FIXME: m_offset = nArgs["Offset"];
46  m_delta = nArgs["Delta"];
47  m_base = vArgs["Base"];
48 
49  LogDebug( "DDAlgorithm" ) << "DDLinear: Parameters for position"
50  << "ing:: n " << m_n << " Direction Theta, Phi, Offset, Delta "
51  << m_theta/CLHEP::deg << " "
52  << m_phi/CLHEP::deg << " "
53  // FIXME: << m_offset/CLHEP::deg
54  << " " << m_delta/CLHEP::deg
55  << " Base " << m_base[0]
56  << ", " << m_base[1] << ", " << m_base[2];
57 
58  m_childNmNs = DDSplit( sArgs["ChildName"] );
59  if( m_childNmNs.second.empty())
61 
62  DDName parentName = parent().name();
63  LogDebug( "DDAlgorithm" ) << "DDLinear: Parent " << parentName
64  << "\tChild " << m_childNmNs.first << " NameSpace "
65  << m_childNmNs.second;
66 }
67 
68 void
70 {
71  DDName mother = parent().name();
72  DDName ddname( m_childNmNs.first, m_childNmNs.second );
73  int copy = m_startCopyNo;
74 
75  DDTranslation direction( sin( m_theta ) * cos( m_phi ),
76  sin( m_theta ) * sin( m_phi ),
77  cos( m_theta ));
78 
79  DDTranslation basetr( m_base[0],
80  m_base[1],
81  m_base[2] );
82 
83  DDRotation rotation = DDRotation( "IdentityRotation" );
84  if( !rotation )
85  {
86  LogDebug( "DDAlgorithm" ) << "DDLinear: Creating a new "
87  << "rotation: IdentityRotation for " << ddname;
88 
89  rotation = DDrot( "IdentityRotation", new DDRotationMatrix());
90  }
91 
92  for( int i = 0; i < m_n; ++i )
93  {
94  DDTranslation tran = basetr + ( /*m_offset + */ double( copy ) * m_delta ) * direction;
95  cpv.position( ddname, mother, copy, tran, rotation );
96  LogDebug( "DDAlgorithm" ) << "DDLinear: " << m_childNmNs.second << ":" << m_childNmNs.first << " number "
97  << copy << " positioned in " << mother << " at "
98  << tran << " with " << rotation;
99  copy += m_incrCopyNo;
100  }
101 }
#define LogDebug(id)
int m_startCopyNo
Definition: DDLinear.h:29
double m_phi
Definition: DDLinear.h:32
int m_incrCopyNo
Definition: DDLinear.h:30
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
double m_delta
Definition: DDLinear.h:35
static std::string & ns()
void execute(DDCompactView &cpv) override
Definition: DDLinear.cc:69
type of data representation of DDCompactView
Definition: DDCompactView.h:90
std::pair< std::string, std::string > m_childNmNs
Definition: DDLinear.h:38
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
double m_theta
Definition: DDLinear.h:31
DDLinear(void)
Definition: DDLinear.cc:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int m_n
Definition: DDLinear.h:28
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
std::vector< double > m_base
Definition: DDLinear.h:36
~DDLinear(void) override
Definition: DDLinear.cc:30
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDLinear.cc:34
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.