Geometry
TrackerCommonData
plugins
dd4hep
DDPixFwdDiskAlgo.cc
Go to the documentation of this file.
1
// File: DDPixFwdDiskAlgo.cc
3
// Description: Position n copies at given z-values
5
6
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
7
#include "
DetectorDescription/DDCMS/interface/DDPlugins.h
"
8
#include "DD4hep/DetFactoryHelper.h"
9
#include "DD4hep/Printout.h"
10
11
#include "
DataFormats/Math/interface/CMSUnits.h
"
12
13
#include <sstream>
14
15
using namespace
cms_units::operators
;
// _deg and convertRadToDeg
16
17
static
long
algorithm
(
dd4hep::Detector
&
/* description */
,
18
cms::DDParsingContext
& ctxt,
19
xml_h
e
,
20
dd4hep::SensitiveDetector&
/* sens */
) {
21
cms::DDNamespace
ns(ctxt,
e
,
true
);
22
cms::DDAlgoArguments
args
(ctxt,
e
);
23
24
int
nBlades;
//Number of blades
25
int
startCopyNo;
//Start Copy number
26
double
bladeAngle;
//Angle of blade rotation aroung y-axis
27
double
bladeTilt;
//Tilt of the blade around x-axis
28
double
zPlane;
//Common shift in z for all blades
29
std::vector<double> bladeZShift;
//Shift in Z of individual blades
30
double
anchorR;
//Distance of beam line to anchor point
31
32
std::string
childName;
//Child name
33
std::string
rotName;
//Name of the base rotation matrix
34
std::string
flagString;
//Flag if a blade is present
35
36
dd4hep::Volume
mother = ns.
volume
(
args
.parentName());
37
dd4hep::PlacedVolume
pv
;
38
39
startCopyNo =
args
.find(
"StartCopyNo"
) ?
args
.value<
int
>(
"StartCopyNo"
) : 0;
40
nBlades =
args
.value<
int
>(
"NumberOfBlades"
);
41
bladeAngle =
args
.value<
double
>(
"BladeAngle"
);
42
bladeTilt =
args
.value<
double
>(
"BladeTilt"
);
43
zPlane =
args
.value<
double
>(
"BladeCommonZ"
);
44
anchorR =
args
.value<
double
>(
"AnchorRadius"
);
45
46
bladeZShift =
args
.value<std::vector<double> >(
"BladeZShift"
);
47
48
childName =
args
.value<
std::string
>(
"ChildName"
);
49
rotName =
args
.value<
std::string
>(
"RotationName"
);
50
flagString =
args
.value<
std::string
>(
"FlagString"
);
51
52
if
(strchr(childName.c_str(),
NAMESPACE_SEP
) ==
nullptr
)
53
childName = ns.
prepend
(childName);
54
55
dd4hep::Volume
child
= ns.
volume
(childName);
56
57
edm::LogVerbatim
(
"TrackerGeom"
) <<
"DDPixFwdDiskAlgo debug: Parent "
<< mother.name() <<
"\tChild "
<<
child
.name()
58
<<
" NameSpace "
<< ns.
name
() <<
"\tRot Name "
<< rotName <<
"\tCopyNo (Start/Total) "
59
<< startCopyNo <<
", "
<< nBlades <<
"\tAngles "
<<
convertRadToDeg
(bladeAngle)
60
<<
", "
<<
convertRadToDeg
(bladeTilt) <<
"\tZshifts "
<< zPlane <<
"\tAnchor Radius "
61
<< anchorR;
62
63
for
(
int
iBlade = 0; iBlade < nBlades; ++iBlade) {
64
edm::LogVerbatim
(
"TrackerGeom"
) <<
"DDPixFwdDiskAlgo: Blade "
<< iBlade <<
" flag "
<< flagString[iBlade]
65
<<
" zshift "
<< bladeZShift[iBlade];
66
}
67
68
double
deltaPhi
= 360.0_deg / (double)nBlades;
69
int
copyNo = startCopyNo;
70
std::string
flagSelector =
"Y"
;
71
72
for
(
int
iBlade = 0; iBlade < nBlades; ++iBlade) {
73
if
(flagString[iBlade] == flagSelector[0]) {
74
std::string
rotstr = rotName[0] + std::to_string(
double
(copyNo));
75
double
phi = (iBlade + 0.5) *
deltaPhi
;
76
double
phix = atan2(
sin
(phi) *
cos
(bladeAngle),
cos
(phi) *
cos
(bladeAngle));
77
double
thetx = acos(-
sin
(bladeAngle));
78
double
phiy = atan2((
cos
(phi) *
cos
(bladeTilt) +
sin
(phi) *
sin
(bladeAngle) *
sin
(bladeTilt)),
79
(-
sin
(phi) *
cos
(bladeTilt) +
cos
(phi) *
sin
(bladeAngle) *
sin
(bladeTilt)));
80
81
double
thety = acos(
cos
(bladeAngle) *
sin
(bladeTilt));
82
double
phiz = atan2((-
cos
(phi) *
sin
(bladeTilt) +
sin
(phi) *
sin
(bladeAngle) *
cos
(bladeTilt)),
83
(
sin
(phi) *
sin
(bladeTilt) +
cos
(phi) *
sin
(bladeAngle) *
cos
(bladeTilt)));
84
85
double
thetz = acos(
cos
(bladeAngle) *
cos
(bladeTilt));
86
87
auto
rot
= dd4hep::Rotation3D();
88
89
auto
irot = ctxt.
rotations
.find(ns.
prepend
(rotstr));
90
91
if
(irot != ctxt.
rotations
.end()) {
92
edm::LogVerbatim
(
"TrackerGeom"
) <<
"DDPixFwdDiskAlgo test: Creating a new "
93
<<
"rotation: "
<< rotstr <<
"\t"
<<
convertRadToDeg
(thetx) <<
", "
94
<<
convertRadToDeg
(phix) <<
", "
<<
convertRadToDeg
(thety) <<
", "
95
<<
convertRadToDeg
(phiy) <<
", "
<<
convertRadToDeg
(thetz) <<
", "
96
<<
convertRadToDeg
(phiz);
97
98
edm::LogVerbatim
(
"TrackerGeom"
) <<
"Rotation Matrix ("
<<
convertRadToDeg
(phi) <<
", "
99
<<
convertRadToDeg
(bladeAngle) <<
", "
<<
convertRadToDeg
(bladeTilt) <<
") "
100
<<
cos
(phi) *
cos
(bladeAngle) <<
", "
101
<< (-
sin
(phi) *
cos
(bladeTilt) +
cos
(phi) *
sin
(bladeAngle) *
sin
(bladeTilt))
102
<<
", "
103
<< (
sin
(phi) *
sin
(bladeTilt) +
cos
(phi) *
sin
(bladeAngle) *
cos
(bladeTilt))
104
<<
", "
<<
sin
(phi) *
cos
(bladeAngle) <<
", "
105
<< (
cos
(phi) *
cos
(bladeTilt) +
sin
(phi) *
sin
(bladeAngle) *
sin
(bladeTilt))
106
<<
", "
107
<< (-
cos
(phi) *
sin
(bladeTilt) +
sin
(phi) *
sin
(bladeAngle) *
cos
(bladeTilt))
108
<<
", "
<< -
sin
(bladeAngle) <<
", "
<<
cos
(bladeAngle) *
sin
(bladeTilt) <<
", "
109
<<
cos
(bladeAngle) *
cos
(bladeTilt);
110
rot
=
cms::makeRotation3D
(thetx, phix, thety, phiy, thetz, phiz);
111
}
112
double
xpos = anchorR * (-
sin
(phi) *
cos
(bladeTilt) +
cos
(phi) *
sin
(bladeAngle) *
sin
(bladeTilt));
113
double
ypos = anchorR * (
cos
(phi) *
cos
(bladeTilt) +
sin
(phi) *
sin
(bladeAngle) *
sin
(bladeTilt));
114
double
zpos = anchorR * (
cos
(bladeAngle) *
sin
(bladeTilt)) + zPlane + bladeZShift[iBlade];
115
116
dd4hep::Position
tran(xpos, ypos, zpos);
117
pv
= mother.placeVolume(
child
, copyNo, dd4hep::Transform3D(
rot
, tran));
118
edm::LogVerbatim
(
"TrackerGeom"
) <<
"DDPixFwdDiskAlgo test: "
<<
pv
.name() <<
": "
<< childName <<
" number "
119
<< copyNo <<
" positioned in "
<< mother.name() <<
" at "
<< tran <<
" with "
120
<<
rot
;
121
}
122
copyNo++;
123
}
124
125
edm::LogVerbatim
(
"TrackerGeom"
) <<
"Finished...."
;
126
return
cms::s_executed
;
127
}
128
129
DECLARE_DDCMS_DETELEMENT
(DDCMS_track_DDPixFwdDiskAlgo,
algorithm
)
writedatasetfile.args
args
Definition:
writedatasetfile.py:18
cms_units::operators
Definition:
CMSUnits.h:13
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition:
DDPlugins.h:30
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:16
cms::makeRotation3D
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition:
DDAlgoArguments.cc:20
cms::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition:
DDFilteredView.h:46
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
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition:
SiPixelRawToDigiRegional_cfi.py:9
cms::DDParsingContext::rotations
tbb::concurrent_unordered_map< std::string, dd4hep::Rotation3D > rotations
Definition:
DDParsingContext.h:37
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition:
DDNamespace.cc:66
PixelTestBeamValidation_cfi.Position
Position
Definition:
PixelTestBeamValidation_cfi.py:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition:
DDFilteredView.h:45
DDPlugins.h
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
Definition:
DDPixFwdDiskAlgo.cc:17
MetAnalyzer.pv
def pv(vc)
Definition:
MetAnalyzer.py:7
edm::LogVerbatim
Definition:
MessageLogger.h:297
cms::DDAlgoArguments
Definition:
DDAlgoArguments.h:28
cms::s_executed
static constexpr long s_executed
Definition:
DDAlgoArguments.h:16
align::Detector
Definition:
StructureType.h:86
makeMuonMisalignmentScenario.rot
rot
Definition:
makeMuonMisalignmentScenario.py:322
CMSUnits.h
NAMESPACE_SEP
#define NAMESPACE_SEP
Definition:
DDNamespace.h:79
child
Definition:
simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition:
DDNamespace.h:68
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition:
DDNamespace.cc:190
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
Generated for CMSSW Reference Manual by
1.8.16