tpia_angular.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 
00038 #include "tpia_target.h"
00039 #include "tpia_misc.h"
00040 
00041 #if defined __cplusplus
00042 namespace GIDI {
00043 using namespace GIDI;
00044 #endif
00045 
00046 /*
00047 ************************************************************
00048 */
00049 int tpia_angular_initialize( statusMessageReporting *smr, tpia_angular *angular ) {
00050 
00051     memset( angular, 0, sizeof( tpia_angular ) );
00052     if( tpia_frame_setFromString( smr, "", "", 0, &(angular->frame) ) ) return( 1 );
00053     angular->binned.numberOfEs = 0;
00054     angular->binned.energies = NULL;
00055     return( 0 );
00056 }
00057 /*
00058 ************************************************************
00059 */
00060 int tpia_angular_release( statusMessageReporting *smr, tpia_angular *angular ) {
00061 
00062     //angular->binned.energies = xData_free( smr, angular->binned.energies );
00063     angular->binned.energies = (tpia_EqualProbableBinSpectrum*) xData_free( smr, angular->binned.energies );
00064     angular->binned.numberOfEs = 0;
00065     return( 0 );
00066 }
00067 /*
00068 ************************************************************
00069 */
00070 int tpia_angular_getFromElement( statusMessageReporting *smr, xData_element *angularElement, tpia_angular *angular ) {
00071 
00072     xData_Int n, nBins;
00073 
00074     if( ( tpia_frame_setFromElement( smr, angularElement, 3, &(angular->frame) ) ) != 0 ) return( 1 );
00075     if( ( angular->binned.energies = tpia_misc_getEqualProbableBin( smr, angularElement, &n, &nBins ) ) != NULL ) {
00076         angular->binned.iValue = 0;
00077         angular->binned.dValue = 0;
00078         angular->binned.nBins = (int) nBins;
00079         angular->binned.numberOfEs = (int) n;
00080         return( 0 );
00081     }
00082     return( 1 );
00083 }
00084 /*
00085 ************************************************************
00086 */
00087 int tpia_angular_SampleMu( statusMessageReporting *smr, tpia_angular *angular, tpia_decaySamplingInfo *decaySamplingInfo ) {
00088 
00089     tpia_EqualProbableBinSpectra *binned = &(angular->binned);
00090     int nBins = binned->nBins, status = 1;
00091     double mu;
00092 /*
00093 Currently, only equal probable binning is supported.
00094 Need to return frame info for mu also.
00095 */
00096     if( binned->numberOfEs > 0 ) {
00097         tpia_misc_sampleEqualProbableBin( smr, decaySamplingInfo, decaySamplingInfo->e_in, nBins, binned, &mu );
00098         if( mu < -1. ) mu = -1.;
00099         if( mu >  1. ) mu =  1.;
00100         decaySamplingInfo->mu = mu;
00101         status = 0;
00102     }
00103 
00104     return( status );
00105 }
00106 
00107 #if defined __cplusplus
00108 }
00109 #endif

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