![]() |
|
|||
File indexing completed on 2025-02-23 09:22:39
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 // 0027 /// \file RunAction.cc 0028 /// \brief Implementation of the RunAction class 0029 0030 #include "RunAction.hh" 0031 0032 #include "G4AnalysisManager.hh" 0033 #include "G4Run.hh" 0034 #include "G4RunManager.hh" 0035 #include "G4SystemOfUnits.hh" 0036 #include "G4UnitsTable.hh" 0037 0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0039 0040 RunAction::RunAction(const G4String& fileName) : fFileName(fileName) 0041 { 0042 // Create analysis manager 0043 auto analysisManager = G4AnalysisManager::Instance(); 0044 analysisManager->SetDefaultFileType("root"); 0045 analysisManager->SetVerboseLevel(1); 0046 analysisManager->SetNtupleMerging(true); 0047 G4cout << "Using " << analysisManager->GetType() << G4endl; 0048 // Note: merging ntuples is available only with Root output 0049 0050 // Set default fileName 0051 analysisManager->SetFileName(fFileName); 0052 0053 // Create ntuple 0054 // 0055 analysisManager->CreateNtuple("Screen", "Screen hits"); 0056 analysisManager->CreateNtupleIColumn("ID"); // column id = 0 0057 analysisManager->CreateNtupleIColumn("PDG"); // column id = 1 0058 analysisManager->CreateNtupleDColumn("Ekin"); // column id = 2 0059 analysisManager->CreateNtupleDColumn("Xpos"); // column id = 3 0060 analysisManager->CreateNtupleDColumn("Ypos"); // column id = 4 0061 analysisManager->CreateNtupleDColumn("time"); // column id = 5 0062 analysisManager->FinishNtuple(); 0063 } 0064 0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0066 0067 void RunAction::BeginOfRunAction(const G4Run* /*run*/) 0068 { 0069 // Get analysis manager 0070 auto analysisManager = G4AnalysisManager::Instance(); 0071 0072 // Open an output file 0073 analysisManager->OpenFile(); 0074 } 0075 0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0077 0078 void RunAction::EndOfRunAction(const G4Run* /*run*/) 0079 { 0080 // Save ntuple and close file 0081 auto analysisManager = G4AnalysisManager::Instance(); 0082 analysisManager->Write(); 0083 analysisManager->CloseFile(); 0084 } 0085 0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |