From 89c6f27ae1f396b5d092c8f55f015bc2c75a67c6 Mon Sep 17 00:00:00 2001 From: Kamil Sedlak Date: Fri, 14 Oct 2011 08:11:54 +0000 Subject: [PATCH] 14.10.2011 Kamil Sedlak 1) change in the way how random time scattering in APD is generated for optical photons - now the events should be reproducible irrespective of whether the random time is or is not requested. 2) indroducing a possibility to simulate optical photons, but not to process them - this option, however, does not seem to speed up the simulation significantly. --- include/musrParameters.hh | 6 ++++++ include/musrScintSD.hh | 2 +- src/musrDetectorConstruction.cc | 2 +- src/musrParameters.cc | 4 ++++ src/musrScintSD.cc | 21 +++++++++++++-------- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/include/musrParameters.hh b/include/musrParameters.hh index aa830f6..c6bb627 100644 --- a/include/musrParameters.hh +++ b/include/musrParameters.hh @@ -54,6 +54,12 @@ class musrParameters { static G4bool boolG4GeneralParticleSource; // if true, G4GeneralParticleSource will be initialised instead of G4ParticleGun // - needed for the radioactive source static G4bool boolG4OpticalPhotons; // if true, optical photons will be used (in the sensitive scintillators) + static G4bool boolG4OpticalPhotonsUnprocess; // if true, optical photons will not be processed - it might be + // usefull if the user wants to preselect some interesting events, + // and then to run the time-consuming processing of opt. photons + // again only for the interesting events. This way the random number + // generator can generate the reproducible events. + // This option only works with "boolG4OpticalPhotons". static G4bool field_DecayWithSpin; // if true, then the routins for calculating the magnetic field will // use more precise argument. This variable is set to "true" by // the SteppinAction and reset to "false" in the GetFieldValue. diff --git a/include/musrScintSD.hh b/include/musrScintSD.hh index fab656b..38ed1b0 100644 --- a/include/musrScintSD.hh +++ b/include/musrScintSD.hh @@ -105,7 +105,7 @@ class musrScintSD : public G4VSensitiveDetector OPSAhistoNbin=nBins; OPSAhistoMin=min; OPSAhistoMax=max; OPSAhistoBinWidth=(max-min)/nBins; OPSAhistoBinWidth1000=OPSAhistoBinWidth*1000; } - void ProcessOpticalPhoton(G4Step*); + void ProcessOpticalPhoton(G4Step* aStep, G4double APDcellsTimeVariation); void EndOfEvent_OptiacalPhotons(); void ReadInPulseShapeArray(const char* filename); void FindCFDtime(G4double& OPSA_CFD_time, G4double& OPSA_CFD_ampl, G4double timeOfFirstPhoton); diff --git a/src/musrDetectorConstruction.cc b/src/musrDetectorConstruction.cc index 09ee21f..046b8e4 100644 --- a/src/musrDetectorConstruction.cc +++ b/src/musrDetectorConstruction.cc @@ -1422,7 +1422,7 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() { } } - else if ((strcmp(tmpString1,"process")==0)||(strcmp(tmpString1,"G4OpticalPhotons")==0) + else if ((strcmp(tmpString1,"process")==0)||(strcmp(tmpString1,"G4OpticalPhotons")==0)||(strcmp(tmpString1,"G4OpticalPhotonsUnprocess")==0) ||(strcmp(tmpString1,"materialPropertiesTable")==0)||(strcmp(tmpString1,"setMaterialPropertiesTable")==0)) { ; // processes are interpreded later in musrPhysicsList.cc } diff --git a/src/musrParameters.cc b/src/musrParameters.cc index a309313..d0e1606 100644 --- a/src/musrParameters.cc +++ b/src/musrParameters.cc @@ -78,6 +78,9 @@ musrParameters::musrParameters(G4String steeringFileName) if (strcmp(tmpString1,"G4OpticalPhotons")==0){ if (strcmp(tmpString2,"true")==0){ musrParameters::boolG4OpticalPhotons = true; } } + if (strcmp(tmpString1,"G4OpticalPhotonsUnprocess")==0){ + if (strcmp(tmpString2,"true")==0){ musrParameters::boolG4OpticalPhotonsUnprocess = true; } + } if (strcmp(tmpString1,"region")==0) { boolG4RegionRequested = true; } @@ -115,6 +118,7 @@ G4bool musrParameters::killAllGammas=false; G4bool musrParameters::killAllNeutrinos=true; G4bool musrParameters::boolG4GeneralParticleSource=false; G4bool musrParameters::boolG4OpticalPhotons=false; +G4bool musrParameters::boolG4OpticalPhotonsUnprocess=false; //cks G4bool musrParameters::includeMuoniumProcesses =true; // TS //G4bool musrParameters::boolG4GeneralParticleSource=true; G4int musrParameters::nrOfEventsToBeGenerated=0; diff --git a/src/musrScintSD.cc b/src/musrScintSD.cc index 6ba7a38..e16b958 100644 --- a/src/musrScintSD.cc +++ b/src/musrScintSD.cc @@ -121,10 +121,12 @@ void musrScintSD::Initialize(G4HCofThisEvent* HCE) { // In case of optical photons, delete all optHitDetectorMap* from the previous event (if they exist). if (musrParameters::boolG4OpticalPhotons) { - for (optHitMapType::const_iterator it=optHitMap.begin() ; it != optHitMap.end(); it++ ) { - delete (it->second); + if (!musrParameters::boolG4OpticalPhotonsUnprocess) { + for (optHitMapType::const_iterator it=optHitMap.begin() ; it != optHitMap.end(); it++ ) { + delete (it->second); + } + optHitMap.clear(); } - optHitMap.clear(); } } @@ -145,7 +147,8 @@ G4bool musrScintSD::ProcessHits(G4Step* aStep,G4TouchableHistory*) G4String particleName=aTrack->GetDefinition()->GetParticleName(); // if (particleName=="opticalphoton") {G4cout<<"UFON JE TU: edep="<GetPostStepPoint()->GetProcessDefinedStep(); // G4String processName = (process) ? process->GetProcessName() : "Unknown"; @@ -210,7 +213,6 @@ void musrScintSD::ProcessOpticalPhoton(G4Step* aStep) { // G4cout<<"\n ABSORPTION\n"; // } - G4OpBoundaryProcessStatus boundaryStatus=Undefined; static G4OpBoundaryProcess* boundaryProc=NULL; //find the boundary process only once @@ -269,7 +271,8 @@ void musrScintSD::ProcessOpticalPhoton(G4Step* aStep) { // whether a given cell already fired - if so, do not store the photon. G4bool APDcellAlreadyFired = false; G4int APDcellID = 0; - if (APDcellsTimeVariationRequested) tmpTime += G4RandGauss::shoot(0,APDcellsTimeVariationSigma); + if (APDcellsTimeVariationRequested) tmpTime += APDcellsTimeVariation; + // if (APDcellsTimeVariationRequested) tmpTime += G4RandGauss::shoot(0,APDcellsTimeVariationSigma); if (APDcellsEffectRequested) { APDcellID = FindAPDcellID(aStep); @@ -543,7 +546,9 @@ void musrScintSD::EndOfEvent(G4HCofThisEvent*) { } //end "if (NbHits>0)" // Analyse optical photons if they were produced - if (musrParameters::boolG4OpticalPhotons) EndOfEvent_OptiacalPhotons(); + if (musrParameters::boolG4OpticalPhotons) { + if (!musrParameters::boolG4OpticalPhotonsUnprocess) EndOfEvent_OptiacalPhotons(); + } }