Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef TRACKBASE_TRKRHITSET_H
0002 #define TRACKBASE_TRKRHITSET_H
0003 /**
0004  * @file trackbase/TrkrHitSet.h
0005  * @author D. McGlinchey, H. PEREIRA DA COSTA
0006  * @date 4 June 2018
0007  * @brief Base Class Container for storing TrkrHit's
0008  */
0009 
0010 #include "TrkrDefs.h"
0011 
0012 #include <phool/PHObject.h>
0013 
0014 #include <iostream>
0015 #include <map>
0016 #include <utility>  // for pair
0017 
0018 //! forward declaration
0019 class TrkrHit;
0020 
0021 /**
0022  * @brief Container for storing TrkrHit's
0023  *
0024  * Container object which stores a set of TrkrHit objects.
0025  * A single TrkrHitSet is meant to represent a geometric detector object
0026  * which bounds clustering. Therefore, a TrkrHitSet should contain all
0027  * TrkrHits which could belong the the same cluster.
0028  */
0029 class TrkrHitSet : public PHObject
0030 {
0031  public:
0032   // iterator typedef
0033   using Map = std::map<TrkrDefs::hitkey, TrkrHit*>;
0034   using ConstIterator = Map::const_iterator;
0035   using ConstRange = std::pair<ConstIterator, ConstIterator>;
0036 
0037   //! TObject functions
0038   void identify(std::ostream& /*os*/ = std::cout) const override
0039   {
0040   }
0041 
0042   void Reset() override
0043   {
0044   }
0045 
0046   /**
0047    * @brief Set the key for this object
0048    * @param key
0049    */
0050   virtual void setHitSetKey(const TrkrDefs::hitsetkey)
0051   {
0052   }
0053 
0054   /**
0055    * @brief Get the key for this object
0056    * @param[out] object key
0057    */
0058   virtual TrkrDefs::hitsetkey getHitSetKey() const
0059   {
0060     return TrkrDefs::HITSETKEYMAX;
0061   }
0062 
0063   /**
0064    * @brief Add a hit to this container using a specific key.
0065    * @param[in] key Hit key
0066    * @param[in] hit Hit to be added.
0067    *
0068    * NOTE: This TrkrHitSet takes ownership of the passed TrkrHit pointer
0069    * and will delete it in the Reset() method.
0070    */
0071   virtual ConstIterator addHitSpecificKey(const TrkrDefs::hitkey, TrkrHit*);
0072 
0073   /**
0074    * @brief Remove a hit using its key
0075    * @param[in] key to be removed
0076    */
0077   virtual void removeHit(TrkrDefs::hitkey)
0078   {
0079   }
0080 
0081   /**
0082    * @brief Get a specific hit based on its index.
0083    * @param key of the desired hit
0084    * @param[out] Pointer to the desired hit. nullptr if no hit.
0085    *
0086    * Get a desired hit based on its key.
0087    */
0088   virtual TrkrHit* getHit(const TrkrDefs::hitkey) const
0089   {
0090     return nullptr;
0091   }
0092 
0093   /**
0094    * @brief Get all hits
0095    * @param[out] Pair of iterator to vector begin and end
0096    */
0097   virtual ConstRange getHits() const;
0098 
0099   /**
0100    * @brief Get the number of hits stored
0101    * @param[out] number of hits
0102    */
0103   // Get number of hits
0104   virtual unsigned int size() const
0105   {
0106     return 0;
0107   }
0108 
0109  protected:
0110   //! ctor, not to be called
0111   TrkrHitSet() = default;
0112 
0113  private:
0114   ClassDefOverride(TrkrHitSet, 1);
0115 };
0116 
0117 #endif  // TRACKBASE_TRKRHITSET_H