Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-07 07:52:50

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 Par02FastSimModelTracker.cc
0027 /// \brief Implementation of the Par02FastSimModelTracker class
0028 
0029 #include "Par02FastSimModelTracker.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 "G4Electron.hh"
0038 #include "G4Event.hh"
0039 #include "G4FieldTrack.hh"
0040 #include "G4FieldTrackUpdator.hh"
0041 #include "G4Gamma.hh"
0042 #include "G4PathFinder.hh"
0043 #include "G4Positron.hh"
0044 #include "G4RunManager.hh"
0045 #include "G4SystemOfUnits.hh"
0046 #include "G4Track.hh"
0047 #include "Randomize.hh"
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 Par02FastSimModelTracker::Par02FastSimModelTracker(
0052   G4String aModelName, G4Region* aEnvelope, Par02DetectorParametrisation::Parametrisation aType)
0053   : G4VFastSimulationModel(aModelName, aEnvelope),
0054     fCalculateParametrisation(),
0055     fParametrisation(aType)
0056 {}
0057 
0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0059 
0060 Par02FastSimModelTracker::Par02FastSimModelTracker(G4String aModelName, G4Region* aEnvelope)
0061   : G4VFastSimulationModel(aModelName, aEnvelope),
0062     fCalculateParametrisation(),
0063     fParametrisation(Par02DetectorParametrisation::eCMS)
0064 {}
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 Par02FastSimModelTracker::Par02FastSimModelTracker(G4String aModelName)
0069   : G4VFastSimulationModel(aModelName),
0070     fCalculateParametrisation(),
0071     fParametrisation(Par02DetectorParametrisation::eCMS)
0072 {}
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 Par02FastSimModelTracker::~Par02FastSimModelTracker() = default;
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 G4bool Par02FastSimModelTracker::IsApplicable(const G4ParticleDefinition& aParticleType)
0081 {
0082   return aParticleType.GetPDGCharge() != 0;  // Applicable for all charged particles
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 G4bool Par02FastSimModelTracker::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 Par02FastSimModelTracker::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
0095 {
0096   G4cout << " ________Tracker model triggered _________" << G4endl;
0097 
0098   // Calculate the final position (at the outer boundary of the tracking detector)
0099   // of the particle with the momentum at the entrance of the tracking detector.
0100 
0101   G4Track track = *aFastTrack.GetPrimaryTrack();
0102   G4FieldTrack aFieldTrack('0');
0103   G4FieldTrackUpdator::Update(&aFieldTrack, &track);
0104 
0105   G4double retSafety = -1.0;
0106   ELimited retStepLimited;
0107   G4FieldTrack endTrack('a');
0108   G4double currentMinimumStep = 10.0 * m;  // Temporary: change that to sth connected
0109                                            // to particle momentum.
0110   G4PathFinder* fPathFinder = G4PathFinder::GetInstance();
0111   /*G4double lengthAlongCurve = */
0112   fPathFinder->ComputeStep(aFieldTrack, currentMinimumStep, 0,
0113                            aFastTrack.GetPrimaryTrack()->GetCurrentStepNumber(), retSafety,
0114                            retStepLimited, endTrack, aFastTrack.GetPrimaryTrack()->GetVolume());
0115 
0116   // Place the particle at the tracking detector exit
0117   // (at the place it would reach without the change of its momentum).
0118   aFastStep.ProposePrimaryTrackFinalPosition(endTrack.GetPosition());
0119 
0120   // Consider only primary tracks (do nothing else for secondary charged particles)
0121   G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
0122   if (!aFastTrack.GetPrimaryTrack()->GetParentID()) {
0123     auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation();
0124     if (info->GetDoSmearing()) {
0125       // Smearing according to the tracking detector resolution
0126       G4double res = fCalculateParametrisation->GetResolution(
0127         Par02DetectorParametrisation::eTRACKER, fParametrisation, Porg.mag());
0128       G4double eff = fCalculateParametrisation->GetEfficiency(
0129         Par02DetectorParametrisation::eTRACKER, fParametrisation, Porg.mag());
0130       G4ThreeVector Psm;
0131       Psm = Par02Smearer::Instance()->SmearMomentum(aFastTrack.GetPrimaryTrack(), res);
0132       Par02Output::Instance()->FillHistogram(0, ((Psm.mag() / MeV) / (Porg.mag() / MeV)));
0133       // Setting the values of Psm, res and eff
0134       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0135                                             aFastTrack.GetPrimaryTrack()
0136                                               ->GetDynamicParticle()
0137                                               ->GetPrimaryParticle())
0138                                             ->GetUserInformation()))
0139         ->SetTrackerMomentum(Psm);
0140       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0141                                             aFastTrack.GetPrimaryTrack()
0142                                               ->GetDynamicParticle()
0143                                               ->GetPrimaryParticle())
0144                                             ->GetUserInformation()))
0145         ->SetTrackerResolution(res);
0146       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0147                                             aFastTrack.GetPrimaryTrack()
0148                                               ->GetDynamicParticle()
0149                                               ->GetPrimaryParticle())
0150                                             ->GetUserInformation()))
0151         ->SetTrackerEfficiency(eff);
0152     }
0153     else {
0154       // No smearing: simply setting the value of Porg
0155       ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0156                                             aFastTrack.GetPrimaryTrack()
0157                                               ->GetDynamicParticle()
0158                                               ->GetPrimaryParticle())
0159                                             ->GetUserInformation()))
0160         ->SetTrackerMomentum(Porg);
0161     }
0162   }
0163 }
0164 
0165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......