00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "TStandard_SD.hh"
00027
00028
00029
00030
00031
00032 TStandard_SD::TStandard_SD (G4String aSDName) : G4VSensitiveDetector (aSDName)
00033 {
00034
00035 if (gMyDebug) { G4cout << "\n### In TStandard_SD::TStandard_SD() \n" ; }
00036
00037 fSDName = aSDName ;
00038 collectionName.insert(fSDName+"_HC") ;
00039 fHitsColl_ID = -1 ;
00040 fEdep = -1. ;
00041
00042 if (gMyDebug) { G4cout << "\n### Out of TStandard_SD::TStandard_SD() \n" ; }
00043
00044 }
00045
00046
00047
00048
00049
00050 TStandard_SD::~TStandard_SD ()
00051 {
00052
00053 if (gMyDebug) { G4cout << "\n### In TStandard_SD::~TStandard_SD() \n" ; }
00054
00055
00056 if (gMyDebug) { G4cout << "\n### Out of TStandard_SD::~TStandard_SD() \n" ; }
00057
00058 }
00059
00060
00061
00062
00063
00064 void TStandard_SD::Initialize (G4HCofThisEvent* aHCE)
00065 {
00066
00067 if (gMyDebug) { G4cout << "\n### In TStandard_SD::Initialize() \n" ; }
00068
00069 fHitsColl = new THitsCollection (SensitiveDetectorName,collectionName[0]) ;
00070 if ( fHitsColl_ID < 0 ) { fHitsColl_ID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsColl) ; }
00071 aHCE->AddHitsCollection (fHitsColl_ID, fHitsColl) ;
00072
00073 if (gMyDebug) { G4cout << "\n### Out of TStandard_SD::Initialize() \n" ; }
00074
00075 return ;
00076
00077 }
00078
00079
00080
00081
00082
00083 G4bool TStandard_SD::ProcessHits (G4Step* aStep, G4TouchableHistory* aTouchableHistory)
00084 {
00085
00086 if (gMyDebug) { G4cout << "\n### In TStandard_SD::ProcessHits() \n" ; }
00087
00088 fEdep = aStep->GetTotalEnergyDeposit() ;
00089
00090
00091 if ( fEdep == 0. ) { return (false) ; }
00092
00093 TStandard_Hit* newHit = new TStandard_Hit () ;
00094
00095 fParticleName = aStep->GetTrack()->GetDefinition()->GetParticleName() ;
00096 fZ = G4int(aStep->GetTrack()->GetDefinition()->GetPDGCharge()) ;
00097 fA = aStep->GetTrack()->GetDefinition()->GetBaryonNumber() ;
00098 fTrackID = aStep->GetTrack()->GetTrackID() ;
00099 fParentTrackID = aStep->GetTrack()->GetParentID() ;
00100 fCreatorProcessName = aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() ;
00101
00102 fEkin0 = aStep->GetTrack()->GetVertexKineticEnergy() ;
00103 fPosition0 = aStep->GetTrack()->GetVertexPosition() ;
00104 fRx0 = fPosition0.getX() ;
00105 fRy0 = fPosition0.getY() ;
00106 fRz0 = fPosition0.getZ() ;
00107 fDirection0 = aStep->GetTrack()->GetVertexMomentumDirection() ;
00108 fTheta0 = fDirection0.theta() ;
00109 fPhi0 = fDirection0.phi() ;
00110
00111 fVolumeName = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ;
00112 fEkin = aStep->GetPreStepPoint()->GetKineticEnergy() ;
00113 fDose = fEdep / aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMass() ;
00114 fRangeTot = aStep->GetStepLength() ;
00115 fPosition = aStep->GetPreStepPoint()->GetPosition() ;
00116 fRx = fPosition.getX() ;
00117 fRy = fPosition.getY() ;
00118 fRz = fPosition.getZ() ;
00119 fDirection = aStep->GetPreStepPoint()->GetMomentumDirection() ;
00120 fTheta = fDirection.theta() ;
00121 fPhi = fDirection.phi() ;
00122 fGlobalTime = aStep->GetTrack()->GetGlobalTime () ;
00123 fLocalTime = aStep->GetTrack()->GetLocalTime () ;
00124 fWeight = aStep->GetTrack()->GetWeight () ;
00125
00126 newHit->SetParticleName ( fParticleName ) ;
00127 newHit->SetZ ( fZ ) ;
00128 newHit->SetA ( fA ) ;
00129 newHit->SetTrackID ( fTrackID ) ;
00130 newHit->SetParentTrackID ( fParentTrackID ) ;
00131 newHit->SetCreatorProcessName ( fCreatorProcessName ) ;
00132
00133 newHit->SetEkin0 ( fEkin0 ) ;
00134 newHit->SetRx0 ( fRx0 ) ;
00135 newHit->SetRy0 ( fRy0 ) ;
00136 newHit->SetRz0 ( fRz0 ) ;
00137 newHit->SetTheta0 ( fTheta0 ) ;
00138 newHit->SetPhi0 ( fPhi0 ) ;
00139
00140 newHit->SetVolumeName ( fVolumeName ) ;
00141 newHit->SetEkin ( fEkin ) ;
00142 newHit->SetEdep ( fEdep ) ;
00143 newHit->SetDose ( fDose ) ;
00144 newHit->SetRangeTot ( fRangeTot ) ;
00145 newHit->SetPosition ( fPosition ) ;
00146 newHit->SetRx ( fRx ) ;
00147 newHit->SetRy ( fRy ) ;
00148 newHit->SetRz ( fRz ) ;
00149 newHit->SetTheta ( fTheta ) ;
00150 newHit->SetPhi ( fPhi ) ;
00151 newHit->SetDirection ( fDirection ) ;
00152 newHit->SetGlobalTime ( fGlobalTime ) ;
00153 newHit->SetLocalTime ( fLocalTime ) ;
00154 newHit->SetWeight ( fWeight ) ;
00155
00156 fHitsColl->insert( newHit ) ;
00157
00158
00159
00160
00161 if (gMyDebug) { G4cout << "\n### Out of TStandard_SD::ProcessHits() \n" ; }
00162
00163 return (true) ;
00164
00165 }
00166
00167
00168
00169
00170
00171 void TStandard_SD::EndOfEvent (G4HCofThisEvent* aHCofThisEvent)
00172 {
00173
00174 if (gMyDebug) { G4cout << "\n### In TStandard_SD::EndOfEvent() \n" ; }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 if (gMyDebug) { G4cout << "\n### Out of TStandard_SD::EndOfEvent() \n" ; }
00186
00187 return ;
00188
00189 }
00190