|
|
|||
File indexing completed on 2026-03-30 07:49:56
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 RunAction.cc 0027 /// \brief Implementation of the B5::RunAction class 0028 0029 #include "RunAction.hh" 0030 0031 #include "EventAction.hh" 0032 0033 #include "G4AnalysisManager.hh" 0034 0035 namespace B5 0036 { 0037 0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0039 0040 RunAction::RunAction(EventAction* eventAction) : fEventAction(eventAction) 0041 { 0042 // Create the generic analysis manager 0043 auto analysisManager = G4AnalysisManager::Instance(); 0044 analysisManager->SetDefaultFileType("root"); 0045 // If the filename extension is not provided, the default file type (root) 0046 // will be used for all files specified without extension. 0047 analysisManager->SetVerboseLevel(1); 0048 0049 // Default settings 0050 analysisManager->SetNtupleMerging(true); 0051 // Note: merging ntuples is available only with Root output 0052 analysisManager->SetFileName("B5"); 0053 0054 // Book histograms, ntuple 0055 0056 // Creating 1D histograms 0057 analysisManager->CreateH1("Chamber1", "Drift Chamber 1 # Hits", 50, 0., 50); // h1 Id = 0 0058 analysisManager->CreateH1("Chamber2", "Drift Chamber 2 # Hits", 50, 0., 50); // h1 Id = 1 0059 0060 // Creating 2D histograms 0061 analysisManager->CreateH2("Chamber1 XY", "Drift Chamber 1 X vs Y", // h2 Id = 0 0062 50, -1000., 1000, 50, -300., 300.); 0063 analysisManager->CreateH2("Chamber2 XY", "Drift Chamber 2 X vs Y", // h2 Id = 1 0064 50, -1500., 1500, 50, -300., 300.); 0065 0066 // Creating ntuple 0067 if (fEventAction) { 0068 analysisManager->CreateNtuple("B5", "Hits"); 0069 analysisManager->CreateNtupleIColumn("Dc1Hits"); // column Id = 0 0070 analysisManager->CreateNtupleIColumn("Dc2Hits"); // column Id = 1 0071 analysisManager->CreateNtupleDColumn("ECEnergy"); // column Id = 2 0072 analysisManager->CreateNtupleDColumn("HCEnergy"); // column Id = 3 0073 analysisManager->CreateNtupleDColumn("Time1"); // column Id = 4 0074 analysisManager->CreateNtupleDColumn("Time2"); // column Id = 5 0075 analysisManager // column Id = 6 0076 ->CreateNtupleDColumn("ECEnergyVector", fEventAction->GetEmCalEdep()); 0077 analysisManager // column Id = 7 0078 ->CreateNtupleDColumn("HCEnergyVector", fEventAction->GetHadCalEdep()); 0079 analysisManager->FinishNtuple(); 0080 } 0081 0082 // Set ntuple output file 0083 analysisManager->SetNtupleFileName(0, "B5ntuple"); 0084 } 0085 0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0087 0088 void RunAction::BeginOfRunAction(const G4Run* /*run*/) 0089 { 0090 // inform the runManager to save random number seed 0091 // G4RunManager::GetRunManager()->SetRandomNumberStore(true); 0092 0093 // Get analysis manager 0094 auto analysisManager = G4AnalysisManager::Instance(); 0095 0096 // Reset histograms from previous run 0097 analysisManager->Reset(); 0098 0099 // Open an output file 0100 // The default file name is set in RunAction::RunAction(), 0101 // it can be overwritten in a macro 0102 analysisManager->OpenFile(); 0103 } 0104 0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0106 0107 void RunAction::EndOfRunAction(const G4Run* /*run*/) 0108 { 0109 // save histograms & ntuple 0110 // 0111 auto analysisManager = G4AnalysisManager::Instance(); 0112 analysisManager->Write(); 0113 analysisManager->CloseFile(false); 0114 // Keep content of histos so that they are plotted. 0115 // The content will be reset at start of the next run. 0116 } 0117 0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0119 0120 } // namespace B5
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|