CMS 3D CMS Logo

DDTrackerRingAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace std;
7 using namespace dd4hep;
8 using namespace cms;
9 using namespace cms_units::operators;
10 
11 namespace {
12  long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
13  DDNamespace ns(ctxt, e, true);
14  DDAlgoArguments args(ctxt, e);
15  Volume mother = ns.volume(args.parentName());
16  string childName = args.value<string>("ChildName");
17  Volume child = ns.volume(childName);
18 
19  string parentName = args.parentName();
20  int n = args.value<int>("N");
21  int startCopyNo = args.value<int>("StartCopyNo");
22  int incrCopyNo = args.value<int>("IncrCopyNo");
23  double rangeAngle = args.value<double>("RangeAngle");
24  double startAngle = args.value<double>("StartAngle");
25  double radius = args.value<double>("Radius");
26  vector<double> center = args.value<vector<double> >("Center");
27  bool isZPlus = args.value<int>("IsZPlus") == 1;
28  double tiltAngle = args.value<double>("TiltAngle");
29  bool isFlipped = args.value<int>("IsFlipped") == 1;
30  double delta = 0.;
31 
32  if (abs(rangeAngle - 360.0_deg) < 0.001_deg) {
33  delta = rangeAngle / double(n);
34  } else {
35  if (n > 1) {
36  delta = rangeAngle / double(n - 1);
37  } else {
38  delta = 0.;
39  }
40  }
41 
42  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo debug: Parameters for position"
43  << "ing:: n " << n << " Start, Range, Delta " << convertRadToDeg(startAngle) << " "
44  << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) << " Radius "
45  << radius << " Centre " << center[0] << ", " << center[1] << ", " << center[2];
46 
47  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo debug: Parent " << parentName << "\tChild " << childName
48  << " NameSpace " << ns.name();
49 
50  Rotation3D flipMatrix, tiltMatrix, phiRotMatrix, globalRotMatrix; // Identity matrix
51 
52  // flipMatrix calculus
53  if (isFlipped) {
54  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: "
55  << "\t90., 180., "
56  << "90., 90., "
57  << "180., 0.";
58  flipMatrix = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0._deg);
59  }
60  // tiltMatrix calculus
61  if (isZPlus) {
62  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: "
63  << "\t90., 90., " << convertRadToDeg(tiltAngle) << ", 180., "
64  << convertRadToDeg(90._deg - tiltAngle) << ", 0.";
65  tiltMatrix = makeRotation3D(90._deg, 90._deg, tiltAngle, 180._deg, 90._deg - tiltAngle, 0._deg);
66  if (isFlipped) {
67  tiltMatrix *= flipMatrix;
68  }
69  } else {
70  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: "
71  << "\t90., 90., " << convertRadToDeg(tiltAngle) << ", 0., "
72  << convertRadToDeg(90._deg + tiltAngle) << ", 0.";
73  tiltMatrix = makeRotation3D(90._deg, 90._deg, tiltAngle, 0._deg, 90._deg + tiltAngle, 0._deg);
74  if (isFlipped) {
75  tiltMatrix *= flipMatrix;
76  }
77  }
78 
79  // Loops for all phi values
80  double theta = 90._deg;
81  int copy = startCopyNo;
82  double phi = startAngle;
83 
84  for (int i = 0; i < n; ++i) {
85  // phiRotMatrix calculus
86  double phix = phi;
87  double phiy = phix + 90._deg;
88  if (phix != 0.) {
89  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: "
90  << "\t90., " << convertRadToDeg(phix) << ", 90.," << convertRadToDeg(phiy)
91  << ", 0., 0.";
92  phiRotMatrix = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
93  }
94 
95  globalRotMatrix = phiRotMatrix * tiltMatrix;
96 
97  // translation def
98  double xpos = radius * cos(phi) + center[0];
99  double ypos = radius * sin(phi) + center[1];
100  double zpos = center[2];
101  Position tran(xpos, ypos, zpos);
102 
103  // Positions child with respect to parent
104  mother.placeVolume(child, copy, Transform3D(globalRotMatrix, tran));
105  edm::LogVerbatim("TrackerGeom") << "DDTrackerRingAlgo test " << child.data()->GetName() << " number " << copy
106  << " positioned in " << mother.data()->GetName() << " at " << tran << " with "
107  << globalRotMatrix;
108 
109  copy += incrCopyNo;
110  phi += delta;
111  }
112  return s_executed;
113  }
114 } // namespace
115 // first argument is the type from the xml file
116 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerRingAlgo, ::algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
cms_units::operators
Definition: CMSUnits.h:13
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
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
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
PVValHelper::phi
Definition: PVValidationHelpers.h:69
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDPlugins.h
qcdUeDQM_cfi.algorithm
algorithm
Definition: qcdUeDQM_cfi.py:32
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dd4hep
Definition: DDPlugins.h:8
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
CMSUnits.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
child
Definition: simpleInheritance.h:11
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37