Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // Gorad (Geant4 Open-source Radiation Analysis and Design) 27 // 28 // Author : Makoto Asai (SLAC National Accelerator Laboratory) 29 // 30 // Development of Gorad is funded by NASA Johnson Space Center (JSC) 31 // under the contract NNJ15HK11B. 32 // 33 // ******************************************************************** 34 // 35 // GRRunAction.hh 36 // Header file of Gorad Run Action class that takes care of 37 // handling histograms and n-tuple. 38 // 39 // History 40 // September 8th, 2020 : first implementation 41 // 42 // ******************************************************************** 43 44 #ifndef GRRunAction_h 45 #define GRRunAction_h 1 46 47 #include "G4UserRunAction.hh" 48 #include "globals.hh" 49 50 class G4Run; 51 class GRRunActionMessenger; 52 class GRRunAction; 53 #include "GRRun.hh" 54 55 #include <map> 56 class G4VPrimitivePlotter; 57 58 class GRHistoType 59 { 60 friend class GRRunAction; 61 friend class GRRun; 62 private: 63 GRHistoType() 64 {;} 65 private: 66 G4int histID = -1; 67 G4int histType = -1; 68 G4int histDup = 1; 69 70 G4int collID = -1; 71 G4String meshName = "dummy"; 72 G4String primName = "dummy"; 73 G4int idx = -1; 74 75 G4int collID2 = -1; 76 G4String meshName2 = "dummy"; 77 G4String primName2 = "dummy"; 78 G4int idx2 = -1; 79 80 G4int biasf = 0; 81 G4double fuct = 1.; 82 G4VPrimitivePlotter* pplotter = nullptr; 83 }; 84 85 class GRRunAction : public G4UserRunAction 86 { 87 friend class GRRun; 88 public: 89 GRRunAction(); 90 virtual ~GRRunAction(); 91 92 virtual G4Run* GenerateRun() 93 { return new GRRun(this); } 94 virtual void BeginOfRunAction(const G4Run*); 95 virtual void EndOfRunAction(const G4Run*); 96 97 private: 98 GRRunActionMessenger* messenger; 99 100 public: 101 void SetVerbose(G4int); 102 void ListHistograms(); 103 G4bool Open(G4int); 104 G4bool SetAllPlotting(G4bool val=true); 105 G4bool SetPlotting(G4int,G4bool val=true); 106 void Flush(); 107 void Reset(); 108 109 G4int Create1D(G4String&,G4String&,G4int); 110 G4int Create1DForPrimary(G4String&,G4bool); 111 G4int Create1DForPlotter(G4String&,G4String&,G4bool); 112 G4bool Set1D(G4int,G4int,G4double,G4double,G4String&,G4String&,G4bool); 113 G4bool Set1DTitle(G4int,G4String&,G4String&,G4String&); 114 G4bool Set1DYAxisLog(G4int,G4bool); 115 116 G4int Create1P(G4String&,G4String&,G4int); 117 G4bool Set1P(G4int,G4double,G4double,G4String&,G4String&,G4String&,G4String&); 118 G4bool Set1PTitle(G4int,G4String&,G4String&,G4String&); 119 120 G4int NtupleColumn(G4String&,G4String&,G4String&,G4int); 121 122 private: 123 void OpenFile(); 124 void DefineNTColumn(); 125 void MergeNtuple(); 126 127 public: 128 inline void SetFileName(G4String& fn) 129 { fileName = fn; } 130 inline const G4String& GetFileName() const 131 { return fileName; } 132 inline G4int GetVerbose() const 133 { return verbose; } 134 inline void SetCarry(G4bool val = true) 135 { ifCarry = val; } 136 inline G4bool GetCarry() const 137 { return ifCarry; } 138 inline void SetOffset(G4int offset,G4int factor) 139 { 140 id_offset = offset; 141 id_factor = factor; 142 } 143 inline void GetOffset(G4int& offset,G4int& factor) const 144 { 145 offset = id_offset; 146 factor = id_factor; 147 } 148 149 private: 150 G4String fileName; 151 G4bool fileOpen; 152 G4int verbose; 153 G4bool ifCarry; 154 G4int id_offset; 155 G4int id_factor; 156 157 private: 158 std::map<G4int,GRHistoType*> IDMap; 159 std::map<G4int,GRHistoType*> NTMap; 160 }; 161 162 #endif 163