CMS 3D CMS Logo

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 
13 #include "CLHEP/Units/GlobalPhysicalConstants.h"
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
16 
17 DDTrackerPhiAlgo::DDTrackerPhiAlgo() : startcn(1), incrcn(1) {
18  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo info: Creating an instance";
19 }
20 
22 
24  const DDVectorArguments & vArgs,
25  const DDMapArguments & ,
26  const DDStringArguments & sArgs,
27  const DDStringVectorArguments & ) {
28 
29  if ( nArgs.find("StartCopyNo") != nArgs.end() ) {
30  startcn = size_t(nArgs["StartCopyNo"]);
31  } else {
32  startcn = 1;
33  }
34  if ( nArgs.find("IncrCopyNo") != nArgs.end() ) {
35  incrcn = int(nArgs["IncrCopyNo"]);
36  } else {
37  incrcn = 1;
38  }
39 
40 
41  radius = nArgs["Radius"];
42  tilt = nArgs["Tilt"];
43  phi = vArgs["Phi"];
44  zpos = vArgs["ZPos"];
45 
46  if ( nArgs.find("NumCopies") != nArgs.end() ) {
47  numcopies = size_t(nArgs["NumCopies"]);
48  if ( numcopies != phi.size() ) {
49  edm::LogError("TrackerGeom") << "DDTrackerPhiAlgo error: Parameter "
50  << "NumCopies does not agree with the size "
51  << "of the Phi vector. It was adjusted to "
52  << "be the size of the Phi vector and may "
53  << "lead to crashes or errors.";
54  }
55  } else {
56  numcopies = phi.size();
57  }
58 
59  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parameters for position"
60  << "ing:: " << " Radius " << radius << " Tilt "
61  << tilt/CLHEP::deg << " Copies " << phi.size()
62  << " at";
63  for (int i=0; i<(int)(phi.size()); i++)
64  LogDebug("TrackerGeom") << "\t[" << i << "] phi = " << phi[i]/CLHEP::deg
65  << " z = " << zpos[i];
66 
68  childName = sArgs["ChildName"];
69  DDName parentName = parent().name();
70  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parent " << parentName
71  <<"\tChild " << childName << " NameSpace "
72  << idNameSpace;
73 }
74 
76 
77  DDName mother = parent().name();
79  double theta = 90.*CLHEP::deg;
80  size_t i = 0;
81  int ci = startcn;
82  for ( ; i < numcopies; ++i) {
83  double phix = phi[i] + tilt;
84  double phiy = phix + 90.*CLHEP::deg;
85  double phideg = phi[i]/CLHEP::deg;
86 
87  std::string rotstr = DDSplit(childName).first + std::to_string(phideg);
89  if (!rotation) {
90  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: Creating a new "
91  << "rotation: " << rotstr << "\t" << "90., "
92  << phix/CLHEP::deg << ", 90.,"
93  << phiy/CLHEP::deg << ", 0, 0";
94  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
95  0., 0.);
96  }
97 
98  double xpos = radius*cos(phi[i]);
99  double ypos = radius*sin(phi[i]);
100  DDTranslation tran(xpos, ypos, zpos[i]);
101 
102  cpv.position(child, mother, ci, tran, rotation);
103  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: " << child << " number "
104  << ci << " positioned in " << mother << " at "
105  << tran << " with " << rotation;
106  ci=ci+incrcn;
107  }
108 }
#define LogDebug(id)
std::vector< double > phi
virtual ~DDTrackerPhiAlgo()
std::string childName
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:16
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
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