Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:33

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 //
0027 /// \file Par02FastSimModelEMCal.cc
0028 /// \brief Implementation of the Par02FastSimModelEMCal class
0029 
0030 #include "Par02FastSimModelEMCal.hh"
0031 
0032 #include "Par02EventInformation.hh"
0033 #include "Par02Output.hh"
0034 #include "Par02PrimaryParticleInformation.hh"
0035 #include "Par02Smearer.hh"
0036 
0037 #include "G4AnalysisManager.hh"
0038 #include "G4Electron.hh"
0039 #include "G4Event.hh"
0040 #include "G4Gamma.hh"
0041 #include "G4Positron.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4Track.hh"
0045 #include "Randomize.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope,
0050                                                Par02DetectorParametrisation::Parametrisation aType)
0051   : G4VFastSimulationModel(aModelName, aEnvelope),
0052     fCalculateParametrisation(),
0053     fParametrisation(aType)
0054 {}
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope)
0059   : G4VFastSimulationModel(aModelName, aEnvelope),
0060     fCalculateParametrisation(),
0061     fParametrisation(Par02DetectorParametrisation::eCMS)
0062 {}
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName)
0067   : G4VFastSimulationModel(aModelName),
0068     fCalculateParametrisation(),
0069     fParametrisation(Par02DetectorParametrisation::eCMS)
0070 {}
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 Par02FastSimModelEMCal::~Par02FastSimModelEMCal() = default;
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 
0078 G4bool Par02FastSimModelEMCal::IsApplicable(const G4ParticleDefinition& aParticleType)
0079 {
0080   // Applicable for electrons, positrons, and gammas
0081   return &aParticleType == G4Electron::Definition() || &aParticleType == G4Positron::Definition()
0082          || &aParticleType == G4Gamma::Definition();
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 G4bool Par02FastSimModelEMCal::ModelTrigger(const G4FastTrack& /*aFastTrack*/)
0088 {
0089   return true;  // No kinematical restrictions to apply the parametrisation
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 void Par02FastSimModelEMCal::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
0095 {
0096   // G4cout << " ________EMCal model triggered _________" << G4endl;
0097 
0098   // Kill the parameterised particle at the entrance of the electromagnetic calorimeter
0099   aFastStep.KillPrimaryTrack();
0100   aFastStep.ProposePrimaryTrackPathLength(0.0);
0101   G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
0102 
0103   // Consider only primary tracks (do nothing else for secondary e-, e+, gammas)
0104   G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
0105   if (!aFastTrack.GetPrimaryTrack()->GetParentID()) {
0106     auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation();
0107     if (info->GetDoSmearing()) {
0108       // Smearing according to the electromagnetic calorimeter resolution
0109       G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
0110       G4double res = fCalculateParametrisation->GetResolution(Par02DetectorParametrisation::eEMCAL,
0111                                                               fParametrisation, Porg.mag());
0112       G4double eff = fCalculateParametrisation->GetEfficiency(Par02DetectorParametrisation::eEMCAL,
0113                                                               fParametrisation, Porg.mag());
0114       G4double Esm;
0115       Esm = std::abs(Par02Smearer::Instance()->SmearEnergy(aFastTrack.GetPrimaryTrack(), res));
0116       Par02Output::Instance()->FillHistogram(1, (Esm / MeV) / (Edep / MeV));
0117       // Setting the values of Pos, Esm, res and eff
0118       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0119                                             aFastTrack.GetPrimaryTrack()
0120                                               ->GetDynamicParticle()
0121                                               ->GetPrimaryParticle())
0122                                             ->GetUserInformation()))
0123         ->SetEMCalPosition(Pos);
0124       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0125                                             aFastTrack.GetPrimaryTrack()
0126                                               ->GetDynamicParticle()
0127                                               ->GetPrimaryParticle())
0128                                             ->GetUserInformation()))
0129         ->SetEMCalEnergy(Esm);
0130       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0131                                             aFastTrack.GetPrimaryTrack()
0132                                               ->GetDynamicParticle()
0133                                               ->GetPrimaryParticle())
0134                                             ->GetUserInformation()))
0135         ->SetEMCalResolution(res);
0136       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0137                                             aFastTrack.GetPrimaryTrack()
0138                                               ->GetDynamicParticle()
0139                                               ->GetPrimaryParticle())
0140                                             ->GetUserInformation()))
0141         ->SetEMCalEfficiency(eff);
0142       // The (smeared) energy of the particle is deposited in the step
0143       // (which corresponds to the entrance of the electromagnetic calorimeter)
0144       aFastStep.ProposeTotalEnergyDeposited(Esm);
0145     }
0146     else {
0147       // No smearing: simply setting the value of Edep
0148       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0149                                             aFastTrack.GetPrimaryTrack()
0150                                               ->GetDynamicParticle()
0151                                               ->GetPrimaryParticle())
0152                                             ->GetUserInformation()))
0153         ->SetEMCalEnergy(Edep);
0154       // The (initial) energy of the particle is deposited in the step
0155       // (which corresponds to the entrance of the electromagnetic calorimeter)
0156       aFastStep.ProposeTotalEnergyDeposited(Edep);
0157     }
0158   }
0159 }
0160 
0161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......