CMS 3D CMS Logo

DDTrackerAngular.cc
Go to the documentation of this file.
1 // File: DDTrackerAngular.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 DDTrackerAngular : public DDAlgorithm {
21 public:
22  //Constructor and Destructor
24  ~DDTrackerAngular() 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  int n; //Number of copies
36  int startCopyNo; //Start Copy number
37  int incrCopyNo; //Increment in Copy number
38  double rangeAngle; //Range in angle
39  double startAngle; //Start anle
40  double radius; //Radius
41  vector<double> center; //Phi values
42  double delta; //Increment in phi
43 
44  string idNameSpace; //Namespace of this and ALL sub-parts
45  string childName; //Child name
46 };
47 
48 DDTrackerAngular::DDTrackerAngular() { LogDebug("TrackerGeom") << "DDTrackerAngular info: Creating an instance"; }
49 
51 
53  const DDVectorArguments& vArgs,
54  const DDMapArguments&,
55  const DDStringArguments& sArgs,
56  const DDStringVectorArguments&) {
57  n = int(nArgs["N"]);
58  startCopyNo = int(nArgs["StartCopyNo"]);
59  incrCopyNo = int(nArgs["IncrCopyNo"]);
60  rangeAngle = nArgs["RangeAngle"];
61  startAngle = nArgs["StartAngle"];
62  radius = nArgs["Radius"];
63  center = vArgs["Center"];
64 
65  if (fabs(rangeAngle - 360.0 * CLHEP::deg) < 0.001 * CLHEP::deg) {
66  delta = rangeAngle / double(n);
67  } else {
68  if (n > 1) {
69  delta = rangeAngle / double(n - 1);
70  } else {
71  delta = 0.;
72  }
73  }
74 
75  LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parameters for position"
76  << "ing:: n " << n << " Start, Range, Delta " << startAngle / CLHEP::deg << " "
77  << rangeAngle / CLHEP::deg << " " << delta / CLHEP::deg << " Radius " << radius << " Centre "
78  << center[0] << ", " << center[1] << ", " << center[2];
79 
80  idNameSpace = DDCurrentNamespace::ns();
81  childName = sArgs["ChildName"];
82 
83  DDName parentName = parent().name();
84  LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
85  << idNameSpace;
86 }
87 
89  DDName mother = parent().name();
90  DDName child(DDSplit(childName).first, DDSplit(childName).second);
91  double theta = 90. * CLHEP::deg;
92  int copy = startCopyNo;
93  double phi = startAngle;
94  for (int i = 0; i < n; i++) {
95  double phix = phi;
96  double phiy = phix + 90. * CLHEP::deg;
97  double phideg = phix / CLHEP::deg;
98 
100  if (phideg != 0) {
101  string rotstr = DDSplit(childName).first + to_string(phideg * 10.);
102  rotation = DDRotation(DDName(rotstr, idNameSpace));
103  if (!rotation) {
104  LogDebug("TrackerGeom") << "DDTrackerAngular test: Creating a new "
105  << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.,"
106  << phiy / CLHEP::deg << ", 0, 0";
107  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
108  }
109  }
110 
111  double xpos = radius * cos(phi) + center[0];
112  double ypos = radius * sin(phi) + center[1];
113  double zpos = center[2];
114  DDTranslation tran(xpos, ypos, zpos);
115 
116  cpv.position(child, mother, copy, tran, rotation);
117  LogDebug("TrackerGeom") << "DDTrackerAngular test " << child << " number " << copy << " positioned in " << mother
118  << " at " << tran << " with " << rotation;
119  copy += incrCopyNo;
120  phi += delta;
121  }
122 }
123 
124 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerAngular, "track:DDTrackerAngular");
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
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
DDTrackerAngular::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTrackerAngular.cc:52
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
DDTrackerAngular::incrCopyNo
int incrCopyNo
Definition: DDTrackerAngular.cc:37
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDTrackerAngular::n
int n
Definition: DDTrackerAngular.cc:35
DDTrackerAngular::idNameSpace
string idNameSpace
Definition: DDTrackerAngular.cc:44
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
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DDTrackerAngular::center
vector< double > center
Definition: DDTrackerAngular.cc:41
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDTypes.h
DDTrackerAngular
Definition: DDTrackerAngular.cc:20
createfilelist.int
int
Definition: createfilelist.py:10
DDTrackerAngular::DDTrackerAngular
DDTrackerAngular()
Definition: DDTrackerAngular.cc:48
DDTrackerAngular::radius
double radius
Definition: DDTrackerAngular.cc:40
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDTrackerAngular::execute
void execute(DDCompactView &cpv) override
Definition: DDTrackerAngular.cc:88
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
DDTrackerAngular::delta
double delta
Definition: DDTrackerAngular.cc:42
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDTrackerAngular::startAngle
double startAngle
Definition: DDTrackerAngular.cc:39
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDTrackerAngular::~DDTrackerAngular
~DDTrackerAngular() override
Definition: DDTrackerAngular.cc:50
DDTrackerAngular::childName
string childName
Definition: DDTrackerAngular.cc:45
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:98
DDTrackerAngular::startCopyNo
int startCopyNo
Definition: DDTrackerAngular.cc:36
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDTrackerAngular::rangeAngle
double rangeAngle
Definition: DDTrackerAngular.cc:38
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:76