12 collectionName.insert(hitsCollectionName);
16 case fIsNominalEfficiency:
18 fPDE =
new G4PhysicsFreeVector(GS::pdeEnergies, GS::pdeValues);
20 case fIsFixedEfficiency:
21 fFixedEfficiency = GS::meanPDE;
23 case fIsRandomEfficiency:
26 case fIsAssignedEfficiency:
38 G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
48 G4Track *track = aStep->GetTrack();
49 G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
50 const G4VTouchable *touchable = preStepPoint->GetTouchable();
51 G4double phEnergy = preStepPoint->GetTotalEnergy();
56 case fIsNominalEfficiency:
57 if(G4UniformRand() > fPDE->Value(phEnergy))
return false;
59 case fIsFixedEfficiency:
60 if(G4UniformRand() > fFixedEfficiency)
return false;
62 case fIsRandomEfficiency:
63 case fIsAssignedEfficiency:
64 G4int ch = touchable->GetCopyNumber(2);
65 G4bool isFront = (touchable->GetVolume(2)->GetTranslation().z() <
GS::zScintillator);
78 if(track->GetParticleDefinition()->GetPDGEncoding()==-22)
79 track->SetTrackStatus(fStopAndKill);
107 G4cout <<
"\n Randomization of efficiencies... \n" << G4endl;
110 std::ofstream file(
"random_efficiencies.txt");
115 G4cerr <<
"Can't open the file!" << G4endl;
119 file <<
"# Channel Eff Front Eff Back" << G4endl;
139 std::ifstream file(
"random_efficiencies.txt");
144 G4cerr <<
"Can't open the file!" << G4endl;
152 while(std::getline(file, line))
158 std::istringstream iss(line);
159 G4double effFront, effBack;
162 if(!(iss >> ch >> effFront >> effBack))
164 G4cerr <<
"Error in reading the file!" << G4endl;
176 G4cout <<
"\n Data read from random_efficiencies.txt successfully. \n" << G4endl;
Concrete class of G4VHit, representing a hit in the MySensitiveDetector.
void SetDetectorChannel(G4int ch)
Set the channel of the SiPM hit by the optical photon.
void SetDetectionTime(G4double t)
Set the detection time of the optical photon.
void SetDetectorPosition(G4ThreeVector xyz)
Set the position (center) of the SiPM hit by the optical photon.
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
For every optical photon that hits the SD this method instantiates a MyHit object,...
G4double fBackEfficiency[GS::nOfSiPMs]
Array of PDEs for back MPPCs.
void Initialize(G4HCofThisEvent *hce) override
Associates a new MyHitsCollection with a G4HCofThisEvent object at the beginning of each event.
void GetEfficienciesFromFile()
Reads and sets the efficiencies from the file.
MySensitiveDetector(G4String name, G4String hitsCollectionName)
Constructor of the class.
SetEfficiencies fEfficiencySetting
Type of SetEfficiencies.
MyHitsCollection * fHitsCollection
Pointer to the hits collection of the event.
G4double fFrontEfficiency[GS::nOfSiPMs]
Array of PDEs for front MPPCs.
void RandomizeEfficiencies()
Fixes random efficiencies for all MPPCs.
Declaration of the class MySensitiveDetector.
G4THitsCollection< MyHit > MyHitsCollection
Concrete hit collection class for MyHit.
constexpr G4double zScintillator
z-position of the scintillator crystal.
constexpr G4int nOfSiPMs
The number of SiPMs on a detector face.