Commit in lcdd on MAIN | |||
include/lcdd/hits/CalorimeterHitMap.hh | +60 | added 1.1 | |
src/lcdd/hits/CalorimeterHitMap.cc | +26 | added 1.1 | |
+86 |
add class for fast lookup of CalorimeterHit objects by 64 bit identifier
diff -N CalorimeterHitMap.hh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CalorimeterHitMap.hh 14 Sep 2013 01:40:04 -0000 1.1 @@ -0,0 +1,60 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHitMap.hh,v 1.1 2013/09/14 01:40:04 jeremy Exp $ + +#ifndef lcdd_hits_CalorimeterHitMap_hh +#define lcdd_hits_CalorimeterHitMap_hh 1 + +// LCDD +#include "lcdd/id/Id64bit.hh" +#include "lcdd/hits/CalorimeterHit.hh" + +// STL +#include <map> + +/** + * This class maps CalorimeterHit objects to their 64-bit identifiers + * for fast lookup with O(1) performance. + */ +class CalorimeterHitMap +{ + + /** + * Type definition for map. + */ + typedef std::map<Id64bit::ValueType, CalorimeterHit*> MapType; + +public: + + /** + * Class constructor. + */ + CalorimeterHitMap(); + + /** + * Class destructor. + */ + ~CalorimeterHitMap(); + + /** + * Add a hit. + * @param hit The hit to add. + */ + void add(CalorimeterHit* hit); + + /** + * Get a hit by its 64-bit identifier. + * @param id The identifier of the hit. + * @return The matching hit or 0 if does not exist. + */ + CalorimeterHit* get(const Id64bit& id); + + /** + * Clear all entries from this hit map. + */ + void clear(); + +private: + + MapType _map; +}; + +#endif
diff -N CalorimeterHitMap.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CalorimeterHitMap.cc 14 Sep 2013 01:40:04 -0000 1.1 @@ -0,0 +1,26 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHitMap.cc,v 1.1 2013/09/14 01:40:04 jeremy Exp $ + +#include "lcdd/hits/CalorimeterHitMap.hh" + +CalorimeterHitMap::CalorimeterHitMap() +{} + +CalorimeterHitMap::~CalorimeterHitMap() +{ + _map.clear(); +} + +void CalorimeterHitMap::add(CalorimeterHit* hit) +{ + _map[hit->getId64bit().getValue()] = hit; +} + +CalorimeterHit* CalorimeterHitMap::get(const Id64bit& id) +{ + return _map[id.getValue()]; +} + +void CalorimeterHitMap::clear() +{ + _map.clear(); +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1