ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CellContainer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CellContainer.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef G4DETECTORS_PHG4CELLCONTAINER_H
4 #define G4DETECTORS_PHG4CELLCONTAINER_H
5 
6 #include "PHG4CellDefs.h" // for keytype
7 
8 #include <phool/PHObject.h>
9 
10 #include <iostream> // for cout, ostream
11 #include <map>
12 #include <utility> // for pair
13 
14 class PHG4Cell;
15 
17 {
18 
19  public:
20  typedef std::map<PHG4CellDefs::keytype,PHG4Cell *> Map;
21  typedef Map::iterator Iterator;
22  typedef Map::const_iterator ConstIterator;
23  typedef std::pair<Iterator, Iterator> Range;
24  typedef std::pair<ConstIterator, ConstIterator> ConstRange;
25 
27 
28  ~PHG4CellContainer() override {}
29 
30 // from PHObject
31  void Reset() override;
32  void identify(std::ostream& os = std::cout) const override;
33 
34  ConstIterator AddCell(PHG4Cell *newCell);
36 
39  cellmap.erase(key);
40  }
41 
43  void RemoveCell(PHG4Cell *cell)
44  {
45  Iterator its = cellmap.begin();
46  Iterator last = cellmap.end();
47  for (; its != last;)
48  {
49  if (its->second == cell)
50  {
51  cellmap.erase(its++);
52  }
53  else
54  {
55  ++its;
56  }
57  }
58  }
59 
60 
62 
64  ConstRange getCells(const unsigned short int detid) const;
65 
67  ConstRange getCells( void ) const;
68 
70 
71  unsigned int size( void ) const
72  { return cellmap.size(); }
73 
74  double getTotalEdep() const;
75 
76  protected:
78  ClassDefOverride(PHG4CellContainer,1)
79 };
80 
81 #endif