CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
global_angular_0 Class Reference

#include <global_angular.h>

Inheritance diagram for global_angular_0:
AlgoImpl

Public Member Functions

bool checkParameters ()
 subclass must check the supplied parameters ParE_, ParS_ More...
 
void checkTermination ()
 for algorithms with incr_==0 the algorithm must check whether to terminate More...
 
int copyno () const
 copy-number calculation More...
 
 global_angular_0 (AlgoPos *, std::string label)
 
DDRotationMatrix rotation ()
 subclass must calculate a rotation matrix More...
 
void stream (std::ostream &) const
 
DDTranslation translation ()
 subclass must calculate a translation std::vector More...
 
 ~global_angular_0 ()
 
- Public Member Functions inherited from AlgoImpl
 AlgoImpl (AlgoPos *, std::string label)
 subclass must provide a similar constructor and call this one More...
 

Public Attributes

bool alignSolid_
 
std::vector< double > center_
 
double delta_
 
int incrCopyNo_
 
int n_
 
DDRotationMatrix planeRot_
 
double radius_
 
double rangeAngle_
 
std::vector< double > rotate_
 
std::vector< double > rotateSolid_
 
DDRotationMatrix solidRot_
 
double startAngle_
 
int startCopyNo_
 

Additional Inherited Members

- Protected Member Functions inherited from AlgoImpl
void terminate ()
 stop the current iteration of the algorithm (for incr_==0 types of algorithms) More...
 
virtual ~AlgoImpl ()
 
- Static Protected Member Functions inherited from AlgoImpl
static std::string d2s (double x)
 ahh, converts a double into a std::string ... yet another one of this kind! More...
 
- Protected Attributes inherited from AlgoImpl
const int & count_
 
const int & curr_
 
const int & end_
 
std::string & err_
 
const int & incr_
 
std::string label_
 
parE_typeParE_
 
parS_typeParS_
 
const int & start_
 
bool & terminate_
 

Detailed Description

theta, phi, angle ... axis of rotation. Object will be placed in a plane going through the origin having the axis (theta,phi) perpendicular to itself. startAngle, rangeAngle ... position rotated object starting at startAngle going to startAngle+rangeAngle. startAngle = 0 denotes the x-axis in the local frame in case of (phi=0 and theta=0), otherwise it denotes the

Definition at line 36 of file global_angular.h.

Constructor & Destructor Documentation

global_angular_0::global_angular_0 ( AlgoPos a,
std::string  label 
)

Definition at line 20 of file global_angular.cc.

References DCOUT.

21  : AlgoImpl( a, label ),
22  rotate_( 0 ),
23  center_( 3 ),
24  rotateSolid_( 0 ),
25  alignSolid_( true ),
26  n_( 1 ),
27  startCopyNo_( 1 ),
28  incrCopyNo_( 1 ),
29  startAngle_( 0 ),
30  rangeAngle_( 360.*deg ),
31  radius_( 0. ),
32  delta_( 0. )
33 {
34  DCOUT('A', "Creating angular label=" << label);
35 }
std::vector< double > rotateSolid_
std::vector< double > rotate_
std::vector< double > center_
AlgoImpl(AlgoPos *, std::string label)
subclass must provide a similar constructor and call this one
Definition: AlgoImpl.cc:6
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
global_angular_0::~global_angular_0 ( )

Definition at line 37 of file global_angular.cc.

38 { }

Member Function Documentation

bool global_angular_0::checkParameters ( )
virtual

subclass must check the supplied parameters ParE_, ParS_

whether they are correct and should select this paricular algorithm.

If the parameters are correct by should not select this particular algorithm, checkParamters must return false otherwise true.

The std::string err_ is to be used to be extended with error information in case any errors have been detected. Error information must be attached to err_ because of the possibility of already contained error information.

In case of errors: If an DDException is thrown by the algorithm implementation, further processing of any other implementations of the algorithm will be stopped. If no exception is thrown, checkParamters must return false. It's preferable not to throw an exception in case of errors. The algorithm implementation will throw if all checkParamters() of all registered algorithm implementations have returned false.

Implements AlgoImpl.

Definition at line 49 of file global_angular.cc.

References alignSolid_, center_, AlgoImpl::d2s(), DCOUT, delta_, AlgoImpl::err_, fUnitVector(), i, incrCopyNo_, n_, AlgoImpl::ParE_, AlgoImpl::ParS_, planeRot_, radius_, rangeAngle_, query::result, rotate_, rotateSolid_, solidRot_, startAngle_, startCopyNo_, and groupFilesInBlocks::temp.

