Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 07:56:52

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