5#ifndef TRUTHUTILS_LOOPS_H
6#define TRUTHUTILS_LOOPS_H
23 const auto parentOrigVtx = parent->production_vertex();
34 const int parentPDG = parent->pdg_id();
35 for (
const auto& aChild: childOrigVtx->particles_out()) {
36 if (!aChild)
continue;
49 decltype(child->production_vertex()) child_prdVtx{};
50 decltype(child->end_vertex()) child_endVtx{};
52 child_prdVtx = child->production_vertex();
53 child_endVtx = child->end_vertex();
55 decltype(parent->production_vertex()) parent_prdVtx{};
56 decltype(parent->end_vertex()) parent_endVtx{};
58 parent_prdVtx = parent->production_vertex();
59 parent_endVtx = parent->end_vertex();
61 return (child_endVtx == parent_prdVtx && child_prdVtx == parent_endVtx);
72template <
class Evt,
class Prt,
class Vtx>
110 if (evt ==
m_evt && !force)
return 0;
120 std::map<Prt, int> incycle;
123 for (
const auto & p: *
m_evt){
124 if (!p->end_vertex()||!p->production_vertex()){
132 size_t minincycle =
m_evt->particles_size();
136 for (
const auto & p: *
m_evt) {
139 if (incycle[p] != 0)
continue;
144 auto ev = p->end_vertex();
149 for (
auto& po: *
ev) goodo = goodo && (incycle[po] == -1);
150 if (goodo) incycle[p] = -1;
154 auto pv = p->production_vertex();
159 for (
auto&
pi: pv->particles_in()) goodi = goodi && (incycle[
pi] == -1);
160 if (goodi) incycle[p] = -1;
164 if (minincycle == unknown)
break;
166 minincycle = std::min(minincycle, unknown);
171 for (
const auto & p: *
m_evt){
172 if (incycle[p] == 0) incycle[p] = 1;
177 for (
auto & v:
m_evt->vertices()) {
181 for (
auto& pin: v->particles_in()){
182 if (incycle[pin] == 1) {
191 for (
const auto& pou: *v) {
192 if (incycle[pou] == 1) {
bool isLoop(const Prt &p) const
Is this particle in a loop?
const Evt * m_evt
Local pointer to the event passed in the constructor or most recent call to findLoops.
Loops(const Evt *evt)
Constructor passing the event; immediately index the event that is passed.
Loops()
Default constructor.
bool isLoop(const Vtx &v) const
Is this vertex in a loop?
const std::vector< Vtx > & loop_vertices() const
Accessor: return the full list of vertices in loops.
std::vector< Vtx > m_loop_vertices
List of all vertices in m_evt that are in loops.
int findLoops(const Evt *evt, bool force)
Function that does the work to identify loops Pass the event of interest.
const std::vector< Prt > & loop_particles() const
Accessor: return the full list of particles in loops.
std::vector< Prt > m_loop_particles
List of all particles in m_evt that are in loops.
bool is_same_generator_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same generated particle.
bool is_same_vertex(const T1 &p1, const T2 &p2)
Method to establish if two vertices in the GenEvent actually represent the same vertex.
bool TruthLoopDetectionMethod1(const V &childOrigVtx, const T &parent)
Method 1: true if the parent is among the children produced at the child's production vertex,...
bool TruthLoopDetectionMethod2(const T1 &child, const T2 &parent)
Method 2: true if the parent's production vertex is the child's decay vertex and the child's producti...
bool TruthLoopDetectionMethod3(const V &childOrigVtx, const T &parent)
Protection against loops in the truth record (MCTruthClassifier legacy).
A namespace for all vertexing packages and related stuff.