9#include <analysis/utility/ReferenceFrame.h>
10#include <analysis/VariableManager/Manager.h>
12#include <Math/Vector3D.h>
14#include <mdst/dataobjects/MCParticle.h>
16#include <vxd/geometry/GeoCache.h>
32 std::tuple<ROOT::Math::XYZVector, int, int, int> getmcLocalCoordinates(
const Particle* part)
35 auto* mcparticle = part->getMCParticle();
39 const auto& mcglobal = mcparticle->getDecayVertex();
41 for (
const auto& layer : geo.getLayers()) {
42 for (
const auto& ladder : geo.getLadders(layer)) {
43 for (
const auto& sensor : geo.getSensors(ladder)) {
44 const auto& sInfo = geo.getSensorInfo(sensor);
45 const auto& mclocal = sInfo.pointToLocal(mcglobal,
true);
46 if (sInfo.inside(mclocal))
47 return std::make_tuple(mclocal, sensor.getLayerNumber(), sensor.getLadderNumber(), sensor.getSensorNumber());
54 double mcDecayVertexU(
const Particle* part)
56 return std::get<0>(getmcLocalCoordinates(part)).X();
59 double mcDecayVertexV(
const Particle* part)
61 return std::get<0>(getmcLocalCoordinates(part)).Y();
64 double mcDecayVertexW(
const Particle* part)
66 return std::get<0>(getmcLocalCoordinates(part)).Z();
68 double mcDecayVertexLayer(
const Particle* part)
70 return std::get<1>(getmcLocalCoordinates(part));
73 double mcDecayVertexLadder(
const Particle* part)
75 return std::get<2>(getmcLocalCoordinates(part));
78 double mcDecayVertexSensor(
const Particle* part)
80 return std::get<3>(getmcLocalCoordinates(part));
85 std::tuple<ROOT::Math::XYZVector, int, int, int> getLocalCoordinates(
const Particle* part)
89 const auto& global = frame.getVertex(part);
91 for (
const auto& layer : geo.getLayers()) {
92 for (
const auto& ladder : geo.getLadders(layer)) {
93 for (
const auto& sensor : geo.getSensors(ladder)) {
95 const auto& sInfo = geo.getSensorInfo(sensor);
96 const auto& local = sInfo.pointToLocal(global,
true);
97 if (sInfo.inside(local.X(), local.Y(), 0.1, 0.1)) {
98 if (abs(local.Z()) < 0.1) {
99 return std::make_tuple(local, sensor.getLayerNumber(), sensor.getLadderNumber(), sensor.getSensorNumber());
101 ROOT::Math::XYZVector localz{local.X(), local.Y(), abs(local.Z()) - 0.1};
102 if (sInfo.inside(localz))
103 return std::make_tuple(local, sensor.getLayerNumber(), sensor.getLadderNumber(), sensor.getSensorNumber());
113 double particleU(
const Particle* part)
115 return std::get<0>(getLocalCoordinates(part)).X();
118 double particleV(
const Particle* part)
120 return std::get<0>(getLocalCoordinates(part)).Y();
123 double particleW(
const Particle* part)
125 return std::get<0>(getLocalCoordinates(part)).Z();
127 double particleLayer(
const Particle* part)
129 return std::get<1>(getLocalCoordinates(part));
132 double particleLadder(
const Particle* part)
134 return std::get<2>(getLocalCoordinates(part));
137 double particleSensor(
const Particle* part)
139 return std::get<3>(getLocalCoordinates(part));
142 VARIABLE_GROUP(
"Local Vertex Information");
144 REGISTER_VARIABLE(
"mcDecayVertexU", mcDecayVertexU,
145 "Returns the U position of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
146 REGISTER_VARIABLE(
"mcDecayVertexV", mcDecayVertexV,
147 "Returns the V position of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
148 REGISTER_VARIABLE(
"mcDecayVertexW", mcDecayVertexW,
149 "Returns the W position of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
150 REGISTER_VARIABLE(
"mcDecayVertexLayer", mcDecayVertexLayer,
151 "Returns the Layer ID of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
152 REGISTER_VARIABLE(
"mcDecayVertexLadder", mcDecayVertexLadder,
153 "Returns the ladder ID of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
154 REGISTER_VARIABLE(
"mcDecayVertexSensor", mcDecayVertexSensor,
155 "Returns the sensor ID of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
156 REGISTER_VARIABLE(
"u", particleU,
157 "u local sensor coordinate of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
158 REGISTER_VARIABLE(
"v", particleV,
159 "V local sensor coordinate of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
160 REGISTER_VARIABLE(
"w", particleW,
161 "w local sensor coordinate of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
162 REGISTER_VARIABLE(
"layer", particleLayer,
163 "layer identification of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
164 REGISTER_VARIABLE(
"ladder", particleLadder,
165 "layer identification of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
166 REGISTER_VARIABLE(
"sensor", particleSensor,
167 "sensor identification of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
static const double doubleNaN
quiet_NaN
static const ReferenceFrame & GetCurrent()
Get current rest frame.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Abstract base class for different kinds of events.