EIC 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  void Reset() override;
38  int isValid() const override { return 1; }
39  PHHepMCGenEventMap* CloneMe() const override { return new PHHepMCGenEventMap(*this); }
41  bool empty() const { return _map.empty(); }
42  size_t size() const { return _map.size(); }
43  size_t count(int idkey) const { return _map.count(idkey); }
44  void clear() { Reset(); }
46  const PHHepMCGenEvent* get(int idkey) const;
47  PHHepMCGenEvent* get(int idkey);
48 
50  PHHepMCGenEvent* insert(const PHHepMCGenEvent* event) { return insert_active_event(event); }
52  PHHepMCGenEvent* insert_active_event(const PHHepMCGenEvent* event = nullptr);
56  PHHepMCGenEvent* insert_event(const int embedding_id, const PHHepMCGenEvent* event = nullptr);
57 
58  size_t erase(int idkey)
59  {
60  delete _map[idkey];
61  return _map.erase(idkey);
62  }
63 
65  ConstIter find(unsigned int idkey) const { return _map.find(idkey); }
66  Iter find(int idkey) { return _map.find(idkey); }
68  ConstIter begin() const { return _map.begin(); }
69  ConstIter end() const { return _map.end(); }
70  Iter begin() { return _map.begin(); }
71  Iter end() { return _map.end(); }
73  ConstReverseIter rbegin() const { return _map.rbegin(); }
74  ConstReverseIter rend() const { return _map.rend(); }
75  ReverseIter rbegin() { return _map.rbegin(); }
76  ReverseIter rend() { return _map.rend(); }
77  //
79  const HepMCGenEventMap& get_map() const { return _map; }
80  HepMCGenEventMap& get_map() { return _map; }
81 
82  private:
84 
86 };
87 
88 #endif