Warning, file /geant4/examples/advanced/air_shower/src/UltraPMTSD.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 #include "UltraPMTSD.hh"
0042
0043 #include "G4Material.hh"
0044 #include "G4Step.hh"
0045 #include "G4VTouchable.hh"
0046 #include "G4TouchableHistory.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4OpticalPhoton.hh"
0049 #include "G4ParticleDefinition.hh"
0050
0051
0052
0053 UltraPMTSD::UltraPMTSD(G4String name):G4VSensitiveDetector(name)
0054 {
0055
0056 collectionName.insert("OpticalHitsCollection");
0057
0058 }
0059
0060
0061
0062
0063 UltraPMTSD::~UltraPMTSD()
0064 {;}
0065
0066
0067
0068 void UltraPMTSD::Initialize(G4HCofThisEvent* HCE)
0069 {
0070
0071
0072 static int HCID1 = -1;
0073
0074
0075
0076
0077 OpticalHitsCollection =
0078 new UltraOpticalHitsCollection(SensitiveDetectorName,collectionName[0]);
0079
0080 if(HCID1<0)
0081 { HCID1 = GetCollectionID(0); }
0082 HCE->AddHitsCollection(HCID1,OpticalHitsCollection);
0083
0084 }
0085
0086
0087
0088 G4bool UltraPMTSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
0089 {
0090
0091
0092
0093 auto thisVolume = aStep->GetTrack()->GetVolume()->GetName() ;
0094 const auto particle = aStep->GetTrack()->GetDefinition();
0095
0096
0097 if (thisVolume != "PMT1" && thisVolume != "PMT2")
0098 return false;
0099 if (particle != G4OpticalPhoton::Definition() )
0100 return false;
0101
0102 if(particle == G4OpticalPhoton::Definition())
0103 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
0104
0105 auto kineticEnergy = aStep->GetTrack()->GetKineticEnergy();
0106 auto HitPosition = aStep->GetPreStepPoint()->GetPosition() ;
0107
0108 auto OpticalHit = new UltraOpticalHit ;
0109 OpticalHit->SetEnergy(kineticEnergy);
0110 OpticalHit->SetPosition(HitPosition);
0111
0112
0113 OpticalHitsCollection->insert(OpticalHit);
0114
0115
0116 #ifdef ULTRA_VERBOSE
0117 G4cout << "*******************************" << G4endl;
0118 G4cout << " PMT HIT " << G4endl;
0119 G4cout << " Volume: " << thisVolume << G4endl;
0120 G4cout << " Photon energy (eV) : " << kineticEnergy/CLHEP::eV << G4endl;
0121 G4cout << " POSITION (mm) : "
0122 << HitPosition.x()/CLHEP::mm << " " << HitPosition.y()/CLHEP::mm << " " << HitPosition.z()/CLHEP::mm << G4endl;
0123 G4cout << "*******************************" << G4endl;
0124 #endif
0125
0126
0127 return true;
0128 }
0129
0130
0131 void UltraPMTSD::EndOfEvent(G4HCofThisEvent* HCE)
0132 {
0133 static G4int HCID = -1;
0134 if(HCID<0)
0135 {
0136 HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0137 }
0138 HCE->AddHitsCollection(HCID,OpticalHitsCollection);
0139
0140 }
0141
0142
0143
0144 void UltraPMTSD::clear()
0145 {;}
0146
0147
0148
0149 void UltraPMTSD::DrawAll()
0150 {;}
0151
0152
0153
0154 void UltraPMTSD::PrintAll()
0155 {;}
0156
0157