Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:54

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  * ============================================================================
0028  *
0029  *       Filename:  CexmcTrackingAction.cc
0030  *
0031  *    Description:  tracking action
0032  *
0033  *        Version:  1.0
0034  *        Created:  22.11.2009 18:22:22
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * ============================================================================
0042  */
0043 
0044 #include <G4ParticleDefinition.hh>
0045 #include <G4VProcess.hh>
0046 #include <G4Track.hh>
0047 #include <G4RunManager.hh>
0048 #include "CexmcTrackingAction.hh"
0049 #include "CexmcTrackInfo.hh"
0050 #include "CexmcIncidentParticleTrackInfo.hh"
0051 #include "CexmcProductionModel.hh"
0052 #include "CexmcPhysicsManager.hh"
0053 #include "CexmcSetup.hh"
0054 #include "CexmcException.hh"
0055 #include "CexmcCommon.hh"
0056 
0057 
0058 CexmcTrackingAction::CexmcTrackingAction(
0059                                     CexmcPhysicsManager *  physicsManager_ ) :
0060     physicsManager( physicsManager_ ), targetVolume( NULL ),
0061     outputParticleTrackId( CexmcInvalidTrackId ),
0062     outputParticleDecayProductCopyNumber( 0 ), incidentParticle( NULL ),
0063     outputParticle( NULL ), nucleusOutputParticle( NULL )
0064 {
0065     CexmcProductionModel *  productionModel(
0066                                     physicsManager->GetProductionModel() );
0067     if ( ! productionModel )
0068         throw CexmcException( CexmcWeirdException );
0069 
0070     incidentParticle = productionModel->GetIncidentParticle();
0071     outputParticle = productionModel->GetOutputParticle();
0072     nucleusOutputParticle = productionModel->GetNucleusOutputParticle();
0073 
0074     if ( ! incidentParticle || ! outputParticle || ! nucleusOutputParticle )
0075         throw CexmcException( CexmcIncompleteProductionModel );
0076 
0077     G4RunManager *      runManager( G4RunManager::GetRunManager() );
0078     const CexmcSetup *  setup( static_cast< const CexmcSetup * >(
0079                                 runManager->GetUserDetectorConstruction() ) );
0080     targetVolume = setup->GetVolume( CexmcSetup::Target );
0081 }
0082 
0083 
0084 void  CexmcTrackingAction::PreUserTrackingAction( const G4Track *  track )
0085 {
0086     CexmcTrackInfo *  trackInfo( static_cast< CexmcTrackInfo * >(
0087                                                 track->GetUserInformation() ) );
0088 
0089     if ( trackInfo )
0090         return;
0091 
0092     G4Track *  theTrack( const_cast< G4Track * >( track ) );
0093 
0094     do
0095     {
0096         if ( track->GetParentID() == 0 )
0097         {
0098             if ( *track->GetDefinition() == *incidentParticle )
0099             {
0100                 trackInfo = new CexmcIncidentParticleTrackInfo(
0101                                                     CexmcBeamParticleTrack );
0102                 theTrack->SetUserInformation( trackInfo );
0103                 SetupIncidentParticleTrackInfo( track );
0104             }
0105             else
0106             {
0107                 trackInfo = new CexmcTrackInfo( CexmcBeamParticleTrack );
0108             }
0109             break;
0110         }
0111 
0112         if ( track->GetCreatorProcess()->GetProcessName() ==
0113              CexmcStudiedProcessFullName )
0114         {
0115             do
0116             {
0117                 if ( *track->GetDefinition() == *outputParticle )
0118                 {
0119                     outputParticleTrackId = track->GetTrackID();
0120                     trackInfo = new CexmcTrackInfo( CexmcOutputParticleTrack );
0121                     break;
0122                 }
0123                 if ( *track->GetDefinition() == *nucleusOutputParticle )
0124                 {
0125                     trackInfo = new CexmcTrackInfo( CexmcNucleusParticleTrack );
0126                     break;
0127                 }
0128             } while ( false );
0129             break;
0130         }
0131 
0132         if ( track->GetParentID() == outputParticleTrackId )
0133         {
0134             trackInfo = new CexmcTrackInfo(
0135                                     CexmcOutputParticleDecayProductTrack,
0136                                     outputParticleDecayProductCopyNumber++ );
0137             break;
0138         }
0139 
0140         if ( *track->GetDefinition() == *incidentParticle )
0141         {
0142             if ( physicsManager->OnlyBeamParticleCanTriggerStudiedProcess() )
0143                 break;
0144             trackInfo = new CexmcIncidentParticleTrackInfo( CexmcInsipidTrack );
0145             theTrack->SetUserInformation( trackInfo );
0146             SetupIncidentParticleTrackInfo( track );
0147             break;
0148         }
0149     } while ( false );
0150 
0151     if ( ! trackInfo )
0152         return;
0153 
0154     if ( ! track->GetUserInformation() )
0155         theTrack->SetUserInformation( trackInfo );
0156 }
0157 
0158 
0159 void  CexmcTrackingAction::SetupIncidentParticleTrackInfo(
0160                                                     const G4Track *  track )
0161 {
0162     CexmcIncidentParticleTrackInfo *  trackInfo(
0163                     static_cast< CexmcIncidentParticleTrackInfo * >(
0164                                                 track->GetUserInformation() ) );
0165 
0166     if ( ! trackInfo )
0167         return;
0168 
0169     G4VPhysicalVolume *  volume( track->GetVolume() );
0170 
0171     if ( volume && volume->GetLogicalVolume() == targetVolume )
0172     {
0173         physicsManager->ResampleTrackLengthInTarget( track );
0174         trackInfo->ActivateStudiedProcess();
0175     }
0176 }
0177