CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDTrackerZPosAlgo.cc
Go to the documentation of this file.
1 // File: DDTrackerZPosAlgo.cc
3 // Description: Position n copies at given z-values
5 
12 
13 #include <string>
14 #include <vector>
15 
16 using namespace std;
17 
18 class DDTrackerZPosAlgo : public DDAlgorithm {
19 public:
20  //Constructor and Destructor
22  ~DDTrackerZPosAlgo() override;
23 
24  void initialize(const DDNumericArguments& nArgs,
25  const DDVectorArguments& vArgs,
26  const DDMapArguments& mArgs,
27  const DDStringArguments& sArgs,
28  const DDStringVectorArguments& vsArgs) override;
29 
30  void execute(DDCompactView& cpv) override;
31 
32 private:
33  vector<double> zvec; //Z positions
34  vector<string> rotMat; //Names of rotation matrices
35 
36  string idNameSpace; //Namespace of this and ALL sub-parts
37  string childName; //Child name
38  int startCopyNo; //Start Copy number
39  int incrCopyNo; //Increment in Copy number
40 };
41 
42 DDTrackerZPosAlgo::DDTrackerZPosAlgo() { LogDebug("TrackerGeom") << "DDTrackerZPosAlgo info: Creating an instance"; }
43 
45 
47  const DDVectorArguments& vArgs,
48  const DDMapArguments&,
49  const DDStringArguments& sArgs,
50  const DDStringVectorArguments& vsArgs) {
51  startCopyNo = int(nArgs["StartCopyNo"]);
52  incrCopyNo = int(nArgs["IncrCopyNo"]);
53  zvec = vArgs["ZPositions"];
54  rotMat = vsArgs["Rotations"];
55 
56  idNameSpace = DDCurrentNamespace::ns();
57  childName = sArgs["ChildName"];
58  DDName parentName = parent().name();
59  LogDebug("TrackerGeom") << "DDTrackerZPosAlgo debug: Parent " << parentName << "\tChild " << childName
60  << " NameSpace " << idNameSpace << "\tCopyNo (Start/Increment) " << startCopyNo << ", "
61  << incrCopyNo << "\tNumber " << zvec.size();
62  for (int i = 0; i < (int)(zvec.size()); i++) {
63  LogDebug("TrackerGeom") << "\t[" << i << "]\tZ = " << zvec[i] << ", Rot.Matrix = " << rotMat[i];
64  }
65 }
66 
68  int copy = startCopyNo;
69  DDName mother = parent().name();
70  DDName child(DDSplit(childName).first, DDSplit(childName).second);
71 
72  for (int i = 0; i < (int)(zvec.size()); i++) {
73  DDTranslation tran(0, 0, zvec[i]);
74  string rotstr = DDSplit(rotMat[i]).first;
76  if (rotstr != "NULL") {
77  string rotns = DDSplit(rotMat[i]).second;
78  rot = DDRotation(DDName(rotstr, rotns));
79  }
80  cpv.position(child, mother, copy, tran, rot);
81  LogDebug("TrackerGeom") << "DDTrackerZPosAlgo test: " << child << " number " << copy << " positioned in " << mother
82  << " at " << tran << " with " << rot;
83  copy += incrCopyNo;
84  }
85 }
86 
87 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerZPosAlgo, "track:DDTrackerZPosAlgo");
static AlgebraicMatrix initialize()
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
vector< double > zvec
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
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
void execute(DDCompactView &cpv) override
~DDTrackerZPosAlgo() override
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
vector< string > rotMat
#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)