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:
parent
00263998df
commit
2f8ac8f904
BIN
doc/musrSim.pdf
BIN
doc/musrSim.pdf
Binary file not shown.
@ -126,6 +126,7 @@ in the macro file:
|
||||
|
||||
By default, the output of the simulation is written out in the subdirectory ``data'' with
|
||||
the name ``musr\_RUNNUMBER.root''.
|
||||
(Note that the execution of the simulation can be terminated gently by creating a file ``RUNNUMBER.stop'' in the working directory.)
|
||||
|
||||
\section{Conventions}
|
||||
The default units of the musrSim in both the macro file (RUNNUMBER.mac) and in the Root tree
|
||||
@ -766,7 +767,10 @@ Three special volumes ``Target, M0, M1 and M2''.
|
||||
the job will be terminated gently if its physical execution time
|
||||
exceeds \emph{timeMax}.
|
||||
Note that the units of \emph{timeMax} are seconds,
|
||||
and the default value is set to 85000\,s (23\,hours, 37\,minutes).
|
||||
and the default value is set to 85000\,s (23\,hours, 37\,minutes).\\
|
||||
(Note that the simulation can also be terminated gently by creating a file
|
||||
``RUNNUMBER.stop'' in the working directory, where RUNNUMBER matches the
|
||||
run number specified in the name of the macro file.)
|
||||
\end{description}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\section{Output root tree variables}
|
||||
|
@ -34,6 +34,7 @@ class musrParameters {
|
||||
static musrParameters* GetInstance();
|
||||
|
||||
static G4String mySteeringFileName; // name of the steering file (e.g. the *.mac file)
|
||||
static G4String myStopFileName; // name of the stop file (e.g. the *.stop file), which will stop the run if it is created
|
||||
static G4bool storeOnlyEventsWithHits; // variable specifying whether to store interesting
|
||||
// or all events into the ROOT tree. (default = true)
|
||||
static G4int storeOnlyEventsWithHitInDetID; // simillar to "storeOnlyEventsWithHits". The event is stored
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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......
|
||||
|
Loading…
x
Reference in New Issue
Block a user