Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-14 08:30:37

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 TSRun.hh
0027 /// \brief Definition of the TSRun class
0028 ///
0029 /// TSRun contains three collections of hits maps: a thread-local hits map,
0030 ///     a global atomic hits map (implemented as a static since TSRun is
0031 ///     implemented as a thread-local instance), and a global "mutex" hits map
0032 ///     (also implemented as a static). The thread-local hits map is the
0033 ///     same as you will find in many other examples. The atomics hits map
0034 ///     is the purpose of this example. Code-wise, the implementation looks
0035 ///     extremely similar to the thread-local version with the 3 primary
0036 ///     exceptions: (1) construction - there should only be one instance so
0037 ///     it should be a static member variable or a pointer/reference to a
0038 ///     single instance elsewhere in the code (stored in ActionInitialization,
0039 ///     for instance); (2) It does not need to, nor should be, summed in
0040 ///     G4Run::Merge(); and (3) destruction -- it should only be cleared by
0041 ///     the master thread since there is only one instance.
0042 ///
0043 /// A "mutex" hits map is also included as reference for checking the results
0044 ///     accumulated by the thread-local hits maps and atomic hits maps. The
0045 ///     differences w.r.t. this hits maps are computed in
0046 ///     TSRunAction::EndOfRunAction
0047 //
0048 //
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 #ifndef tsrun_h
0053 #define tsrun_h 1
0054 
0055 #include "G4ConvergenceTester.hh"
0056 #include "G4Event.hh"
0057 #include "G4Run.hh"
0058 #include "G4StatAnalysis.hh"
0059 #include "G4TAtomicHitsMap.hh"
0060 #include "G4THitsMap.hh"
0061 #include "G4THitsVector.hh"
0062 #include "globals.hh"
0063 
0064 #include <vector>
0065 
0066 class G4Event;
0067 
0068 // template <typename _Tp> using G4StatContainer = G4THitsMap<_Tp>;
0069 // template <typename _Tp> using G4StatContainer = G4THitsVector<_Tp>;
0070 template<typename _Tp>
0071 using G4StatContainer = G4THitsDeque<_Tp>;
0072 
0073 class TSRun : public G4Run
0074 {
0075   public:
0076     typedef std::map<G4int, G4double> MutexHitsMap_t;
0077 
0078   public:
0079     TSRun(const G4String&);
0080     virtual ~TSRun();
0081 
0082     // virtual method from G4Run.
0083     // The method is overriden in this class for scoring.
0084     virtual void RecordEvent(const G4Event*);
0085 
0086     // Access methods for scoring information.
0087     // - Get HitsMap of this RUN.
0088     G4THitsMap<G4double>* GetHitsMap(const G4String& collname) const;
0089     G4TAtomicHitsMap<G4double>* GetAtomicHitsMap(const G4String&) const;
0090     MutexHitsMap_t* GetMutexHitsMap(const G4String&) const;
0091     G4StatContainer<G4StatAnalysis>* GetStatMap(const G4String& collname) const;
0092     G4StatContainer<G4ConvergenceTester>* GetConvMap(const G4String&) const;
0093 
0094     void ConstructMFD(const G4String&);
0095 
0096     virtual void Merge(const G4Run*);
0097 
0098   private:
0099     std::vector<G4String> fCollNames;
0100     std::vector<G4int> fCollIDs;
0101     std::vector<G4THitsMap<G4double>*> fRunMaps;
0102     std::vector<G4StatContainer<G4StatAnalysis>*> fStatMaps;
0103     static std::vector<G4TAtomicHitsMap<G4double>*> fAtomicRunMaps;
0104     static std::map<G4String, MutexHitsMap_t> fMutexRunMaps;
0105     static std::vector<G4StatContainer<G4ConvergenceTester>*> fConvMaps;
0106 };
0107 
0108 #endif