00001
00002 #ifndef GlastEvent_McIntegratingHit_H
00003 #define GlastEvent_McIntegratingHit_H 1
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <map>
00012 #include "CLHEP/Geometry/Point3D.h"
00013 #include "GaudiKernel/Kernel.h"
00014 #include "GaudiKernel/ContainedObject.h"
00015 #include "GaudiKernel/SmartRefVector.h"
00016 #include "GlastEvent/TopLevel/Definitions.h"
00017 #include "GlastEvent/Utilities/VolumeID.h"
00018 #include "GlastEvent/Utilities/CLHEPStreams.h"
00019
00020
00021 #include "GaudiKernel/ObjectVector.h"
00022 #include "GaudiKernel/ObjectList.h"
00023
00024
00025
00044
00045
00046
00047
00048
00049 #include "GlastEvent/MonteCarlo/McParticle.h"
00050
00051 extern const CLID& CLID_McIntegratingHit;
00052
00053
00054 class McIntegratingHit : virtual public ContainedObject {
00055 public:
00056
00057 virtual const CLID& clID() const { return McIntegratingHit::classID(); }
00058 static const CLID& classID() { return CLID_McIntegratingHit; }
00060
00061
00062 typedef std::map<McParticle*,double> energyDepositMap;
00063
00065 McIntegratingHit() : m_packedFlags(0)
00066 {}
00068 ~McIntegratingHit(){}
00069
00070
00072 const VolumeID volumeID() const;
00074 void setVolumeID( VolumeID value );
00075
00077 double totalEnergy() const;
00079 const HepPoint3D moment1 () const;
00080 HepPoint3D moment1 ();
00082 const HepPoint3D moment2 () const;
00083 HepPoint3D moment2 ();
00084
00086 const energyDepositMap& itemizedEnergy() const;
00087 energyDepositMap& itemizedEnergy();
00089 void setEnergyItems( const energyDepositMap& value );
00091 void clearEnergyItems();
00093 void addEnergyItem( const double& energy, McParticle* t, const HepPoint3D& position );
00094 void addEnergyItem( const double& energy, SmartRef<McParticle> t, const HepPoint3D& position );
00095
00097 bool primaryOrigin() const;
00099 void setPrimaryOrigin( bool value );
00100
00102 bool needDigi() const;
00104 void setNeedDigi( bool value );
00105
00107 virtual StreamBuffer& serialize( StreamBuffer& s );
00109 virtual StreamBuffer& serialize( StreamBuffer& s ) const;
00111 virtual std::ostream& fillStream( std::ostream& s ) const;
00112
00113 private:
00115 VolumeID m_volumeID;
00117 energyDepositMap m_energyItem;
00119 double m_totalEnergy;
00121 HepPoint3D m_moment1seed;
00123 HepPoint3D m_moment2seed;
00125 unsigned long m_packedFlags;
00126 };
00127
00128
00129
00130 template <class TYPE> class ObjectVector;
00131 typedef ObjectVector<McIntegratingHit> McIntegratingHitVector;
00132 template <class TYPE> class ObjectList;
00133 typedef ObjectList<McIntegratingHit> McIntegratingHitList;
00134
00136 inline StreamBuffer& McIntegratingHit::serialize( StreamBuffer& s ) const
00137 {
00138 ContainedObject::serialize(s);
00139 s
00140 << m_volumeID
00141 << m_totalEnergy
00142 << m_moment1seed
00143 << m_moment2seed
00144
00145 << m_energyItem.size();
00146 energyDepositMap::const_iterator it;
00147 for (it = m_energyItem.begin(); it != m_energyItem.end(); it++){
00148 s << it->first
00149 << it->second;
00150 }
00151 return s
00152 << m_packedFlags;
00153 }
00154
00155
00157 inline StreamBuffer& McIntegratingHit::serialize( StreamBuffer& s )
00158 {
00159 energyDepositMap::size_type m_energyItem_size;
00160 ContainedObject::serialize(s);
00161 s
00162 >> m_volumeID
00163 >> m_totalEnergy
00164 >> m_moment1seed
00165 >> m_moment2seed
00166
00167 >> m_energyItem_size;
00168 m_energyItem.clear();
00169 energyDepositMap::size_type i;
00170 for (i = 0; i < m_energyItem_size; i++){
00171 SmartRef<McParticle> first;
00172 double second;
00173 s >> first(this)
00174 >> second;
00175 m_energyItem[first] = second;
00176 }
00177 return s
00178 >> m_packedFlags;
00179 }
00180
00181
00183 inline std::ostream& McIntegratingHit::fillStream( std::ostream& s ) const
00184 {
00185 s << "class McCaloHitBase :"
00186 << "\n Deposited Energy = "
00187 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00188 << m_totalEnergy
00189 << "\n First moment (x, y, z) = "
00190 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00191 << m_moment1seed.x() / m_totalEnergy << ", "
00192 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00193 << m_moment1seed.y() / m_totalEnergy << ", "
00194 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00195 << m_moment1seed.z() / m_totalEnergy << " )"
00196 << "\n Second moment (x, y, z) = "
00197 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00198 << m_moment2seed.x() / m_totalEnergy << ", "
00199 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00200 << m_moment2seed.y() / m_totalEnergy << ", "
00201 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00202 << m_moment2seed.z() / m_totalEnergy << " )"
00203 << "\n Volume ID = " << m_volumeID;
00204 return s;
00205 }
00206
00207 #endif // GlastEvent_McIntegratingHit_H