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 <G4DigiManager.hh>
0045 #include <G4RunManager.hh>
0046 #include <G4String.hh>
0047 #include "CexmcTrackPointsDigitizer.hh"
0048 #include "CexmcTrackPoints.hh"
0049 #include "CexmcTrackPointsInLeftRightSet.hh"
0050 #include "CexmcTrackPointsInCalorimeter.hh"
0051 #include "CexmcSensitiveDetectorsAttributes.hh"
0052 #include "CexmcCommon.hh"
0053
0054
0055 CexmcTrackPointsDigitizer::CexmcTrackPointsDigitizer( const G4String & name ) :
0056 G4VDigitizerModule( name ), hasTriggered( false )
0057 {
0058 G4RunManager * runManager( G4RunManager::GetRunManager() );
0059 const CexmcSetup * setup( static_cast< const CexmcSetup * >(
0060 runManager->GetUserDetectorConstruction() ) );
0061 calorimeterGeometry = setup->GetCalorimeterGeometry();
0062 }
0063
0064
0065 void CexmcTrackPointsDigitizer::InitializeData( void )
0066 {
0067 monitorTP.trackId = CexmcInvalidTrackId;
0068 targetTPBeamParticle.trackId = CexmcInvalidTrackId;
0069 targetTPOutputParticle.trackId = CexmcInvalidTrackId;
0070 targetTPNucleusParticle.trackId = CexmcInvalidTrackId;
0071 targetTPOutputParticleDecayProductParticle[ 0 ].trackId =
0072 CexmcInvalidTrackId;
0073 targetTPOutputParticleDecayProductParticle[ 1 ].trackId =
0074 CexmcInvalidTrackId;
0075 vetoCounterTPLeft.trackId = CexmcInvalidTrackId;
0076 vetoCounterTPRight.trackId = CexmcInvalidTrackId;
0077 calorimeterTPLeft.trackId = CexmcInvalidTrackId;
0078 calorimeterTPRight.trackId = CexmcInvalidTrackId;
0079 hasTriggered = false;
0080 }
0081
0082
0083 void CexmcTrackPointsDigitizer::Digitize( void )
0084 {
0085 InitializeData();
0086
0087 G4int nCrystalsInColumn( calorimeterGeometry.nCrystalsInColumn );
0088 G4int nCrystalsInRow( calorimeterGeometry.nCrystalsInRow );
0089 G4double crystalWidth( calorimeterGeometry.crystalWidth );
0090 G4double crystalHeight( calorimeterGeometry.crystalHeight );
0091
0092 G4DigiManager * digiManager( G4DigiManager::GetDMpointer() );
0093 G4int hcId( digiManager->GetHitsCollectionID(
0094 CexmcDetectorRoleName[ CexmcMonitorDetectorRole ] +
0095 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] ) );
0096 const CexmcTrackPointsCollection *
0097 hitsCollection( static_cast< const CexmcTrackPointsCollection * >(
0098 digiManager->GetHitsCollection( hcId ) ) );
0099
0100 if ( hitsCollection )
0101 {
0102 for ( CexmcTrackPointsCollectionData::iterator
0103 k( hitsCollection->GetMap()->begin() );
0104 k != hitsCollection->GetMap()->end(); ++k )
0105 {
0106 monitorTP = *k->second;
0107 break;
0108 }
0109 }
0110
0111 hcId = digiManager->GetHitsCollectionID(
0112 CexmcDetectorRoleName[ CexmcTargetDetectorRole ] +
0113 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
0114 hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
0115 digiManager->GetHitsCollection( hcId ) );
0116
0117 if ( hitsCollection )
0118 {
0119 for ( CexmcTrackPointsCollectionData::iterator
0120 k( hitsCollection->GetMap()->begin() );
0121 k != hitsCollection->GetMap()->end(); ++k )
0122 {
0123 do
0124 {
0125 if ( k->second->trackType == CexmcBeamParticleTrack )
0126 {
0127 targetTPBeamParticle = *k->second;
0128 break;
0129 }
0130 if ( k->second->trackType == CexmcOutputParticleTrack )
0131 {
0132 targetTPOutputParticle = *k->second;
0133 hasTriggered = targetTPOutputParticle.IsValid();
0134 break;
0135 }
0136 if ( k->second->trackType == CexmcNucleusParticleTrack )
0137 {
0138 targetTPNucleusParticle = *k->second;
0139 break;
0140 }
0141 if ( k->second->trackType ==
0142 CexmcOutputParticleDecayProductTrack )
0143 {
0144
0145
0146
0147
0148
0149
0150 G4int index(
0151 targetTPOutputParticleDecayProductParticle[ 0 ].
0152 trackId > 0 ? 1 : 0 );
0153 targetTPOutputParticleDecayProductParticle[ index ] =
0154 *k->second;
0155 break;
0156 }
0157 } while ( false );
0158 }
0159 }
0160
0161 hcId = digiManager->GetHitsCollectionID(
0162 CexmcDetectorRoleName[ CexmcVetoCounterDetectorRole ] +
0163 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
0164 hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
0165 digiManager->GetHitsCollection( hcId ) );
0166
0167 if ( hitsCollection )
0168 {
0169 for ( CexmcTrackPointsCollectionData::iterator
0170 k( hitsCollection->GetMap()->begin() );
0171 k != hitsCollection->GetMap()->end(); ++k )
0172 {
0173 if ( k->second->trackType != CexmcOutputParticleDecayProductTrack )
0174 continue;
0175
0176 G4int index( k->first );
0177 CexmcSide side( CexmcTrackPointsInLeftRightSet::GetSide(
0178 index ) );
0179 switch ( side )
0180 {
0181 case CexmcLeft :
0182 vetoCounterTPLeft = *k->second;
0183 break;
0184 case CexmcRight :
0185 vetoCounterTPRight = *k->second;
0186 break;
0187 default :
0188 break;
0189 }
0190 }
0191 }
0192
0193 hcId = digiManager->GetHitsCollectionID(
0194 CexmcDetectorRoleName[ CexmcCalorimeterDetectorRole ] +
0195 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
0196 hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
0197 digiManager->GetHitsCollection( hcId ) );
0198
0199 if ( hitsCollection )
0200 {
0201 for ( CexmcTrackPointsCollectionData::iterator
0202 k( hitsCollection->GetMap()->begin() );
0203 k != hitsCollection->GetMap()->end(); ++k )
0204 {
0205 if ( k->second->trackType != CexmcOutputParticleDecayProductTrack )
0206 continue;
0207
0208 G4int index( k->first );
0209 CexmcSide side( CexmcTrackPointsInLeftRightSet::GetSide(
0210 index ) );
0211 G4int row( CexmcTrackPointsInCalorimeter::GetRow( index ) );
0212 G4int column( CexmcTrackPointsInCalorimeter::GetColumn(
0213 index ) );
0214 G4double xInCalorimeterOffset(
0215 ( G4double( column ) - G4double( nCrystalsInRow ) / 2 ) *
0216 crystalWidth + crystalWidth / 2 );
0217 G4double yInCalorimeterOffset(
0218 ( G4double( row ) - G4double( nCrystalsInColumn ) / 2 ) *
0219 crystalHeight + crystalHeight / 2 );
0220 switch ( side )
0221 {
0222 case CexmcLeft :
0223 calorimeterTPLeft = *k->second;
0224 calorimeterTPLeft.positionLocal.setX( xInCalorimeterOffset +
0225 calorimeterTPLeft.positionLocal.x() );
0226 calorimeterTPLeft.positionLocal.setY( yInCalorimeterOffset +
0227 calorimeterTPLeft.positionLocal.y() );
0228 break;
0229 case CexmcRight :
0230 calorimeterTPRight = *k->second;
0231 calorimeterTPRight.positionLocal.setX( xInCalorimeterOffset +
0232 calorimeterTPRight.positionLocal.x() );
0233 calorimeterTPRight.positionLocal.setY( yInCalorimeterOffset +
0234 calorimeterTPRight.positionLocal.y() );
0235 break;
0236 default :
0237 break;
0238 }
0239 }
0240 }
0241 }
0242