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>
33 std::tuple<ROOT::Math::XYZVector, int, int, int> getmcLocalCoordinates(
const Particle* part)
36 auto* mcparticle = part->getMCParticle();
40 const auto& mcglobal = mcparticle->getDecayVertex();
42 for (
const auto& layer : geo.getLayers()) {
43 for (
const auto& ladder : geo.getLadders(layer)) {
44 for (
const auto& sensor : geo.getSensors(ladder)) {
45 const auto& sInfo = geo.getSensorInfo(sensor);
46 const auto& mclocal = sInfo.pointToLocal(mcglobal,
true);
47 if (sInfo.inside(mclocal))
48 return std::make_tuple(mclocal, sensor.getLayerNumber(), sensor.getLadderNumber(), sensor.getSensorNumber());
55 double mcDecayVertexU(
const Particle* part)
57 return std::get<0>(getmcLocalCoordinates(part)).X();
60 double mcDecayVertexV(
const Particle* part)
62 return std::get<0>(getmcLocalCoordinates(part)).Y();
65 double mcDecayVertexW(
const Particle* part)
67 return std::get<0>(getmcLocalCoordinates(part)).Z();
69 double mcDecayVertexLayer(
const Particle* part)
71 return std::get<1>(getmcLocalCoordinates(part));
74 double mcDecayVertexLadder(
const Particle* part)
76 return std::get<2>(getmcLocalCoordinates(part));
79 double mcDecayVertexSensor(
const Particle* part)
81 return std::get<3>(getmcLocalCoordinates(part));
86 std::tuple<ROOT::Math::XYZVector, int, int, int> getLocalCoordinates(
const Particle* part)
90 const auto& global = frame.getVertex(part);
92 for (
const auto& layer : geo.getLayers()) {
93 for (
const auto& ladder : geo.getLadders(layer)) {
94 for (
const auto& sensor : geo.getSensors(ladder)) {
96 const auto& sInfo = geo.getSensorInfo(sensor);
97 const auto& local = sInfo.pointToLocal(global,
true);
98 if (sInfo.inside(local.X(), local.Y(), 0.1, 0.1)) {
99 if (std::abs(local.Z()) < 0.1) {
100 return std::make_tuple(local, sensor.getLayerNumber(), sensor.getLadderNumber(), sensor.getSensorNumber());
102 ROOT::Math::XYZVector localz{local.X(), local.Y(), std::abs(local.Z()) - 0.1};
103 if (sInfo.inside(localz))
104 return std::make_tuple(local, sensor.getLayerNumber(), sensor.getLadderNumber(), sensor.getSensorNumber());
114 double particleU(
const Particle* part)
116 return std::get<0>(getLocalCoordinates(part)).X();
119 double particleV(
const Particle* part)
121 return std::get<0>(getLocalCoordinates(part)).Y();
124 double particleW(
const Particle* part)
126 return std::get<0>(getLocalCoordinates(part)).Z();
128 double particleLayer(
const Particle* part)
130 return std::get<1>(getLocalCoordinates(part));
133 double particleLadder(
const Particle* part)
135 return std::get<2>(getLocalCoordinates(part));
138 double particleSensor(
const Particle* part)
140 return std::get<3>(getLocalCoordinates(part));
143 VARIABLE_GROUP(
"Local Vertex Information");
145 REGISTER_VARIABLE(
"mcDecayVertexU", mcDecayVertexU,
146 "Returns the U position of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
147 REGISTER_VARIABLE(
"mcDecayVertexV", mcDecayVertexV,
148 "Returns the V position of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
149 REGISTER_VARIABLE(
"mcDecayVertexW", mcDecayVertexW,
150 "Returns the W position of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
151 REGISTER_VARIABLE(
"mcDecayVertexLayer", mcDecayVertexLayer,
152 "Returns the Layer ID of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
153 REGISTER_VARIABLE(
"mcDecayVertexLadder", mcDecayVertexLadder,
154 "Returns the ladder ID of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
155 REGISTER_VARIABLE(
"mcDecayVertexSensor", mcDecayVertexSensor,
156 "Returns the sensor ID of the decay vertex of the matched generated particle. Returns nan if the particle has no matched generated particle.");
157 REGISTER_VARIABLE(
"u", particleU,
158 "u local sensor coordinate of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
159 REGISTER_VARIABLE(
"v", particleV,
160 "V local sensor coordinate of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
161 REGISTER_VARIABLE(
"w", particleW,
162 "w local sensor coordinate of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
163 REGISTER_VARIABLE(
"layer", particleLayer,
164 "layer identification of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
165 REGISTER_VARIABLE(
"ladder", particleLadder,
166 "layer identification of vertex in case of composite particle, or point of closest approach (POCA) in case of a track");
167 REGISTER_VARIABLE(
"sensor", particleSensor,
168 "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
Class to store reconstructed particles.
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.