CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDTrackerPhiAlgo.cc
Go to the documentation of this file.
1 // File: DDTrackerPhiAlgo.cc
3 // Description: Position n copies at prescribed phi values
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 #include "CLHEP/Units/GlobalPhysicalConstants.h"
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 
17 
18 DDTrackerPhiAlgo::DDTrackerPhiAlgo() : startcn(1), incrcn(1) {
19  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo info: Creating an instance";
20 }
21 
23 
25  const DDVectorArguments & vArgs,
26  const DDMapArguments & ,
27  const DDStringArguments & sArgs,
28  const DDStringVectorArguments & ) {
29 
30  if ( nArgs.find("StartCopyNo") != nArgs.end() ) {
31  startcn = size_t(nArgs["StartCopyNo"]);
32  } else {
33  startcn = 1;
34  }
35  if ( nArgs.find("IncrCopyNo") != nArgs.end() ) {
36  incrcn = int(nArgs["IncrCopyNo"]);
37  } else {
38  incrcn = 1;
39  }
40 
41 
42  radius = nArgs["Radius"];
43  tilt = nArgs["Tilt"];
44  phi = vArgs["Phi"];
45  zpos = vArgs["ZPos"];
46 
47  if ( nArgs.find("NumCopies") != nArgs.end() ) {
48  numcopies = size_t(nArgs["NumCopies"]);
49  if ( numcopies != phi.size() ) {
50  edm::LogError("TrackerGeom") << "DDTrackerPhiAlgo error: Parameter "
51  << "NumCopies does not agree with the size "
52  << "of the Phi vector. It was adjusted to "
53  << "be the size of the Phi vector and may "
54  << "lead to crashes or errors.";
55  }
56  } else {
57  numcopies = phi.size();
58  }
59 
60  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parameters for position"
61  << "ing:: " << " Radius " << radius << " Tilt "
62  << tilt/CLHEP::deg << " Copies " << phi.size()
63  << " at";
64  for (int i=0; i<(int)(phi.size()); i++)
65  LogDebug("TrackerGeom") << "\t[" << i << "] phi = " << phi[i]/CLHEP::deg
66  << " z = " << zpos[i];
67 
69  childName = sArgs["ChildName"];
70  DDName parentName = parent().name();
71  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parent " << parentName
72  <<"\tChild " << childName << " NameSpace "
73  << idNameSpace;
74 }
75 
77 
78  DDName mother = parent().name();
80  double theta = 90.*CLHEP::deg;
81  size_t i = 0;
82  int ci = startcn;
83  for ( ; i < numcopies; ++i) {
84  double phix = phi[i] + tilt;
85  double phiy = phix + 90.*CLHEP::deg;
86  double phideg = phi[i]/CLHEP::deg;
87 
88  std::string rotstr = DDSplit(childName).first + dbl_to_string(phideg);
90  if (!rotation) {
91  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: Creating a new "
92  << "rotation: " << rotstr << "\t" << "90., "
93  << phix/CLHEP::deg << ", 90.,"
94  << phiy/CLHEP::deg << ", 0, 0";
95  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
96  0., 0.);
97  }
98 
99  double xpos = radius*cos(phi[i]);
100  double ypos = radius*sin(phi[i]);
101  DDTranslation tran(xpos, ypos, zpos[i]);
102 
103  cpv.position(child, mother, ci, tran, rotation);
104  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: " << child << " number "
105  << ci << " positioned in " << mother << " at "
106  << tran << " with " << rotation;
107  ci=ci+incrcn;
108  }
109 }
#define LogDebug(id)
std::vector< double > phi
int i
Definition: DBlmapReader.cc:9
virtual ~DDTrackerPhiAlgo()
std::string childName
parent
Definition: confdb.py:1052
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
type of data representation of DDCompactView
Definition: DDCompactView.h:77
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
U second(std::pair< T, U > const &p)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void execute(DDCompactView &cpv)
std::vector< double > zpos
std::string idNameSpace
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4