CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DDTrackerRingAlgo Class Reference

#include <DDTrackerRingAlgo.h>

Inheritance diagram for DDTrackerRingAlgo:

Public Member Functions

 DDTrackerRingAlgo ()
 
void execute (DDCompactView &cpv) override
 
void initialize (const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
 
 ~DDTrackerRingAlgo () override
 

Private Attributes

std::vector< double > center
 
std::string childName
 
double delta
 
std::string idNameSpace
 
int incrCopyNo
 
bool isFlipped
 
bool isZPlus
 
int n
 
double radius
 
double rangeAngle
 
double startAngle
 
int startCopyNo
 
double tiltAngle
 

Detailed Description

Definition at line 41 of file DDTrackerRingAlgo.h.

Constructor & Destructor Documentation

DDTrackerRingAlgo::DDTrackerRingAlgo ( )

Definition at line 21 of file DDTrackerRingAlgo.cc.

References LogDebug.

21  {
22  LogDebug("TrackerGeom") << "DDTrackerRingAlgo info: Creating an instance";
23 }
#define LogDebug(id)
DDTrackerRingAlgo::~DDTrackerRingAlgo ( )
override

Definition at line 25 of file DDTrackerRingAlgo.cc.

25 {}

Member Function Documentation

void DDTrackerRingAlgo::execute ( DDCompactView cpv)
override

Definition at line 70 of file DDTrackerRingAlgo.cc.

References center, class-composition::child, childName, popcon2dropbox::copy(), funct::cos(), DDrot(), DDSplit(), delta, plotBeamSpotDB::first, mps_fire::i, idNameSpace, incrCopyNo, isFlipped, isZPlus, LogDebug, DDRotation::matrix(), n, class-composition::parent, phi, DDCompactView::position(), radius, edm::second(), funct::sin(), startAngle, startCopyNo, AlCaHLTBitMon_QueryRunRegistry::string, theta(), and tiltAngle.

70  {
71 
72  DDRotation flipRot, tiltRot, phiRot, globalRot; // Identity
73  DDRotationMatrix flipMatrix, tiltMatrix, phiRotMatrix, globalRotMatrix; // Identity matrix
74  std::string rotstr = "RTrackerRingAlgo";
75 
76  // flipMatrix calculus
77  if (isFlipped) {
78  std::string flipRotstr = rotstr + "Flip";
79  flipRot = DDRotation(DDName(flipRotstr, idNameSpace));
80  if (!flipRot) {
81  LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " << flipRotstr
82  << "\t90., 180., "
83  << "90., 90., "
84  << "180., 0.";
85  flipRot = DDrot(DDName(flipRotstr, idNameSpace),
86  90.*CLHEP::deg, 180.*CLHEP::deg, 90.*CLHEP::deg, 90.*CLHEP::deg, 180.*CLHEP::deg, 0.);
87  }
88  flipMatrix = flipRot.matrix();
89  }
90  // tiltMatrix calculus
91  if (isZPlus) {
92  std::string tiltRotstr = rotstr + "Tilt" + std::to_string(tiltAngle/CLHEP::deg) + "ZPlus";
93  tiltRot = DDRotation(DDName(tiltRotstr, idNameSpace));
94  if (!tiltRot) {
95  LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " << tiltRotstr
96  << "\t90., 90., "
97  << tiltAngle/CLHEP::deg << ", 180., "
98  << 90. - tiltAngle/CLHEP::deg << ", 0.";
99  tiltRot = DDrot(DDName(tiltRotstr, idNameSpace),
100  90.*CLHEP::deg, 90.*CLHEP::deg, tiltAngle, 180.*CLHEP::deg, 90.*CLHEP::deg - tiltAngle, 0.);
101  }
102  tiltMatrix = tiltRot.matrix();
103  if (isFlipped) { tiltMatrix *= flipMatrix; }
104  }
105  else {
106  std::string tiltRotstr = rotstr + "Tilt" + std::to_string(tiltAngle/CLHEP::deg) + "ZMinus";
107  tiltRot = DDRotation(DDName(tiltRotstr, idNameSpace));
108  if (!tiltRot) {
109  LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " << tiltRotstr
110  << "\t90., 90., "
111  << tiltAngle/CLHEP::deg << ", 0., "
112  << 90. + tiltAngle/CLHEP::deg << ", 0.";
113  tiltRot = DDrot(DDName(tiltRotstr, idNameSpace),
114  90.*CLHEP::deg, 90.*CLHEP::deg, tiltAngle, 0., 90.*CLHEP::deg + tiltAngle, 0.);
115  }
116  tiltMatrix = tiltRot.matrix();
117  if (isFlipped) { tiltMatrix *= flipMatrix; }
118  }
119 
120  // Loops for all phi values
121  DDName mother = parent().name();
123  double theta = 90.*CLHEP::deg;
124  int copy = startCopyNo;
125  double phi = startAngle;
126 
127  for (int i=0; i<n; i++) {
128 
129  // phiRotMatrix calculus
130  double phix = phi;
131  double phiy = phix + 90.*CLHEP::deg;
132  double phideg = phix/CLHEP::deg;
133  if (phideg != 0) {
134  std::string phiRotstr = rotstr + "Phi" + std::to_string(phideg*10.);
135  phiRot = DDRotation(DDName(phiRotstr, idNameSpace));
136  if (!phiRot) {
137  LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " << phiRotstr
138  << "\t90., " << phix/CLHEP::deg
139  << ", 90.," << phiy/CLHEP::deg
140  <<", 0., 0.";
141  phiRot = DDrot(DDName(phiRotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
142  }
143  phiRotMatrix = phiRot.matrix();
144  }
145 
146  // globalRot def
147  std::string globalRotstr = rotstr + "Phi" + std::to_string(phideg*10.) + "Tilt" + std::to_string(tiltAngle/CLHEP::deg);
148  if (isZPlus) {
149  globalRotstr += "ZPlus";
150  if (isFlipped) { globalRotstr += "Flip"; }
151  }
152  else {
153  globalRotstr += "ZMinus";
154  if (isFlipped) { globalRotstr += "Flip"; }
155  }
156  globalRot = DDRotation(DDName(globalRotstr, idNameSpace));
157  if (!globalRot) {
158  LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new "
159  << "rotation: " << globalRotstr;
160  globalRotMatrix = phiRotMatrix * tiltMatrix;
161  globalRot = DDrot(DDName(globalRotstr, idNameSpace), std::make_unique<DDRotationMatrix>(globalRotMatrix));
162  }
163 
164  // translation def
165  double xpos = radius*cos(phi) + center[0];
166  double ypos = radius*sin(phi) + center[1];
167  double zpos = center[2];
168  DDTranslation tran(xpos, ypos, zpos);
169 
170  // Positions child with respect to parent
171  cpv.position(child, mother, copy, tran, globalRot);
172  LogDebug("TrackerGeom") << "DDTrackerRingAlgo test " << child << " number "
173  << copy << " positioned in " << mother << " at "
174  << tran << " with " << globalRot;
175 
176  copy += incrCopyNo;
177  phi += delta;
178  }
179 }
#define LogDebug(id)
def copy(args, dbName)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Geom::Theta< T > theta() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::string idNameSpace
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
U second(std::pair< T, U > const &p)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:80
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
DDRotationMatrix & matrix()
Definition: DDTransform.h:97
std::vector< double > center
void DDTrackerRingAlgo::initialize ( const DDNumericArguments nArgs,
const DDVectorArguments vArgs,
const DDMapArguments mArgs,
const DDStringArguments sArgs,
const DDStringVectorArguments vsArgs 
)
override

Definition at line 27 of file DDTrackerRingAlgo.cc.

References electrons_cff::bool, center, childName, delta, idNameSpace, incrCopyNo, createfilelist::int, isFlipped, isZPlus, LogDebug, n, DDCurrentNamespace::ns(), class-composition::parent, radius, rangeAngle, startAngle, startCopyNo, and tiltAngle.

31  {
32 
33  n = int(nArgs["N"]);
34  startCopyNo = int(nArgs["StartCopyNo"]);
35  incrCopyNo = int(nArgs["IncrCopyNo"]);
36  rangeAngle = nArgs["RangeAngle"];
37  startAngle = nArgs["StartAngle"];
38  radius = nArgs["Radius"];
39  center = vArgs["Center"];
40  isZPlus = bool(nArgs["IsZPlus"]);
41  tiltAngle = nArgs["TiltAngle"];
42  isFlipped = bool(nArgs["IsFlipped"]);
43 
44  if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) {
45  delta = rangeAngle/double(n);
46  } else {
47  if (n > 1) {
48  delta = rangeAngle/double(n-1);
49  } else {
50  delta = 0.;
51  }
52  }
53 
54  LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parameters for position"
55  << "ing:: n " << n << " Start, Range, Delta "
56  << startAngle/CLHEP::deg << " "
57  << rangeAngle/CLHEP::deg << " " << delta/CLHEP::deg
58  << " Radius " << radius << " Centre " << center[0]
59  << ", " << center[1] << ", "<<center[2];
60 
62  childName = sArgs["ChildName"];
63 
64  DDName parentName = parent().name();
65  LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parent " << parentName
66  << "\tChild " << childName << " NameSpace "
67  << idNameSpace;
68 }
#define LogDebug(id)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
std::string idNameSpace
std::vector< double > center

Member Data Documentation

std::vector<double> DDTrackerRingAlgo::center
private

Definition at line 64 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

std::string DDTrackerRingAlgo::childName
private

Definition at line 71 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

double DDTrackerRingAlgo::delta
private

Definition at line 68 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

std::string DDTrackerRingAlgo::idNameSpace
private

Definition at line 70 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

int DDTrackerRingAlgo::incrCopyNo
private

Definition at line 60 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

bool DDTrackerRingAlgo::isFlipped
private

Definition at line 67 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

bool DDTrackerRingAlgo::isZPlus
private

Definition at line 65 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

int DDTrackerRingAlgo::n
private

Definition at line 58 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

double DDTrackerRingAlgo::radius
private

Definition at line 63 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

double DDTrackerRingAlgo::rangeAngle
private

Definition at line 61 of file DDTrackerRingAlgo.h.

Referenced by initialize().

double DDTrackerRingAlgo::startAngle
private

Definition at line 62 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

int DDTrackerRingAlgo::startCopyNo
private

Definition at line 59 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().

double DDTrackerRingAlgo::tiltAngle
private

Definition at line 66 of file DDTrackerRingAlgo.h.

Referenced by execute(), and initialize().