ATLAS Offline Software
Loading...
Searching...
No Matches
McEventCollection.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7namespace {
8 class MatchEventNumber {
9 public:
10 MatchEventNumber(int eventNumber) : m_evtNumber(eventNumber) {}
11 bool operator()(const HepMC::GenEvent* pGE) const {
12 return (m_evtNumber == pGE->event_number());
13 }
14 private:
15 int m_evtNumber;
16 };
17 class FilledMatchEventNumber {
18 public:
19 FilledMatchEventNumber(int eventNumber) : m_evtNumber(eventNumber) {}
20 bool operator()(const HepMC::GenEvent* pGE) const {
21 return ((m_evtNumber == pGE->event_number()) && !(pGE->vertices_empty()) );
22 }
23 private:
24 int m_evtNumber;
25 };
26}
27
28
29const HepMC::GenEvent*
30McEventCollection::find(int eventNumber) const {
31 const_iterator i(std::find_if(begin(), end(), FilledMatchEventNumber(eventNumber)));
32 if (end() == i)
33 {
34 //Didn't find a filled copy, so checking for an empty one.
35 return (end() != (i=std::find_if(begin(), end(), MatchEventNumber(eventNumber)))) ? *i : nullptr ;
36
37 }
38 return *i;
39
40
41}
42
43
44template class ClassName<McEventCollection>;
An interface for getting the name of a class as a string.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
const HepMC::GenEvent * find(int evtNumber) const