Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-18 08:28:38

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: hoang tran
0027 
0028 #ifndef PULSE_PULSEACTION_HH
0029 #define PULSE_PULSEACTION_HH 1
0030 
0031 #include "CLHEP/Random/RandGeneral.h"
0032 
0033 #include "G4AutoLock.hh"
0034 #include "G4UserTrackingAction.hh"
0035 #include "G4VUserPulseInfo.hh"
0036 #include "G4VUserTrackInformation.hh"
0037 
0038 #include <map>
0039 #include <vector>
0040 
0041 class G4ParticleDefinition;
0042 
0043 class PulseActionMessenger;
0044 
0045 class PulseInfo : public G4VUserPulseInfo
0046 {
0047   public:
0048     explicit PulseInfo(G4double delayedTime);
0049 
0050     ~PulseInfo() override;
0051 
0052     G4double GetDelayedTime() const override;
0053 
0054   private:
0055     G4double fDelayedTime = 0;
0056 };
0057 
0058 class PulseAction : public G4UserTrackingAction
0059 {
0060   public:
0061     using PulseMap = std::map<G4double, G4double>;
0062 
0063     PulseAction(const G4String& pulse, G4bool useHisto = false);
0064 
0065     ~PulseAction() override;
0066 
0067     void Initialize();
0068 
0069     void PreUserTrackingAction(const G4Track*) override;
0070 
0071     G4double RandomizeInPulse();
0072 
0073     G4double PulseSpectrum(G4double);
0074 
0075     static G4double Interpolate(const std::array<G4double, 5>& dat);
0076 
0077     G4double GetLonggestDelayedTime() const;
0078 
0079     inline void SetPulse(const G4bool& pulse) { fActivePulse = pulse; }
0080 
0081     inline G4bool IsActivedPulse() const { return fActivePulse; }
0082     // L.T. Anh added getter/setter for interpulse class:
0083     void SetLonggestDelayedTime(G4double lt) { fLonggestDelayedTime = lt; }
0084     const G4String GetPulseFileName() { return fFileName; }
0085     G4int GetVerbose() { return fVerbose; }
0086     G4double GetPulseLarger() const;
0087 
0088   protected:
0089     G4int fVerbose = 1;
0090     G4double fDelayedTime = 0;
0091 
0092 private:
0093     void InitializeForHistoInput();
0094     std::unique_ptr<PulseInfo> fpPulseInfo;
0095     G4double fPulseLarger = 0;
0096     PulseMap fPulseData;
0097     std::vector<G4double> fPulseVector;
0098     G4double fLonggestDelayedTime = 0;
0099     std::unique_ptr<PulseActionMessenger> fpMessenger;
0100     G4bool fActivePulse = false;
0101     G4String fFileName = "";
0102     std::unique_ptr<CLHEP::RandGeneral> fRandGeneral{
0103       nullptr};  // L. T. Anh: pointer to radomize histogram from CLHEP
0104     G4bool fUseHistoInput{false};  // L. T. Anh: flag to use histo Input
0105     G4double fTmin{0.}, fTmax{0.};
0106     static G4Mutex gUHDRMutex;  // Le Tuan Anh: protect reading input files in MT mode
0107 };
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0109 
0110 #endif