QwGeant4
QweakSimPMTOnly_PMTSD.cc
Go to the documentation of this file.
1 
2 // QweakSimPMTOnly_PMTSD.cc
3 // Martin McHugh
4 // 2013-08-01
5 
7 
8 // geant4 includes
9 #include "G4OpticalPhoton.hh"
10 
11 // user includes
16 #include "QweakSimTrajectory.hh"
17 
18 
19 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
21 :G4VSensitiveDetector(name)
22 {
23  collectionName.insert("PMTHitCollection");
25  myUserInfo = userInfo;
26 }
27 
28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 {
31 }
32 
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 void QweakSimPMTOnly_PMTSD::Initialize(G4HCofThisEvent* HCE)
35 {
36  PMTOnly_PMTHitsCollection = new QweakSimPMTOnly_PMTHitsCollection(SensitiveDetectorName,collectionName[0]);
37 
39  { PMTOnlyPMT_CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(PMTOnly_PMTHitsCollection); }
40  HCE->AddHitsCollection(PMTOnlyPMT_CollectionID , PMTOnly_PMTHitsCollection);
41 }
42 
43 G4bool QweakSimPMTOnly_PMTSD::ProcessHits(G4Step* ,G4TouchableHistory* ){
44  return false;
45 }
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 G4bool QweakSimPMTOnly_PMTSD::ProcessHits_constStep(const G4Step* aStep, G4TouchableHistory* )
49 {
50  // Make sure that this is a
51  if (aStep->GetTrack()->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition())
52  return false;
53 
54  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
55  G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
56 
57  if (postStepPoint->GetStepStatus() != fGeomBoundary) return false;
58  if (preStepPoint->GetStepStatus() != fGeomBoundary) return false; // Entering Volume
59 
60  G4double currentPhotonEnergy = aStep->GetTrack()->GetTotalEnergy();
62 
63  aHit->StorePhotonEnergy(currentPhotonEnergy);
64  G4int hitCount = PMTOnly_PMTHitsCollection->insert(aHit);
65  aHit->StoreHitID(hitCount);
66 
67  return true;
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 void QweakSimPMTOnly_PMTSD::EndOfEvent(G4HCofThisEvent* )
72 {
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 {
78  G4TrajectoryContainer* trajectoryContainer =
79  G4RunManager::GetRunManager()->GetCurrentEvent()->GetTrajectoryContainer();
80 
81  if(trajectoryContainer==0) {
82  G4cout << " Could not find the TrajectoryContainer" << G4endl;
83  return 0;
84  }
85 
86  G4int i = 0;
87  G4int n_entries = trajectoryContainer->entries();
88  while( i < n_entries) {
89  QweakSimTrajectory* trj = (QweakSimTrajectory*)((*trajectoryContainer)[i]);
90  G4cout << " Current charge of possible parent track = " <<trj->GetCharge() << "--- Parent ID = "
91  << trj->GetTrackID() << G4endl;
92  if(trj->GetTrackID()==parentID) return trj;
93  i++;
94  }
95 
96  return 0;
97 }
98 
QweakSimPMTOnly_PMTHitsCollection * PMTOnly_PMTHitsCollection
Stores the information about the various tracks.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *)
QweakSimTrajectory * GetParentTrajectory(G4int parentID)
void StorePhotonEnergy(G4double eng)
G4int GetTrackID() const
void EndOfEvent(G4HCofThisEvent *HCE)
QweakSimUserInformation * myUserInfo
G4double GetCharge() const
G4THitsCollection< QweakSimPMTOnly_PMTHit > QweakSimPMTOnly_PMTHitsCollection
QweakSimPMTOnly_PMTSD(G4String name, QweakSimUserInformation *userInfo)
void Initialize(G4HCofThisEvent *HCE)
G4bool ProcessHits_constStep(const G4Step *, G4TouchableHistory *)