ATLAS Offline Software
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 
7 namespace {
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 
29 const HepMC::GenEvent*
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 
44 template class ClassName<McEventCollection>;
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
McEventCollection.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
ClassName
An interface for getting the name of a class as a string.
Definition: AthenaKernel/AthenaKernel/ClassName.h:31
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
DataVector< HepMC::GenEvent >::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
McEventCollection::find
const HepMC::GenEvent * find(int evtNumber) const
Definition: McEventCollection.cxx:30
DataVector< HepMC::GenEvent >::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.