Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/exoticphysics/saxs/src/SAXSRunAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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