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