2 #include "G4ParticleTypes.hh"
3 #include "G4HCofThisEvent.hh"
4 #include "G4TouchableHistory.hh"
6 #include "G4ThreeVector.hh"
7 #include "G4SDManager.hh"
8 #include "G4RunManager.hh"
9 #include "Randomize.hh"
12 #include "G4PhysicalConstants.hh"
13 #include "G4SystemOfUnits.hh"
23 G4String detectorElement)
24 :G4VSensitiveDetector(name), detectorElement(detectorElement)
33 collectionName.insert(CollectionName);
46 (SensitiveDetectorName,collectionName[0]);
55 HCID = GetCollectionID(0);
72 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
73 G4TouchableHandle theTouchable = preStepPoint->GetTouchableHandle();
74 G4VPhysicalVolume* thePhysical = theTouchable->GetVolume();
78 G4ThreeVector worldPosition = preStepPoint->GetPosition();
79 G4ThreeVector localPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldPosition);
80 G4ThreeVector worldDirection = preStepPoint->GetMomentumDirection();
81 G4ThreeVector localDirection = theTouchable->GetHistory()->GetTopTransform().TransformAxis(worldDirection);
91 primParentID = aStep->GetTrack()->GetTrackID();
93 G4int trackID = aStep->GetTrack()->GetTrackID();
94 G4String volumeName = aStep->GetTrack()->GetVolume()->GetName();
96 G4double energyDeposition = aStep->GetTotalEnergyDeposit();
97 G4double hitTime = aStep->GetPreStepPoint()->GetGlobalTime();
99 G4ParticleDefinition *particleDefinition =
100 aStep->GetTrack()->GetDefinition();
102 if ( particleDefinition != G4OpticalPhoton::OpticalPhotonDefinition()
103 && energyDeposition == 0.0)
107 if ( particleDefinition != G4OpticalPhoton::OpticalPhotonDefinition())
111 G4String WCCollectionName;
117 if ((aStep->GetTrack()->GetTrackStatus() == fAlive )
118 &&(particleDefinition == G4OpticalPhoton::OpticalPhotonDefinition()))
128 std::stringstream tubeTag;
136 for (G4int i = theTouchable->GetHistoryDepth()-1 ; i >= 0; i--){
137 tubeTag <<
":" << theTouchable->GetVolume(i)->GetName();
138 tubeTag <<
"-" << theTouchable->GetCopyNumber(i);
149 else G4cout <<
"detectorElement not defined..." << G4endl;
151 G4double theta_angle = 0.;
152 G4double effectiveAngularEfficiency = 0.;
156 G4double wavelength = (2.0*M_PI*197.3)/( aStep->GetTrack()->GetTotalEnergy()/eV);
159 G4double photonQE = 0.;
164 maxQE =
fdet->
GetPMTQE(WCCollectionName,wavelength,0,240,660,ratio);
165 photonQE =
fdet->
GetPMTQE(volumeName, wavelength,1,240,660,ratio);
166 photonQE = photonQE/maxQE;
168 ratio = 1./(1.-0.25);
169 photonQE =
fdet->
GetPMTQE(volumeName, wavelength,1,240,660,ratio);
174 if (G4UniformRand() <= photonQE){
176 G4double local_x = localPosition.x();
177 G4double local_y = localPosition.y();
178 G4double local_z = localPosition.z();
179 theta_angle = acos(fabs(local_z)/sqrt(pow(local_x,2)+pow(local_y,2)+pow(local_z,2)))/3.1415926*180.;
183 G4SDManager* SDman = G4SDManager::GetSDMpointer();
184 G4RunManager* Runman = G4RunManager::GetRunManager();
185 G4int collectionID = SDman->GetCollectionID(volumeName);
186 const G4Event* currentEvent = Runman->GetCurrentEvent();
187 G4HCofThisEvent* HCofEvent = currentEvent->GetHCofThisEvent();
196 newHit->
SetEdep(energyDeposition);
199 G4AffineTransform aTrans = theTouchable->GetHistory()->GetTopTransform();
200 newHit->
SetRot(aTrans.NetRotation());
203 newHit->
SetPos(aTrans.NetTranslation());
207 (*hitsCollection)[
PMTHitMap[replicaNumber]-1]->AddPe(hitTime);
208 (*hitsCollection)[
PMTHitMap[replicaNumber]-1]->AddParentID(primParentID);
214 (*hitsCollection)[
PMTHitMap[replicaNumber]-1]->AddPe(hitTime);
215 (*hitsCollection)[
PMTHitMap[replicaNumber]-1]->AddParentID(primParentID);
231 G4SDManager* SDman = G4SDManager::GetSDMpointer();
232 G4int collectionID = SDman->GetCollectionID(WCIDCollectionName);
237 G4cout <<
"There are " << numHits <<
" hits in the "<<
detectorElement<<
" : "<< G4endl;
238 for (G4int i=0; i < numHits; i++)
G4double GetPMTQE(G4String, G4double, G4int, G4double, G4double, G4double)
void SetMaxPe(G4int number=0)
void SetTubeID(G4int tube)
void SetRot(G4RotationMatrix rotMatrix)
void EndOfEvent(G4HCofThisEvent *)
static G4int GetODTubeID(std::string tubeTag)
void Initialize(G4HCofThisEvent *)
static G4int GetTubeID(std::string tubeTag)
G4THitsCollection< WCSimWCHit > WCSimWCHitsCollection
G4double GetPMTCollectionEfficiency(G4double theta_angle, G4String CollectionName)
G4String GetIDCollectionName()
void SetLogicalVolume(G4LogicalVolume *logV)
WCSimWCSD(G4String, G4String, WCSimDetectorConstruction *, G4String)
void SetTrackID(G4int track)
void SetPos(G4ThreeVector xyz)
WCSimWCHitsCollection * hitsCollection
G4bool ProcessHits(G4Step *, G4TouchableHistory *)
G4String GetODCollectionName()
WCSimDetectorConstruction * fdet
std::map< int, int > PMTHitMap
void SetEdep(G4double de)