13.1.2010 Kamil Sedlak

1) The filling of the root tree was called from musrScintSD.cc, which was
   problematic, because no variables were written out if there was no
   sensitive volume defined (problem for example when one wants to study
   the beam-line properties using just save volumes).
   Therefore the tree filling is now called from musrEventAction.cc.

2) A possibility to gently stop the run by creating a file with the
   name "RUNNUMBER.stop" in the working directory has been introduced.
   ("Gently" means that root output file is closed properly.)
This commit is contained in:
2010-01-13 16:50:57 +00:00
parent 00263998df
commit 2f8ac8f904
7 changed files with 42 additions and 12 deletions

View File

@@ -30,11 +30,14 @@
#include "G4ios.hh"
#include "G4TransportationManager.hh"
#include "G4FieldManager.hh"
#include "musrParameters.hh"
#include "musrRootOutput.hh"
#include "musrErrorMessage.hh"
#include "musrSteppingAction.hh"
#include "F04GlobalField.hh"
#include "G4RunManager.hh" // needed just in order to save random number generator seed
#include "G4Run.hh"
#include "G4RunManager.hh"
#include <sys/stat.h>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -75,6 +78,13 @@ void musrEventAction::EndOfEventAction(const G4Event* evt) {
// cout << ":." << flush;
long thisEventNr = (long) evt->GetEventID();
// write out the root tree:
musrRootOutput* myRootOutput = musrRootOutput::GetRootInstance();
G4RunManager* fRunManager = G4RunManager::GetRunManager();
myRootOutput->SetRunID(fRunManager->GetCurrentRun()->GetRunID());
myRootOutput->SetEventID(fRunManager->GetCurrentEvent()->GetEventID());
myRootOutput->FillEvent();
// get number of stored trajectories
G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
G4int n_trajectories = 0;
@@ -94,6 +104,19 @@ void musrEventAction::EndOfEventAction(const G4Event* evt) {
G4RunManager* fRunManager = G4RunManager::GetRunManager();
fRunManager->AbortRun(true);
}
// Stop the run, if the user wished that (by creating a file "RUNNUMBER.stop"
struct stat stFileInfo;
if (stat((musrParameters::myStopFileName).c_str(),&stFileInfo)==0) {
// Stop the execution of the run - the file "RUNNUMBER.stop" was found
remove((musrParameters::myStopFileName).c_str());
char eMessage[200];
sprintf(eMessage,"musrEventAction::EndOfEventAction(): Request to stop the run was found (%s) ==> RUN STOPPED",musrParameters::myStopFileName.c_str());
musrErrorMessage::GetInstance()->musrError(WARNING,eMessage,false);
G4RunManager* fRunManager = G4RunManager::GetRunManager();
fRunManager->AbortRun(true);
}
if (thisEventNr != 0 and thisEventNr%nHowOftenToPrintEvent == 0) {
time_t curr=time(0);
//char * ctime(const time_t * tp);

View File

@@ -30,6 +30,12 @@ musrParameters::musrParameters(G4String steeringFileName)
pointerToParameters = this;
boolG4RegionRequested = false;
mySteeringFileName = steeringFileName;
myStopFileName = mySteeringFileName;
// myStopFileName.replace(myStopFileName.end()-2,myStopFileName.end(),"stop");
// Int_t lengthOfFileName=
// myStopFileName.replace(3,5,"stop");
myStopFileName.replace(myStopFileName.length()-3,myStopFileName.length()-1,"stop");
// Read in the parameters, which have to be known before the detector construction is run
// (and therefore the parameters can not be read in in the musrDetectorConstruction.cc class).
@@ -98,7 +104,8 @@ musrParameters* musrParameters::GetInstance() {
return pointerToParameters;
}
G4String musrParameters::mySteeringFileName="Unset";
G4String musrParameters::mySteeringFileName="Unset";
G4String musrParameters::myStopFileName="Unsetblablabla034tdk40928jfmfnakfh921djf02UNSET";
G4bool musrParameters::storeOnlyEventsWithHits=true;
G4int musrParameters::storeOnlyEventsWithHitInDetID=0;
G4double musrParameters::signalSeparationTime=100*nanosecond;

View File

@@ -25,6 +25,7 @@
#include "G4RunManager.hh"
#include "G4Run.hh"
#include "musrErrorMessage.hh"
#include "musrParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -310,7 +311,9 @@ void musrRootOutput::FillEvent() {
htest5->Fill(atan2(posIniMomy_t,posIniMomx_t));
htest6->Fill(atan2(sqrt(posIniMomx_t*posIniMomx_t+posIniMomy_t*posIniMomy_t),posIniMomz_t));
if (weight_t>0.) {
rootTree->Fill();
if ( !((musrParameters::storeOnlyEventsWithHits)&&(det_n<=0)) ) {
rootTree->Fill();
}
}
}

View File

@@ -29,8 +29,6 @@
#include "G4ios.hh"
#include <algorithm> // needed for the sort() function
#include "G4VProcess.hh" // needed for the degugging message of the process name
#include "G4RunManager.hh"
#include "G4Run.hh"
#include "musrParameters.hh"
#include "musrErrorMessage.hh"
#include "musrSteppingAction.hh"
@@ -154,10 +152,6 @@ void musrScintSD::EndOfEvent(G4HCofThisEvent*) {
// Positron_momentum_already_stored=0;
musrRootOutput* myRootOutput = musrRootOutput::GetRootInstance();
G4RunManager* fRunManager = G4RunManager::GetRunManager();
myRootOutput->SetRunID(fRunManager->GetCurrentRun()->GetRunID());
myRootOutput->SetEventID(fRunManager->GetCurrentEvent()->GetEventID());
G4int NbHits = scintCollection->entries();
if (myStoreOnlyEventsWithHits) {
@@ -373,8 +367,6 @@ void musrScintSD::EndOfEvent(G4HCofThisEvent*) {
}
} //end "if (NbHits>0)"
myRootOutput->FillEvent();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......