Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-15 07:42:02

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 XSHistoManager.hh
0027 /// \brief Definition of the XSHistoManager class
0028 ///
0029 /// Create a set of profiles for XS study.
0030 
0031 //
0032 //  Adapted from hadronic/Hadr00/include/HistoManager.hh
0033 //  Author: G.Hugo, 06 January 2023
0034 //
0035 // ***************************************************************************
0036 //
0037 ///  \class XSHistoManager
0038 ///
0039 ///  Create a set of profiles for XS study.
0040 ///
0041 ///  All profiles are G4H1.
0042 ///  They are created and filled via G4VAnalysisManager.
0043 ///
0044 ///  The profiles can be dumped to all usual formats, including ROOT
0045 ///  (via G4VAnalysisManager).
0046 ///  An interesting added feature here, is that the plots, while being allocated
0047 ///  and filled via G4VAnalysisManager, are also dumped
0048 ///  in a Flair-compatible format (via tools::histo::flair).
0049 ///
0050 ///  NB: tools::histo::flair code, which allows the dump of any G4H1
0051 ///  into Flair-compatible format, is fully application-agnostic,
0052 ///  and is placed in FlukaCern/utils.
0053 ///  It could also be added as an extension of core G4 Analysis Manager.
0054 //
0055 // ***************************************************************************
0056 
0057 
0058 #ifndef XS_HISTO_MANAGER_HH
0059 #define XS_HISTO_MANAGER_HH
0060 
0061 #include "XSHistoManagerMessenger.hh"
0062 
0063 #include "G4SystemOfUnits.hh"
0064 #include "globals.hh"
0065 
0066 #include <unordered_map>
0067 
0068 class G4ParticleDefinition;
0069 class G4Element;
0070 class G4Material;
0071 class G4VAnalysisManager;
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0074 
0075 class XSHistoManager
0076 {
0077   public:
0078     XSHistoManager();
0079 
0080     void SetOutputFileName(const G4String& outputFileName);
0081     void SetParticle(const G4String& particleName);
0082     void SetElement(const G4String& elementName);
0083     void SetMaterial(const G4String& materialName);
0084     void SetNumberOfBins(const G4int numBins) { fNumBins = numBins; }
0085     void SetMinKinEnergy(const G4double minKineticEnergy) { fMinKineticEnergy = minKineticEnergy; }
0086     void SetMaxKinEnergy(const G4double maxKineticEnergy) { fMaxKineticEnergy = maxKineticEnergy; }
0087 
0088     void Book();
0089     void EndOfRun();
0090 
0091   private:
0092     void CheckInput();
0093     void DumpAllG4H1IntoRootFile() const;
0094     void DumpAllG4H1IntoFlairFile() const;
0095 
0096     XSHistoManagerMessenger* fMessenger = nullptr;
0097 
0098     G4String fOutputFileName = "all_XS";
0099     G4String fRootOutputFileName = "all_XS.root";
0100     G4String fFlairOutputFileName = "all_XS.hist";
0101     const G4ParticleDefinition* fParticle = nullptr;
0102     const G4Element* fElement = nullptr;
0103     const G4Material* fMaterial = nullptr;
0104     G4int fNumBins = 10000;
0105     G4double fMinKineticEnergy = 1. * keV;
0106     G4double fMaxKineticEnergy = 10. * TeV;
0107     G4String fFunctionName = "none";
0108     G4String fBinSchemeName = "log";
0109     G4String fRootEnergyUnit = "MeV";
0110 
0111     G4VAnalysisManager* fAnalysisManager = nullptr;
0112     std::unordered_map<G4int, G4int> fXSProfileIndex;  // key: XS index
0113                                                        // value: histo index from G4VAnalysisManager
0114 
0115     G4int fElasticXSIndex = 0;
0116     G4int fInelasticXSIndex = 1;
0117     G4int fCaptureXSIndex = 2;
0118     G4int fFissionXSIndex = 3;
0119     G4int fChargeExchangeXSIndex = 4;
0120     G4int fTotalXSIndex = 5;
0121     G4int fElasticPerVolumeXSIndex = 6;
0122     G4int fInelasticPerVolumeXSIndex = 7;
0123 };
0124 
0125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0126 
0127 #endif