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