28.10.2011 Kamil Sedlak
1) musrSimAna significantly rewritten, but still needs to be checked. 2) changed way how some optical photon properties are simulated, + added cross-talk effects (if requested).
This commit is contained in:
@ -960,6 +960,11 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
|
||||
sscanf(&line[0],"%*s %*s %*s %lf",&sigma);
|
||||
myMusrScintSD ->SetAPDcellsTimeVariationSigma(sigma*nanosecond);
|
||||
}
|
||||
else if (strcmp(varName,"SetAPDcrossTalk")==0) {
|
||||
double crossTalkProb;
|
||||
sscanf(&line[0],"%*s %*s %*s %lf",&crossTalkProb);
|
||||
myMusrScintSD ->SetAPDcrossTalk(crossTalkProb);
|
||||
}
|
||||
else {
|
||||
G4cout<<"musrDetectorConstruction.cc: ERROR: Unknown parameterName \""
|
||||
<<varName<<"\" ."<<G4endl;
|
||||
|
@ -88,6 +88,8 @@ musrScintSD::musrScintSD(G4String name)
|
||||
APDcell_ax =0.3; APDcell_ay=0.3; APDcell_az=0.3;
|
||||
APDcellsEffectRequested=false;
|
||||
APDcellsTimeVariationRequested=false;
|
||||
APDcrossTalkRequested=false;
|
||||
APDcrossTalkProb=0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@ -147,8 +149,9 @@ G4bool musrScintSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
|
||||
G4String particleName=aTrack->GetDefinition()->GetParticleName();
|
||||
// if (particleName=="opticalphoton") {G4cout<<"UFON JE TU: edep="<<edep<<G4endl; return false;}
|
||||
if (particleName=="opticalphoton") {
|
||||
G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
|
||||
if (!musrParameters::boolG4OpticalPhotonsUnprocess) ProcessOpticalPhoton(aStep,APDcellsTimeVariation);
|
||||
// G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
|
||||
// if (!musrParameters::boolG4OpticalPhotonsUnprocess) ProcessOpticalPhoton(aStep,APDcellsTimeVariation);
|
||||
if (!musrParameters::boolG4OpticalPhotonsUnprocess) ProcessOpticalPhoton(aStep);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -203,8 +206,8 @@ G4bool musrScintSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void musrScintSD::ProcessOpticalPhoton(G4Step* aStep, G4double APDcellsTimeVariation) {
|
||||
void musrScintSD::ProcessOpticalPhoton(G4Step* aStep) {
|
||||
//void musrScintSD::ProcessOpticalPhoton(G4Step* aStep, G4double APDcellsTimeVariation) {
|
||||
// //Was the photon absorbed by the absorption process ?
|
||||
// const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
|
||||
// G4String processName = (process) ? process->GetProcessName() : "Unknown";
|
||||
@ -269,29 +272,28 @@ void musrScintSD::ProcessOpticalPhoton(G4Step* aStep, G4double APDcellsTimeVaria
|
||||
|
||||
// If the simulation of the effect of the finite number of cells in APD is requested, find out
|
||||
// whether a given cell already fired - if so, do not store the photon.
|
||||
G4bool APDcellAlreadyFired = false;
|
||||
G4int APDcellID = 0;
|
||||
if (APDcellsTimeVariationRequested) tmpTime += APDcellsTimeVariation;
|
||||
// if (APDcellsTimeVariationRequested) tmpTime += G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
|
||||
|
||||
if (APDcellsEffectRequested) {
|
||||
APDcellID = FindAPDcellID(aStep);
|
||||
// G4cout<<"Cell ID="<<APDcellID<<G4endl;
|
||||
for (optHitDetectorMapType::iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
|
||||
if ((it2->second)==APDcellID) {
|
||||
// G4cout<<"Already fired cell ="<<APDcellID<<G4endl;
|
||||
APDcellAlreadyFired = true;
|
||||
// Now lets check whether the new photon came earlier than the already saved one.
|
||||
// If so, delete the previous photon and store the time of the new one instead:
|
||||
if (tmpTime<(it2->first)) {
|
||||
optHitDetectorMap->erase(it2);
|
||||
optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!APDcellAlreadyFired) optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
|
||||
// G4bool APDcellAlreadyFired = false;
|
||||
G4int APDcellID = (APDcellsEffectRequested) ? FindAPDcellID(aStep) : 0;
|
||||
FireAPDcell(optHitDetectorMap,APDcellID,tmpTime);
|
||||
// if (APDcellsEffectRequested) {
|
||||
// APDcellID = FindAPDcellID(aStep);
|
||||
// // G4cout<<"Cell ID="<<APDcellID<<G4endl;
|
||||
// for (optHitDetectorMapType::iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
|
||||
// if ((it2->second)==APDcellID) {
|
||||
// // G4cout<<"Already fired cell ="<<APDcellID<<G4endl;
|
||||
// APDcellAlreadyFired = true;
|
||||
// // Now lets check whether the new photon came earlier than the already saved one.
|
||||
// // If so, delete the previous photon and store the time of the new one instead:
|
||||
// if (tmpTime<(it2->first)) {
|
||||
// optHitDetectorMap->erase(it2);
|
||||
// optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!APDcellAlreadyFired) optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
|
||||
//
|
||||
// G4cout<<" tmpTime="<<tmpTime<<G4endl;
|
||||
// G4cout<<" Detection"<<G4endl;
|
||||
// break;
|
||||
@ -590,6 +592,38 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
|
||||
}
|
||||
|
||||
if (optHitDetectorMap->empty()) continue;
|
||||
|
||||
// Do APD cell variation time if requested. Even if not requested, generate the random numbers in order to
|
||||
// have reproducible simulation.
|
||||
for (optHitDetectorMapType::iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
|
||||
G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
|
||||
if (APDcellsTimeVariationRequested) {
|
||||
G4int APDcellID = it2->second;
|
||||
G4double tmpTime = it2->first + APDcellsTimeVariation;
|
||||
optHitDetectorMap->erase(it2);
|
||||
optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
|
||||
}
|
||||
}
|
||||
|
||||
// Simulate cross talk if requested. Even if not requested, generate the random numbers in order to
|
||||
// have reproducible simulation.
|
||||
for (optHitDetectorMapType::const_iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
|
||||
G4double rand = G4UniformRand();
|
||||
if (APDcrossTalkRequested) {
|
||||
if (rand<APDcrossTalkProb) {
|
||||
G4int APDcellID = it2->second;
|
||||
G4double tmpTime = it2->first;
|
||||
if (!APDcellsEffectRequested) FireAPDcell(optHitDetectorMap,APDcellID,tmpTime);
|
||||
else {
|
||||
if (rand<(0.5*APDcrossTalkProb)) APDcellID--;
|
||||
else APDcellID++;
|
||||
if ((APDcellID<0)||(APDcellID>=APDcell_nx*APDcell_ny*APDcell_nz)) continue; // the cross-talk cell is outside range
|
||||
FireAPDcell(optHitDetectorMap,APDcellID,tmpTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
optHitDetectorMapType::const_iterator it2_START = optHitDetectorMap->begin();
|
||||
optHitDetectorMapType::const_iterator it2_STOP = it2_START;
|
||||
optHitDetectorMapType::const_iterator it2_LAST = optHitDetectorMap->end(); it2_LAST--;
|
||||
@ -908,6 +942,28 @@ G4int musrScintSD::FindAPDcellID(G4Step* aStep) {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void musrScintSD::FireAPDcell(optHitDetectorMapType* optHitDetectorMap, G4int APDcellID, G4double time) {
|
||||
if (!APDcellsEffectRequested) {
|
||||
optHitDetectorMap->insert(std::pair<G4double,G4int>(time,0));
|
||||
}
|
||||
else {
|
||||
G4bool APDcellAlreadyFired = false;
|
||||
for (optHitDetectorMapType::iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
|
||||
if ((it2->second)==APDcellID) { // this cell already fired before ==> check times
|
||||
APDcellAlreadyFired = true;
|
||||
if (time<(it2->first)) { // the new cell fired before the already saved cell ==> replace it
|
||||
optHitDetectorMap->erase(it2);
|
||||
optHitDetectorMap->insert(std::pair<G4double,G4int>(time,APDcellID));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!APDcellAlreadyFired) optHitDetectorMap->insert(std::pair<G4double,G4int>(time,APDcellID));
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void musrScintSD::FindCFDtime(G4double& OPSA_CFD_time, G4double& OPSA_CFD_ampl, G4double timeOfFirstPhoton) {
|
||||
OPSA_CFD->Reset("M");
|
||||
for (Int_t iBin=1; iBin<=OPSAhistoNbin; iBin++) { // loop over all bins of electronic signal histogram
|
||||
|
Reference in New Issue
Block a user