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 Par02TrackingAction.cc
0028 /// \brief Implementation of the Par02TrackingAction class
0029 
0030 #include "Par02TrackingAction.hh"
0031 
0032 #include "Par02EventInformation.hh"
0033 #include "Par02Output.hh"
0034 #include "Par02PrimaryParticleInformation.hh"
0035 
0036 #include "G4EventManager.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4ThreeVector.hh"
0040 #include "G4TrackingManager.hh"
0041 #include "Randomize.hh"
0042 
0043 #include <iomanip>
0044 #include <vector>
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 Par02TrackingAction::Par02TrackingAction() : G4UserTrackingAction() {}
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 Par02TrackingAction::~Par02TrackingAction() = default;
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 void Par02TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
0057 {
0058   // Kill the tracks that have a small transverse momentum or that are not
0059   // in the central region.
0060   if (aTrack->GetMomentum().perp() < 1.0 * MeV
0061       || std::abs(aTrack->GetMomentum().pseudoRapidity()) > 5.5)
0062   {
0063     ((G4Track*)aTrack)->SetTrackStatus(fStopAndKill);
0064   }
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 void Par02TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
0070 {
0071   if (aTrack->GetTrackStatus() == fStopAndKill && aTrack->GetParentID() == 0) {
0072     auto info = (Par02PrimaryParticleInformation*)aTrack->GetDynamicParticle()
0073                   ->GetPrimaryParticle()
0074                   ->GetUserInformation();
0075     // info->Print();
0076     Par02Output::Instance()->SaveTrack(Par02Output::eSaveMC, info->GetPartID(), info->GetPDG(),
0077                                        info->GetMCMomentum() / MeV);
0078     Par02Output::Instance()->SaveTrack(Par02Output::eSaveTracker, info->GetPartID(), info->GetPDG(),
0079                                        info->GetTrackerMomentum() / MeV,
0080                                        info->GetTrackerResolution(), info->GetTrackerEfficiency());
0081     Par02Output::Instance()->SaveTrack(Par02Output::eSaveEMCal, info->GetPartID(), info->GetPDG(),
0082                                        info->GetEMCalPosition() / mm, info->GetEMCalResolution(),
0083                                        info->GetEMCalEfficiency(), info->GetEMCalEnergy() / MeV);
0084     Par02Output::Instance()->SaveTrack(Par02Output::eSaveHCal, info->GetPartID(), info->GetPDG(),
0085                                        info->GetHCalPosition() / mm, info->GetHCalResolution(),
0086                                        info->GetHCalEfficiency(), info->GetHCalEnergy() / MeV);
0087   }
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......