Geant4_10
tpia_decayChannel.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 #ifdef WIN32
38  #define _USE_MATH_DEFINES
39 #endif
40 #include <cmath>
41 #include "tpia_target.h"
42 
43 #if defined __cplusplus
44 namespace GIDI {
45 using namespace GIDI;
46 #endif
47 
48 /*
49 ************************************************************
50 */
52 
53  return( decayChannel->products );
54 }
55 /*
56 ************************************************************
57 */
59 
60  return( product->next );
61 }
62 /*
63 ************************************************************
64 */
66  int nProductData, tpia_productOutgoingData *productDatas ) {
67 
68  int i, n = 0, multiplicity, secondTwoBody = 0, labFrame = tpia_referenceFrame_lab;
69  tpia_product *product, *nextProduct;
70  double phi, p;
71 
72  if( nProductData < decayChannel->numberOfProducts ) {
73  smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "nProductData = %d < decayChannel->numberOfProducts = %d", nProductData,
74  decayChannel->numberOfProducts );
75  return( -1 );
76  }
77  for( i = 0, product = tpia_decayChannel_getFirstProduct( decayChannel ); product != NULL; i++, product = tpia_decayChannel_getNextProduct( product ) ) {
78  nextProduct = tpia_decayChannel_getNextProduct( product );
79  if( !secondTwoBody ) {
80  if( ( multiplicity = product->multiplicity ) == 0 ) multiplicity = tpia_product_sampleMultiplicity( smr, product, decaySamplingInfo->e_in,
81  tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState ) );
82  while( multiplicity > 0 ) {
83  if( n >= nProductData ) break; /* This needs work. */
84  multiplicity--;
85  decaySamplingInfo->genre = product->genre;
86  decaySamplingInfo->productID = product->productID;
87  decaySamplingInfo->mu = 0;
88  decaySamplingInfo->Ep = 0;
89  productDatas[n].genre = product->genre;
90  productDatas[n].isVelocity = decaySamplingInfo->isVelocity;
91  tpia_frame_setColumns( smr, &(productDatas[n].frame), 1, &labFrame );
92  productDatas[n].productID = product->productID;
93  productDatas[n].decayChannel = &(product->decayChannel);
94  if( strcmp( product->genre, "twoBody_angular" ) == 0 ) {
95  secondTwoBody = 1;
96  productDatas[n+1].productID = nextProduct->productID;
97  productDatas[n].genre = product->genre;
98  tpia_angular_SampleMu( smr, &(product->angular), decaySamplingInfo ); /* Need to test for success. */
99  if( smr_isOk( smr ) ) {
100  phi = 2. * M_PI * tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState );
101  productDatas[n].isVelocity = decaySamplingInfo->isVelocity;
102  productDatas[n].frame = decaySamplingInfo->frame;
103  tpia_kinetics_2BodyReaction( smr, decayChannel, decaySamplingInfo->e_in, decaySamplingInfo->mu, phi, &(productDatas[n]) );
104  } }
105  else if( strcmp( product->genre, "NBody_Legendre" ) == 0 ) {
106  tpia_Legendre_SampleEp( smr, &(product->Legendre), 1, decaySamplingInfo ); }
107  else if( strcmp( product->genre, "NBody_angular_energy" ) == 0 ) {
108  tpia_angular_SampleMu( smr, &(product->angular), decaySamplingInfo ); /* Need to test for success. */
109  tpia_angularEnergy_SampleEp( smr, &(product->angularEnergy), decaySamplingInfo ); }
110  else if( strcmp( product->genre, "NBody_uncorrelate_Legendre" ) == 0 ) {
111  tpia_angular_SampleMu( smr, &(product->angular), decaySamplingInfo ); /* Need to test for success. */
112  tpia_Legendre_SampleEp( smr, &(product->Legendre), 0, decaySamplingInfo ); }
113  else if( strcmp( product->genre, "unknown" ) == 0 ) {
114  }
115  else {
116  printf( "Unknown spectral data form product name = %s, genre = %s\n", product->productID->name, product->genre );
117  }
118  if( !smr_isOk( smr ) ) return( -1 );
119  if( secondTwoBody ) {
120  n++;
121  productDatas[n].productID = nextProduct->productID;
122  productDatas[n].genre = nextProduct->genre; }
123  else {
124  productDatas[n].kineticEnergy = decaySamplingInfo->Ep;
125  p = std::sqrt( decaySamplingInfo->Ep * ( decaySamplingInfo->Ep + 2. * product->productID->fullMass_MeV ) );
126  productDatas[n].pz_vz = p * decaySamplingInfo->mu;
127  p = std::sqrt( 1. - decaySamplingInfo->mu * decaySamplingInfo->mu ) * p;
128  phi = 2. * M_PI * tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState );
129  productDatas[n].px_vx = p * std::sin( phi );
130  productDatas[n].py_vy = p * std::cos( phi );
131  }
132  n++;
133  }
134  }
135  }
136  return( n );
137 }
138 
139 #if defined __cplusplus
140 }
141 #endif
int tpia_angular_SampleMu(statusMessageReporting *smr, tpia_angular *angular, tpia_decaySamplingInfo *decaySamplingInfo)
Definition: tpia_angular.cc:87
tpia_product * next
Definition: tpia_target.h:232
#define M_PI
Definition: SbMath.h:34
const char * p
Definition: xmltok.h:285
double tpia_misc_drng(double(*rng)(void *), void *rngState)
Definition: tpia_misc.cc:403
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
tpia_particle * productID
Definition: tpia_target.h:155
tpia_product * products
Definition: tpia_target.h:211
int tpia_kinetics_2BodyReaction(statusMessageReporting *smr, tpia_decayChannel *decayChannel, double K, double mu, double phi, tpia_productOutgoingData *outgoingData)
Char_t n[5]
int tpia_Legendre_SampleEp(statusMessageReporting *smr, tpia_Legendre *Legendre, int sampleMu, tpia_decaySamplingInfo *decaySamplingInfo)
double(* rng)(void *)
Definition: tpia_target.h:153
int tpia_decayChannel_sampleProductsAtE(statusMessageReporting *smr, tpia_decayChannel *decayChannel, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productData)
tpia_data_frame frame
Definition: tpia_target.h:152
int smr_isOk(statusMessageReporting *smr)
#define tpia_referenceFrame_lab
Definition: tpia_target.h:85
int tpia_frame_setColumns(statusMessageReporting *smr, tpia_data_frame *frame, int nColumns, int *values)
Definition: tpia_frame.cc:179
tpia_particle * productID
Definition: tpia_target.h:165
int tpia_angularEnergy_SampleEp(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy, tpia_decaySamplingInfo *decaySamplingInfo)
char const * genre
Definition: tpia_target.h:237
tpia_decayChannel * decayChannel
Definition: tpia_target.h:170
printf("%d Experimental points found\n", nlines)
int tpia_product_sampleMultiplicity(statusMessageReporting *smr, tpia_product *product, double e_in, double r)
tpia_product * tpia_decayChannel_getFirstProduct(tpia_decayChannel *decayChannel)
tpia_particle * productID
Definition: tpia_target.h:236
tpia_product * tpia_decayChannel_getNextProduct(tpia_product *product)