|
|
|
@ -70,8 +70,8 @@ musrScintSD::musrScintSD(G4String name)
|
|
|
|
|
OPSA_signalSeparationTime = 10.;
|
|
|
|
|
OPSA_fracA = 0.01;
|
|
|
|
|
OPSA_fracB = 0.05;
|
|
|
|
|
OPSA_fracC = 0.10;
|
|
|
|
|
OPSA_fracD = 0.20;
|
|
|
|
|
OPSA_C_threshold = 0.5;
|
|
|
|
|
OPSA_D_threshold = 0.5;
|
|
|
|
|
bool_multimapOfEventIDsForOPSAhistosEXISTS = false;
|
|
|
|
|
bool_StoreThisOPSAhistSUMMED = false;
|
|
|
|
|
bool_StoreThisOPSAhistALL = false;
|
|
|
|
@ -593,8 +593,6 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
|
|
|
|
|
G4double OPSA_f_nPhot = OPSA_nPhot;
|
|
|
|
|
G4int NA = int (OPSA_fracA * OPSA_f_nPhot + 0.5); if (NA<=0) NA=1;
|
|
|
|
|
G4int NB = int (OPSA_fracB * OPSA_f_nPhot + 0.5); if (NB<=0) NB=1;
|
|
|
|
|
G4int NC = int (OPSA_fracC * OPSA_f_nPhot + 0.5); if (NC<=0) NC=1;
|
|
|
|
|
G4int ND = int (OPSA_fracD * OPSA_f_nPhot + 0.5); if (ND<=0) ND=1;
|
|
|
|
|
|
|
|
|
|
Int_t nP=0;
|
|
|
|
|
// Define OPSA histograms if required for this event
|
|
|
|
@ -641,10 +639,21 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
|
|
|
|
|
if (nP==1) OPSA_timeFirst = timePhot;
|
|
|
|
|
if (nP==NA) OPSA_timeA = timePhot;
|
|
|
|
|
if (nP==NB) OPSA_timeB = timePhot;
|
|
|
|
|
if (nP==NC) OPSA_timeC = timePhot;
|
|
|
|
|
if (nP==ND) OPSA_timeD = timePhot;
|
|
|
|
|
if (nP==OPSA_nPhot) OPSA_timeLast = timePhot;
|
|
|
|
|
if ((boolStoreThisOPSAhist)||(bool_pulseShapeExists)) OPSAhisto->Fill(timePhot-OPSA_timeFirst+0.00000000001);
|
|
|
|
|
if ((boolStoreThisOPSAhist)||(bool_pulseShapeExists)) {
|
|
|
|
|
G4double tt = timePhot-OPSA_timeFirst+0.00000000001;
|
|
|
|
|
OPSAhisto->Fill(tt);
|
|
|
|
|
if (bool_pulseShapeExists) { // fill contribution of this detected photon to the overall signal shape
|
|
|
|
|
Int_t iBin = int(tt/OPSAhistoBinWidth);
|
|
|
|
|
Double_t rest = tt - iBin*OPSAhistoBinWidth;
|
|
|
|
|
for (Int_t iBinNew=0; iBinNew<OPSAhistoNbin-iBin; iBinNew++) { // loop over all bins of the shape histogram
|
|
|
|
|
Int_t iPS = int( (double(iBinNew))*OPSAhistoBinWidth1000+rest*1000 ); // iPS is time in picoseconds
|
|
|
|
|
// and also the index of the shape array
|
|
|
|
|
if (iPS>=iPSmax-1) break; // out of the pulse shape info ==> leave this loop
|
|
|
|
|
OPSAshape->Fill((iBin+iBinNew+0.5)*OPSAhistoBinWidth,pulseShapeArray[iPS]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (bool_StoreThisOPSAhistSUMMED) {
|
|
|
|
|
OPSAhistoSUM ->Fill(timePhot-OPSA_timeFirst+0.00000000001);
|
|
|
|
|
OPSAhistoSUM0->Fill(timePhot+0.00000000001);
|
|
|
|
@ -657,16 +666,18 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
|
|
|
|
|
|
|
|
|
|
// if required, convert the histogram with photon times to histogram of electronic pulse shape
|
|
|
|
|
if (bool_pulseShapeExists) {
|
|
|
|
|
for (Int_t iBin=1; iBin<=OPSAhistoNbin; iBin++) { // loop over all bins of photon histogram
|
|
|
|
|
Double_t photonCount = OPSAhisto ->GetBinContent(iBin);
|
|
|
|
|
if (photonCount==0.) break; //nothing to be done for bins without any photons
|
|
|
|
|
for (Int_t iBinNew=0; iBinNew<(OPSAhistoNbin-iBin); iBinNew++) { // loop over all bins from the actual one to the end
|
|
|
|
|
Int_t iPS = int( (double(iBinNew)+0.5)*OPSAhistoBinWidth1000 );
|
|
|
|
|
if (iPS>=iPSmax-1) break; // out of the pulse shape info ==> leave this loop
|
|
|
|
|
// OPSAshape->AddBinContent(iBin+iBinNew,photonCount*pulseShapeArray[iPS]*OPSAhistoBinWidth); // iPS corresponds to time in picoseconds
|
|
|
|
|
OPSAshape->Fill((iBin+iBinNew-0.5)*OPSAhistoBinWidth,photonCount*pulseShapeArray[iPS]*OPSAhistoBinWidth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// for (Int_t iBin=1; iBin<=OPSAhistoNbin; iBin++) { // loop over all bins of photon histogram
|
|
|
|
|
// Double_t photonCount = OPSAhisto ->GetBinContent(iBin);
|
|
|
|
|
// // if (photonCount==0.) break; //nothing to be done for bins without any photons
|
|
|
|
|
// here was error - instead of continue I used break !!!
|
|
|
|
|
// if (photonCount==0.) continue; //nothing to be done for bins without any photons
|
|
|
|
|
// for (Int_t iBinNew=0; iBinNew<(OPSAhistoNbin-iBin); iBinNew++) { // loop over all bins from the actual one to the end
|
|
|
|
|
// Int_t iPS = int( (double(iBinNew)+0.5)*OPSAhistoBinWidth1000 );
|
|
|
|
|
// if (iPS>=iPSmax-1) break; // out of the pulse shape info ==> leave this loop
|
|
|
|
|
// // OPSAshape->AddBinContent(iBin+iBinNew,photonCount*pulseShapeArray[iPS]*OPSAhistoBinWidth); // iPS corresponds to time in picoseconds
|
|
|
|
|
// OPSAshape->Fill((iBin+iBinNew-0.5)*OPSAhistoBinWidth,photonCount*pulseShapeArray[iPS]*OPSAhistoBinWidth);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (boolStoreThisOPSAhist) OPSAshape -> Write();
|
|
|
|
|
|
|
|
|
|
// Now fill the histogram with the CFD signal
|
|
|
|
@ -696,7 +707,34 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
|
|
|
|
|
OPSA_CFD_time += OPSA_timeFirst - OPSA_CFD_delay + OPSA_CFD_timeShiftOffset; // correct for
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// G4cout<<" OPSA_CFD_time = "<< OPSA_CFD_time<<" OPSA_CFD_ampl="<<OPSA_CFD_ampl<<" OPSA_timeFirst"<<OPSA_timeFirst<<G4endl;
|
|
|
|
|
|
|
|
|
|
// Find the timeC and timeD from the shape histogram
|
|
|
|
|
yValue=-1000;
|
|
|
|
|
G4bool OPSA_C_time_found = false;
|
|
|
|
|
G4bool OPSA_D_time_found = false;
|
|
|
|
|
Double_t D_threshold = OPSA_D_threshold * (OPSAshape->GetMaximum()); // covert relative "OPSA_D_threshold" into
|
|
|
|
|
// the absolute threshold using signal amplitude
|
|
|
|
|
for (Int_t iBin=1; iBin<=OPSAhistoNbin; iBin++) { // loop over all bins of CFD histogram
|
|
|
|
|
Double_t xValue = (iBin-0.5)*OPSAhistoBinWidth;
|
|
|
|
|
oldYvalue = yValue;
|
|
|
|
|
yValue = OPSAshape->GetBinContent(iBin);
|
|
|
|
|
if ( (yValue>=OPSA_C_threshold) && (!OPSA_C_time_found) ) { // signal just moved above the threshold
|
|
|
|
|
OPSA_C_time_found = true;
|
|
|
|
|
OPSA_timeC = xValue - (yValue-OPSA_C_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
|
|
|
|
|
OPSA_timeC += OPSA_timeFirst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (yValue>=D_threshold) && (!OPSA_D_time_found) ) { // signal just moved above the threshold
|
|
|
|
|
OPSA_D_time_found = true;
|
|
|
|
|
OPSA_timeD = xValue - (yValue-D_threshold)/(yValue-oldYvalue)*OPSAhistoBinWidth; //linear interpolation
|
|
|
|
|
OPSA_timeD += OPSA_timeFirst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (OPSA_C_time_found && OPSA_D_time_found) break; // times C and D found, no need to continue looping.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
|
|
|
|
|
// Delete the histograms from memory if they were created
|
|
|
|
|