Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21: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 /*
0027  * =============================================================================
0028  *
0029  *       Filename:  CexmcPhysicsList.hh
0030  *
0031  *    Description:  mandatory physics list
0032  *
0033  *        Version:  1.0
0034  *        Created:  11.10.2009 14:51:08
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * =============================================================================
0042  */
0043 
0044 #ifndef CEXMC_PHYSICS_LIST_HH
0045 #define CEXMC_PHYSICS_LIST_HH
0046 
0047 #include <Randomize.hh>
0048 #include <G4Track.hh>
0049 #include <G4StepPoint.hh>
0050 #include <G4ThreeVector.hh>
0051 #include <G4AffineTransform.hh>
0052 #include "CexmcPhysicsManager.hh"
0053 #include "CexmcProductionModel.hh"
0054 #include "CexmcIncidentParticleTrackInfo.hh"
0055 #include "CexmcSetup.hh"
0056 #include "CexmcException.hh"
0057 #include "CexmcCommon.hh"
0058 
0059 
0060 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0061             typename  ProductionModel >
0062 class  CexmcPhysicsList : public BasePhysics, public CexmcPhysicsManager
0063 {
0064     public:
0065         CexmcPhysicsList();
0066 
0067     public:
0068         CexmcProductionModel *  GetProductionModel( void );
0069 
0070         G4bool  IsStudiedProcessAllowed( void ) const;
0071 
0072         void    ResampleTrackLengthInTarget( const G4Track *  track,
0073                                              const G4StepPoint *  stepPoint );
0074 
0075         void    SetupConstructionHook( const CexmcSetup *  setup );
0076 
0077     protected:
0078         void  CalculateBasicMaxIL( const G4ThreeVector &  direction );
0079 
0080     private:
0081         StudiedPhysics< ProductionModel > *  studiedPhysics;
0082 
0083         G4VSolid *                           targetSolid;
0084 
0085         G4AffineTransform                    targetTransform;
0086 };
0087 
0088 
0089 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0090             typename  ProductionModel >
0091 CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0092                 CexmcPhysicsList() : studiedPhysics( NULL ), targetSolid( NULL )
0093 {
0094     studiedPhysics = new StudiedPhysics< ProductionModel >( this );
0095     this->RegisterPhysics( studiedPhysics );
0096 }
0097 
0098 
0099 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0100             typename  ProductionModel >
0101 CexmcProductionModel *
0102             CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0103                 GetProductionModel( void )
0104 {
0105     return studiedPhysics->GetProductionModel();
0106 }
0107 
0108 
0109 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0110             typename  ProductionModel >
0111 G4bool  CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0112                 IsStudiedProcessAllowed( void ) const
0113 {
0114     return numberOfTriggeredStudiedInteractions == 0;
0115 }
0116 
0117 
0118 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0119             typename  ProductionModel >
0120 void  CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0121                 ResampleTrackLengthInTarget( const G4Track *  track,
0122                                              const G4StepPoint *  stepPoint )
0123 {
0124     /* BEWARE: all callers must ensure that:
0125      * 1) track (or stepPoint if not NULL) is inside target volume:
0126      *    in this case we can use already calculated targetTransform
0127      * 2) track info object is of type CexmcIncidentParticleTrackInfo*:
0128      *    in this case we can use static_cast<> for trackInfo */
0129     CexmcIncidentParticleTrackInfo *  trackInfo(
0130                 static_cast< CexmcIncidentParticleTrackInfo * >(
0131                                                 track->GetUserInformation() ) );
0132 
0133     if ( ! trackInfo )
0134         return;
0135 
0136     G4ThreeVector  position;
0137     G4ThreeVector  direction;
0138 
0139     if ( stepPoint )
0140     {
0141         position = targetTransform.TransformPoint( stepPoint->GetPosition() );
0142         direction = targetTransform.TransformAxis(
0143                                             stepPoint->GetMomentumDirection() );
0144     }
0145     else
0146     {
0147         position = targetTransform.TransformPoint( track->GetPosition() );
0148         direction = targetTransform.TransformAxis(
0149                                             track->GetMomentumDirection() );
0150     }
0151 
0152     G4double  distanceInTarget( targetSolid->DistanceToOut( position,
0153                                                             direction ) );
0154     trackInfo->ResetCurrentTrackLengthInTarget();
0155     trackInfo->SetFinalTrackLengthInTarget( G4UniformRand() *
0156                                 std::max( distanceInTarget, proposedMaxIL ) );
0157     trackInfo->SetNeedsTrackLengthResampling( false );
0158 }
0159 
0160 
0161 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0162             typename  ProductionModel >
0163 void  CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0164                 CalculateBasicMaxIL( const G4ThreeVector &  direction )
0165 {
0166     /* basicMaxIL is double distance from the point (0, 0, 0) to the edge of the
0167      * target solid along the specified direction */
0168     basicMaxIL = targetSolid->DistanceToOut( G4ThreeVector(),
0169                             targetTransform.TransformAxis( direction ) ) * 2;
0170 }
0171 
0172 
0173 template  < typename  BasePhysics, template  < typename > class  StudiedPhysics,
0174             typename  ProductionModel >
0175 void  CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0176                 SetupConstructionHook( const CexmcSetup *  setup )
0177 {
0178     targetSolid = setup->GetVolume( CexmcSetup::Target )->GetSolid();
0179     targetTransform = setup->GetTargetTransform().Inverse();
0180 }
0181 
0182 
0183 #endif
0184