CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDAngular.cc
Go to the documentation of this file.
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 
10  : m_n( 1 ),
11  m_startCopyNo( 1 ),
12  m_incrCopyNo( 1 ),
13  m_startAngle( 0. ),
14  m_rangeAngle( 360*deg ),
15  m_radius( 0. ),
16  m_delta( 0. )
17 {
18  LogDebug( "DDAlgorithm" ) << "DDAngular: Creating an instance.";
19 }
20 
22 {}
23 
24 void
26  const DDVectorArguments & vArgs,
27  const DDMapArguments & ,
28  const DDStringArguments & sArgs,
29  const DDStringVectorArguments & )
30 {
31  m_n = int(nArgs["N"]);
32  m_startCopyNo = int(nArgs["StartCopyNo"]);
33  m_incrCopyNo = int(nArgs["IncrCopyNo"]);
34  m_rangeAngle = nArgs["RangeAngle"];
35  m_startAngle = nArgs["StartAngle"];
36  m_radius = nArgs["Radius"];
37  m_center = vArgs["Center"];
38  m_rotateSolid = vArgs["RotateSolid"];
39 
41 
42  if( fabs( m_rangeAngle - 360.0 * CLHEP::deg ) < 0.001 * CLHEP::deg )
43  {
44  m_delta = m_rangeAngle / double( m_n );
45  }
46  else
47  {
48  if( m_n > 1 )
49  {
50  m_delta = m_rangeAngle / double( m_n - 1 );
51  }
52  else
53  {
54  m_delta = 0.;
55  }
56  }
57 
58  LogDebug( "DDAlgorithm" ) << "DDAngular: Parameters for position"
59  << "ing:: n " << m_n << " Start, Range, Delta "
60  << m_startAngle/CLHEP::deg << " "
61  << m_rangeAngle/CLHEP::deg << " " << m_delta/CLHEP::deg
62  << " Radius " << m_radius << " Centre " << m_center[0]
63  << ", " << m_center[1] << ", " << m_center[2];
64 
65  //======= collect data concerning the rotation of the solid
66  typedef parE_type::mapped_type::size_type sz_type;
67  sz_type sz = m_rotateSolid.size();
68  if( sz%3 )
69  {
70  LogDebug( "DDAlgorithm" ) << "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n"
71  << "\t currently it appears " << sz << " times!\n";
72  }
73  for( sz_type i = 0; i < sz; i += 3 )
74  {
75  if(( m_rotateSolid[i] > 180. * deg ) || ( m_rotateSolid[i] < 0. ))
76  {
77  LogDebug( "DDAlgorithm" ) << "\trotateSolid \'theta\' must be in range [0,180*deg]\n"
78  << "\t currently it is " << m_rotateSolid[i]/deg
79  << "*deg in rotateSolid[" << double(i) << "]!\n";
80  }
82  m_rotateSolid[i + 2] );
83  LogDebug( "DDAlgorithm" ) << " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg;
84  m_solidRot = temp * m_solidRot;
85  }
86 
88  m_childNmNs = DDSplit( sArgs["ChildName"] );
89  if( m_childNmNs.second.empty())
91 
92  DDName parentName = parent().name();
93  LogDebug( "DDAlgorithm" ) << "DDAngular: Parent " << parentName
94  << "\tChild " << m_childNmNs.first << "\tNameSpace "
95  << m_childNmNs.second;
96 }
97 
98 void
100 {
101  DDName mother = parent().name();
102  DDName ddname( m_childNmNs.first, m_childNmNs.second );
103  double theta = 90.*CLHEP::deg;
104  int copy = m_startCopyNo;
105  double phi = m_startAngle;
106 
107  for( int i = 0; i < m_n; ++i )
108  {
109  double phix = phi;
110  double phiy = phix + 90. * CLHEP::deg;
111  double phideg = phix / CLHEP::deg;
112 
113  std::string rotstr = m_childNmNs.first + "_" + dbl_to_string( phideg * 10.);
115  if( !rotation )
116  {
117  LogDebug( "DDAlgorithm" ) << "DDAngular: Creating a new "
118  << "rotation: " << rotstr << "\t90., "
119  << phix / CLHEP::deg << ", 90.,"
120  << phiy / CLHEP::deg << ", 0, 0";
121 
122  rotation = DDrot( DDName( rotstr, m_idNameSpace ), new DDRotationMatrix(( *DDcreateRotationMatrix( theta, phix, theta, phiy,
123  0., 0. ) * m_solidRot )));
124  }
125 
126  double xpos = m_radius * cos( phi ) + m_center[0];
127  double ypos = m_radius * sin( phi ) + m_center[1];
128  double zpos = m_center[2];
129  DDTranslation tran( xpos, ypos, zpos );
130 
131  cpv.position( ddname, mother, copy, tran, rotation );
132  LogDebug( "DDAlgorithm" ) << "DDAngular: child " << m_childNmNs.second << ":" << m_childNmNs.first << " number "
133  << copy << " positioned in " << mother << " at "
134  << tran << " with " << rotation << "\n";
135  copy += m_incrCopyNo;
136  phi += m_delta;
137  }
138 }
139 
140 DD3Vector
142 {
143  return DD3Vector( cos( phi ) * sin( theta ),
144  sin( phi ) * sin( theta ),
145  cos( theta ));
146 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
double m_radius
Definition: DDAngular.h:30
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
static std::string & ns()
std::string dbl_to_string(const double &in)
Converts only the integer part of a double to a string.
Definition: DDutils.cc:12
DD3Vector fUnitVector(double theta, double phi)
Definition: DDAngular.cc:141
type of data representation of DDCompactView
Definition: DDCompactView.h:77
uint16_t size_type
DDRotationMatrix m_solidRot
Definition: DDAngular.h:39
double m_delta
Definition: DDAngular.h:31
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
virtual ~DDAngular(void)
Definition: DDAngular.cc:21
int m_n
Definition: DDAngular.h:25
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int m_incrCopyNo
Definition: DDAngular.h:27
std::vector< double > m_rotateSolid
Definition: DDAngular.h:33
std::vector< double > m_center
Definition: DDAngular.h:32
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
std::string m_idNameSpace
Definition: DDAngular.h:35
DDAngular(void)
Definition: DDAngular.cc:9
double m_rangeAngle
Definition: DDAngular.h:29
Geom::Phi< T > phi() const
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Definition: DDAngular.cc:25
std::pair< std::string, std::string > m_childNmNs
Definition: DDAngular.h:36
void execute(DDCompactView &cpv)
Definition: DDAngular.cc:99
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
ROOT::Math::AxisAngle DDAxisAngle
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
int m_startCopyNo
Definition: DDAngular.h:26
double m_startAngle
Definition: DDAngular.h:28
DDRotationMatrix * DDcreateRotationMatrix(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
create a new DDRotationMatrix in the GEANT3 style.
Definition: DDRotation.cc:165