Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Authors: Susanna Guatelli and Francesco Romano
0027 // susanna@uow.edu.au, francesco.romano@ct.infn.it
0028 // 
0029 
0030 #include "RunAction.hh"
0031 #include "AnalysisManager.hh"
0032 #include "G4SystemOfUnits.hh"
0033 #include "G4UnitsTable.hh"
0034 #include "G4ios.hh"
0035 #include "G4Run.hh"
0036 
0037 #ifdef ANALYSIS_USE
0038 RunAction::RunAction(AnalysisManager* analysis, DetectorMessenger* detector)
0039 { 
0040 
0041   analysisMan = analysis;
0042   detectorMess = detector;
0043 
0044 }
0045 #else
0046 RunAction::RunAction(DetectorMessenger* detector)
0047 {
0048    detectorMess = detector;
0049 }
0050 #endif
0051 
0052 RunAction::~RunAction()
0053 { }
0054 
0055 void RunAction::BeginOfRunAction(const G4Run* aRun)
0056 {
0057   G4int run_number = aRun->GetRunID();
0058   G4cout << "### Run " << run_number << " start." << G4endl;
0059 
0060 #ifdef ANALYSIS_USE
0061   G4bool additionalOutput;
0062   G4String detectorType = detectorMess -> GetDetectorType();
0063   if( detectorType == "DiamondTelescope" ) additionalOutput = true;
0064   else additionalOutput = false;
0065   
0066   // Create ROOT file, histograms and ntuple
0067   analysisMan -> book(additionalOutput);
0068 #else
0069   G4cout << "Output to file disabled: no file will be generated. "
0070   << "To enable it, re-run cmake with the -DWITH_ANALYSIS_USE=ON flag." << G4endl;
0071 #endif
0072   
0073   // check if there are pending changes in the geometry
0074   if( detectorMess -> AreTherePendingChanges() )
0075   {
0076     G4cout << "WARNING: pending changes to the geometry found during BeginOfRunAction. " 
0077     << "These will be ignored during the current run. "
0078     << "Use /geometrySetup/applyChanges if you want to apply them in your next run." << G4endl;
0079   }
0080   
0081   // print the current geometry setup
0082   G4cout << "Simulating the " << detectorMess->GetDetectorType() << " detector "
0083   << "with dimensions: " << detectorMess->GetDetectorSizeWidth()/um << " um width, "
0084   << detectorMess->GetDetectorSizeThickness()/um << " um thickness." << G4endl;
0085 }
0086 
0087 void RunAction::EndOfRunAction(const G4Run* aRun)
0088 {
0089   G4cout << "Number of events = " << aRun->GetNumberOfEvent() << G4endl;
0090 
0091 #ifdef ANALYSIS_USE
0092 // Close the output ROOT file with the results
0093    analysisMan -> finish(); 
0094 #endif
0095 }
0096