00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SimEvent_SimHitHeader_H
00016 #define SimEvent_SimHitHeader_H 1
00017
00018
00019 #include "GaudiKernel/boost_allocator.h"
00020 #include <map>
00021 #include <ostream>
00022
00023
00024
00025 namespace DayaBay
00026 {
00027
00028
00029 class SimHeader;
00030 class SimHitCollection;
00031
00032
00042 class SimHitHeader
00043 {
00044 public:
00045
00047 typedef std::map<short int,DayaBay::SimHitCollection*> hc_map;
00048
00050 SimHitHeader(DayaBay::SimHeader* header) : m_header(header),
00051 m_hitCollection() {}
00052
00054 SimHitHeader() : m_header(0),
00055 m_hitCollection() {}
00056
00058 ~SimHitHeader();
00059
00061 hc_map& hitCollection();
00062
00064 void addHitCollection(DayaBay::SimHitCollection* hc);
00065
00067 std::vector<short int> hitDetectors();
00068
00070 SimHitCollection* hitsByDetector(short int detector);
00071
00073 std::ostream& fillStream(std::ostream& s) const;
00074
00077 const DayaBay::SimHeader* header() const;
00078
00081 void setHeader(DayaBay::SimHeader* value);
00082
00085 const hc_map& hitCollection() const;
00086
00087
00088 #ifndef GOD_NOALLOC
00090 static void* operator new ( size_t size )
00091 {
00092 return ( sizeof(SimHitHeader) == size ?
00093 boost::singleton_pool<SimHitHeader, sizeof(SimHitHeader)>::malloc() :
00094 ::operator new(size) );
00095 }
00096
00100 static void* operator new ( size_t size, void* pObj )
00101 {
00102 return ::operator new (size,pObj);
00103 }
00104
00106 static void operator delete ( void* p )
00107 {
00108 boost::singleton_pool<SimHitHeader, sizeof(SimHitHeader)>::is_from(p) ?
00109 boost::singleton_pool<SimHitHeader, sizeof(SimHitHeader)>::free(p) :
00110 ::operator delete(p);
00111 }
00112
00115 static void operator delete ( void* p, void* pObj )
00116 {
00117 ::operator delete (p, pObj);
00118 }
00119 #endif
00120 protected:
00121
00122 private:
00123
00124 DayaBay::SimHeader* m_header;
00125 hc_map m_hitCollection;
00126
00127 };
00128
00129 inline std::ostream& operator<< (std::ostream& str, const SimHitHeader& obj)
00130 {
00131 return obj.fillStream(str);
00132 }
00133
00134 }
00135
00136
00137
00138
00139
00140
00141 #include "SimHeader.h"
00142 #include "SimHitCollection.h"
00143
00144
00145 inline const DayaBay::SimHeader* DayaBay::SimHitHeader::header() const
00146 {
00147 return m_header;
00148 }
00149
00150 inline void DayaBay::SimHitHeader::setHeader(DayaBay::SimHeader* value)
00151 {
00152 m_header = value;
00153 }
00154
00155 inline const DayaBay::SimHitHeader::hc_map& DayaBay::SimHitHeader::hitCollection() const
00156 {
00157 return m_hitCollection;
00158 }
00159
00160 inline std::vector<short int> DayaBay::SimHitHeader::hitDetectors()
00161 {
00162
00163 hc_map::iterator hcIter, hcEnd = m_hitCollection.end();
00164 std::vector<short int> detectors;
00165 for(hcIter=m_hitCollection.begin(); hcIter != hcEnd; hcIter++)
00166 detectors.push_back(hcIter->first);
00167 return detectors;
00168
00169 }
00170
00171 inline DayaBay::SimHitCollection* DayaBay::SimHitHeader::hitsByDetector(short int detector)
00172 {
00173
00174 hc_map::iterator hcIter = m_hitCollection.find(detector);
00175 if(hcIter == m_hitCollection.end())
00176 return 0;
00177 return hcIter->second;
00178
00179 }
00180
00181
00182 #endif