Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:31:31

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 StackingAction.cc
0027 /// \brief Implementation of the StackingAction class
0028 
0029 #include "StackingAction.hh"
0030 
0031 #include "EventAction.hh"
0032 #include "HistoManager.hh"
0033 #include "Run.hh"
0034 #include "StackingMessenger.hh"
0035 
0036 #include "G4EmSecondaryParticleType.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4Track.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 StackingAction::StackingAction(EventAction* event) : fEventAction(event)
0043 {
0044   fStackMessenger = new StackingMessenger(this);
0045 }
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 StackingAction::~StackingAction()
0050 {
0051   delete fStackMessenger;
0052 }
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrack)
0057 {
0058   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0059 
0060   // keep primary particle
0061   if (aTrack->GetParentID() == 0) {
0062     return fUrgent;
0063   }
0064 
0065   G4int procID = aTrack->GetCreatorProcess()->GetProcessSubType();
0066   G4int modelID = aTrack->GetCreatorModelID();
0067 
0068   // count secondary particles
0069   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0070   run->CountParticles(aTrack->GetDefinition());
0071   /*
0072   G4cout << "###StackingAction: new "
0073          << aTrack->GetDefinition()->GetParticleName()
0074          << " E(MeV)= " << aTrack->GetKineticEnergy()
0075          << "  " << aTrack->GetMomentumDirection() << G4endl;
0076   */
0077   //
0078   // energy spectrum of secondaries
0079   //
0080   G4double energy = aTrack->GetKineticEnergy();
0081   G4double charge = aTrack->GetDefinition()->GetPDGCharge();
0082 
0083   if (charge != 0.) {
0084     analysisManager->FillH1(2, energy);
0085     analysisManager->FillH1(4, energy);
0086     if (procID >= 51 && procID <= 65) {
0087       analysisManager->FillH1(58, energy);
0088       analysisManager->FillH1(60, energy);
0089     }
0090     else if (_AugerElectron == modelID) {
0091       analysisManager->FillH1(50, energy);
0092       analysisManager->FillH1(52, energy);
0093     }
0094     else if (_ePIXE == modelID) {
0095       analysisManager->FillH1(54, energy);
0096       analysisManager->FillH1(56, energy);
0097     }
0098   }
0099 
0100   if (aTrack->GetDefinition() == G4Gamma::Gamma()) {
0101     analysisManager->FillH1(3, energy);
0102     analysisManager->FillH1(5, energy);
0103     if (procID >= 51 && procID <= 65) {
0104       analysisManager->FillH1(59, energy);
0105       analysisManager->FillH1(61, energy);
0106     }
0107     else if (_Fluorescence == modelID) {
0108       analysisManager->FillH1(51, energy);
0109       analysisManager->FillH1(53, energy);
0110     }
0111     else if (_GammaPIXE == modelID) {
0112       analysisManager->FillH1(55, energy);
0113       analysisManager->FillH1(57, energy);
0114     }
0115   }
0116 
0117   // stack or delete secondaries
0118   G4ClassificationOfNewTrack status = fUrgent;
0119   if (0 < fKillSecondary) {
0120     if (fKillSecondary == 1) {
0121       fEventAction->AddEnergy(energy);
0122     }
0123     status = fKill;
0124   }
0125 
0126   return status;
0127 }
0128 
0129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......