CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDTrackerLinear.cc
Go to the documentation of this file.
1 // File: DDTrackerLinear.cc
3 // Description: Position n copies at given intervals along an axis
5 
12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
15 #include <string>
16 #include <vector>
17 
18 using namespace std;
19 
20 class DDTrackerLinear : public DDAlgorithm {
21 public:
22  //Constructor and Destructor
24  ~DDTrackerLinear() override;
25 
26  void initialize(const DDNumericArguments& nArgs,
27  const DDVectorArguments& vArgs,
28  const DDMapArguments& mArgs,
29  const DDStringArguments& sArgs,
30  const DDStringVectorArguments& vsArgs) override;
31 
32  void execute(DDCompactView& cpv) override;
33 
34 private:
35  string idNameSpace; //Namespace of this and ALL sub-parts
36  string childName; //Child name
37  int number; //Number of positioning
38  int startcn; //Start copy no index
39  int incrcn; //Increment of copy no.
40  double theta; //Direction of translation
41  double phi; // ......
42  double offset; //Offset along (theta,phi) direction
43  double delta; //Increment ................
44  vector<double> centre; //Centre
45  string rotMat; //Rotation matrix
46 };
47 
48 DDTrackerLinear::DDTrackerLinear() : startcn(1), incrcn(1) {
49  LogDebug("TrackerGeom") << "DDTrackerLinear info: Creating an instance";
50 }
51 
53 
55  const DDVectorArguments& vArgs,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
59  number = int(nArgs["Number"]);
60  theta = nArgs["Theta"];
61  phi = nArgs["Phi"];
62  offset = nArgs["Offset"];
63  delta = nArgs["Delta"];
64  centre = vArgs["Center"];
65  rotMat = sArgs["Rotation"];
66  if (nArgs.find("StartCopyNo") != nArgs.end()) {
67  startcn = size_t(nArgs["StartCopyNo"]);
68  } else {
69  startcn = 1;
70  }
71  if (nArgs.find("IncrCopyNo") != nArgs.end()) {
72  incrcn = int(nArgs["IncrCopyNo"]);
73  } else {
74  incrcn = 1;
75  }
76 
78  childName = sArgs["ChildName"];
79  DDName parentName = parent().name();
80  LogDebug("TrackerGeom") << "DDTrackerLinear debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
81  << idNameSpace << "\tNumber " << number << "\tAxis (theta/phi) " << theta / CLHEP::deg << ", "
82  << phi / CLHEP::deg << "\t(Offset/Delta) " << offset << ", " << delta << "\tCentre "
83  << centre[0] << ", " << centre[1] << ", " << centre[2] << "\tRotation " << rotMat;
84 }
85 
87  DDName mother = parent().name();
89  DDTranslation direction(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
91  string rotstr = DDSplit(rotMat).first;
93  if (rotstr != "NULL") {
94  string rotns = DDSplit(rotMat).second;
95  rot = DDRotation(DDName(rotstr, rotns));
96  }
97  int ci = startcn;
98  for (int i = 0; i < number; i++) {
99  DDTranslation tran = base + (offset + double(i) * delta) * direction;
100  cpv.position(child, mother, ci, tran, rot);
101  LogDebug("TrackerGeom") << "DDTrackerLinear test: " << child << " number " << ci << " positioned in " << mother
102  << " at " << tran << " with " << rot;
103  ++ci;
104  }
105 }
106 
107 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerLinear, "track:DDTrackerLinear");
tuple base
Main Program
Definition: newFWLiteAna.py:92
static AlgebraicMatrix initialize()
void execute(DDCompactView &cpv) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
~DDTrackerLinear() override
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
vector< double > centre
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
#define LogDebug(id)