ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LXePMTSD.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LXePMTSD.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
29 //
30 //
31 #include "LXePMTSD.hh"
32 #include "LXePMTHit.hh"
35 
36 #include "G4VPhysicalVolume.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4Track.hh"
39 #include "G4Step.hh"
40 #include "G4VTouchable.hh"
41 #include "G4TouchableHistory.hh"
42 #include "G4ios.hh"
43 #include "G4ParticleTypes.hh"
44 #include "G4ParticleDefinition.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49  : G4VSensitiveDetector(name),fPMTHitCollection(nullptr),
50  fPMTPositionsX(nullptr),fPMTPositionsY(nullptr),fPMTPositionsZ(nullptr)
51 {
52  collectionName.insert("pmtHitCollection");
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
61 void LXePMTSD::SetPmtPositions(const std::vector<G4ThreeVector>& positions)
62 {
63  for (G4int i=0; i<G4int(positions.size()); ++i) {
64  if(fPMTPositionsX)fPMTPositionsX->push_back(positions[i].x());
65  if(fPMTPositionsY)fPMTPositionsY->push_back(positions[i].y());
66  if(fPMTPositionsZ)fPMTPositionsZ->push_back(positions[i].z());
67  }
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
75  //Store collection with event and keep ID
76  static G4int hitCID = -1;
77  if(hitCID<0){
78  hitCID = GetCollectionID(0);
79  }
80  hitsCE->AddHitsCollection( hitCID, fPMTHitCollection );
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86  return false;
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
91 //Generates a hit and uses the postStepPoint's mother volume replica number
92 //PostStepPoint because the hit is generated manually when the photon is
93 //absorbed by the photocathode
94 
97 
98  //need to know if this is an optical photon
99  if(aStep->GetTrack()->GetDefinition()
100  != G4OpticalPhoton::OpticalPhotonDefinition()) return false;
101 
102  //User replica number 1 since photocathode is a daughter volume
103  //to the pmt which was replicated
104  G4int pmtNumber=
106  G4VPhysicalVolume* physVol=
107  aStep->GetPostStepPoint()->GetTouchable()->GetVolume(1);
108 
109  //Find the correct hit collection
111  LXePMTHit* hit = nullptr;
112  for(G4int i=0;i<n;i++){
113  if((*fPMTHitCollection)[i]->GetPMTNumber()==pmtNumber){
114  hit=(*fPMTHitCollection)[i];
115  break;
116  }
117  }
118 
119  if (hit == nullptr) {//this pmt wasnt previously hit in this event
120  hit = new LXePMTHit(); //so create new hit
121  hit->SetPMTNumber(pmtNumber);
122  hit->SetPMTPhysVol(physVol);
124  hit->SetPMTPos((*fPMTPositionsX)[pmtNumber],(*fPMTPositionsY)[pmtNumber],
125  (*fPMTPositionsZ)[pmtNumber]);
126  }
127 
128  hit->IncPhotonCount(); //increment hit for the selected pmt
129 
131  hit->SetDrawit(true);
132  //If the sphere is disabled then this hit is automaticaly drawn
133  }
134  else{//sphere enabled
135  LXeUserTrackInformation* trackInfo=
137  if(trackInfo->GetTrackStatus()&hitSphere)
138  //only draw this hit if the photon has hit the sphere first
139  hit->SetDrawit(true);
140  }
141 
142  return true;
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
148 
149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
150 
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158