Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:51: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 // Author: M.A. Cortes-Giraldo, Universidad de Sevilla
0027 //
0028 // History changelog prior creation of this example:
0029 // - 17/10/2009: inheritance removed (not needed)
0030 // - 17/10/2009: version 1.0
0031 // - 07/10/2024: version 2.0 for Geant4 example (MT compliant)
0032 // - 18/10/2025: version 3.0
0033 //   - Creation of IAEASourceIdRegistry for thread-safe source_id assignation
0034 //
0035 
0036 #ifndef G4IAEAphspWriter_hh
0037 #define G4IAEAphspWriter_hh 1
0038 
0039 #include "G4ThreeVector.hh"
0040 #include "globals.hh"
0041 
0042 #include <map>
0043 #include <vector>
0044 
0045 class G4Run;
0046 class G4Step;
0047 
0048 class G4IAEAphspWriterStack;
0049 
0050 //------------------------------------------------------------------------------
0051 
0052 class G4IAEAphspWriter
0053 {
0054 
0055 public:
0056 
0057   G4IAEAphspWriter(const G4String filename);
0058   ~G4IAEAphspWriter();
0059 
0060   void OpenIAEAphspOutFiles(const G4Run*);
0061   void WriteIAEAParticle(const size_t idx, const G4int nStat, const G4int pdg,
0062              const G4double kinE, const G4double wt,
0063              const G4ThreeVector pos, const G4ThreeVector momDir);
0064   void CloseIAEAphspOutFiles();
0065 
0066   void AddZphsp(const G4double zphsp);
0067   void SetDataFromIAEAStack(const G4IAEAphspWriterStack* );
0068   // void UpdateHeaders();
0069 
0070   void SetFileName(const G4String name)     { fFileName = name; }
0071   void SetConstVariable(G4int idx, G4double value);
0072   void SumOrigHistories(size_t idx, G4int value)
0073   { fOrigHistories->at(idx) += value; }
0074 
0075   const G4String GetFileName() const                 { return fFileName; }
0076   const std::vector<G4double>* GetZphspVec() const   { return fZphspVec; }
0077   const std::vector<G4int>* GetOrigHistoriesVec() const
0078   { return fOrigHistories; }
0079 
0080 
0081 private:
0082 
0083   G4IAEAphspWriter() = default;
0084   void WriteIAEAParticle(const G4Step* aStep, const G4int zStopIdx);
0085 
0086   // ------------
0087   // DATA MEMBERS
0088   // ------------
0089 
0090   // FILE PROPERTIES
0091 
0092   G4String fFileName;
0093   // Must include the path but not any of the IAEA extensions.
0094 
0095   std::vector<G4double>* fZphspVec = nullptr;
0096   // Vector storing the z-value of the phsp planes.
0097 
0098   std::map<G4int, G4double>* fConstVariables = nullptr;
0099   // Map to store the value of the variables set as constant for the phsp's
0100   // to save disk space.
0101 
0102   // COUNTERS AND FLAGS
0103 
0104   std::vector<G4int>* fOrigHistories = nullptr;
0105   // Vector bookkeeping the number of original histories recorded for each phsp.
0106   // For regular simulations, all the elements should have the same value.
0107 
0108   G4int fIAEASourcesOpen;
0109   // This is a counter to consider if there is another IAEA file already open,
0110   // e.g. a source IAEAphsp file to generate particles.
0111 
0112 };
0113 
0114 #endif