Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:49

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 electromagnetic/TestEm1/src/TrackingAction.cc
0027 /// \brief Implementation of the TrackingAction class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "TrackingAction.hh"
0034 
0035 #include "HistoManager.hh"
0036 #include "PrimaryGeneratorAction.hh"
0037 #include "Run.hh"
0038 
0039 #include "G4RunManager.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4Track.hh"
0042 #include "G4UnitsTable.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 TrackingAction::TrackingAction(PrimaryGeneratorAction* prim) : fPrimary(prim) {}
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 void TrackingAction::PreUserTrackingAction(const G4Track*)
0051 {
0052   /*
0053     //debug
0054     const G4DynamicParticle* dynamic = aTrack->GetDynamicParticle();
0055     G4double dynamCharge = dynamic->GetCharge();
0056     G4int occup          = dynamic->GetTotalOccupancy();
0057     G4double   pdgMass   = dynamic->GetParticleDefinition()->GetPDGMass();
0058     G4double invarMass   = dynamic->Get4Momentum().m();
0059     G4double dynamMass   = dynamic->GetMass();
0060     G4double dif1 = invarMass - pdgMass;
0061     G4double dif2 = dynamMass - pdgMass;
0062 
0063     G4cout
0064       << "\n  Begin of track :"
0065       << "\n    charge= " <<  dynamCharge << "  occupancy= " << occup
0066       << "\n   pdgMass= " << G4BestUnit (pdgMass  , "Energy")
0067   ///    << "\n invarMass= " << G4BestUnit (invarMass, "Energy")
0068   ///    << "   invar-pdg= " << G4BestUnit (dif1     , "Energy")
0069       << "\n dynamMass= " << G4BestUnit (dynamMass, "Energy")
0070       << "   dynam-pdg= " << G4BestUnit (dif2     , "Energy")
0071       << G4endl;
0072   */
0073 }
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0076 
0077 void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
0078 {
0079   // increase nb of processed tracks
0080   // count nb of steps of this track
0081   G4int nbSteps = aTrack->GetCurrentStepNumber();
0082   G4double Trleng = aTrack->GetTrackLength();
0083 
0084   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0085 
0086   if (aTrack->GetDefinition()->GetPDGCharge() == 0.) {
0087     run->CountTraks0(1);
0088     run->CountSteps0(nbSteps);
0089   }
0090   else {
0091     run->CountTraks1(1);
0092     run->CountSteps1(nbSteps);
0093   }
0094 
0095   // true and projected ranges for primary particle
0096   if (aTrack->GetTrackID() == 1) {
0097     run->AddTrueRange(Trleng);
0098     G4ThreeVector vertex = fPrimary->GetParticleGun()->GetParticlePosition();
0099     G4ThreeVector position = aTrack->GetPosition() - vertex;
0100     run->AddProjRange(position.x());
0101     run->AddTransvDev(position.y());
0102     run->AddTransvDev(position.z());
0103 
0104     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0105     analysisManager->FillH1(1, Trleng);
0106     analysisManager->FillH1(2, (float)nbSteps);
0107   }
0108   /*
0109     //debug
0110     const G4DynamicParticle* dynamic = aTrack->GetDynamicParticle();
0111     G4double dynamCharge = dynamic->GetCharge();
0112     G4int occup          = dynamic->GetTotalOccupancy();
0113     G4double   pdgMass   = dynamic->GetParticleDefinition()->GetPDGMass();
0114     G4double invarMass   = dynamic->Get4Momentum().m();
0115     G4double dynamMass   = dynamic->GetMass();
0116     G4double dif1 = invarMass - pdgMass;
0117     G4double dif2 = dynamMass - pdgMass;
0118 
0119     G4cout
0120       << "\n  End of track :"
0121       << "\n    charge= " <<  dynamCharge << "  occupancy= " << occup
0122       << "\n   pdgMass= " << G4BestUnit (pdgMass  , "Energy")
0123   ///    << "\n invarMass= " << G4BestUnit (invarMass, "Energy")
0124   ///    << "   invar-pdg= " << G4BestUnit (dif1     , "Energy")
0125       << "\n dynamMass= " << G4BestUnit (dynamMass, "Energy")
0126       << "   dynam-pdg= " << G4BestUnit (dif2     , "Energy")
0127       << G4endl;
0128   */
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......