File indexing completed on 2025-08-05 08:17:43
0001
0002
0003 #ifndef G4DETECTORS_PHG4CELLCONTAINER_H
0004 #define G4DETECTORS_PHG4CELLCONTAINER_H
0005
0006 #include "PHG4CellDefs.h" // for keytype
0007
0008 #include <phool/PHObject.h>
0009
0010 #include <iostream> // for cout, ostream
0011 #include <map>
0012 #include <utility> // for pair
0013
0014 class PHG4Cell;
0015
0016 class PHG4CellContainer : public PHObject
0017 {
0018 public:
0019 typedef std::map<PHG4CellDefs::keytype, PHG4Cell *> Map;
0020 typedef Map::iterator Iterator;
0021 typedef Map::const_iterator ConstIterator;
0022 typedef std::pair<Iterator, Iterator> Range;
0023 typedef std::pair<ConstIterator, ConstIterator> ConstRange;
0024
0025 PHG4CellContainer();
0026
0027 ~PHG4CellContainer() override {}
0028
0029
0030 void Reset() override;
0031 void identify(std::ostream &os = std::cout) const override;
0032
0033 ConstIterator AddCell(PHG4Cell *newCell);
0034 ConstIterator AddCellSpecifyKey(const PHG4CellDefs::keytype key, PHG4Cell *newCell);
0035
0036
0037 void RemoveCell(PHG4CellDefs::keytype key)
0038 {
0039 cellmap.erase(key);
0040 }
0041
0042
0043 void RemoveCell(PHG4Cell *cell)
0044 {
0045 Iterator its = cellmap.begin();
0046 Iterator last = cellmap.end();
0047 for (; its != last;)
0048 {
0049 if (its->second == cell)
0050 {
0051 cellmap.erase(its++);
0052 }
0053 else
0054 {
0055 ++its;
0056 }
0057 }
0058 }
0059
0060 Iterator findOrAddCell(PHG4CellDefs::keytype key);
0061
0062
0063 ConstRange getCells(const unsigned short int detid) const;
0064
0065
0066 ConstRange getCells(void) const;
0067
0068 PHG4Cell *findCell(PHG4CellDefs::keytype key);
0069
0070 unsigned int size(void) const
0071 {
0072 return cellmap.size();
0073 }
0074
0075 double getTotalEdep() const;
0076
0077 protected:
0078 Map cellmap;
0079 ClassDefOverride(PHG4CellContainer, 1)
0080 };
0081
0082 #endif