File indexing completed on 2025-08-06 08:18:56
0001
0002
0003 #ifndef G4DETECTORS_PHG4CYLINDERCELLCONTAINER_H
0004 #define G4DETECTORS_PHG4CYLINDERCELLCONTAINER_H
0005
0006 #include "PHG4CylinderCellDefs.h" // for keytype
0007
0008 #include <phool/PHObject.h>
0009
0010 #include <iostream> // for cout, ostream
0011 #include <map>
0012 #include <set>
0013 #include <utility> // for pair, make_pair
0014
0015 class PHG4CylinderCell;
0016
0017 class PHG4CylinderCellContainer : public PHObject
0018 {
0019 public:
0020 typedef std::map<PHG4CylinderCellDefs::keytype, PHG4CylinderCell *> Map;
0021 typedef Map::iterator Iterator;
0022 typedef Map::const_iterator ConstIterator;
0023 typedef std::pair<Iterator, Iterator> Range;
0024 typedef std::pair<ConstIterator, ConstIterator> ConstRange;
0025 typedef std::set<int>::const_iterator LayerIter;
0026 typedef std::pair<LayerIter, LayerIter> LayerRange;
0027
0028 PHG4CylinderCellContainer() {}
0029
0030 ~PHG4CylinderCellContainer() override {}
0031
0032
0033 void identify(std::ostream &os = std::cout) const override;
0034 void Reset() override;
0035
0036 ConstIterator AddCylinderCell(const unsigned int detid, PHG4CylinderCell *newcylinderCell);
0037 ConstIterator AddCylinderCellSpecifyKey(const PHG4CylinderCellDefs::keytype key, PHG4CylinderCell *newcylinderCell);
0038
0039
0040 void RemoveCylinderCell(PHG4CylinderCellDefs::keytype key)
0041 {
0042 cellmap.erase(key);
0043 }
0044
0045
0046 void RemoveCylinderCell(PHG4CylinderCell *cell)
0047 {
0048 Iterator its = cellmap.begin();
0049 Iterator last = cellmap.end();
0050 for (; its != last;)
0051 {
0052 if (its->second == cell)
0053 {
0054 cellmap.erase(its++);
0055 }
0056 else
0057 {
0058 ++its;
0059 }
0060 }
0061 }
0062
0063 Iterator findOrAddCylinderCell(PHG4CylinderCellDefs::keytype key);
0064
0065 PHG4CylinderCellDefs::keytype genkey(const unsigned int detid);
0066
0067
0068 ConstRange getCylinderCells(const unsigned int detid) const;
0069
0070
0071 ConstRange getCylinderCells(void) const;
0072
0073 PHG4CylinderCell *findCylinderCell(PHG4CylinderCellDefs::keytype key);
0074
0075 unsigned int size(void) const
0076 {
0077 return cellmap.size();
0078 }
0079 unsigned int num_layers(void) const
0080 {
0081 return layers.size();
0082 }
0083 LayerRange getLayers() const
0084 {
0085 return make_pair(layers.begin(), layers.end());
0086 }
0087
0088 double getTotalEdep() const;
0089
0090 protected:
0091 Map cellmap;
0092 std::set<int> layers;
0093
0094 ClassDefOverride(PHG4CylinderCellContainer, 1)
0095 };
0096
0097 #endif