50 {
51  bool result = true;
52 
55 
56  radius_ = ParE_["radius"][0];
57 
58  startAngle_ = ParE_["startAngle"][0];
59  rangeAngle_ = ParE_["rangeAngle"][0];
60  n_ = int(ParE_["n"][0]);
61  startCopyNo_ = int(ParE_["startCopyNo"][0]);
62  incrCopyNo_ = int(ParE_["incrCopyNo"][0]);
63 
64  if (fabs(rangeAngle_-360.0*deg)<0.001*deg) { // a full 360deg range
65  delta_ = rangeAngle_/double(n_);
66  }
67  else {
68  if (n_ > 1) {
69  delta_ = rangeAngle_/double(n_-1);
70  }
71  else {
72  delta_ = 0.;
73  }
74  }
75 
76  DCOUT('a', " startA=" << startAngle_/deg << " rangeA=" << rangeAngle_/deg <<
77  " n=" << n_ << " delta=" << delta_/deg);
78 
79  //======= collect data concerning the rotation of the solid
80  typedef parE_type::mapped_type::size_type sz_type;
81  sz_type sz = ParE_["rotateSolid"].size();
82  rotateSolid_.clear();
83  rotateSolid_.resize(sz);
84  if (sz%3) {
85  err_ += "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n";
86  err_ += "\t currently it appears " + d2s(sz) + " times!\n";
87  result = false;
88  }
89  for (sz_type i=0; i<sz; ++i) {
90  rotateSolid_[i] = ParE_["rotateSolid"][i];
91  }
92  for (sz_type i=0; i<sz; i += 3 ) {
93  if ( (rotateSolid_[i] > 180.*deg) || (rotateSolid_[i] < 0.) ) {
94  err_ += "\trotateSolid \'theta\' must be in range [0,180*deg]\n";
95  err_ += "\t currently it is " + d2s(rotateSolid_[i]/deg)
96  + "*deg in rotateSolid[" + d2s(double(i)) + "]!\n";
97  result = false;
98  }
100  rotateSolid_[i+2]);
101  DCOUT('a', " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
103  }
104  // DCOUT('a', " rotsolid axis=" << solidRot_.getAxis() << " rot.angle=" << solidRot_.delta()/deg);
105 
106 
107  //======== collect data concerning the rotation of the x-y plane
108  sz = ParE_["rotate"].size();
109  rotate_.clear();
110  rotate_.resize(sz);
111  if (sz%3) {
112  err_ += "\trotate must occur 3*n times (defining n subsequent rotations)\n";
113  err_ += "\t currently it appears " + d2s(sz) + " times!\n";
114  result = false;
115  }
116  for (sz_type i=0; i<sz; ++i) {
117  rotate_[i] = ParE_["rotate"][i];
118  }
119  for (sz_type i=0; i<sz; i += 3 ) {
120  if ( (rotate_[i] > 180.*deg) || (rotate_[i] < 0) ) {
121  err_ += "\trotate \'theta\' must be in range [0,180*deg]\n";
122  err_ += "\t currently it is " + d2s(rotate_[i]/deg)
123  + "*deg in rotate[" + d2s(double(i)) + "]!\n";
124  result = false;
125  }
127  rotateSolid_[i+2]);
128  DCOUT('a', " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
129  planeRot_ = planeRot_*temp;
130  }
131  // DCOUT('a', " rotplane axis=" << planeRot_.getAxis() << " rot.angle=" << planeRot_.delta()/deg);
132 
133  center_[0] = ParE_["center"][0];
134  center_[1] = ParE_["center"][1];
135  center_[2] = ParE_["center"][2];
136 
137  if (ParS_["alignSolid"][0] != "T") {
138  DCOUT('a', " alignSolid = false");
139  alignSolid_ = false;
140  }
141  else {
142  alignSolid_ = true;
143  }
144 
145  return result;
146 }
int i
Definition: DBlmapReader.cc:9
DDRotationMatrix planeRot_
std::vector< double > rotateSolid_
parE_type & ParE_
Definition: AlgoImpl.h:113
uint16_t size_type
std::string & err_
Definition: AlgoImpl.h:120
tuple result
Definition: query.py:137
DD3Vector fUnitVector(double theta, double phi)
static std::string d2s(double x)
ahh, converts a double into a std::string ... yet another one of this kind!
Definition: AlgoImpl.cc:40
std::vector< double > rotate_
std::vector< double > center_
parS_type & ParS_
Definition: AlgoImpl.h:112
DDRotationMatrix solidRot_
ROOT::Math::AxisAngle DDAxisAngle
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
void global_angular_0::checkTermination ( void  )
virtual

for algorithms with incr_==0 the algorithm must check whether to terminate

Overload this function in case the algorithm is a 'incr_==0' type. In this case provide some code which checks using perhaps the value of count_ and/or supplied algorithm parameters to check whether terminate() has to be called or not. If terminate() is called, the current iteration of the algorithm is not taken into account!

The default implementation will immidiately terminate the algorithm in case incr_==0.

In case of incr_!=0: checkTermination() is not called at all; the algorithm will terminate automatically when the specified range [start_, end_, incr_] has been covered or terminate() has been called from within translation() or rotation().

Reimplemented from AlgoImpl.

Definition at line 200 of file global_angular.cc.

References AlgoImpl::count_, n_, and AlgoImpl::terminate().

201 {
202  if ( (n_-count_) == -1 ) terminate();
203 }
const int & count_
Definition: AlgoImpl.h:118
void terminate()
stop the current iteration of the algorithm (for incr_==0 types of algorithms)
Definition: AlgoImpl.cc:28
int global_angular_0::copyno ( void  ) const
virtual

copy-number calculation

