ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
MC::Loops< Evt, Prt, Vtx > Class Template Reference

#include <Loops.h>

Collaboration diagram for MC::Loops< Evt, Prt, Vtx >:

Public Member Functions

 Loops ()
 
 Loops (const Evt *evt)
 
bool isLoop (const Prt &p) const
 
bool isLoop (const Vtx &v) const
 
const std::vector< Prt > & loop_particles () const
 
const std::vector< Vtx > & loop_vertices () const
 
int findLoops (const Evt *evt, bool force)
 

Private Attributes

const Evt * m_evt = nullptr
 
std::vector< Prt > m_loop_particles
 
std::vector< Vtx > m_loop_vertices
 

Detailed Description

template<class Evt, class Prt, class Vtx>
class MC::Loops< Evt, Prt, Vtx >

Definition at line 13 of file Loops.h.

Constructor & Destructor Documentation

◆ Loops() [1/2]

template<class Evt , class Prt , class Vtx >
MC::Loops< Evt, Prt, Vtx >::Loops ( )
inline

Definition at line 15 of file Loops.h.

15 {}

◆ Loops() [2/2]

template<class Evt , class Prt , class Vtx >
MC::Loops< Evt, Prt, Vtx >::Loops ( const Evt *  evt)
inline

Definition at line 16 of file Loops.h.

16  {
17  findLoops(evt,true);
18  }

Member Function Documentation

◆ findLoops()

template<class Evt , class Prt , class Vtx >
int MC::Loops< Evt, Prt, Vtx >::findLoops ( const Evt *  evt,
bool  force 
)
inline

Definition at line 31 of file Loops.h.

31  {
32  if (!evt) return -1;
33  if (evt == m_evt && !force) return 0;
34  m_evt = evt;
35  m_loop_particles.clear();
36  m_loop_vertices.clear();
37  std::map<Prt, int> incycle;
38  for (const auto & p: *m_evt) if (!p->end_vertex()||!p->production_vertex()) incycle[p] = -1;
39  else incycle[p] = 0;
40  size_t minincycle = m_evt->particles_size();
41  for (;;) {
42  size_t unknown = 0;
43  for (const auto & p: *m_evt) {
44  if (incycle[p] != 0) continue;
45  unknown++;
46  auto ev = p->end_vertex();
47  if (ev) {
48  bool goodo = true;
49  for (auto& po: *ev) goodo = goodo && (incycle[po] == -1);
50  if (goodo) incycle[p] = -1;
51  }
52  auto pv = p->production_vertex();
53  if (pv) {
54  bool goodi = true;
55 #ifdef HEPMC3
56  for (auto& pi: ev->particles_in()) goodi = goodi && (incycle[pi] == -1);
57 #else
58  for (auto ip = ev->particles_in_const_begin();
59  ip != ev->particles_in_const_end();
60  ++ip)
61  {
62  goodi = goodi && (incycle[*ip] == -1);
63  }
64 #endif
65  if (goodi) incycle[p] = -1;
66  }
67  }
68  if (minincycle == unknown) break;
69  minincycle = std::min(minincycle, unknown);
70  }
71  for (const auto & p: *m_evt) if (incycle[p] == 0) incycle[p] = 1;
72 
73  for (const auto & p: *m_evt) if (incycle[p] == 1) m_loop_particles.push_back(p);
74 #ifdef HEPMC3
75  for (auto & v: m_evt->vertices()) {
76 #else
77  for (auto iv = m_evt->vertices_begin(); iv != m_evt->vertices_end(); ++iv) {
78  auto v = *iv;
79 #endif
80  bool push = false;
81 #ifdef HEPMC3
82  for ( auto& pin: v->particles_in()) if (incycle[pin] == 1) {
83 #else
84  for ( auto ipin = v->particles_in_const_begin();
85  ipin != v->particles_in_const_end();
86  ++ipin)
87  if (incycle[*ipin] == 1) {
88 #endif
89  push = true;
90  break;
91  }
92  if(!push) {
93  for ( const auto& pou: *v) {
94  if (incycle[pou] == 1) {
95  push = true;
96  break;
97  }
98  }
99  }
100  if (push) m_loop_vertices.push_back(v);
101  }
102  return 0;
103  }

◆ isLoop() [1/2]

template<class Evt , class Prt , class Vtx >
bool MC::Loops< Evt, Prt, Vtx >::isLoop ( const Prt &  p) const
inline

Definition at line 19 of file Loops.h.

19  {
20  return std::find(m_loop_particles.begin(), m_loop_particles.end(), p) != m_loop_particles.end();
21  }

◆ isLoop() [2/2]

template<class Evt , class Prt , class Vtx >
bool MC::Loops< Evt, Prt, Vtx >::isLoop ( const Vtx &  v) const
inline

Definition at line 22 of file Loops.h.

22  {
23  return std::find(m_loop_vertices.begin(), m_loop_vertices.end(), v) != m_loop_vertices.end();
24  }

◆ loop_particles()

template<class Evt , class Prt , class Vtx >
const std::vector<Prt>& MC::Loops< Evt, Prt, Vtx >::loop_particles ( ) const
inline

Definition at line 25 of file Loops.h.

25  {
26  return m_loop_particles;
27  }

◆ loop_vertices()

template<class Evt , class Prt , class Vtx >
const std::vector<Vtx>& MC::Loops< Evt, Prt, Vtx >::loop_vertices ( ) const
inline

Definition at line 28 of file Loops.h.

28  {
29  return m_loop_vertices;
30  }

Member Data Documentation

◆ m_evt

template<class Evt , class Prt , class Vtx >
const Evt* MC::Loops< Evt, Prt, Vtx >::m_evt = nullptr
private

Definition at line 106 of file Loops.h.

◆ m_loop_particles

template<class Evt , class Prt , class Vtx >
std::vector<Prt> MC::Loops< Evt, Prt, Vtx >::m_loop_particles
private

Definition at line 107 of file Loops.h.

◆ m_loop_vertices

template<class Evt , class Prt , class Vtx >
std::vector<Vtx> MC::Loops< Evt, Prt, Vtx >::m_loop_vertices
private

Definition at line 108 of file Loops.h.


The documentation for this class was generated from the following file:
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
calibdata.force
bool force
Definition: calibdata.py:19
MC::Loops::m_loop_vertices
std::vector< Vtx > m_loop_vertices
Definition: Loops.h:108
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
pi
#define pi
Definition: TileMuonFitter.cxx:65
MC::Loops::m_loop_particles
std::vector< Prt > m_loop_particles
Definition: Loops.h:107
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ev
int ev
Definition: globals.cxx:25
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
MC::Loops::m_evt
const Evt * m_evt
Definition: Loops.h:106
min
#define min(a, b)
Definition: cfImp.cxx:40
Muon::nsw::unknown
@ unknown
Definition: NSWTriggerElink.h:36
python.PyAthena.v
v
Definition: PyAthena.py:154
python.changerun.pv
pv
Definition: changerun.py:81
MC::Loops::findLoops
int findLoops(const Evt *evt, bool force)
Definition: Loops.h:31