Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-17 07:41:48

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