Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /* 27 * =========================================== 28 * 29 * Filename: CexmcEnergyDepositDigitize 30 * 31 * Description: digitizes of energy deposi 32 * 33 * Version: 1.0 34 * Created: 23.11.2009 14:39:41 35 * Revision: none 36 * Compiler: gcc 37 * 38 * Author: Alexey Radkov (), 39 * Company: PNPI 40 * 41 * =========================================== 42 */ 43 44 #include <iostream> 45 #include <iomanip> 46 #include <G4DigiManager.hh> 47 #include <G4String.hh> 48 #include <Randomize.hh> 49 #include "CexmcEnergyDepositDigitizer.hh" 50 #include "CexmcEnergyDepositDigitizerMessenger 51 #include "CexmcSimpleEnergyDeposit.hh" 52 #include "CexmcEnergyDepositInLeftRightSet.hh" 53 #include "CexmcEnergyDepositInCalorimeter.hh" 54 #include "CexmcSetup.hh" 55 #include "CexmcRunManager.hh" 56 #include "CexmcSensitiveDetectorsAttributes.hh 57 58 59 CexmcEnergyDepositDigitizer::CexmcEnergyDeposi 60 61 G4VDigitizerModule( name ), monitorED( 0 ) 62 vetoCounterEDLeft( 0 ), vetoCounterEDRight 63 calorimeterEDLeft( 0 ), calorimeterEDRight 64 calorimeterEDLeftMaxX( 0 ), calorimeterEDL 65 calorimeterEDRightMaxX( 0 ), calorimeterED 66 monitorHasTriggered( false ), hasTriggered 67 monitorEDThreshold( 0 ), 68 vetoCounterEDLeftThreshold( 0 ), vetoCount 69 calorimeterEDLeftThreshold( 0 ), calorimet 70 calorimeterTriggerAlgorithm( CexmcAllCryst 71 outerCrystalsVetoAlgorithm( CexmcNoOuterCr 72 outerCrystalsVetoFraction( 0 ), monitorEDT 73 vetoCounterEDLeftThresholdRef( 0 ), vetoCo 74 calorimeterEDLeftThresholdRef( 0 ), calori 75 calorimeterTriggerAlgorithmRef( CexmcAllCr 76 outerCrystalsVetoAlgorithmRef( CexmcNoOute 77 outerCrystalsVetoFractionRef( 0 ), nCrysta 78 nCrystalsInRow( 1 ), applyFiniteCrystalRes 79 messenger( NULL ) 80 { 81 G4RunManager * runManager( G4RunManag 82 const CexmcSetup * setup( static_cast< co 83 runManager->Ge 84 const CexmcSetup::CalorimeterGeometryData 85 se 86 87 nCrystalsInColumn = calorimeterGeometry.nC 88 nCrystalsInRow = calorimeterGeometry.nCrys 89 90 if ( nCrystalsInColumn > 0 ) 91 { 92 calorimeterEDLeftCollection.resize( nC 93 calorimeterEDRightCollection.resize( n 94 } 95 96 if ( nCrystalsInRow > 0 ) 97 { 98 for ( CexmcEnergyDepositCalorimeterCol 99 k( calorimeterEDLeftCollection 100 k != calorimeterEDLeftColl 101 { 102 k->resize( nCrystalsInRow ); 103 } 104 for ( CexmcEnergyDepositCalorimeterCol 105 k( calorimeterEDRightCollectio 106 k != calorimeterEDRightCol 107 { 108 k->resize( nCrystalsInRow ); 109 } 110 } 111 112 messenger = new CexmcEnergyDepositDigitize 113 } 114 115 116 CexmcEnergyDepositDigitizer::~CexmcEnergyDepos 117 { 118 delete messenger; 119 } 120 121 122 void CexmcEnergyDepositDigitizer::InitializeD 123 { 124 monitorED = 0; 125 vetoCounterEDLeft = 0; 126 vetoCounterEDRight = 0; 127 calorimeterEDLeft = 0; 128 calorimeterEDRight = 0; 129 calorimeterEDLeftMaxX = 0; 130 calorimeterEDLeftMaxY = 0; 131 calorimeterEDRightMaxX = 0; 132 calorimeterEDRightMaxY = 0; 133 monitorHasTriggered = false; 134 hasTriggered = false; 135 136 for ( CexmcEnergyDepositCalorimeterCollect 137 k( calorimeterEDLeftCollection.b 138 k != calorimeterEDLeftCollec 139 { 140 for ( CexmcEnergyDepositCrystalRowColl 141 l( k->begin() ); l != k->end() 142 { 143 *l = 0; 144 } 145 } 146 for ( CexmcEnergyDepositCalorimeterCollect 147 k( calorimeterEDRightCollection. 148 k != calorimeterEDRightColle 149 { 150 for ( CexmcEnergyDepositCrystalRowColl 151 l( k->begin() ); l != k->end() 152 { 153 *l = 0; 154 } 155 } 156 } 157 158 159 void CexmcEnergyDepositDigitizer::Digitize( v 160 { 161 InitializeData(); 162 163 G4DigiManager * digiManager( G4DigiManage 164 G4int hcId( digiManager->GetHitsCollect 165 CexmcDetectorRoleName[ Cex 166 "/" + CexmcDetectorTypeNam 167 const CexmcEnergyDepositCollection * 168 hitsCollection( static_cast< const Ce 169 digiManage 170 171 if ( hitsCollection ) 172 { 173 /* it always must have index 0 */ 174 if ( ( *hitsCollection )[ 0 ] ) 175 monitorED = *( *hitsCollection )[ 176 } 177 178 hcId = digiManager->GetHitsCollectionID( 179 CexmcDetectorRoleName[ Cex 180 "/" + CexmcDetectorTypeNam 181 hitsCollection = static_cast< const CexmcE 182 digiManage 183 if ( hitsCollection ) 184 { 185 for ( CexmcEnergyDepositCollectionData 186 k( hitsCollection->GetMap()- 187 k != hitsCollection->Get 188 { 189 G4int index( k->first ); 190 CexmcSide side( CexmcEnergyDeposi 191 192 switch ( side ) 193 { 194 case CexmcLeft : 195 vetoCounterEDLeft = *k->second 196 break; 197 case CexmcRight : 198 vetoCounterEDRight = *k->secon 199 break; 200 default : 201 break; 202 } 203 } 204 } 205 206 G4double maxEDCrystalLeft( 0 ); 207 G4double maxEDCrystalRight( 0 ); 208 G4double outerCrystalsEDLeft( 0 ); 209 G4double outerCrystalsEDRight( 0 ); 210 G4double innerCrystalsEDLeft( 0 ); 211 G4double innerCrystalsEDRight( 0 ); 212 213 CexmcRunManager * runManager( static_cast 214 G4 215 216 hcId = digiManager->GetHitsCollectionID( 217 CexmcDetectorRoleName[ Cex 218 "/" + CexmcDetectorTypeNam 219 hitsCollection = static_cast< const CexmcE 220 digiManage 221 if ( hitsCollection ) 222 { 223 for ( CexmcEnergyDepositCollectionData 224 k( hitsCollection->GetMap()- 225 k != hitsCollection->Get 226 { 227 G4int index( k->first ); 228 CexmcSide side( CexmcEnergyDeposi 229 230 G4int row( CexmcEnergyDeposit 231 G4int column( CexmcEnergyDepo 232 233 G4double value( *k->second ); 234 if ( applyFiniteCrystalResolution 235 236 { 237 for ( CexmcEnergyRangeWithDoub 238 l( crystalResolution 239 l != crystalResoluti 240 { 241 if ( value < l->bottom || 242 continue; 243 value = G4RandGauss::shoot 244 value 245 if ( value < 0. ) 246 value = 0.; 247 break; 248 } 249 } 250 switch ( side ) 251 { 252 case CexmcLeft : 253 if ( value > maxEDCrystalLeft 254 { 255 calorimeterEDLeftMaxX = co 256 calorimeterEDLeftMaxY = ro 257 maxEDCrystalLeft = value; 258 } 259 if ( IsOuterCrystal( column, r 260 { 261 outerCrystalsEDLeft += val 262 } 263 else 264 { 265 innerCrystalsEDLeft += val 266 } 267 calorimeterEDLeft += value; 268 calorimeterEDLeftCollection[ r 269 break; 270 case CexmcRight : 271 if ( value > maxEDCrystalRight 272 { 273 calorimeterEDRightMaxX = c 274 calorimeterEDRightMaxY = r 275 maxEDCrystalRight = value; 276 } 277 if ( IsOuterCrystal( column, r 278 { 279 outerCrystalsEDRight += va 280 } 281 else 282 { 283 innerCrystalsEDRight += va 284 } 285 calorimeterEDRight += value; 286 calorimeterEDRightCollection[ 287 break; 288 default : 289 break; 290 } 291 } 292 } 293 294 G4double calorimeterEDLeftEffective( calo 295 G4double calorimeterEDRightEffective( cal 296 297 if ( calorimeterTriggerAlgorithm == 298 CexmcInnerCrystalsMakeEDTriggerThresh 299 { 300 calorimeterEDLeftEffective = innerCrys 301 calorimeterEDRightEffective = innerCry 302 } 303 304 monitorHasTriggered = monitorED >= monitor 305 306 hasTriggered = monitorHasTriggered && 307 vetoCounterEDLeft < vetoCou 308 vetoCounterEDRight < vetoCo 309 calorimeterEDLeftEffective 310 calorimeterEDRightEffective 311 312 /* event won't trigger if outer crystals v 313 if ( hasTriggered ) 314 { 315 switch ( outerCrystalsVetoAlgorithm ) 316 { 317 case CexmcNoOuterCrystalsVeto : 318 break; 319 case CexmcMaximumEDInASingleOuterCryst 320 hasTriggered = 321 ! IsOuterCrystal( calorime 322 calorime 323 ! IsOuterCrystal( calorime 324 calorime 325 break; 326 case CexmcFractionOfEDInOuterCrystalsV 327 hasTriggered = 328 ( ( outerCrystalsEDLeft / 329 330 ( ( outerCrystalsEDRight / 331 332 break; 333 default : 334 break; 335 } 336 } 337 } 338 339 340 std::ostream & operator<<( std::ostream & ou 341 const CexmcEnergyDepositCalori 342 { 343 std::streamsize prec( out.precision() ); 344 345 out.precision( 4 ); 346 347 out << std::endl; 348 for ( CexmcEnergyDepositCalorimeterCollect 349 k( edCollection.rbegin() ); k != e 350 { 351 for ( CexmcEnergyDepositCrystalRowColl 352 l( k->rbegin() ); l != k->rend 353 out << std::setw( 10 ) << *l; 354 out << std::endl; 355 } 356 357 out.precision( prec ); 358 359 return out; 360 } 361 362