Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:29

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