Back to home page

EIC code displayed by LXR

 
 

    


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

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:  CexmcProductionModel.cc
0030  *
0031  *    Description:  interface to production model
0032  *
0033  *        Version:  1.0
0034  *        Created:  03.11.2009 16:56:51
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * ============================================================================
0042  */
0043 
0044 #include "CexmcRunManager.hh"
0045 #include "CexmcProductionModel.hh"
0046 #include "CexmcProductionModelMessenger.hh"
0047 
0048 
0049 CexmcProductionModel::CexmcProductionModel( const G4String &  name_,
0050                                             G4bool  fermiMotionIsOn_ ) :
0051     name( name_ ), fermiMotionIsOn( fermiMotionIsOn_ ),
0052     incidentParticle( NULL ), nucleusParticle( NULL ), outputParticle( NULL ),
0053     nucleusOutputParticle( NULL ), messenger( NULL )
0054 {
0055     angularRanges.push_back( CexmcAngularRange( 1.0, -1.0, 0 ) );
0056     messenger = new CexmcProductionModelMessenger( this );
0057 }
0058 
0059 
0060 CexmcProductionModel::~CexmcProductionModel()
0061 {
0062     delete messenger;
0063 }
0064 
0065 
0066 void  CexmcProductionModel::SetAngularRange( G4double  top, G4double  bottom,
0067                                              G4int  nmbOfDivs )
0068 {
0069     if ( ! IsValidCandidateForAngularRange( top, bottom, nmbOfDivs ) )
0070         throw CexmcException( CexmcInvalidAngularRange );
0071 
0072     if ( ! IsGoodCandidateForAngularRange( top, bottom ) )
0073         throw CexmcException( CexmcBadAngularRange );
0074 
0075     angularRanges.clear();
0076     G4double  curBottom( top );
0077     for ( int  i( 0 ); i < nmbOfDivs; ++i )
0078     {
0079         G4double  binWidth( ( top - bottom ) / nmbOfDivs );
0080         G4double  curTop( curBottom );
0081         curBottom -= binWidth;
0082         angularRanges.push_back( CexmcAngularRange( curTop, curBottom, i ) );
0083     }
0084 #ifdef CEXMC_USE_ROOT
0085     CexmcHistoManager::Instance()->SetupARHistos( angularRanges );
0086 #endif
0087 }
0088 
0089 
0090 void  CexmcProductionModel::AddAngularRange( G4double  top, G4double  bottom,
0091                                              G4int  nmbOfDivs )
0092 {
0093     if ( ! IsValidCandidateForAngularRange( top, bottom, nmbOfDivs ) )
0094         throw CexmcException( CexmcInvalidAngularRange );
0095 
0096     if ( ! IsGoodCandidateForAngularRange( top, bottom ) )
0097         throw CexmcException( CexmcBadAngularRange );
0098 
0099     G4int  curIndex( angularRanges.size() );
0100     G4double  curBottom( top );
0101     for ( int  i( 0 ); i < nmbOfDivs; ++i )
0102     {
0103         G4double  binWidth( ( top - bottom ) / nmbOfDivs );
0104         G4double  curTop( curBottom );
0105         curBottom -= binWidth;
0106         CexmcAngularRange  aRange( curTop, curBottom, curIndex + i );
0107         angularRanges.push_back( aRange );
0108 #ifdef CEXMC_USE_ROOT
0109         CexmcHistoManager::Instance()->AddARHistos( aRange );
0110 #endif
0111     }
0112 }
0113 
0114 
0115 void  CexmcProductionModel::SetTriggeredAngularRanges( G4double  opCosThetaSCM )
0116 {
0117     triggeredAngularRanges.clear();
0118 
0119     for ( CexmcAngularRangeList::iterator  k( angularRanges.begin() );
0120                                             k != angularRanges.end(); ++k )
0121     {
0122         if ( opCosThetaSCM <= k->top && opCosThetaSCM > k->bottom )
0123             triggeredAngularRanges.push_back( CexmcAngularRange(
0124                                             k->top, k->bottom, k->index ) );
0125     }
0126 }
0127 
0128 
0129 void  CexmcProductionModel::FermiMotionStatusChangeHook( void )
0130 {
0131 }
0132 
0133 
0134 G4bool  CexmcProductionModel::IsGoodCandidateForAngularRange( G4double  top,
0135                                                       G4double  bottom ) const
0136 {
0137     CexmcRunManager *  runManager( static_cast< CexmcRunManager * >(
0138                                            G4RunManager::GetRunManager() ) );
0139 
0140     if ( ! runManager->ProjectIsRead() )
0141         return true;
0142 
0143     CexmcAngularRangeList  normalizedARanges;
0144     GetNormalizedAngularRange( angularRangesRef, normalizedARanges );
0145 
0146     for ( CexmcAngularRangeList::iterator  k( normalizedARanges.begin() );
0147                                             k != normalizedARanges.end(); ++k )
0148     {
0149         if ( top <= k->top && bottom >= k->bottom )
0150             return true;
0151     }
0152 
0153     return false;
0154 }
0155