00001
00002
00003 #include <iostream>
00004 #include "CLHEP/Geometry/Point3D.h"
00005 #include "GlastEvent/MonteCarlo/McIntegratingHit.h"
00006 #include "GlastEvent/Utilities/CLHEPStreams.h"
00007
00008
00009
00010
00011
00012
00013
00014 using namespace GlastEvent;
00015
00017 void McIntegratingHit::setEnergyItems( const energyDepositMap& value )
00018 {
00019 m_energyItem = value;
00020 m_totalEnergy = 0.;
00021 m_moment1seed = HepPoint3D(0., 0., 0.);
00022 m_moment2seed = HepPoint3D(0., 0., 0.);
00023 typedef energyDepositMap::const_iterator CI;
00024 for (CI it = m_energyItem.begin(); it != m_energyItem.end(); it++){
00025 const double& energy = it->second;
00026 const HepPoint3D& position = it->first->mcVertex()->finalPosition();
00027 HepPoint3D position2 = HepPoint3D(position.x()*position.x(), position.y()*position.y(), position.z()*position.z());
00028 m_totalEnergy += energy;
00029 m_moment1seed += energy * position;
00030 m_moment2seed += energy * position2;
00031 }
00032 }
00033
00034
00036 void McIntegratingHit::clearEnergyItems()
00037 {
00038 m_energyItem.clear();
00039 m_totalEnergy = 0.;
00040 m_moment1seed = HepPoint3D(0., 0., 0.);
00041 m_moment2seed = HepPoint3D(0., 0., 0.);
00042 }
00043
00044
00045
00046
00047
00049 const VolumeID McIntegratingHit::volumeID() const
00050 {
00051 return m_volumeID;
00052 }
00053
00054
00056 void McIntegratingHit::setVolumeID( VolumeID value )
00057 {
00058 m_volumeID = value;
00059 }
00060
00061
00063 double McIntegratingHit::totalEnergy() const
00064 {
00065 return m_totalEnergy;
00066 }
00067
00068
00070 const HepPoint3D McIntegratingHit::moment1 () const
00071 {
00072 return m_moment1seed * (1./m_totalEnergy);
00073 }
00074 HepPoint3D McIntegratingHit::moment1 ()
00075 {
00076 return m_moment1seed * (1./m_totalEnergy);
00077 }
00078
00079
00081 const HepPoint3D McIntegratingHit::moment2 () const
00082 {
00083 return m_moment2seed * (1./m_totalEnergy);
00084 }
00085 HepPoint3D McIntegratingHit::moment2 ()
00086 {
00087 return m_moment2seed * (1./m_totalEnergy);
00088 }
00089
00090
00092 const McIntegratingHit::energyDepositMap& McIntegratingHit::itemizedEnergy() const
00093 {
00094 return m_energyItem;
00095 }
00096
00097 McIntegratingHit::energyDepositMap& McIntegratingHit::itemizedEnergy()
00098 {
00099 return m_energyItem;
00100 }
00101
00102
00104 void McIntegratingHit::addEnergyItem(const double& energy, McParticle* t, const HepPoint3D& position)
00105 {
00106 m_energyItem[t] += energy;
00107
00108 HepPoint3D position2 = HepPoint3D(position.x()*position.x(), position.y()*position.y(), position.z()*position.z());
00109 m_totalEnergy += energy;
00110 m_moment1seed += energy * position;
00111 m_moment2seed += energy * position2;
00112 }
00113
00114
00116 void McIntegratingHit::addEnergyItem(const double& energy, SmartRef<McParticle> t, const HepPoint3D& position)
00117 {
00118 m_energyItem[t] += energy;
00119
00120 HepPoint3D position2 = HepPoint3D(position.x()*position.x(), position.y()*position.y(), position.z()*position.z());
00121 m_totalEnergy += energy;
00122 m_moment1seed += energy * position;
00123 m_moment2seed += energy * position2;
00124 }
00125
00126
00128 bool McIntegratingHit::primaryOrigin() const
00129 {
00130 using GlastEvent::McConstants::ORIGIN_PRIMARY;
00131 return m_packedFlags & ORIGIN_PRIMARY;
00132 }
00133
00134
00136 void McIntegratingHit::setPrimaryOrigin( bool value )
00137 {
00138 using GlastEvent::McConstants::ORIGIN_PRIMARY;
00139 if (value){
00140 m_packedFlags |= ORIGIN_PRIMARY;
00141 } else {
00142 m_packedFlags &= ~ORIGIN_PRIMARY;
00143 }
00144 }
00145
00146
00148 bool McIntegratingHit::needDigi() const
00149 {
00150 using GlastEvent::McConstants::NEED_DIGI;
00151 return m_packedFlags & NEED_DIGI;
00152 }
00153
00154
00156 void McIntegratingHit::setNeedDigi( bool value )
00157 {
00158 using GlastEvent::McConstants::NEED_DIGI;
00159 if (value){
00160 m_packedFlags |= NEED_DIGI;
00161 } else {
00162 m_packedFlags &= ~NEED_DIGI;
00163 }
00164 }