Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/hadronic/FlukaCern/ProcessLevel/FinalState/include/FinalStateHistoManager.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 FinalStateHistoManager.hh
0027 ///  \brief Create a set of histos for final state study.
0028 //
0029 //  Author: G.Hugo, 08 December 2022
0030 //
0031 // ***************************************************************************
0032 //
0033 //      FinalStateHistoManager
0034 //
0035 ///  Create a set of histos for final state study.
0036 ///  In practice, the interactions studied here are hadron nuclear inelastic interactions
0037 ///  (though the code is fully generic).
0038 ///
0039 ///  Energy spectra are plotted for all encountered secondaries
0040 ///  (one histo per secondary).
0041 ///  In addition, the residual nuclei Z and A distributions are plotted.
0042 ///
0043 ///  All histograms are G4H1.
0044 ///  They are created and filled via the G4VAnalysisManager.
0045 ///
0046 ///  The histograms can be dumped to all usual formats, including ROOT
0047 ///  (via G4VAnalysisManager).
0048 ///  An interesting added feature here, is that the plots, while being allocated
0049 ///  and filled via G4VAnalysisManager, are also dumped
0050 ///  in a Flair-compatible format (via tools::histo::flair).
0051 ///
0052 ///  NB 1: Note that instead of a hardcoded number associated to a hardcoded set of particles,
0053 ///  particle PDG IDs are used to index the histos.
0054 ///  This allows a dynamic storage of all particles encountered in the final states.
0055 ///
0056 ///  NB 2: tools::histo::flair code, which allows the dump of any G4H1
0057 ///  into Flair-compatible format, is fully application-agnostic,
0058 ///  and is placed in FlukaCern/utils.
0059 ///  It could also be added as an extension of core G4 Analysis Manager.
0060 //
0061 // ***************************************************************************
0062 
0063 #ifndef FINAL_STATE_HISTO_MANAGER_HH
0064 #define FINAL_STATE_HISTO_MANAGER_HH
0065 
0066 #include "G4H1Wrapper.hh"
0067 #include "G4SystemOfUnits.hh"
0068 #include "globals.hh"
0069 
0070 #include <memory>
0071 #include <unordered_map>
0072 #include <vector>
0073 
0074 class G4DynamicParticle;
0075 class G4VAnalysisManager;
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0078 
0079 class FinalStateHistoManager
0080 {
0081   public:
0082     FinalStateHistoManager();
0083 
0084     void Book();
0085     void BeginOfEvent();
0086     void ScoreSecondary(const G4DynamicParticle* const secondary);
0087     void EndOfEvent();
0088     void EndOfRun() const;
0089 
0090   private:
0091     void DumpAllG4H1IntoRootFile() const;
0092     void
0093     DumpAllG4H1IntoFlairFile(const std::map<G4String, const G4H1Wrapper*>& particlesHistos) const;
0094 
0095     G4String fOutputFileName = "all_secondaries";
0096     G4String fRootOutputFileName = fOutputFileName + ".root";
0097     G4String fFlairOutputFileName = fOutputFileName + ".hist";
0098 
0099     G4int fNumBins = 90;
0100     G4double fMinKineticEnergy = 10. * keV;
0101     G4double fMaxKineticEnergy = 10. * TeV;
0102     G4String fFunctionName = "none";
0103     G4String fBinSchemeName = "log";
0104     G4String fRootEnergyUnit = "MeV";
0105 
0106     G4int fNucleiZMax = 25;
0107     G4int fNucleiAMax = 50;
0108 
0109     G4int fNumEvents = 0;
0110 
0111     G4VAnalysisManager* fAnalysisManager = nullptr;
0112 
0113     // key is particle PDG ID:
0114     std::unordered_map<G4int, std::unique_ptr<G4H1Wrapper>> fParticleData;
0115     // key is nuclei Z or A score index:
0116     std::unordered_map<G4int, std::unique_ptr<G4H1Wrapper>> fNucleiData;
0117     G4int fNucleiZScoreIndex = 0;
0118     G4int fNucleiAScoreIndex = 1;
0119 };
0120 
0121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0122 
0123 #endif