Back to home page

EIC code displayed by LXR

 
 

    


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

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:  CexmcGenbod.cc
0030  *
0031  *    Description:  original fortran routine GENBOD wrapper
0032  *
0033  *        Version:  1.0
0034  *        Created:  08.09.2010 14:36:23
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * =============================================================================
0042  */
0043 
0044 #ifdef CEXMC_USE_GENBOD
0045 
0046 #include <G4SystemOfUnits.hh>
0047 #include "CexmcGenbod.hh"
0048 #include "CexmcException.hh"
0049 
0050 
0051 extern "C"
0052 {
0053     extern int  genbod_( void );
0054 }
0055 
0056 
0057 extern struct  genbod_in_data
0058 {
0059     int    np;
0060     float  tecm;
0061     float  amass[ 18 ];
0062     int    kgenev;
0063 }  genin_;
0064 
0065 
0066 extern struct  genbod_out_data
0067 {
0068     float  pcm[ 18 ][ 5 ];
0069     float  wt;
0070 }  genout_;
0071 
0072 
0073 CexmcGenbod::CexmcGenbod()
0074 {
0075     genin_.np = 0;
0076     genin_.kgenev = 1;
0077 }
0078 
0079 
0080 G4bool  CexmcGenbod::CheckKinematics( void )
0081 {
0082     totalEnergy = 0.;
0083     for ( CexmcPhaseSpaceInVector::const_iterator  k( inVec.begin() );
0084                                                         k != inVec.end(); ++k )
0085     {
0086         totalEnergy += ( *k )->e();
0087     }
0088 
0089     /* epsilon is needed to compensate float to fortran real cast accuracy,
0090      * the value 3E-6 was found experimentally, maybe has to be made bigger,
0091      * but not smaller */
0092     const float  epsilon( 3E-6 );
0093 
0094     return totalEnergy - totalMass > 0.0f + epsilon;
0095 }
0096 
0097 
0098 G4double  CexmcGenbod::Generate( void )
0099 {
0100     genin_.tecm = totalEnergy / GeV;
0101 
0102     genbod_();
0103 
0104     float ( *pcm )[ 5 ]( &genout_.pcm[ 0 ] );
0105 
0106     for ( CexmcPhaseSpaceOutVector::iterator  k( outVec.begin() );
0107                                                         k != outVec.end(); ++k )
0108     {
0109         k->lVec->setPx( ( *pcm )[ 0 ] * GeV );
0110         k->lVec->setPy( ( *pcm )[ 1 ] * GeV );
0111         k->lVec->setPz( ( *pcm )[ 2 ] * GeV );
0112         k->lVec->setE( ( *pcm++ )[ 3 ] * GeV );
0113     }
0114 
0115     return genout_.wt;
0116 }
0117 
0118 
0119 void  CexmcGenbod::ParticleChangeHook( void )
0120 {
0121     size_t  nmbOfOutputParticles( outVec.size() );
0122 
0123     if ( nmbOfOutputParticles < 2 || nmbOfOutputParticles > 18 )
0124         throw CexmcException( CexmcKinematicsException );
0125 
0126     genin_.np = nmbOfOutputParticles;
0127 
0128     float *  amass( genin_.amass );
0129 
0130     for ( CexmcPhaseSpaceOutVector::const_iterator  k( outVec.begin() );
0131                                                         k != outVec.end(); ++k )
0132     {
0133         *amass++ = k->mass / GeV;
0134     }
0135 }
0136 
0137 
0138 void  CexmcGenbod::FermiEnergyDepStatusChangeHook( void )
0139 {
0140     genin_.kgenev = fermiEnergyDepIsOn ? 2 : 1;
0141 }
0142 
0143 #endif
0144