Geant4  10.00.p01
tpia_angular.cc
Go to the documentation of this file.
1 /*
2 # <<BEGIN-copyright>>
3 # Copyright (c) 2010, Lawrence Livermore National Security, LLC.
4 # Produced at the Lawrence Livermore National Laboratory
5 # Written by Bret R. Beck, beck6@llnl.gov.
6 # CODE-461393
7 # All rights reserved.
8 #
9 # This file is part of GIDI. For details, see nuclear.llnl.gov.
10 # Please also read the "Additional BSD Notice" at nuclear.llnl.gov.
11 #
12 # Redistribution and use in source and binary forms, with or without modification,
13 # are permitted provided that the following conditions are met:
14 #
15 # 1) Redistributions of source code must retain the above copyright notice,
16 # this list of conditions and the disclaimer below.
17 # 2) Redistributions in binary form must reproduce the above copyright notice,
18 # this list of conditions and the disclaimer (as noted below) in the
19 # documentation and/or other materials provided with the distribution.
20 # 3) Neither the name of the LLNS/LLNL nor the names of its contributors may be
21 # used to endorse or promote products derived from this software without
22 # specific prior written permission.
23 #
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
25 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27 # SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR
28 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 # <<END-copyright>>
35 */
36 #include <string.h>
37 
38 #include "tpia_target.h"
39 #include "tpia_misc.h"
40 
41 #if defined __cplusplus
42 namespace GIDI {
43 using namespace GIDI;
44 #endif
45 
46 /*
47 ************************************************************
48 */
49 int tpia_angular_initialize( statusMessageReporting *smr, tpia_angular *angular ) {
50 
51  memset( angular, 0, sizeof( tpia_angular ) );
52  if( tpia_frame_setFromString( smr, "", "", 0, &(angular->frame) ) ) return( 1 );
53  angular->binned.numberOfEs = 0;
54  angular->binned.energies = NULL;
55  return( 0 );
56 }
57 /*
58 ************************************************************
59 */
60 int tpia_angular_release( statusMessageReporting *smr, tpia_angular *angular ) {
61 
62  //angular->binned.energies = xData_free( smr, angular->binned.energies );
63  angular->binned.energies = (tpia_EqualProbableBinSpectrum*) xData_free( smr, angular->binned.energies );
64  angular->binned.numberOfEs = 0;
65  return( 0 );
66 }
67 /*
68 ************************************************************
69 */
70 int tpia_angular_getFromElement( statusMessageReporting *smr, xData_element *angularElement, tpia_angular *angular ) {
71 
72  xData_Int n, nBins;
73 
74  if( ( tpia_frame_setFromElement( smr, angularElement, 3, &(angular->frame) ) ) != 0 ) return( 1 );
75  if( ( angular->binned.energies = tpia_misc_getEqualProbableBin( smr, angularElement, &n, &nBins ) ) != NULL ) {
76  angular->binned.iValue = 0;
77  angular->binned.dValue = 0;
78  angular->binned.nBins = (int) nBins;
79  angular->binned.numberOfEs = (int) n;
80  return( 0 );
81  }
82  return( 1 );
83 }
84 /*
85 ************************************************************
86 */
87 int tpia_angular_SampleMu( statusMessageReporting *smr, tpia_angular *angular, tpia_decaySamplingInfo *decaySamplingInfo ) {
88 
89  tpia_EqualProbableBinSpectra *binned = &(angular->binned);
90  int nBins = binned->nBins, status = 1;
91  double mu;
92 /*
93 Currently, only equal probable binning is supported.
94 Need to return frame info for mu also.
95 */
96  if( binned->numberOfEs > 0 ) {
97  tpia_misc_sampleEqualProbableBin( smr, decaySamplingInfo, decaySamplingInfo->e_in, nBins, binned, &mu );
98  if( mu < -1. ) mu = -1.;
99  if( mu > 1. ) mu = 1.;
100  decaySamplingInfo->mu = mu;
101  status = 0;
102  }
103 
104  return( status );
105 }
106 
107 #if defined __cplusplus
108 }
109 #endif
int tpia_angular_release(statusMessageReporting *smr, tpia_angular *angular)
Definition: tpia_angular.cc:60
int tpia_angular_SampleMu(statusMessageReporting *smr, tpia_angular *angular, tpia_decaySamplingInfo *decaySamplingInfo)
Definition: tpia_angular.cc:87
tpia_EqualProbableBinSpectrum * tpia_misc_getEqualProbableBin(statusMessageReporting *smr, xData_element *parent, xData_Int *n, xData_Int *nBins)
Definition: tpia_misc.cc:317
int tpia_angular_getFromElement(statusMessageReporting *smr, xData_element *angularElement, tpia_angular *angular)
Definition: tpia_angular.cc:70
int tpia_frame_setFromString(statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:75
int tpia_angular_initialize(statusMessageReporting *smr, tpia_angular *angular)
Definition: tpia_angular.cc:49
const G4int n
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:62
void * xData_free(statusMessageReporting *, void *p)
Definition: xDataMisc.cc:89
int tpia_misc_sampleEqualProbableBin(statusMessageReporting *, tpia_decaySamplingInfo *decaySamplingInfo, double e_in, int nBins, tpia_EqualProbableBinSpectra *binned, double *value_)
Definition: tpia_misc.cc:420