Geometry
TrackerCommonData
plugins
dd4hep
DDTECOptoHybAlgo.cc
Go to the documentation of this file.
1
#include "DD4hep/DetFactoryHelper.h"
2
#include "
DataFormats/Math/interface/CMSUnits.h
"
3
#include "
DetectorDescription/DDCMS/interface/DDPlugins.h
"
4
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
5
6
using namespace
std
;
7
using namespace
dd4hep
;
8
using namespace
cms
;
9
using namespace
cms_units::operators
;
10
11
static
long
algorithm
(
Detector
&
/* description */
,
cms::DDParsingContext
& ctxt, xml_h
e
) {
12
cms::DDNamespace
ns(ctxt,
e
,
true
);
13
DDAlgoArguments
args
(ctxt,
e
);
14
int
startCopyNo =
args
.value<
int
>(
"StartCopyNo"
);
15
double
rpos =
args
.value<
double
>(
"Rpos"
);
16
double
zpos =
args
.value<
double
>(
"Zpos"
);
17
double
optoHeight =
args
.value<
double
>(
"OptoHeight"
);
18
double
optoWidth =
args
.value<
double
>(
"OptoWidth"
);
19
vector<double>
angles
=
args
.value<vector<double> >(
"Angles"
);
20
Volume
child
= ns.
volume
(
args
.value<
string
>(
"ChildName"
));
21
Volume
mother = ns.
volume
(
args
.parentName());
22
23
LogDebug
(
"TECGeom"
) <<
"Parent "
<< mother.name() <<
" Child "
<<
child
.name() <<
" NameSpace "
<< ns.
name
();
24
LogDebug
(
"TECGeom"
) <<
"Height of the Hybrid "
<< optoHeight <<
" and Width "
<< optoWidth <<
"Rpos "
<< rpos
25
<<
" Zpos "
<< zpos <<
" StartCopyNo "
<< startCopyNo <<
" Number "
<<
angles
.size();
26
27
// given r positions are for the lower left corner
28
rpos += optoHeight / 2;
29
int
copyNo = startCopyNo;
30
for
(
double
angle
:
angles
) {
31
double
phix = -
angle
;
32
// given phi positions are for the lower left corner
33
phix += asin(optoWidth / 2 / rpos);
34
double
xpos = rpos *
cos
(phix);
35
double
ypos = rpos *
sin
(phix);
36
Position
tran(xpos, ypos, zpos);
37
38
Rotation3D
rotation
;
39
double
phiy = phix + 90._deg;
40
double
phideg =
convertRadToDeg
(phix);
41
if
(phideg != 0) {
42
string
rotstr = ns.
nsName
(
child
.name()) + std::to_string(phideg * 1000.);
43
auto
irot = ctxt.
rotations
.find(ns.
prepend
(rotstr));
44
if
(irot != ctxt.
rotations
.end()) {
45
rotation
= ns.
rotation
(ns.
prepend
(rotstr));
46
}
else
{
47
double
theta
= 90._deg;
48
LogDebug
(
"TECGeom"
) <<
"test: Creating a new "
49
<<
"rotation: "
<< rotstr <<
"\t90., "
<<
convertRadToDeg
(phix) <<
", 90.,"
50
<<
convertRadToDeg
(phiy) <<
", 0, 0"
;
51
rotation
=
makeRotation3D
(
theta
, phix,
theta
, phiy, 0., 0.);
52
}
53
}
54
mother.placeVolume(
child
, copyNo, Transform3D(
rotation
, tran));
55
LogDebug
(
"TECGeom"
) <<
"test "
<<
child
.name() <<
" number "
<< copyNo <<
" positioned in "
<< mother.name()
56
<<
" at "
<< tran <<
" with "
<<
rotation
;
57
copyNo++;
58
}
59
LogDebug
(
"TECGeom"
) <<
"<<== End of DDTECOptoHybAlgo construction ..."
;
60
return
1;
61
}
62
63
// first argument is the type from the xml file
64
DECLARE_DDCMS_DETELEMENT
(DDCMS_track_DDTECOptoHybAlgo,
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
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition:
DDTECOptoHybAlgo.cc:11
cms::DDParsingContext
Definition:
DDParsingContext.h:13
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition:
angle_units.h:21
cms::DDNamespace
Definition:
DDNamespace.h:16
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition:
DDAlgoArguments.cc:20
cms::DDParsingContext::rotations
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
Definition:
DDParsingContext.h:71
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
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition:
DDNamespace.cc:60
theta
Geom::Theta< T > theta() const
Definition:
Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition:
PixelTestBeamValidation_cfi.py:75
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition:
DDNamespace.cc:125
cms::Volume
dd4hep::Volume Volume
Definition:
DDFilteredView.h:47
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:233
idealTransformation.rotation
dictionary rotation
Definition:
idealTransformation.py:1
DDPlugins.h
cms::DDAlgoArguments
Definition:
DDAlgoArguments.h:28
align::Detector
Definition:
StructureType.h:92
cms::DDNamespace::nsName
static std::string nsName(const std::string &)
Definition:
DDNamespace.cc:83
std
Definition:
JetResolutionObject.h:76
particleFlowDisplacedVertex_cfi.angles
angles
Definition:
particleFlowDisplacedVertex_cfi.py:84
dd4hep
Definition:
DDPlugins.h:8
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition:
angle.h:11
CMSUnits.h
child
Definition:
simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition:
DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition:
DDNamespace.cc:205
cms
Namespace of DDCMS conversion namespace.
Definition:
ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
Generated for CMSSW Reference Manual by
1.8.16