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.
6 #include "CLHEP/Units/GlobalSystemOfUnits.h"
7 
9  : m_n( 1 ),
10  m_startCopyNo( 1 ),
11  m_incrCopyNo( 1 ),
12  m_startAngle( 0. ),
13  m_rangeAngle( 360*deg ),
14  m_radius( 0. ),
15  m_delta( 0. )
16 {
17  LogDebug( "DDAlgorithm" ) << "DDAngular: Creating an instance.";
18 }
19 
21 {}
22 
23 void
25  const DDVectorArguments & vArgs,
26  const DDMapArguments & ,
27  const DDStringArguments & sArgs,
28  const DDStringVectorArguments & )
29 {
30  m_n = int(nArgs["N"]);
31  m_startCopyNo = int(nArgs["StartCopyNo"]);
32  m_incrCopyNo = int(nArgs["IncrCopyNo"]);
33  m_rangeAngle = nArgs["RangeAngle"];
34  m_startAngle = nArgs["StartAngle"];
35  m_radius = nArgs["Radius"];
36  m_center = vArgs["Center"];
37  m_rotateSolid = vArgs["RotateSolid"];
38 
40 
41  if( fabs( m_rangeAngle - 360.0 * CLHEP::deg ) < 0.001 * CLHEP::deg )
42  {
43  m_delta = m_rangeAngle / double( m_n );
44  }
45  else
46  {
47  if( m_n > 1 )
48  {
49  m_delta = m_rangeAngle / double( m_n - 1 );
50  }
51  else
52  {
53  m_delta = 0.;
54  }
55  }
56 
57  LogDebug( "DDAlgorithm" ) << "DDAngular: Parameters for position"
58  << "ing:: n " << m_n << " Start, Range, Delta "
59  << m_startAngle/CLHEP::deg << " "
60  << m_rangeAngle/CLHEP::deg << " " << m_delta/CLHEP::deg
61  << " Radius " << m_radius << " Centre " << m_center[0]
62  << ", " << m_center[1] << ", " << m_center[2];
63 
64  //======= collect data concerning the rotation of the solid
65  typedef parE_type::mapped_type::size_type sz_type;
66  sz_type sz = m_rotateSolid.size();
67  if( sz%3 )
68  {
69  LogDebug( "DDAlgorithm" ) << "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n"
70  << "\t currently it appears " << sz << " times!\n";
71  }
72  for( sz_type i = 0; i < sz; i += 3 )
73  {
74  if(( m_rotateSolid[i] > 180. * deg ) || ( m_rotateSolid[i] < 0. ))
75  {
76  LogDebug( "DDAlgorithm" ) << "\trotateSolid \'theta\' must be in range [0,180*deg]\n"
77  << "\t currently it is " << m_rotateSolid[i]/deg
78  << "*deg in rotateSolid[" << double(i) << "]!\n";
79  }
81  m_rotateSolid[i + 2] );
82  LogDebug( "DDAlgorithm" ) << " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg;
83  m_solidRot = temp * m_solidRot;
84  }
85 
87 // m_childName = sArgs["ChildName"];
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
list parent
Definition: dbtoconf.py:74
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)
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
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:20
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:8
double m_rangeAngle
Definition: DDAngular.h:29
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Definition: DDAngular.cc:24
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.
int m_startCopyNo
Definition: DDAngular.h:26
double m_startAngle
Definition: DDAngular.h:28
Definition: DDAxes.h:10
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