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 
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 DDTrackerPhiAlgo : public DDAlgorithm {
21 public:
22  //Constructor and Destructor
24  ~DDTrackerPhiAlgo() 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  double radius; //Radius
36  double tilt; //Tilt angle
37  vector<double> phi; //Phi values
38  vector<double> zpos; //Z positions
39 
40  string idNameSpace; //Namespace of this and ALL sub-parts
41  string childName; //Child name
42 
43  size_t startcn; //Start index of copy numbers.
44  int incrcn; //Increment of copy number index.
45  size_t numcopies; //Number of copies == phi.size() above.
46 };
47 
48 DDTrackerPhiAlgo::DDTrackerPhiAlgo() : startcn(1), incrcn(1) {
49  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo info: Creating an instance";
50 }
51 
53 
55  const DDVectorArguments& vArgs,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
59  if (nArgs.find("StartCopyNo") != nArgs.end()) {
60  startcn = size_t(nArgs["StartCopyNo"]);
61  } else {
62  startcn = 1;
63  }
64  if (nArgs.find("IncrCopyNo") != nArgs.end()) {
65  incrcn = int(nArgs["IncrCopyNo"]);
66  } else {
67  incrcn = 1;
68  }
69 
70  radius = nArgs["Radius"];
71  tilt = nArgs["Tilt"];
72  phi = vArgs["Phi"];
73  zpos = vArgs["ZPos"];
74 
75  if (nArgs.find("NumCopies") != nArgs.end()) {
76  numcopies = size_t(nArgs["NumCopies"]);
77  if (numcopies != phi.size()) {
78  edm::LogError("TrackerGeom") << "DDTrackerPhiAlgo error: Parameter "
79  << "NumCopies does not agree with the size "
80  << "of the Phi vector. It was adjusted to "
81  << "be the size of the Phi vector and may "
82  << "lead to crashes or errors.";
83  }
84  } else {
85  numcopies = phi.size();
86  }
87 
88  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parameters for position"
89  << "ing:: "
90  << " Radius " << radius << " Tilt " << tilt / CLHEP::deg << " Copies " << phi.size() << " at";
91  for (int i = 0; i < (int)(phi.size()); i++)
92  LogDebug("TrackerGeom") << "\t[" << i << "] phi = " << phi[i] / CLHEP::deg << " z = " << zpos[i];
93 
95  childName = sArgs["ChildName"];
96  DDName parentName = parent().name();
97  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
98  << idNameSpace;
99 }
100 
102  DDName mother = parent().name();
104  double theta = 90. * CLHEP::deg;
105  size_t i = 0;
106  int ci = startcn;
107  for (; i < numcopies; ++i) {
108  double phix = phi[i] + tilt;
109  double phiy = phix + 90. * CLHEP::deg;
110  double phideg = phi[i] / CLHEP::deg;
111 
112  string rotstr = DDSplit(childName).first + to_string(phideg);
114  if (!rotation) {
115  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: Creating a new "
116  << "rotation: " << rotstr << "\t"
117  << "90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg << ", 0, 0";
118  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
119  }
120 
121  double xpos = radius * cos(phi[i]);
122  double ypos = radius * sin(phi[i]);
123  DDTranslation tran(xpos, ypos, zpos[i]);
124 
125  cpv.position(child, mother, ci, tran, rotation);
126  LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: " << child << " number " << ci << " positioned in " << mother
127  << " at " << tran << " with " << rotation;
128  ci = ci + incrcn;
129  }
130 }
131 
132 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerPhiAlgo, "track:DDTrackerPhiAlgo");
DDTrackerPhiAlgo::~DDTrackerPhiAlgo
~DDTrackerPhiAlgo() override
Definition: DDTrackerPhiAlgo.cc:52
DDTrackerPhiAlgo::startcn
size_t startcn
Definition: DDTrackerPhiAlgo.cc:43
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
DDTrackerPhiAlgo::childName
string childName
Definition: DDTrackerPhiAlgo.cc:41
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDSplit.h
DDTrackerPhiAlgo::zpos
vector< double > zpos
Definition: DDTrackerPhiAlgo.cc:38
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDTrackerPhiAlgo::radius
double radius
Definition: DDTrackerPhiAlgo.cc:35
dqmdumpme.first
first
Definition: dqmdumpme.py:55
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDTrackerPhiAlgo
Definition: DDTrackerPhiAlgo.cc:20
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDTrackerPhiAlgo::DDTrackerPhiAlgo
DDTrackerPhiAlgo()
Definition: DDTrackerPhiAlgo.cc:48
DDTrackerPhiAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTrackerPhiAlgo.cc:101
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edm::LogError
Definition: MessageLogger.h:183
DDTrackerPhiAlgo::idNameSpace
string idNameSpace
Definition: DDTrackerPhiAlgo.cc:40
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTrackerPhiAlgo::tilt
double tilt
Definition: DDTrackerPhiAlgo.cc:36
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
ReadMapType< double >
DDTrackerPhiAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTrackerPhiAlgo.cc:54
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDTrackerPhiAlgo::phi
vector< double > phi
Definition: DDTrackerPhiAlgo.cc:37
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
class-composition.child
child
Definition: class-composition.py:91
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDTrackerPhiAlgo::incrcn
int incrcn
Definition: DDTrackerPhiAlgo.cc:44
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18
DDTrackerPhiAlgo::numcopies
size_t numcopies
Definition: DDTrackerPhiAlgo.cc:45