23.11.2011 Kamil Sedlak

Three major changes in the photon simulation:
1) Added timeC1 ... timeC20
2) Added odet_nPhotPrim[odet_n]  (number of primary photons)
3) Added all individual photons:  phot_time[nOptPhotDet]
Documentation has not been updated yet.
This commit is contained in:
2011-11-23 15:35:49 +00:00
parent 4d069f990c
commit 455786e3fd
5 changed files with 326 additions and 78 deletions

View File

@ -1365,6 +1365,7 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
if (strcmp(tmpString2,"posIniMomY")==0) {musrRootOutput::store_posIniMomY = false;}
if (strcmp(tmpString2,"posIniMomZ")==0) {musrRootOutput::store_posIniMomZ = false;}
if (strcmp(tmpString2,"nOptPhot")==0) {musrRootOutput::store_nOptPhot = false;}
if (strcmp(tmpString2,"nOptPhotDet")==0) {musrRootOutput::store_nOptPhotDet = false;}
if (strcmp(tmpString2,"fieldNomVal")==0) {musrRootOutput::store_fieldNomVal = false;}
if (strcmp(tmpString2,"det_ID")==0) {musrRootOutput::store_det_ID = false;}
if (strcmp(tmpString2,"det_edep")==0) {musrRootOutput::store_det_edep = false;}
@ -1398,6 +1399,7 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
if (strcmp(tmpString2,"det_VvvParticleID")==0){musrRootOutput::store_det_VvvParticleID = false;}
if (strcmp(tmpString2,"odet_ID")==0) {musrRootOutput::store_odet_ID = false;}
if (strcmp(tmpString2,"odet_nPhot")==0) {musrRootOutput::store_odet_nPhot = false;}
if (strcmp(tmpString2,"odet_nPhotPrim")==0) {musrRootOutput::store_odet_nPhotPrim = false;}
if (strcmp(tmpString2,"odet_timeFirst")==0) {musrRootOutput::store_odet_timeFirst = false;}
if (strcmp(tmpString2,"odet_timeSecond")==0) {musrRootOutput::store_odet_timeSecond = false;}
if (strcmp(tmpString2,"odet_timeThird")==0) {musrRootOutput::store_odet_timeThird = false;}
@ -1418,7 +1420,8 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
if (strcmp(tmpString2,"fieldIntegralBz2")==0){musrRootOutput::store_fieldIntegralBz2 = true;}
if (strcmp(tmpString2,"fieldIntegralBz3")==0){musrRootOutput::store_fieldIntegralBz3 = true;}
if (strcmp(tmpString2,"odet_timeCFDarray")==0){musrRootOutput::store_odet_timeCFDarray = true;}
if (strcmp(tmpString2,"odet_timeC1")==0) {musrRootOutput::store_odet_timeC1 = true;}
if (strcmp(tmpString2,"phot_time")==0) {musrRootOutput::store_phot_time = true;}
if ((musrRootOutput::store_fieldIntegralBx)||(musrRootOutput::store_fieldIntegralBy)||
(musrRootOutput::store_fieldIntegralBz)||(musrRootOutput::store_fieldIntegralBz1)||
(musrRootOutput::store_fieldIntegralBz2)||(musrRootOutput::store_fieldIntegralBz3) ) {

View File

@ -114,6 +114,8 @@ G4bool musrRootOutput::store_posIniMomX = true;
G4bool musrRootOutput::store_posIniMomY = true;
G4bool musrRootOutput::store_posIniMomZ = true;
G4bool musrRootOutput::store_nOptPhot = true;
G4bool musrRootOutput::store_nOptPhotDet= true;
G4bool musrRootOutput::store_phot_time = false;
G4bool musrRootOutput::store_det_ID = true;
G4bool musrRootOutput::store_det_edep = true;
G4bool musrRootOutput::store_det_edep_el = true;
@ -153,6 +155,7 @@ G4bool musrRootOutput::store_fieldIntegralBz2 = false;
G4bool musrRootOutput::store_fieldIntegralBz3 = false;
G4bool musrRootOutput::store_odet_ID = true;
G4bool musrRootOutput::store_odet_nPhot = true;
G4bool musrRootOutput::store_odet_nPhotPrim = true;
G4bool musrRootOutput::store_odet_timeFirst = true;
G4bool musrRootOutput::store_odet_timeSecond = true;
G4bool musrRootOutput::store_odet_timeThird = true;
@ -165,6 +168,7 @@ G4bool musrRootOutput::store_odet_timeLast = true;
G4bool musrRootOutput::store_odet_timeCFD = true;
G4bool musrRootOutput::store_odet_amplCFD = true;
G4bool musrRootOutput::store_odet_timeCFDarray = false;
G4bool musrRootOutput::store_odet_timeC1 = false;
G4int musrRootOutput::oldEventNumberInG4EqEMFieldWithSpinFunction=-1;
@ -229,6 +233,8 @@ void musrRootOutput::BeginOfRunAction() {
if (store_posIniMomY) {rootTree->Branch("posIniMomY",&posIniMomy,"posIniMomY/D");}
if (store_posIniMomZ) {rootTree->Branch("posIniMomZ",&posIniMomz,"posIniMomZ/D");}
if (store_nOptPhot) {rootTree->Branch("nOptPhot",&nOptPhot,"nOptPhot/I");}
if (store_nOptPhotDet) {rootTree->Branch("nOptPhotDet",&nOptPhotDet,"nOptPhotDet/I");}
if (store_phot_time) {rootTree->Branch("phot_time",&phot_time,"phot_time[nOptPhotDet]/D");}
// if (store_globalTime) {rootTree->Branch("globalTime",&globalTime,"globalTime/D");}
// if (store_fieldValue) {rootTree->Branch("fieldValue",&fieldValue,"fieldValue/D");}
if (store_fieldNomVal) {
@ -291,11 +297,13 @@ void musrRootOutput::BeginOfRunAction() {
rootTree->Branch("save_polz",&save_polz,"save_polz[save_n]/D");
}
if (store_odet_ID || store_odet_nPhot || store_odet_timeFirst || store_odet_timeSecond || store_odet_timeThird || store_odet_timeA || store_odet_timeB ||
store_odet_timeC || store_odet_timeD || store_odet_timeMean || store_odet_timeLast || store_odet_timeCFD || store_odet_amplCFD)
if (store_odet_ID || store_odet_nPhot || store_odet_nPhotPrim || store_odet_timeFirst || store_odet_timeSecond ||
store_odet_timeThird || store_odet_timeA || store_odet_timeB || store_odet_timeC || store_odet_timeD ||
store_odet_timeMean || store_odet_timeLast || store_odet_timeCFD || store_odet_amplCFD || store_odet_timeC1)
{rootTree->Branch("odet_n",&odet_n,"odet_n/I");}
if (store_odet_ID) {rootTree->Branch("odet_ID",&odet_ID,"odet_ID[odet_n]/I");}
if (store_odet_nPhot) {rootTree->Branch("odet_nPhot",&odet_nPhot,"odet_nPhot[odet_n]/I");}
if (store_odet_nPhotPrim) {rootTree->Branch("odet_nPhotPrim",&odet_nPhotPrim,"odet_nPhotPrim[odet_n]/I");}
if (store_odet_timeFirst) {rootTree->Branch("odet_timeFirst",&odet_timeFirst,"odet_timeFirst[odet_n]/D");}
if (store_odet_timeSecond) {rootTree->Branch("odet_timeSecond",&odet_timeSecond,"odet_timeSecond[odet_n]/D");}
if (store_odet_timeThird) {rootTree->Branch("odet_timeThird",&odet_timeThird,"odet_timeThird[odet_n]/D");}
@ -374,6 +382,28 @@ void musrRootOutput::BeginOfRunAction() {
rootTree->Branch("odet_timeCFD511",&odet_timeCFD511,"odet_timeCFD511[odet_n]/D");
rootTree->Branch("odet_timeCFD512",&odet_timeCFD512,"odet_timeCFD512[odet_n]/D");
}
if (store_odet_timeC1) {
rootTree->Branch("odet_timeC1",&odet_timeC1,"odet_timeC1[odet_n]/D");
rootTree->Branch("odet_timeC2",&odet_timeC2,"odet_timeC2[odet_n]/D");
rootTree->Branch("odet_timeC3",&odet_timeC3,"odet_timeC3[odet_n]/D");
rootTree->Branch("odet_timeC4",&odet_timeC4,"odet_timeC4[odet_n]/D");
rootTree->Branch("odet_timeC5",&odet_timeC5,"odet_timeC5[odet_n]/D");
rootTree->Branch("odet_timeC6",&odet_timeC6,"odet_timeC6[odet_n]/D");
rootTree->Branch("odet_timeC7",&odet_timeC7,"odet_timeC7[odet_n]/D");
rootTree->Branch("odet_timeC8",&odet_timeC8,"odet_timeC8[odet_n]/D");
rootTree->Branch("odet_timeC9",&odet_timeC9,"odet_timeC9[odet_n]/D");
rootTree->Branch("odet_timeC10",&odet_timeC10,"odet_timeC10[odet_n]/D");
rootTree->Branch("odet_timeC11",&odet_timeC11,"odet_timeC11[odet_n]/D");
rootTree->Branch("odet_timeC12",&odet_timeC12,"odet_timeC12[odet_n]/D");
rootTree->Branch("odet_timeC13",&odet_timeC13,"odet_timeC13[odet_n]/D");
rootTree->Branch("odet_timeC14",&odet_timeC14,"odet_timeC14[odet_n]/D");
rootTree->Branch("odet_timeC15",&odet_timeC15,"odet_timeC15[odet_n]/D");
rootTree->Branch("odet_timeC16",&odet_timeC16,"odet_timeC16[odet_n]/D");
rootTree->Branch("odet_timeC17",&odet_timeC17,"odet_timeC17[odet_n]/D");
rootTree->Branch("odet_timeC18",&odet_timeC18,"odet_timeC18[odet_n]/D");
rootTree->Branch("odet_timeC19",&odet_timeC19,"odet_timeC19[odet_n]/D");
rootTree->Branch("odet_timeC20",&odet_timeC20,"odet_timeC20[odet_n]/D");
}
// htest1 = new TH1F("htest1","The debugging histogram 1",50,-4.,4.);
// htest2 = new TH1F("htest2","The debugging histogram 2",50,0.,3.142);
@ -455,6 +485,7 @@ void musrRootOutput::ClearAllRootVariables() {
muDecayTime=-1000;
posIniMomx=-1000;posIniMomy=-1000;posIniMomz=-1000;
nOptPhot=0;
nOptPhotDet=0;
BxIntegral = -1000; ByIntegral = -1000; BzIntegral = -1000;
BzIntegral1 = -1000; BzIntegral2 = -1000; BzIntegral3 = -1000;
det_n=0;
@ -610,7 +641,7 @@ void musrRootOutput::SetDetectorInfoVvv (G4int nDetectors,
}
void musrRootOutput::SetOPSAinfo (G4int nDetectors, G4int ID, G4int nPhot, G4double timeFirst,
void musrRootOutput::SetOPSAinfo (G4int nDetectors, G4int ID, G4int nPhot, G4int nPhotPrim, G4double timeFirst,
G4double timeSecond, G4double timeThird, G4double timeA, G4double timeB, G4double timeC,
G4double timeD, G4double timeMean, G4double timeLast, G4double timeCFD, G4double amplCFD)
{
@ -624,6 +655,7 @@ void musrRootOutput::SetOPSAinfo (G4int nDetectors, G4int ID, G4int nPhot, G4
odet_n=nDetectors+1;
odet_ID[nDetectors]=ID;
odet_nPhot[nDetectors]=nPhot;
odet_nPhotPrim[nDetectors]=nPhotPrim;
odet_timeFirst[nDetectors]=timeFirst/microsecond;
odet_timeSecond[nDetectors]=timeSecond/microsecond;
odet_timeThird[nDetectors]=timeThird/microsecond;
@ -706,6 +738,32 @@ void musrRootOutput::SetCFDSpecialInfo (G4int n, G4double time) {
else if (n==512) {odet_timeCFD512[odet_n-1] = time/microsecond;}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void musrRootOutput::SetTimeC1SpecialInfo (G4double* time) {
odet_timeC1[odet_n-1] = time[1]/microsecond;
odet_timeC2[odet_n-1] = time[2]/microsecond;
odet_timeC3[odet_n-1] = time[3]/microsecond;
odet_timeC4[odet_n-1] = time[4]/microsecond;
odet_timeC5[odet_n-1] = time[5]/microsecond;
odet_timeC6[odet_n-1] = time[6]/microsecond;
odet_timeC7[odet_n-1] = time[7]/microsecond;
odet_timeC8[odet_n-1] = time[8]/microsecond;
odet_timeC9[odet_n-1] = time[9]/microsecond;
odet_timeC10[odet_n-1] = time[10]/microsecond;
odet_timeC11[odet_n-1] = time[11]/microsecond;
odet_timeC12[odet_n-1] = time[12]/microsecond;
odet_timeC13[odet_n-1] = time[13]/microsecond;
odet_timeC14[odet_n-1] = time[14]/microsecond;
odet_timeC15[odet_n-1] = time[15]/microsecond;
odet_timeC16[odet_n-1] = time[16]/microsecond;
odet_timeC17[odet_n-1] = time[17]/microsecond;
odet_timeC18[odet_n-1] = time[18]/microsecond;
odet_timeC19[odet_n-1] = time[19]/microsecond;
odet_timeC20[odet_n-1] = time[20]/microsecond;
// std::cout<<"odet_timeC1["<<odet_n-1<<"]="<<odet_timeC1[odet_n-1]<<std::endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void musrRootOutput::setRootOutputDirectoryName(char dirName[1000]) {
strcpy(rootOutputDirectoryName,dirName);
@ -713,3 +771,17 @@ void musrRootOutput::setRootOutputDirectoryName(char dirName[1000]) {
sprintf(message,"musrRootOutput.cc::setRootOutputDirectoryName: Root output file will be stored in directory %s",dirName);
musrErrorMessage::GetInstance()->musrError(INFO,message,false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void musrRootOutput::SetPhotDetTime(G4double time) {
if (nOptPhotDet<maxNOptPhotDet) {
phot_time[nOptPhotDet] = time;
nOptPhotDet++;
}
else {
char message[200];
sprintf(message,"musrRootOutput.cc::SetPhotDetTime: number of individual photons larger than maxNOptPhotDet (=%d)",maxNOptPhotDet);
musrErrorMessage::GetInstance()->musrError(WARNING,message,false);
}
}

View File

@ -60,6 +60,27 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4double musrScintSD::OPSA_C1_threshold (0.5);
const G4double musrScintSD::OPSA_C2_threshold (1.);
const G4double musrScintSD::OPSA_C3_threshold (2.);
const G4double musrScintSD::OPSA_C4_threshold (3.);
const G4double musrScintSD::OPSA_C5_threshold (4.);
const G4double musrScintSD::OPSA_C6_threshold (5.);
const G4double musrScintSD::OPSA_C7_threshold (6.);
const G4double musrScintSD::OPSA_C8_threshold (7.);
const G4double musrScintSD::OPSA_C9_threshold (8.);
const G4double musrScintSD::OPSA_C10_threshold (9.);
const G4double musrScintSD::OPSA_C11_threshold (10.);
const G4double musrScintSD::OPSA_C12_threshold (11.);
const G4double musrScintSD::OPSA_C13_threshold (12.);
const G4double musrScintSD::OPSA_C14_threshold (13.);
const G4double musrScintSD::OPSA_C15_threshold (14.);
const G4double musrScintSD::OPSA_C16_threshold (15.);
const G4double musrScintSD::OPSA_C17_threshold (16.);
const G4double musrScintSD::OPSA_C18_threshold (17.);
const G4double musrScintSD::OPSA_C19_threshold (18.);
const G4double musrScintSD::OPSA_C20_threshold (19.);
musrScintSD::musrScintSD(G4String name)
:G4VSensitiveDetector(name)
{
@ -261,15 +282,6 @@ void musrScintSD::ProcessOpticalPhoton(G4Step* aStep) {
musrErrorMessage::GetInstance()->musrError(WARNING,message,true);
}
// switch(boundaryStatus){
// case Absorption:
// G4cout<<" AAAAAAAAAAAAAAAAAA Absorption"<<G4endl;
// break;
// case Detection: //Note, this assumes that the volume causing detection
//is the photocathode because it is the only one with
//non-zero efficiency
// Do APD cell variation time if requested. Even if not requested, generate the random numbers in order to
// have reproducible simulation.
G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
@ -278,49 +290,7 @@ void musrScintSD::ProcessOpticalPhoton(G4Step* aStep) {
// 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.
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;
// case FresnelReflection:
// case LambertianReflection:
// case LobeReflection:
// case TotalInternalReflection:
// case SpikeReflection:
// G4cout<<" Reflection"<<G4endl;
// break;
// case StepTooSmall:
// G4cout<<" StepTooSmall"<<G4endl;
// break;
// case NoRINDEX:
// G4cout<<" NoRINDEX"<<G4endl;
// break;
// // case :
// // G4cout<<" "<<G4endl;
// // break;
// default:
// G4cout<<" SomethingElse"<<G4endl;
// break;
// }
FireAPDcell(optHitDetectorMap,APDcellID,tmpTime,1);
}
}
@ -615,14 +585,14 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
G4double rand = G4UniformRand();
if (APDcrossTalkRequested) {
if (rand<APDcrossTalkProb) {
G4int APDcellID = it2->second;
G4int APDcellID = (it2->second).GetAPDcellID();
G4double tmpTime = it2->first;
if (!APDcellsEffectRequested) FireAPDcell(optHitDetectorMap,APDcellID,tmpTime);
if (!APDcellsEffectRequested) FireAPDcell(optHitDetectorMap,APDcellID,tmpTime,0);
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);
FireAPDcell(optHitDetectorMap,APDcellID,tmpTime,0);
}
}
}
@ -633,6 +603,7 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
optHitDetectorMapType::const_iterator it2_LAST = optHitDetectorMap->end(); it2_LAST--;
Double_t time = -1000, lastTime = -1000;
G4int OPSA_nPhot = 0;
G4int OPSA_nPhotPrim = 0;
G4double OPSA_timeFirst = -1000000;
G4double OPSA_timeSecond = -1000000;
G4double OPSA_timeThird = -1000000;
@ -710,6 +681,7 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
for (optHitDetectorMapType::const_iterator it3 = optHitDetectorSUBmap.begin(); it3 != optHitDetectorSUBmap.end(); it3++) {
nP++;
G4double timePhot = it3->first;
OPSA_nPhotPrim += (it3->second).GetAPDcellNphot();
// if (APDcellsTimeVariationRequested) timePhot += G4RandGauss::shoot(0,APDcellsTimeVariationSigma); // Shifted above
if (nP==1) OPSA_timeFirst = timePhot;
if (nP==2) OPSA_timeSecond= timePhot;
@ -743,6 +715,7 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
// if required, convert the histogram with photon times to histogram of electronic pulse shape
G4double timeCFDarray[1000];
G4double OPSA_timeC1[21];
if (bool_pulseShapeExists) {
// for (Int_t iBin=1; iBin<=OPSAhistoNbin; iBin++) { // loop over all bins of photon histogram
// Double_t photonCount = OPSAhisto ->GetBinContent(iBin);
@ -813,6 +786,120 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
if (OPSA_C_time_found && OPSA_D_time_found) break; // times C and D found, no need to continue looping.
}
if (musrRootOutput::store_odet_timeC1) {
Double_t yValue=-1000;
for (Int_t i=1; i<=20; i++) {OPSA_timeC1[i] = -1000000.;}
G4bool OPSA_C1_time_found = false; G4bool OPSA_C2_time_found = false;
G4bool OPSA_C3_time_found = false; G4bool OPSA_C4_time_found = false;
G4bool OPSA_C5_time_found = false; G4bool OPSA_C6_time_found = false;
G4bool OPSA_C7_time_found = false; G4bool OPSA_C8_time_found = false;
G4bool OPSA_C9_time_found = false; G4bool OPSA_C10_time_found = false;
G4bool OPSA_C11_time_found = false; G4bool OPSA_C12_time_found = false;
G4bool OPSA_C13_time_found = false; G4bool OPSA_C14_time_found = false;
G4bool OPSA_C15_time_found = false; G4bool OPSA_C16_time_found = false;
G4bool OPSA_C17_time_found = false; G4bool OPSA_C18_time_found = false;
G4bool OPSA_C19_time_found = false; G4bool OPSA_C20_time_found = false;
Double_t OPSAshape_histoMax = OPSAshape->GetMaximum();
for (Int_t iBin=1; iBin<=OPSAhistoNbin; iBin++) { // loop over all bins of CFD histogram
Double_t xValue = (iBin-0.5)*OPSAhistoBinWidth;
Double_t oldYvalue = yValue;
yValue = OPSAshape->GetBinContent(iBin);
if ( (yValue>=OPSA_C1_threshold) && (!OPSA_C1_time_found) ) { // signal just moved above the threshold
OPSA_C1_time_found = true;
OPSA_timeC1[1] = OPSA_timeFirst + xValue - (yValue-OPSA_C1_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C2_threshold) && (!OPSA_C2_time_found) ) { // signal just moved above the threshold
OPSA_C2_time_found = true;
OPSA_timeC1[2] = OPSA_timeFirst + xValue - (yValue-OPSA_C2_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C3_threshold) && (!OPSA_C3_time_found) ) { // signal just moved above the threshold
OPSA_C3_time_found = true;
OPSA_timeC1[3] = OPSA_timeFirst + xValue - (yValue-OPSA_C3_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C4_threshold) && (!OPSA_C4_time_found) ) { // signal just moved above the threshold
OPSA_C4_time_found = true;
OPSA_timeC1[4] = OPSA_timeFirst + xValue - (yValue-OPSA_C4_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C5_threshold) && (!OPSA_C5_time_found) ) { // signal just moved above the threshold
OPSA_C5_time_found = true;
OPSA_timeC1[5] = OPSA_timeFirst + xValue - (yValue-OPSA_C5_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C6_threshold) && (!OPSA_C6_time_found) ) { // signal just moved above the threshold
OPSA_C6_time_found = true;
OPSA_timeC1[6] = OPSA_timeFirst + xValue - (yValue-OPSA_C6_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C7_threshold) && (!OPSA_C7_time_found) ) { // signal just moved above the threshold
OPSA_C7_time_found = true;
OPSA_timeC1[7] = OPSA_timeFirst + xValue - (yValue-OPSA_C7_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C8_threshold) && (!OPSA_C8_time_found) ) { // signal just moved above the threshold
OPSA_C8_time_found = true;
OPSA_timeC1[8] = OPSA_timeFirst + xValue - (yValue-OPSA_C8_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C9_threshold) && (!OPSA_C9_time_found) ) { // signal just moved above the threshold
OPSA_C9_time_found = true;
OPSA_timeC1[9] = OPSA_timeFirst + xValue - (yValue-OPSA_C9_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C10_threshold) && (!OPSA_C10_time_found) ) { // signal just moved above the threshold
OPSA_C10_time_found = true;
OPSA_timeC1[10] = OPSA_timeFirst + xValue - (yValue-OPSA_C10_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C11_threshold) && (!OPSA_C11_time_found) ) { // signal just moved above the threshold
OPSA_C11_time_found = true;
OPSA_timeC1[11] = OPSA_timeFirst + xValue - (yValue-OPSA_C11_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C12_threshold) && (!OPSA_C12_time_found) ) { // signal just moved above the threshold
OPSA_C12_time_found = true;
OPSA_timeC1[12] = OPSA_timeFirst + xValue - (yValue-OPSA_C12_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C13_threshold) && (!OPSA_C13_time_found) ) { // signal just moved above the threshold
OPSA_C13_time_found = true;
OPSA_timeC1[13] = OPSA_timeFirst + xValue - (yValue-OPSA_C13_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C14_threshold) && (!OPSA_C14_time_found) ) { // signal just moved above the threshold
OPSA_C14_time_found = true;
OPSA_timeC1[14] = OPSA_timeFirst + xValue - (yValue-OPSA_C14_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C15_threshold) && (!OPSA_C15_time_found) ) { // signal just moved above the threshold
OPSA_C15_time_found = true;
OPSA_timeC1[15] = OPSA_timeFirst + xValue - (yValue-OPSA_C15_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C16_threshold) && (!OPSA_C16_time_found) ) { // signal just moved above the threshold
OPSA_C16_time_found = true;
OPSA_timeC1[16] = OPSA_timeFirst + xValue - (yValue-OPSA_C16_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C17_threshold) && (!OPSA_C17_time_found) ) { // signal just moved above the threshold
OPSA_C17_time_found = true;
OPSA_timeC1[17] = OPSA_timeFirst + xValue - (yValue-OPSA_C17_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C18_threshold) && (!OPSA_C18_time_found) ) { // signal just moved above the threshold
OPSA_C18_time_found = true;
OPSA_timeC1[18] = OPSA_timeFirst + xValue - (yValue-OPSA_C18_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C19_threshold) && (!OPSA_C19_time_found) ) { // signal just moved above the threshold
OPSA_C19_time_found = true;
OPSA_timeC1[19] = OPSA_timeFirst + xValue - (yValue-OPSA_C19_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if ( (yValue>=OPSA_C20_threshold) && (!OPSA_C20_time_found) ) { // signal just moved above the threshold
OPSA_C20_time_found = true;
OPSA_timeC1[20] = OPSA_timeFirst + xValue - (yValue-OPSA_C20_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
}
if (OPSA_C20_time_found) {
if (OPSA_C1_time_found && OPSA_C2_time_found && OPSA_C3_time_found && OPSA_C4_time_found &&
OPSA_C5_time_found && OPSA_C6_time_found && OPSA_C7_time_found && OPSA_C8_time_found &&
OPSA_C9_time_found && OPSA_C10_time_found && OPSA_C11_time_found && OPSA_C12_time_found &&
OPSA_C13_time_found && OPSA_C14_time_found && OPSA_C15_time_found && OPSA_C16_time_found &&
OPSA_C17_time_found && OPSA_C18_time_found && OPSA_C19_time_found) break; // all times found
}
if (yValue==OPSAshape_histoMax) break; // no need for further searching, because maximum was achieved.
}
// myRootOutput -> SetTimeC1SpecialInfo(OPSA_timeC1);
}
// G4cout<<" OPSA_CFD_time = "<< OPSA_CFD_time<<", OPSA_CFD_ampl="<<OPSA_CFD_ampl
// <<", OPSA_timeFirst="<<OPSA_timeFirst<<", OPSA_timeC="<<OPSA_timeC <<", OPSA_timeD="<<OPSA_timeD<<G4endl;
} // end if (pulseShapeExists)
@ -826,12 +913,13 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
}
}
signalInfo* mySignalInfo = new signalInfo(OPSA_detID,OPSA_nPhot,OPSA_timeFirst,OPSA_timeSecond,OPSA_timeThird,
signalInfo* mySignalInfo = new signalInfo(OPSA_detID,OPSA_nPhot,OPSA_nPhotPrim,OPSA_timeFirst,OPSA_timeSecond,OPSA_timeThird,
OPSA_timeA,OPSA_timeB,OPSA_timeC,OPSA_timeD,OPSA_timeMean,OPSA_timeLast,
OPSA_CFD_time,OPSA_CFD_ampl,timeCFDarray);
OPSA_CFD_time,OPSA_CFD_ampl,timeCFDarray,OPSA_timeC1);
OPSA_signal_Map.insert(std::pair<G4int,signalInfo*>(OPSA_nPhot,mySignalInfo) );
}
OPSA_nPhot = 0;
OPSA_nPhotPrim = 0;
OPSA_timeFirst = -1000000;
OPSA_timeSecond = -1000000;
OPSA_timeThird = -1000000;
@ -946,23 +1034,33 @@ G4int musrScintSD::FindAPDcellID(G4Step* aStep) {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void musrScintSD::FireAPDcell(optHitDetectorMapType* optHitDetectorMap, G4int APDcellID, G4double time) {
void musrScintSD::FireAPDcell(optHitDetectorMapType* optHitDetectorMap, G4int APDcellID, G4double time, G4int nTruePhe) {
if ( (musrRootOutput::store_phot_time) && (nTruePhe>0) ) myRootOutput->SetPhotDetTime(time);
if (!APDcellsEffectRequested) {
optHitDetectorMap->insert(std::pair<G4double,G4int>(time,0));
APDidClass tmpAPDid(0,nTruePhe);
// optHitDetectorMap->insert(std::pair<G4double,G4int>(time,0));
optHitDetectorMap->insert(std::pair<G4double,APDidClass>(time,tmpAPDid));
}
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
if ((it2->second).GetAPDcellID()==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
G4int tmpAPDcellNphot = (it2->second).GetAPDcellNphot() + nTruePhe;
APDidClass tmpAPDid(APDcellID,tmpAPDcellNphot);
optHitDetectorMap->erase(it2);
optHitDetectorMap->insert(std::pair<G4double,G4int>(time,APDcellID));
// optHitDetectorMap->insert(std::pair<G4double,G4int>(time,APDcellID));
optHitDetectorMap->insert(std::pair<G4double,APDidClass>(time,tmpAPDid));
}
break;
}
}
if (!APDcellAlreadyFired) optHitDetectorMap->insert(std::pair<G4double,G4int>(time,APDcellID));
if (!APDcellAlreadyFired) {
// optHitDetectorMap->insert(std::pair<G4double,G4int>(time,APDcellID));
APDidClass tmpAPDid(APDcellID,nTruePhe);
optHitDetectorMap->insert(std::pair<G4double,APDidClass>(time,tmpAPDid));
}
}
}