tpia_decayChannel.cc

Go to the documentation of this file.
00001 /*
00002 # <<BEGIN-copyright>>
00003 # Copyright (c) 2010, Lawrence Livermore National Security, LLC. 
00004 # Produced at the Lawrence Livermore National Laboratory 
00005 # Written by Bret R. Beck, beck6@llnl.gov. 
00006 # CODE-461393
00007 # All rights reserved. 
00008 #  
00009 # This file is part of GIDI. For details, see nuclear.llnl.gov. 
00010 # Please also read the "Additional BSD Notice" at nuclear.llnl.gov. 
00011 # 
00012 # Redistribution and use in source and binary forms, with or without modification, 
00013 # are permitted provided that the following conditions are met: 
00014 #
00015 #      1) Redistributions of source code must retain the above copyright notice, 
00016 #         this list of conditions and the disclaimer below.
00017 #      2) Redistributions in binary form must reproduce the above copyright notice, 
00018 #         this list of conditions and the disclaimer (as noted below) in the 
00019 #          documentation and/or other materials provided with the distribution.
00020 #      3) Neither the name of the LLNS/LLNL nor the names of its contributors may be 
00021 #         used to endorse or promote products derived from this software without 
00022 #         specific prior written permission. 
00023 #
00024 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
00025 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00026 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT 
00027 # SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 
00028 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00029 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
00030 # OR SERVICES;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00031 # AND ON  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00032 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
00033 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00034 # <<END-copyright>>
00035 */
00036 #include <string.h>
00037 #ifdef WIN32
00038    #define _USE_MATH_DEFINES
00039 #endif
00040 #include <cmath>
00041 #include "tpia_target.h"
00042 
00043 #if defined __cplusplus
00044 namespace GIDI {
00045 using namespace GIDI;
00046 #endif
00047 
00048 /*
00049 ************************************************************
00050 */
00051 tpia_product *tpia_decayChannel_getFirstProduct( tpia_decayChannel *decayChannel ) {
00052 
00053     return( decayChannel->products );
00054 }
00055 /*
00056 ************************************************************
00057 */
00058 tpia_product *tpia_decayChannel_getNextProduct( tpia_product *product ) {
00059 
00060     return( product->next );
00061 }
00062 /*
00063 ************************************************************
00064 */
00065 int tpia_decayChannel_sampleProductsAtE( statusMessageReporting *smr, tpia_decayChannel *decayChannel, tpia_decaySamplingInfo *decaySamplingInfo,
00066         int nProductData, tpia_productOutgoingData *productDatas ) {
00067 
00068     int i, n = 0, multiplicity, secondTwoBody = 0, labFrame = tpia_referenceFrame_lab;
00069     tpia_product *product, *nextProduct;
00070     double phi, p;
00071 
00072     if( nProductData < decayChannel->numberOfProducts ) {
00073         smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "nProductData = %d < decayChannel->numberOfProducts = %d", nProductData,
00074             decayChannel->numberOfProducts );
00075         return( -1 );
00076     }
00077     for( i = 0, product = tpia_decayChannel_getFirstProduct( decayChannel ); product != NULL; i++, product = tpia_decayChannel_getNextProduct( product ) ) {
00078         nextProduct = tpia_decayChannel_getNextProduct( product );
00079         if( !secondTwoBody ) {
00080             if( ( multiplicity = product->multiplicity ) == 0 ) multiplicity = tpia_product_sampleMultiplicity( smr, product, decaySamplingInfo->e_in,
00081                 tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState ) );
00082             while( multiplicity > 0 ) {
00083                 if( n >= nProductData ) break;          /* This needs work. */
00084                 multiplicity--;
00085                 decaySamplingInfo->genre = product->genre;
00086                 decaySamplingInfo->productID = product->productID;
00087                 decaySamplingInfo->mu = 0;
00088                 decaySamplingInfo->Ep = 0;
00089                 productDatas[n].genre = product->genre;
00090                 productDatas[n].isVelocity = decaySamplingInfo->isVelocity;
00091                 tpia_frame_setColumns( smr, &(productDatas[n].frame), 1, &labFrame );
00092                 productDatas[n].productID = product->productID;
00093                 productDatas[n].decayChannel = &(product->decayChannel);
00094                 if( strcmp( product->genre, "twoBody_angular" ) == 0 ) {
00095                     secondTwoBody = 1;
00096                     productDatas[n+1].productID = nextProduct->productID;
00097                     productDatas[n].genre = product->genre;
00098                     tpia_angular_SampleMu( smr, &(product->angular), decaySamplingInfo );   /* Need to test for success. */
00099                     if( smr_isOk( smr ) ) {
00100                         phi = 2. * M_PI * tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState );
00101                         productDatas[n].isVelocity = decaySamplingInfo->isVelocity;
00102                         productDatas[n].frame = decaySamplingInfo->frame;
00103                         tpia_kinetics_2BodyReaction( smr, decayChannel, decaySamplingInfo->e_in, decaySamplingInfo->mu, phi, &(productDatas[n]) );
00104                     } }
00105                 else if( strcmp( product->genre, "NBody_Legendre" ) == 0 ) {
00106                     tpia_Legendre_SampleEp( smr, &(product->Legendre), 1, decaySamplingInfo ); }
00107                 else if( strcmp( product->genre, "NBody_angular_energy" ) == 0 ) {
00108                     tpia_angular_SampleMu( smr, &(product->angular), decaySamplingInfo );   /* Need to test for success. */
00109                     tpia_angularEnergy_SampleEp( smr, &(product->angularEnergy), decaySamplingInfo ); }
00110                 else if( strcmp( product->genre, "NBody_uncorrelate_Legendre" ) == 0 ) {
00111                     tpia_angular_SampleMu( smr, &(product->angular), decaySamplingInfo );   /* Need to test for success. */
00112                     tpia_Legendre_SampleEp( smr, &(product->Legendre), 0, decaySamplingInfo ); }
00113                 else if( strcmp( product->genre, "unknown" ) == 0 ) {
00114                     }
00115                 else {
00116                     printf( "Unknown spectral data form product name = %s, genre = %s\n", product->productID->name, product->genre );
00117                 }
00118                 if( !smr_isOk( smr ) ) return( -1 );
00119                 if( secondTwoBody ) {
00120                     n++;
00121                     productDatas[n].productID = nextProduct->productID;
00122                     productDatas[n].genre = nextProduct->genre; }
00123                 else {
00124                     productDatas[n].kineticEnergy = decaySamplingInfo->Ep;
00125                     p = std::sqrt( decaySamplingInfo->Ep * ( decaySamplingInfo->Ep + 2. * product->productID->fullMass_MeV ) );
00126                     productDatas[n].pz_vz = p * decaySamplingInfo->mu;
00127                     p = std::sqrt( 1. - decaySamplingInfo->mu * decaySamplingInfo->mu ) * p;
00128                     phi = 2. * M_PI * tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState );
00129                     productDatas[n].px_vx = p * std::sin( phi );
00130                     productDatas[n].py_vy = p * std::cos( phi );
00131                 }
00132                 n++;
00133             }
00134         }
00135     }
00136     return( n );
00137 }
00138 
00139 #if defined __cplusplus
00140 }
00141 #endif

Generated on Mon May 27 17:50:35 2013 for Geant4 by  doxygen 1.4.7