Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHHepMCGenEventMap.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHHepMCGenEventMap.h
1 #ifndef PHHEPMC_PHHEPMCGENEVENTMAP_H
2 #define PHHEPMC_PHHEPMCGENEVENTMAP_H
3 
4 #include "PHHepMCGenEvent.h"
5 
6 #include <phool/PHObject.h>
7 
8 #include <cstddef> // for size_t
9 #include <iostream> // for cout, ostream
10 #include <map>
11 
18 {
19  public:
24  typedef std::map<int, PHHepMCGenEvent*> HepMCGenEventMap;
25  typedef std::map<int, PHHepMCGenEvent*>::const_iterator ConstIter;
26  typedef std::map<int, PHHepMCGenEvent*>::iterator Iter;
27  typedef std::map<int, PHHepMCGenEvent*>::const_reverse_iterator ConstReverseIter;
28  typedef std::map<int, PHHepMCGenEvent*>::reverse_iterator ReverseIter;
29 
30  PHHepMCGenEventMap() = default;
31  PHHepMCGenEventMap(const PHHepMCGenEventMap& eventmap);
33 
34  ~PHHepMCGenEventMap() override;
35 
36  void identify(std::ostream& os = std::cout) const override;
37 // cppcheck-suppress virtualCallInConstructor
38  void Reset() override;
39  int isValid() const override { return 1; }
40  PHHepMCGenEventMap* CloneMe() const override { return new PHHepMCGenEventMap(*this); }
42  bool empty() const { return _map.empty(); }
43  size_t size() const { return _map.size(); }
44  size_t count(int idkey) const { return _map.count(idkey); }
45  void clear() { Reset(); }
47  const PHHepMCGenEvent* get(int idkey) const;
48  PHHepMCGenEvent* get(int idkey);
49 
57  PHHepMCGenEvent* insert_event(const int embedding_id, const PHHepMCGenEvent* event = nullptr);
58 
59  size_t erase(int idkey)
60  {
61  delete _map[idkey];
62  return _map.erase(idkey);
63  }
64 
66  ConstIter find(unsigned int idkey) const { return _map.find(idkey); }
67  Iter find(int idkey) { return _map.find(idkey); }
69  ConstIter begin() const { return _map.begin(); }
70  ConstIter end() const { return _map.end(); }
71  Iter begin() { return _map.begin(); }
72  Iter end() { return _map.end(); }
74  ConstReverseIter rbegin() const { return _map.rbegin(); }
75  ConstReverseIter rend() const { return _map.rend(); }
76  ReverseIter rbegin() { return _map.rbegin(); }
77  ReverseIter rend() { return _map.rend(); }
78  //
80  const HepMCGenEventMap& get_map() const { return _map; }
81  HepMCGenEventMap& get_map() { return _map; }
82 
83  private:
85 
87 };
88 
89 #endif