00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "BesEmcHit.hh"
00011
00012 #include "G4UnitsTable.hh"
00013 #include "G4ios.hh"
00014 #include <iomanip>
00015
00016 G4Allocator<BesEmcHit> BesEmcHitAllocator;
00017 G4Allocator<BesEmcTruthHit> BesEmcTruthHitAllocator;
00018
00019 using namespace std;
00020
00021
00022
00023 BesEmcHit::BesEmcHit()
00024 {
00025 TotalEdepCrystal = 0.; TotalTrackLengthCrystal = 0.;
00026 EdepCrystal = 0.; TrackLengthCrystal = 0.;
00027 EdepCasing = 0.;
00028 PositionCrystal= G4ThreeVector(0,0,0);
00029 TimeCrystal=0.;
00030 PartId=0;
00031 NumTheta=0;
00032 NumPhi=0;
00033 trackIndex=0;
00034 g4Index=0;
00035 momentum = G4ThreeVector(0,0,0);
00036 }
00037
00038
00039
00040 BesEmcHit::~BesEmcHit()
00041 {}
00042
00043
00044
00045 BesEmcHit::BesEmcHit(const BesEmcHit& right)
00046 : G4VHit()
00047 {
00048 EdepCrystal = right.EdepCrystal;
00049 TrackLengthCrystal = right.TrackLengthCrystal;
00050 EdepCasing = right.EdepCasing;
00051 PositionCrystal= right.PositionCrystal;
00052 TimeCrystal = right.TimeCrystal;
00053 PartId = right.PartId;
00054 NumTheta = right.NumTheta;
00055 NumPhi = right.NumPhi;
00056 trackIndex = right.trackIndex;
00057 g4Index = right.g4Index;
00058 momentum = right.momentum;
00059 }
00060
00061
00062
00063 const BesEmcHit& BesEmcHit::operator=(const BesEmcHit& right)
00064 {
00065 EdepCrystal = right.EdepCrystal;
00066 TrackLengthCrystal = right.TrackLengthCrystal;
00067 EdepCasing = right.EdepCasing;
00068 PositionCrystal= right.PositionCrystal;
00069 TimeCrystal = right.TimeCrystal;
00070 PartId = right.PartId;
00071 NumTheta = right.NumTheta;
00072 NumPhi = right.NumPhi;
00073 trackIndex = right.trackIndex;
00074 g4Index = right.g4Index;
00075 momentum = right.momentum;
00076 return *this;
00077 }
00078
00079
00080
00081 int BesEmcHit::operator==(const BesEmcHit& right) const
00082 {
00083 return (this==&right) ? 1 : 0;
00084 }
00085
00086
00087
00088 void BesEmcHit::Draw()
00089 {}
00090
00091
00092
00093 void BesEmcHit::Print(G4int verboseLevel)
00094 {
00095 if(verboseLevel>0)
00096 G4cout << "Hit in crystal:" <<NumTheta<<","<<NumPhi<<G4endl
00097 <<"Energy deposited:"<<G4BestUnit(EdepCrystal,"Energy") <<G4endl;
00098 if(verboseLevel>1)
00099 G4cout <<"Hit time :"<<G4BestUnit(TimeCrystal,"Time")<<G4endl
00100 <<" position :"<<G4BestUnit(PositionCrystal,"Length")<<G4endl;
00101 if(verboseLevel>2)
00102 G4cout <<"Track length :"<<G4BestUnit(TrackLengthCrystal,"Length")<<G4endl;
00103
00104
00105 }
00106
00107 void BesEmcHit::Print()
00108 {
00109 G4cout<<"time: "<<TimeCrystal<<" edep: "<<EdepCrystal<<G4endl;
00110 }
00111
00112
00113 BesEmcTruthHit::BesEmcTruthHit()
00114 {
00115 m_trackIndex = -1;
00116 m_g4TrackId = -1;
00117 m_hitEmc = -1;
00118 m_PDGCode = 0;
00119 m_PDGCharge = 0;
00120 m_particleName = G4String();
00121 m_edep = 0;
00122 m_time = 0;
00123 m_momentum = G4ThreeVector(0,0,0);
00124 m_position = G4ThreeVector(0,0,0);
00125 m_hitMap.clear();
00126 }
00127
00128 BesEmcTruthHit::~BesEmcTruthHit()
00129 {}
00130
00131 BesEmcTruthHit::BesEmcTruthHit(const BesEmcTruthHit& right)
00132 : G4VHit()
00133 {
00134 *this = right;
00135 }
00136
00137 const BesEmcTruthHit& BesEmcTruthHit::operator=(const BesEmcTruthHit& right)
00138 {
00139 m_hitMap.clear();
00140 std::map<Identifier,G4double>::const_iterator iHitMap;
00141 if(this!=&right) {
00142 for(iHitMap=right.Begin();
00143 iHitMap!=right.End();
00144 iHitMap++) {
00145 Insert(iHitMap->first,iHitMap->second);
00146 }
00147
00148 m_identify = right.m_identify;
00149 m_trackIndex = right.m_trackIndex;
00150 m_g4TrackId = right.m_g4TrackId;
00151 m_hitEmc = right.m_hitEmc;
00152 m_PDGCode = right.m_PDGCode;
00153 m_PDGCharge = right.m_PDGCharge;
00154 m_particleName = right.m_particleName;
00155 m_edep = right.m_edep;
00156 m_time = right.m_time;
00157 m_momentum = right.m_momentum;
00158 m_position = right.m_position;
00159 }
00160
00161 return *this;
00162 }
00163
00164 void BesEmcTruthHit::Print()
00165 {
00166 G4cout<<"Id: "<<m_identify<<"\tTrack Index: "<<m_trackIndex<<"\tG4 Track Id: "<<m_g4TrackId
00167 <<"\tHit Emc: "<<m_hitEmc<<"\tTotal Energy: "<<m_edep
00168 <<"\nPDGCode: "<<m_PDGCode<<"\tCharge: "<<m_PDGCharge<<"\tParticle Name: "<<m_particleName
00169 <<"\nGloble Time: "<<m_time<<"\tMomentum: "<<m_momentum.mag()<<"\tPosition: "<<m_position<<G4endl;
00170
00171 std::map<Identifier,G4double>::iterator iHitMap;
00172 for(iHitMap=m_hitMap.begin();iHitMap!=m_hitMap.end();iHitMap++) {
00173 G4cout<<iHitMap->first<<"\t"<<iHitMap->second<<G4endl;
00174 }
00175 }
00176
00177 std::map<Identifier,G4double>::const_iterator BesEmcTruthHit::Begin() const
00178 {
00179 return m_hitMap.begin();
00180 }
00181
00182 std::map<Identifier,G4double>::const_iterator BesEmcTruthHit::End() const
00183 {
00184 return m_hitMap.end();
00185 }
00186
00187 std::map<Identifier,G4double>::const_iterator BesEmcTruthHit::Find(Identifier id) const
00188 {
00189 return m_hitMap.find(id);
00190 }
00191
00192 G4double BesEmcTruthHit::GetEHit(Identifier id)
00193 {
00194 return m_hitMap[id];
00195 }
00196
00197 void BesEmcTruthHit::AddEHit(Identifier id,G4double energy)
00198 {
00199 if(energy>0) m_hitMap[id]+=energy;
00200 }
00201
00202 void BesEmcTruthHit::Insert(Identifier id,G4double energy)
00203 {
00204 if(energy>0) m_hitMap[id]=energy;
00205 }
00206
00207 G4int BesEmcTruthHit::Size() const
00208 {
00209 return m_hitMap.size();
00210 }