Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:14

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 /// \file SAXSRunAction.cc
0027 /// \brief Implementation of the SAXSRunAction class
0028 //
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0030 
0031 #include "SAXSRunAction.hh"
0032 
0033 #include "SAXSDetectorConstruction.hh"
0034 #include "SAXSRunActionMessenger.hh"
0035 
0036 #include "G4AnalysisManager.hh"
0037 #include "G4Run.hh"
0038 #include "G4RunManager.hh"
0039 #include "G4SDManager.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4UnitsTable.hh"
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 SAXSRunAction::SAXSRunAction() : G4UserRunAction()
0046 {
0047   // define the messenger
0048   fMessenger = new SAXSRunActionMessenger(this);
0049 
0050   // default output filename (can be set through macro)
0051   fFileName = "output";
0052 
0053   // Create the analysis manager
0054   fAnalysisManager = G4AnalysisManager::Instance();
0055 
0056   fAnalysisManager->SetDefaultFileType("root");
0057   fAnalysisManager->SetFileName(fFileName);
0058   fAnalysisManager->SetNtupleMerging(true);  // only for root
0059   fAnalysisManager->SetVerboseLevel(1);
0060 
0061   // Creating the SD scoring ntuple
0062   fAnalysisManager->CreateNtuple("part", "Particle");
0063   fAnalysisManager->CreateNtupleDColumn("e");
0064   fAnalysisManager->CreateNtupleDColumn("posx");
0065   fAnalysisManager->CreateNtupleDColumn("posy");
0066   fAnalysisManager->CreateNtupleDColumn("posz");
0067   fAnalysisManager->CreateNtupleDColumn("momx");
0068   fAnalysisManager->CreateNtupleDColumn("momy");
0069   fAnalysisManager->CreateNtupleDColumn("momz");
0070   fAnalysisManager->CreateNtupleDColumn("t");
0071   fAnalysisManager->CreateNtupleIColumn("type");
0072   fAnalysisManager->CreateNtupleIColumn("trackID");
0073   fAnalysisManager->CreateNtupleIColumn("NRi");
0074   fAnalysisManager->CreateNtupleIColumn("NCi");
0075   fAnalysisManager->CreateNtupleIColumn("NDi");
0076   fAnalysisManager->CreateNtupleIColumn("eventID");
0077   fAnalysisManager->CreateNtupleDColumn("weight");
0078   fAnalysisManager->FinishNtuple();
0079 
0080   // Creating ntuple for scattering
0081   fAnalysisManager->CreateNtuple("scatt", "Scattering");
0082   fAnalysisManager->CreateNtupleIColumn("processID");
0083   fAnalysisManager->CreateNtupleDColumn("e");
0084   fAnalysisManager->CreateNtupleDColumn("theta");
0085   fAnalysisManager->CreateNtupleDColumn("weight");
0086   fAnalysisManager->FinishNtuple();
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0090 
0091 SAXSRunAction::~SAXSRunAction()
0092 {
0093   delete fMessenger;
0094 }
0095 
0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0097 
0098 void SAXSRunAction::BeginOfRunAction(const G4Run*)
0099 {
0100   // open the output file
0101   if (!fIsFileOpened) {
0102     fAnalysisManager->OpenFile(fFileName);
0103     fIsFileOpened = true;
0104   }
0105 }
0106 
0107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0108 
0109 void SAXSRunAction::EndOfRunAction(const G4Run* run)
0110 {
0111   G4int nofEvents = run->GetNumberOfEvent();
0112   if (nofEvents == 0) return;
0113 
0114   // print
0115   if (IsMaster()) {
0116     G4cout << G4endl << "--------------------End of Global Run-----------------------" << G4endl
0117            << " The run had " << nofEvents << " events";
0118   }
0119   else {
0120     G4cout << G4endl << "--------------------End of Local Run------------------------" << G4endl
0121            << " The run had " << nofEvents << " events";
0122   }
0123   if (fIsFileOpened) {
0124     fAnalysisManager->Write();
0125     fAnalysisManager->CloseFile();
0126   }
0127 }
0128 
0129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0130 
0131 void SAXSRunAction::SetFileName(const G4String& filename)
0132 {
0133   // method to set the output filename
0134   if (filename != "") fFileName = filename;
0135 }
0136 
0137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......