![]() |
|
|||
File indexing completed on 2025-02-23 09:22:32
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 Par02Output.hh 0028 /// \brief Definition of the Par02Output class 0029 0030 #ifndef PAR02_OUTPUT_H 0031 #define PAR02_OUTPUT_H 0032 0033 #include "G4ThreeVector.hh" 0034 #include "globals.hh" 0035 0036 /// Handling the saving to the file. 0037 /// 0038 /// A singleton class that manages creation, writing to and closing of the 0039 /// Root output file. 0040 /// @author Anna Zaborowska 0041 0042 class Par02Output 0043 { 0044 public: 0045 /// Indicates to which ntuple to save the information. 0046 enum SaveType 0047 { 0048 eNoSave, 0049 eSaveMC, 0050 eSaveTracker, 0051 eSaveEMCal, 0052 eSaveHCal 0053 }; 0054 0055 /// Allows the access to the unique Par02Output object. 0056 /// @return A pointer to the Par02Output class. 0057 static Par02Output* Instance(); 0058 0059 /// Sets the file name of the output root file. 0060 /// @param name The name of the file. 0061 void SetFileName(G4String name); 0062 0063 /// Gets the file name of the output root file. 0064 /// @return The name of the file. 0065 G4String GetFileName(); 0066 0067 /// Sets fFileNameWithRunNo that indicates whether to add the run number 0068 /// to the file name. 0069 /// @param app If add the run number. 0070 void AppendName(G4bool app); 0071 0072 /// Calls the G4AnalysisManager::Instance(). It sets the file name of the 0073 /// output file based on fFileName and fFileNameWithRunNo and opens the file. 0074 /// @param runID A run number (to be added to file name if fFileNameWithRunNo 0075 /// is true). 0076 void StartAnalysis(G4int runID); 0077 0078 /// Calls the G4AnalysisManager::Instance(). 0079 /// It writes to the output file and close it. 0080 void EndAnalysis(); 0081 0082 /// Creates Ntuples used to store information about particle (its ID, PDG code, 0083 /// energy deposits, etc.). To be called for each event in Par02EventAction. 0084 void CreateNtuples(); 0085 0086 /// Creates histograms to combine information from all the events in the run. 0087 /// To be called for each run in Par02RunAction. 0088 void CreateHistograms(); 0089 0090 /// Saves the information about the particle (track). 0091 /// @param aWhatToSave enum indicating what kind of information to store 0092 /// (in which ntuple). 0093 /// @param aPartID A unique ID within event (taken Geant TrackID). 0094 /// @param aPDG A PDG code of a particle. 0095 /// @param aVector A vector to be stored (particle momentum in tracker or 0096 /// position of energy deposit in calorimeter). 0097 /// @param aResolution A resolution of the detector that was used. 0098 /// @param aEfficiency An efficiency of the detector that was used. 0099 /// @param aEnergy An energy deposit (for calorimeters only: 0100 /// Par02Output::SaveType::eEMCal or Par02Output::SaveType::eHCal). 0101 void SaveTrack(SaveType aWhatToSave, G4int aPartID, G4int aPDG, G4ThreeVector aVector, 0102 G4double aResolution = 0, G4double aEfficiency = 1, G4double aEnergy = 0); 0103 0104 /// Fills the histogram. 0105 /// @param HNo Number of a histogram (decided by the order of creation 0106 /// in CreateHistograms(), the first one is 0). 0107 /// @param value A value to be filled into the histogram. 0108 void FillHistogram(G4int HNo, G4double value) const; 0109 0110 ~Par02Output(); 0111 0112 protected: 0113 /// A default, protected constructor (due to singleton pattern). 0114 Par02Output(); 0115 0116 private: 0117 /// The pointer to the only Par02Output class object. 0118 static Par02Output* fPar02Output; 0119 0120 /// Current ntuple Id 0121 static G4ThreadLocal G4int fCurrentNtupleId; 0122 0123 /// A name of the output root file. 0124 G4String fFileName; 0125 0126 /// If true, a run number should be added to the file. Default: false. 0127 G4bool fFileNameWithRunNo; 0128 0129 /// A control value of particle ID to ensure that data saved to various ntuples 0130 /// match the same particle. It is set when Monte Carlo information is saved 0131 /// and checked for all the detectors. 0132 static G4ThreadLocal G4int fCurrentID; 0133 }; 0134 0135 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |