23.2.2010 Kamil Sedlak

1) changed treatment for the odet_timeCFD determination
  2) changed definition of odet_timeC and odet_timeD
  3) corrected bug in execution time calculation for randomOption 3
  4) corrected bug in eventID setting when randomOption=3
This commit is contained in:
2011-02-23 15:22:19 +00:00
parent 1ccd56485e
commit 2eb7e764d9
7 changed files with 79 additions and 29 deletions

View File

@ -713,7 +713,7 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
else if (strcmp(varName,"photonFractions")==0) {
double a, b, c, d;
sscanf(&line[0],"%*s %*s %*s %lf %lf %lf %lf",&a, &b, &c, &d);
myMusrScintSD -> Set_OPSA_frac(a,b,c,d);
myMusrScintSD -> Set_OPSA_variables(a,b,c,d);
}
else if (strcmp(varName,"eventsForOPSAhistos")==0) {
int i_eventID, i_detectorID;

View File

@ -46,6 +46,7 @@ G4double musrEventAction::maximumRunTimeAllowed=85000;
musrEventAction::musrEventAction() {
pointer=this;
timeOfRunStart = -1000;
}
musrEventAction* musrEventAction::pointer=0;
musrEventAction* musrEventAction::GetInstance() {
@ -97,7 +98,7 @@ void musrEventAction::EndOfEventAction(const G4Event* evt) {
// periodic printing
//
// if (thisEventNr != 0 and thisEventNr%10000 == 0) {
if (thisEventNr == 0) timeOfRunStart=time(0);
if (timeOfRunStart == -1000) timeOfRunStart=time(0); // initiate the time when execution starts once at the beginning of run
if ((time(0)-timeOfRunStart)>maximumRunTimeAllowed) {
// Stop the execution of the run - the run took already too long time
char eMessage[200];

View File

@ -492,11 +492,11 @@ void musrPrimaryGeneratorAction::SetOrReadTheRandomNumberSeeds(G4Event* anEvent)
if (!pointerToSeedVector->empty()) {
eventID = pointerToSeedVector->back();
pointerToSeedVector->pop_back();
anEvent -> SetEventID(eventID);
}
else {
eventID = ++lastEventID_in_pointerToSeedVector;
}
anEvent -> SetEventID(eventID);
CLHEP::HepRandom::setTheSeed(eventID);
CLHEP::RandGauss::setFlag(false);
// G4cout <<"musrPrimaryGeneratorAction.cc: seed will be set to="<< eventID<<G4endl;

View File

@ -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