Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /* 26 /* 27 * =========================================== 27 * ============================================================================ 28 * 28 * 29 * Filename: CexmcTrackPointsDigitizer. 29 * Filename: CexmcTrackPointsDigitizer.cc 30 * 30 * 31 * Description: track points collector 31 * Description: track points collector 32 * 32 * 33 * Version: 1.0 33 * Version: 1.0 34 * Created: 24.11.2009 16:34:43 34 * Created: 24.11.2009 16:34:43 35 * Revision: none 35 * Revision: none 36 * Compiler: gcc 36 * Compiler: gcc 37 * 37 * 38 * Author: Alexey Radkov (), 38 * Author: Alexey Radkov (), 39 * Company: PNPI 39 * Company: PNPI 40 * 40 * 41 * =========================================== 41 * ============================================================================ 42 */ 42 */ 43 43 44 #include <G4DigiManager.hh> 44 #include <G4DigiManager.hh> 45 #include <G4RunManager.hh> 45 #include <G4RunManager.hh> 46 #include <G4String.hh> 46 #include <G4String.hh> 47 #include "CexmcTrackPointsDigitizer.hh" 47 #include "CexmcTrackPointsDigitizer.hh" 48 #include "CexmcTrackPoints.hh" 48 #include "CexmcTrackPoints.hh" 49 #include "CexmcTrackPointsInLeftRightSet.hh" 49 #include "CexmcTrackPointsInLeftRightSet.hh" 50 #include "CexmcTrackPointsInCalorimeter.hh" 50 #include "CexmcTrackPointsInCalorimeter.hh" 51 #include "CexmcSensitiveDetectorsAttributes.hh 51 #include "CexmcSensitiveDetectorsAttributes.hh" 52 #include "CexmcCommon.hh" 52 #include "CexmcCommon.hh" 53 53 54 54 55 CexmcTrackPointsDigitizer::CexmcTrackPointsDig 55 CexmcTrackPointsDigitizer::CexmcTrackPointsDigitizer( const G4String & name ) : 56 G4VDigitizerModule( name ), hasTriggered( 56 G4VDigitizerModule( name ), hasTriggered( false ) 57 { 57 { 58 G4RunManager * runManager( G4RunManag 58 G4RunManager * runManager( G4RunManager::GetRunManager() ); 59 const CexmcSetup * setup( static_cast< co 59 const CexmcSetup * setup( static_cast< const CexmcSetup * >( 60 runManager->Ge 60 runManager->GetUserDetectorConstruction() ) ); 61 calorimeterGeometry = setup->GetCalorimete 61 calorimeterGeometry = setup->GetCalorimeterGeometry(); 62 } 62 } 63 63 64 64 65 void CexmcTrackPointsDigitizer::InitializeDat 65 void CexmcTrackPointsDigitizer::InitializeData( void ) 66 { 66 { 67 monitorTP.trackId = CexmcInvalidTrackId; 67 monitorTP.trackId = CexmcInvalidTrackId; 68 targetTPBeamParticle.trackId = CexmcInvali 68 targetTPBeamParticle.trackId = CexmcInvalidTrackId; 69 targetTPOutputParticle.trackId = CexmcInva 69 targetTPOutputParticle.trackId = CexmcInvalidTrackId; 70 targetTPNucleusParticle.trackId = CexmcInv 70 targetTPNucleusParticle.trackId = CexmcInvalidTrackId; 71 targetTPOutputParticleDecayProductParticle 71 targetTPOutputParticleDecayProductParticle[ 0 ].trackId = 72 72 CexmcInvalidTrackId; 73 targetTPOutputParticleDecayProductParticle 73 targetTPOutputParticleDecayProductParticle[ 1 ].trackId = 74 74 CexmcInvalidTrackId; 75 vetoCounterTPLeft.trackId = CexmcInvalidTr 75 vetoCounterTPLeft.trackId = CexmcInvalidTrackId; 76 vetoCounterTPRight.trackId = CexmcInvalidT 76 vetoCounterTPRight.trackId = CexmcInvalidTrackId; 77 calorimeterTPLeft.trackId = CexmcInvalidTr 77 calorimeterTPLeft.trackId = CexmcInvalidTrackId; 78 calorimeterTPRight.trackId = CexmcInvalidT 78 calorimeterTPRight.trackId = CexmcInvalidTrackId; 79 hasTriggered = false; 79 hasTriggered = false; 80 } 80 } 81 81 82 82 83 void CexmcTrackPointsDigitizer::Digitize( voi 83 void CexmcTrackPointsDigitizer::Digitize( void ) 84 { 84 { 85 InitializeData(); 85 InitializeData(); 86 86 87 G4int nCrystalsInColumn( calorimeterGe 87 G4int nCrystalsInColumn( calorimeterGeometry.nCrystalsInColumn ); 88 G4int nCrystalsInRow( calorimeterGeome 88 G4int nCrystalsInRow( calorimeterGeometry.nCrystalsInRow ); 89 G4double crystalWidth( calorimeterGeometr 89 G4double crystalWidth( calorimeterGeometry.crystalWidth ); 90 G4double crystalHeight( calorimeterGeomet 90 G4double crystalHeight( calorimeterGeometry.crystalHeight ); 91 91 92 G4DigiManager * digiManager( G4DigiManage 92 G4DigiManager * digiManager( G4DigiManager::GetDMpointer() ); 93 G4int hcId( digiManager->GetHitsCollect 93 G4int hcId( digiManager->GetHitsCollectionID( 94 CexmcDetectorRoleName[ Cex 94 CexmcDetectorRoleName[ CexmcMonitorDetectorRole ] + 95 "/" + CexmcDetectorTypeNam 95 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] ) ); 96 const CexmcTrackPointsCollection * 96 const CexmcTrackPointsCollection * 97 hitsCollection( static_cast< cons 97 hitsCollection( static_cast< const CexmcTrackPointsCollection * >( 98 digiManage 98 digiManager->GetHitsCollection( hcId ) ) ); 99 99 100 if ( hitsCollection ) 100 if ( hitsCollection ) 101 { 101 { 102 for ( CexmcTrackPointsCollectionData:: 102 for ( CexmcTrackPointsCollectionData::iterator 103 k( hitsCollection->GetMap()- 103 k( hitsCollection->GetMap()->begin() ); 104 k != hitsCollection->Get 104 k != hitsCollection->GetMap()->end(); ++k ) 105 { 105 { 106 monitorTP = *k->second; 106 monitorTP = *k->second; 107 break; 107 break; 108 } 108 } 109 } 109 } 110 110 111 hcId = digiManager->GetHitsCollectionID( 111 hcId = digiManager->GetHitsCollectionID( 112 CexmcDetectorRoleName[ Cex 112 CexmcDetectorRoleName[ CexmcTargetDetectorRole ] + 113 "/" + CexmcDetectorTypeNam 113 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] ); 114 hitsCollection = static_cast< const CexmcT 114 hitsCollection = static_cast< const CexmcTrackPointsCollection * >( 115 digiManage 115 digiManager->GetHitsCollection( hcId ) ); 116 116 117 if ( hitsCollection ) 117 if ( hitsCollection ) 118 { 118 { 119 for ( CexmcTrackPointsCollectionData:: 119 for ( CexmcTrackPointsCollectionData::iterator 120 k( hitsCollection->GetMap()- 120 k( hitsCollection->GetMap()->begin() ); 121 k != hitsCollection->Get 121 k != hitsCollection->GetMap()->end(); ++k ) 122 { 122 { 123 do 123 do 124 { 124 { 125 if ( k->second->trackType == C 125 if ( k->second->trackType == CexmcBeamParticleTrack ) 126 { 126 { 127 targetTPBeamParticle = *k- 127 targetTPBeamParticle = *k->second; 128 break; 128 break; 129 } 129 } 130 if ( k->second->trackType == C 130 if ( k->second->trackType == CexmcOutputParticleTrack ) 131 { 131 { 132 targetTPOutputParticle = * 132 targetTPOutputParticle = *k->second; 133 hasTriggered = targetTPOut 133 hasTriggered = targetTPOutputParticle.IsValid(); 134 break; 134 break; 135 } 135 } 136 if ( k->second->trackType == C 136 if ( k->second->trackType == CexmcNucleusParticleTrack ) 137 { 137 { 138 targetTPNucleusParticle = 138 targetTPNucleusParticle = *k->second; 139 break; 139 break; 140 } 140 } 141 if ( k->second->trackType == 141 if ( k->second->trackType == 142 CexmcO 142 CexmcOutputParticleDecayProductTrack ) 143 { 143 { 144 /* NB: if there are more t 144 /* NB: if there are more than 2 output particle's decay 145 * products then the chose 145 * products then the chosen particles may differ from those 146 * which entered calorimet 146 * which entered calorimeters; however this is not a 147 * critical issue as far a 147 * critical issue as far as information about decay products 148 * is not necessary in rec 148 * is not necessary in reconstruction and only used in some 149 * histograming */ 149 * histograming */ 150 G4int index( 150 G4int index( 151 targetTPOutputPart 151 targetTPOutputParticleDecayProductParticle[ 0 ]. 152 152 trackId > 0 ? 1 : 0 ); 153 targetTPOutputParticleDeca 153 targetTPOutputParticleDecayProductParticle[ index ] = 154 *k->second; 154 *k->second; 155 break; 155 break; 156 } 156 } 157 } while ( false ); 157 } while ( false ); 158 } 158 } 159 } 159 } 160 160 161 hcId = digiManager->GetHitsCollectionID( 161 hcId = digiManager->GetHitsCollectionID( 162 CexmcDetectorRoleName[ Cex 162 CexmcDetectorRoleName[ CexmcVetoCounterDetectorRole ] + 163 "/" + CexmcDetectorTypeNam 163 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] ); 164 hitsCollection = static_cast< const CexmcT 164 hitsCollection = static_cast< const CexmcTrackPointsCollection * >( 165 digiManage 165 digiManager->GetHitsCollection( hcId ) ); 166 166 167 if ( hitsCollection ) 167 if ( hitsCollection ) 168 { 168 { 169 for ( CexmcTrackPointsCollectionData:: 169 for ( CexmcTrackPointsCollectionData::iterator 170 k( hitsCollection->GetMap()- 170 k( hitsCollection->GetMap()->begin() ); 171 k != hitsCollection->Get 171 k != hitsCollection->GetMap()->end(); ++k ) 172 { 172 { 173 if ( k->second->trackType != Cexmc 173 if ( k->second->trackType != CexmcOutputParticleDecayProductTrack ) 174 continue; 174 continue; 175 175 176 G4int index( k->first ); 176 G4int index( k->first ); 177 CexmcSide side( CexmcTrackPointsI 177 CexmcSide side( CexmcTrackPointsInLeftRightSet::GetSide( 178 178 index ) ); 179 switch ( side ) 179 switch ( side ) 180 { 180 { 181 case CexmcLeft : 181 case CexmcLeft : 182 vetoCounterTPLeft = *k->second 182 vetoCounterTPLeft = *k->second; 183 break; 183 break; 184 case CexmcRight : 184 case CexmcRight : 185 vetoCounterTPRight = *k->secon 185 vetoCounterTPRight = *k->second; 186 break; 186 break; 187 default : 187 default : 188 break; 188 break; 189 } 189 } 190 } 190 } 191 } 191 } 192 192 193 hcId = digiManager->GetHitsCollectionID( 193 hcId = digiManager->GetHitsCollectionID( 194 CexmcDetectorRoleName[ Cex 194 CexmcDetectorRoleName[ CexmcCalorimeterDetectorRole ] + 195 "/" + CexmcDetectorTypeNam 195 "/" + CexmcDetectorTypeName[ CexmcTPDetector ] ); 196 hitsCollection = static_cast< const CexmcT 196 hitsCollection = static_cast< const CexmcTrackPointsCollection * >( 197 digiManage 197 digiManager->GetHitsCollection( hcId ) ); 198 198 199 if ( hitsCollection ) 199 if ( hitsCollection ) 200 { 200 { 201 for ( CexmcTrackPointsCollectionData:: 201 for ( CexmcTrackPointsCollectionData::iterator 202 k( hitsCollection->GetMap()- 202 k( hitsCollection->GetMap()->begin() ); 203 k != hitsCollection->Get 203 k != hitsCollection->GetMap()->end(); ++k ) 204 { 204 { 205 if ( k->second->trackType != Cexmc 205 if ( k->second->trackType != CexmcOutputParticleDecayProductTrack ) 206 continue; 206 continue; 207 207 208 G4int index( k->first ); 208 G4int index( k->first ); 209 CexmcSide side( CexmcTrackPointsI 209 CexmcSide side( CexmcTrackPointsInLeftRightSet::GetSide( 210 210 index ) ); 211 G4int row( CexmcTrackPointsIn 211 G4int row( CexmcTrackPointsInCalorimeter::GetRow( index ) ); 212 G4int column( CexmcTrackPoint 212 G4int column( CexmcTrackPointsInCalorimeter::GetColumn( 213 213 index ) ); 214 G4double xInCalorimeterOffset( 214 G4double xInCalorimeterOffset( 215 ( G4double( column ) - G4d 215 ( G4double( column ) - G4double( nCrystalsInRow ) / 2 ) * 216 crysta 216 crystalWidth + crystalWidth / 2 ); 217 G4double yInCalorimeterOffset( 217 G4double yInCalorimeterOffset( 218 ( G4double( row ) - G4doub 218 ( G4double( row ) - G4double( nCrystalsInColumn ) / 2 ) * 219 crysta 219 crystalHeight + crystalHeight / 2 ); 220 switch ( side ) 220 switch ( side ) 221 { 221 { 222 case CexmcLeft : 222 case CexmcLeft : 223 calorimeterTPLeft = *k->second 223 calorimeterTPLeft = *k->second; 224 calorimeterTPLeft.positionLoca 224 calorimeterTPLeft.positionLocal.setX( xInCalorimeterOffset + 225 calori 225 calorimeterTPLeft.positionLocal.x() ); 226 calorimeterTPLeft.positionLoca 226 calorimeterTPLeft.positionLocal.setY( yInCalorimeterOffset + 227 calori 227 calorimeterTPLeft.positionLocal.y() ); 228 break; 228 break; 229 case CexmcRight : 229 case CexmcRight : 230 calorimeterTPRight = *k->secon 230 calorimeterTPRight = *k->second; 231 calorimeterTPRight.positionLoc 231 calorimeterTPRight.positionLocal.setX( xInCalorimeterOffset + 232 calori 232 calorimeterTPRight.positionLocal.x() ); 233 calorimeterTPRight.positionLoc 233 calorimeterTPRight.positionLocal.setY( yInCalorimeterOffset + 234 calori 234 calorimeterTPRight.positionLocal.y() ); 235 break; 235 break; 236 default : 236 default : 237 break; 237 break; 238 } 238 } 239 } 239 } 240 } 240 } 241 } 241 } 242 242 243 243