Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:51

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4DETECTORS_PHG4SCINTILLATORSLATCONTAINER_H
0004 #define G4DETECTORS_PHG4SCINTILLATORSLATCONTAINER_H
0005 
0006 #include "PHG4ScintillatorSlatDefs.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
0014 
0015 class PHG4ScintillatorSlat;
0016 
0017 class PHG4ScintillatorSlatContainer : public PHObject
0018 {
0019  public:
0020   typedef std::map<PHG4ScintillatorSlatDefs::keytype, PHG4ScintillatorSlat *> 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   PHG4ScintillatorSlatContainer() {}
0029 
0030   ~PHG4ScintillatorSlatContainer() override {}
0031 
0032   // from PHObject
0033   void identify(std::ostream &os = std::cout) const override;
0034   void Reset() override;
0035 
0036   ConstIterator AddScintillatorSlat(const PHG4ScintillatorSlatDefs::keytype key, PHG4ScintillatorSlat *newscintillatorSlat);
0037 
0038   //! preferred removal method, key is currently the slat id
0039   void RemoveScintillatorSlat(PHG4ScintillatorSlatDefs::keytype key)
0040   {
0041     slatmap.erase(key);
0042   }
0043 
0044   //! inefficent, use key where possible instead
0045   void RemoveScintillatorSlat(PHG4ScintillatorSlat *slat)
0046   {
0047     Iterator its = slatmap.begin();
0048     Iterator last = slatmap.end();
0049     for (; its != last;)
0050     {
0051       if (its->second == slat)
0052       {
0053         slatmap.erase(its++);
0054       }
0055       else
0056       {
0057         ++its;
0058       }
0059     }
0060   }
0061 
0062   //! return all scintillatorSlats matching a given detid
0063   ConstRange getScintillatorSlats(const short icolumn) const;
0064 
0065   //! return all hist
0066   ConstRange getScintillatorSlats(void) const;
0067 
0068   PHG4ScintillatorSlat *findScintillatorSlat(PHG4ScintillatorSlatDefs::keytype key);
0069 
0070   unsigned int size(void) const
0071   {
0072     return slatmap.size();
0073   }
0074 
0075   double getTotalEdep() const;
0076 
0077  protected:
0078   Map slatmap;
0079 
0080   ClassDefOverride(PHG4ScintillatorSlatContainer, 1)
0081 };
0082 
0083 #endif