Skip to content

Commit

Permalink
Make writting an event to the output optional in FairRunSim.
Browse files Browse the repository at this point in the history
Allow to switch off the writing of an event to the output file in case
of a simulation run. A task running after the simulation in FairRunSim
events loop can set the flag to false which skips writting the whole
event to the output file.
Backport commit 5ccd89b from dev branch.
  • Loading branch information
fuhlig1 committed Jun 6, 2018
1 parent 0877ead commit c191cc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions base/sim/FairMCApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ FairMCApplication::FairMCApplication(const char* name, const char* title,
listDetectors(),
fMC(NULL),
fRun(NULL),
fSaveCurrentEvent(kTRUE),
fRunInfo(),
fGeometryIsInitialized(kFALSE)
{
Expand Down Expand Up @@ -203,6 +204,7 @@ FairMCApplication::FairMCApplication(const FairMCApplication& rhs)
listDetectors(),
fMC(NULL),
fRun(NULL),
fSaveCurrentEvent(kTRUE),
fRunInfo(),
fGeometryIsInitialized(kFALSE)
{
Expand Down Expand Up @@ -293,6 +295,7 @@ FairMCApplication::FairMCApplication()
listActiveDetectors(),
listDetectors(),
fMC(NULL),
fSaveCurrentEvent(kTRUE),
fRunInfo(),
fGeometryIsInitialized(kFALSE)
{
Expand Down Expand Up @@ -828,8 +831,12 @@ void FairMCApplication::FinishEvent()
}


if (fRootManager) fRootManager->Fill();

if (fRootManager && fSaveCurrentEvent) {
fRootManager->Fill();
} else {
fSaveCurrentEvent = kTRUE;
}

for( std::list<FairDetector *>::iterator listIter = listActiveDetectors.begin();
listIter != listActiveDetectors.end();
listIter++)
Expand Down
10 changes: 10 additions & 0 deletions base/sim/FairMCApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ class FairMCApplication : public TVirtualMCApplication

void AddMeshList ( TObjArray* meshList );

/**
* Set if the current event should be written to the output file.
* The default value which is set back after each event is to store
* the event.
*/
void SetSaveCurrentEvent(Bool_t set) {fSaveCurrentEvent=set;}

private:
// methods
Int_t GetIonPdg(Int_t z, Int_t a) const;
Expand Down Expand Up @@ -270,6 +277,9 @@ class FairMCApplication : public TVirtualMCApplication
TVirtualMC* fMC;
/** Pointer to FairRunSim //! */
FairRunSim* fRun;

/** Flag if the current event should be saved */
Bool_t fSaveCurrentEvent;

ClassDef(FairMCApplication,4) //Interface to MonteCarlo application

Expand Down

0 comments on commit c191cc0

Please sign in to comment.