Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:14

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 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
0027 //
0028 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
0029 //
0030 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
0031 //  under the contract NNJ15HK11B.
0032 //
0033 // ********************************************************************
0034 //
0035 // GRRunAction.hh
0036 //   Header file of Gorad Run Action class that takes care of
0037 //   handling histograms and n-tuple.
0038 //
0039 // History
0040 //   September 8th, 2020 : first implementation
0041 //
0042 // ********************************************************************
0043 
0044 #ifndef GRRunAction_h
0045 #define GRRunAction_h 1
0046 
0047 #include "G4UserRunAction.hh"
0048 #include "globals.hh"
0049 
0050 class G4Run;
0051 class GRRunActionMessenger;
0052 class GRRunAction;
0053 #include "GRRun.hh"
0054 
0055 #include <map>
0056 class G4VPrimitivePlotter;
0057 
0058 class GRHistoType
0059 {
0060   friend class GRRunAction;
0061   friend class GRRun;
0062   private:
0063     GRHistoType()
0064     {;}
0065   private:
0066     G4int histID = -1;
0067     G4int histType = -1;
0068     G4int histDup = 1;
0069 
0070     G4int collID = -1;
0071     G4String meshName = "dummy";
0072     G4String primName = "dummy";
0073     G4int idx = -1;
0074 
0075     G4int collID2 = -1;
0076     G4String meshName2 = "dummy";
0077     G4String primName2 = "dummy";
0078     G4int idx2 = -1;
0079 
0080     G4int biasf = 0;
0081     G4double fuct = 1.;
0082     G4VPrimitivePlotter* pplotter = nullptr;
0083 };
0084     
0085 class GRRunAction : public G4UserRunAction
0086 {
0087   friend class GRRun;
0088   public:
0089     GRRunAction();
0090     virtual ~GRRunAction();
0091 
0092     virtual G4Run* GenerateRun()
0093     { return new GRRun(this); }
0094     virtual void BeginOfRunAction(const G4Run*);
0095     virtual void   EndOfRunAction(const G4Run*);
0096 
0097   private:
0098     GRRunActionMessenger* messenger;
0099 
0100   public:
0101     void SetVerbose(G4int);
0102     void ListHistograms();
0103     G4bool Open(G4int);
0104     G4bool SetAllPlotting(G4bool val=true);
0105     G4bool SetPlotting(G4int,G4bool val=true);
0106     void Flush();
0107     void Reset();
0108 
0109     G4int Create1D(G4String&,G4String&,G4int);
0110     G4int Create1DForPrimary(G4String&,G4bool);
0111     G4int Create1DForPlotter(G4String&,G4String&,G4bool);
0112     G4bool Set1D(G4int,G4int,G4double,G4double,G4String&,G4String&,G4bool);
0113     G4bool Set1DTitle(G4int,G4String&,G4String&,G4String&);
0114     G4bool Set1DYAxisLog(G4int,G4bool);
0115 
0116     G4int Create1P(G4String&,G4String&,G4int);
0117     G4bool Set1P(G4int,G4double,G4double,G4String&,G4String&,G4String&,G4String&);
0118     G4bool Set1PTitle(G4int,G4String&,G4String&,G4String&);
0119 
0120     G4int NtupleColumn(G4String&,G4String&,G4String&,G4int);
0121 
0122   private:
0123     void OpenFile();
0124     void DefineNTColumn();
0125     void MergeNtuple();
0126 
0127   public:
0128     inline void SetFileName(G4String& fn)
0129     { fileName = fn; }
0130     inline const G4String& GetFileName() const
0131     { return fileName; }
0132     inline G4int GetVerbose() const
0133     { return verbose; }
0134     inline void SetCarry(G4bool val = true)
0135     { ifCarry = val; }
0136     inline G4bool GetCarry() const
0137     { return ifCarry; }
0138     inline void SetOffset(G4int offset,G4int factor)
0139     { 
0140       id_offset = offset;
0141       id_factor = factor;
0142     }
0143     inline void GetOffset(G4int& offset,G4int& factor) const
0144     {
0145       offset = id_offset;
0146       factor = id_factor;
0147     }
0148 
0149   private:
0150     G4String fileName;
0151     G4bool fileOpen;
0152     G4int verbose;
0153     G4bool ifCarry;
0154     G4int id_offset;
0155     G4int id_factor;
0156 
0157   private:
0158     std::map<G4int,GRHistoType*> IDMap;
0159     std::map<G4int,GRHistoType*> NTMap;
0160 };
0161 
0162 #endif