File indexing completed on 2025-01-31 09:21:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #include <G4HCofThisEvent.hh>
0045 #include <G4AffineTransform.hh>
0046 #include <G4UnitsTable.hh>
0047 #include "CexmcTrackPoints.hh"
0048 #include "CexmcTrackInfo.hh"
0049
0050
0051 CexmcTrackPoints::CexmcTrackPoints( const G4String & name ) :
0052 CexmcPrimitiveScorer( name ), hcId( -1 )
0053 {
0054 }
0055
0056
0057 G4int CexmcTrackPoints::GetTrackId( G4Step * step )
0058 {
0059
0060
0061 CexmcTrackInfo * trackInfo( static_cast< CexmcTrackInfo * >(
0062 step->GetTrack()->GetUserInformation() ) );
0063
0064 G4int ret( trackInfo->GetTrackType() );
0065
0066 if ( ret == CexmcOutputParticleDecayProductTrack )
0067 ret += trackInfo->GetCopyNumber();
0068
0069 return ret;
0070 }
0071
0072
0073 G4int CexmcTrackPoints::GetIndex( G4Step * step )
0074 {
0075 return GetTrackId( step );
0076 }
0077
0078
0079 G4bool CexmcTrackPoints::ProcessHits( G4Step * step, G4TouchableHistory * )
0080 {
0081 G4int index( GetIndex( step ) );
0082
0083 if ( ( *eventMap )[ index ] )
0084 return false;
0085
0086 G4Track * track( step->GetTrack() );
0087 G4ParticleDefinition * particle( track->GetDefinition() );
0088 CexmcTrackType trackType( CexmcInsipidTrack );
0089
0090 G4StepPoint * preStepPoint( step->GetPreStepPoint() );
0091 G4ThreeVector position( preStepPoint->GetPosition() );
0092 G4ThreeVector direction( preStepPoint->GetMomentumDirection() );
0093
0094 const G4AffineTransform & transform( preStepPoint->GetTouchable()->
0095 GetHistory()->GetTopTransform() );
0096
0097 CexmcTrackInfo * trackInfo( static_cast< CexmcTrackInfo * >(
0098 track->GetUserInformation() ) );
0099 trackType = trackInfo->GetTrackType();
0100
0101 CexmcTrackPointInfo trackPointInfo( transform.TransformPoint( position ),
0102 position,
0103 transform.TransformAxis( direction ),
0104 direction,
0105 preStepPoint->GetMomentum().mag(),
0106 particle, track->GetTrackID(),
0107 trackType );
0108
0109 eventMap->set( index, trackPointInfo );
0110
0111 return true;
0112 }
0113
0114
0115 void CexmcTrackPoints::Initialize( G4HCofThisEvent * hcOfEvent )
0116 {
0117 eventMap = new CexmcTrackPointsCollection( detector->GetName(),
0118 primitiveName );
0119
0120 if ( hcId < 0 )
0121 hcId = GetCollectionID( 0 );
0122
0123 hcOfEvent->AddHitsCollection( hcId, eventMap );
0124 }
0125
0126
0127 void CexmcTrackPoints::EndOfEvent( G4HCofThisEvent * )
0128 {
0129 if ( GetVerboseLevel() > 0 )
0130 PrintAll();
0131 }
0132
0133
0134 void CexmcTrackPoints::clear( void )
0135 {
0136 eventMap->clear();
0137 }
0138
0139
0140 void CexmcTrackPoints::DrawAll( void )
0141 {
0142 }
0143
0144
0145 void CexmcTrackPoints::PrintAll( void )
0146 {
0147 G4int nmbOfEntries( eventMap->entries() );
0148
0149 if ( nmbOfEntries == 0 )
0150 return;
0151
0152 PrintHeader( nmbOfEntries );
0153
0154 for ( CexmcTrackPointsCollectionData::iterator
0155 itr( eventMap->GetMap()->begin() );
0156 itr != eventMap->GetMap()->end(); ++itr )
0157 {
0158 G4cout << " track id " << itr->first << G4endl;
0159 G4cout << " , position: " <<
0160 G4BestUnit( itr->second->positionLocal, "Length" ) << G4endl;
0161 G4cout << " , direction: " <<
0162 itr->second->directionLocal << G4endl;
0163 G4cout << " , momentum: " <<
0164 G4BestUnit( itr->second->momentumAmp, "Energy" ) << G4endl;
0165 G4cout << " , particle: " <<
0166 itr->second->particle->GetParticleName() << G4endl;
0167 }
0168 }
0169