In case incr_==0 it makes sense to overload this method, otherwise the invocation-count count_ will be returned as copy-number

If incr_ !=0 the copy-number will be curr_, the actual position in the range [start_,end_,incr_], unless this methods is overloaded.

Reimplemented from AlgoImpl.

Definition at line 189 of file global_angular.cc.

References AlgoImpl::copyno(), incrCopyNo_, and startCopyNo_.

190 {
191  // for the moment rely on the automatic copy-number generation
192  // ( copy-no == invocation count count_ )
193  int factor = AlgoImpl::copyno() - 1;
194  return startCopyNo_ + factor*incrCopyNo_;
195 }
virtual int copyno() const
copy-number calculation
Definition: AlgoImpl.cc:22
DDRotationMatrix global_angular_0::rotation ( )
virtual

subclass must calculate a rotation matrix

depending on the current position curr_ in the range [start_,end_,incr_] and the user supplied parameters ParE_, ParS_

Implements AlgoImpl.

Definition at line 167 of file global_angular.cc.

References alignSolid_, angle(), AlgoImpl::count_, delta_, planeRot_, diffTwoXMLs::r2, makeMuonMisalignmentScenario::rot, rotate_, solidRot_, and startAngle_.

168 {
169  //your code here
171 
172  if (alignSolid_) { // rotate the solid as well
173  double angle = startAngle_+ double(count_-1)*delta_;
174  ROOT::Math::RotationZ r2(angle);
175  rot = r2*rot;
176  }
177  // DCOUT('A', " rot.axis=" << rot.getAxis() << " rot.angle=" << rot.delta()/deg);
178 
179  if (rotate_[2]!=0) {
180  rot = planeRot_*rot;
181  //rot = rot*planeRot_.inverse();
182  //rot = planeRot_.inverse()*rot;
183  }
184 
185  return rot;
186 }
DDRotationMatrix planeRot_
const int & count_
Definition: AlgoImpl.h:118
std::vector< double > rotate_
DDRotationMatrix solidRot_
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
void global_angular_0::stream ( std::ostream &  os) const

Definition at line 206 of file global_angular.cc.

207 {
208  os << "global_angular_0::stream(): not implemented.";
209 }
DDTranslation global_angular_0::translation ( )
virtual

subclass must calculate a translation std::vector

depending on the current position curr_ in the range [start_,end_,incr_] and the user supplied parameters ParE_, ParS_

Implements AlgoImpl.

Definition at line 149 of file global_angular.cc.

References angle(), center_, AlgoImpl::count_, DCOUT, delta_, fUnitVector(), planeRot_, radius_, rotate_, startAngle_, and findQualityFiles::v.

150 {
151  double angle = startAngle_+ double(count_-1)*delta_;
152 
153  DD3Vector v = fUnitVector(90*deg,angle)*radius_ ;
154 
155  if (rotate_[2]!=0) {
156  //v = planeRot_.inverse()*v;
157  v = planeRot_*v;
158  }
159 
160  v += DD3Vector(center_[0], center_[1], center_[2]); // offset
161 
162  DCOUT('A', " angle=" << angle/deg << " translation=" << v << " count_=" << count_);
163  return v;
164 }
DDRotationMatrix planeRot_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
const int & count_
Definition: AlgoImpl.h:118
DD3Vector fUnitVector(double theta, double phi)
std::vector< double > rotate_
std::vector< double > center_
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

Member Data Documentation

bool global_angular_0::alignSolid_

Definition at line 55 of file global_angular.h.

Referenced by checkParameters(), and rotation().

std::vector<double> global_angular_0::center_

Definition at line 54 of file global_angular.h.

Referenced by checkParameters(), and translation().

double global_angular_0::delta_

Definition at line 58 of file global_angular.h.

Referenced by checkParameters(), rotation(), and translation().

int global_angular_0::incrCopyNo_

Definition at line 56 of file global_angular.h.

Referenced by checkParameters(), and copyno().

int global_angular_0::n_

Definition at line 56 of file global_angular.h.

Referenced by checkParameters(), and checkTermination().

DDRotationMatrix global_angular_0::planeRot_

Definition at line 60 of file global_angular.h.

Referenced by checkParameters(), rotation(), and translation().

double global_angular_0::radius_

Definition at line 57 of file global_angular.h.

Referenced by checkParameters(), and translation().

double global_angular_0::rangeAngle_

Definition at line 57 of file global_angular.h.

Referenced by checkParameters().

std::vector<double> global_angular_0::rotate_

Definition at line 54 of file global_angular.h.

Referenced by checkParameters(), rotation(), and translation().

std::vector<double> global_angular_0::rotateSolid_

Definition at line 54 of file global_angular.h.

Referenced by checkParameters().

DDRotationMatrix global_angular_0::solidRot_

Definition at line 59 of file global_angular.h.

Referenced by checkParameters(), and rotation().

double global_angular_0::startAngle_

Definition at line 57 of file global_angular.h.

Referenced by checkParameters(), rotation(), and translation().

int global_angular_0::startCopyNo_

Definition at line 56 of file global_angular.h.

Referenced by checkParameters(), and copyno().