forked from sPHENIX-Collaboration/acts
/
DetUtils.h
115 lines (106 loc) · 5.21 KB
/
DetUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once
// DD4hep
#include "Acts/Plugins/Digitization/CartesianSegmentation.hpp"
#include "Acts/Plugins/Digitization/DigitizationModule.hpp"
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Detector.h"
#include "DD4hep/Objects.h"
#include "DD4hep/Segmentations.h"
#include "DDSegmentation/BitField64.h"
#include "DDSegmentation/CartesianGridXY.h"
#include "DDSegmentation/CartesianGridXYZ.h"
#include "DDSegmentation/PolarGridRPhi.h"
/** Given a xml element with several daughters with the same name, e.g.
<detector> <layer name="1" /> <layer name="2"> </detector>
this method returns the first daughter of type nodeName whose attribute has a
given value
e.g. returns <layer name="2"/> when called with (detector, "layer", "name",
"1") */
namespace det {
namespace utils {
/// Global method to build an Acts::DigitizationModule with rectangular
/// segmentation.
/// @note This function should be used in order to create the input
/// needed for construction with
/// Acts::ActsExtension(std::shared_ptr<const DigitizationModule>)
/// @param halflengthX The half length in x of the detector module
/// @param halflengthZ The half length in z of the detector module
/// @param thickness The thickness of the detector module
/// @param segmentation the DD4hep segmentation
std::shared_ptr<const Acts::DigitizationModule>
rectangleDigiModuleXZ(double halflengthX,
double halflengthZ,
double thickness,
const dd4hep::Segmentation& segmentation);
/// Global method to build an Acts::DigitizationModule with rectangular
/// segmentation.
/// @note This function should be used in order to create the input
/// needed for construction with
/// Acts::ActsExtension(std::shared_ptr<const DigitizationModule>)
/// @param halflengthX The half length in x of the detector module
/// @param halflengthZ The half length in z of the detector module
/// @param thickness The thickness of the detector module
/// @param gridSizeX The grid size in x
/// @param gridSizeY The grid size in y
std::shared_ptr<const Acts::DigitizationModule>
rectangleDigiModuleXZ(double halflengthX,
double halflengthZ,
double thickness,
double gridSizeX,
double gridSizeZ);
/// Global method to build an Acts::DigitizationModule with trapezoidal
/// segmentation.
/// @note This function should be used in order to create the input
/// needed for construction with
/// Acts::ActsExtension(std::shared_ptr<const DigitizationModule>)
/// @param minHalflengthX The half length in x of the detector module on the
/// negative side of z
/// @param maxHalflengthX The half length in x of the detector module on the
/// positive side of z
/// @param halflengthZ The half length in z of the detector module
/// @param thickness The thickness of the detector module
/// @param segmentation the DD4hep segmentation
std::shared_ptr<const Acts::DigitizationModule>
trapezoidalDigiModuleXZ(double minHalflengthX,
double maxHalflengthX,
double halflengthZ,
double thickness,
const dd4hep::Segmentation& segmentation);
/// Global method to build an Acts::DigitizationModule with trapezoidal
/// segmentation.
/// @note This function should be used in order to create the input
/// needed for construction with
/// Acts::ActsExtension(std::shared_ptr<const DigitizationModule>)
/// @param minHalflengthX The half length in x of the detector module on the
/// negative side of z
/// @param maxHalflengthX The half length in x of the detector module on the
/// positive side of z
/// @param halflengthZ The half length in z of the detector module
/// @param thickness The thickness of the detector module
/// @param gridSizeX The grid size in x
/// @param gridSizeY The grid size in y
std::shared_ptr<const Acts::DigitizationModule>
trapezoidalDigiModuleXZ(double minHalflengthX,
double maxHalflengthX,
double halflengthZ,
double thickness,
double gridSizeX,
double gridSizeZ);
/// @brief Retrieves the the node componetn from a mother by the string names
/// @param mother The Handle to the mother volume
/// @param nodeName The name of the note
/// @param attrName The name of the Atribute
/// @param attrValue The attribute value
dd4hep::xml::Component
getNodeByStrAttr(const dd4hep::xml::Handle_t& mother,
const std::string& nodeName,
const std::string& attrName,
const std::string& attrValue);
/// try to get attribute with double value, return defaultValue if attribute
/// not found
double
getAttrValueWithFallback(const dd4hep::xml::Component& node,
const std::string& attrName,
const double& defaultValue);
}
}