38 #define _USE_MATH_DEFINES
41 #include "tpia_target.h"
43 #if defined __cplusplus
53 return( decayChannel->products );
60 return( product->next );
66 int nProductData, tpia_productOutgoingData *productDatas ) {
68 int i,
n = 0, multiplicity, secondTwoBody = 0, labFrame = tpia_referenceFrame_lab;
69 tpia_product *product, *nextProduct;
72 if( nProductData < decayChannel->numberOfProducts ) {
73 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"nProductData = %d < decayChannel->numberOfProducts = %d", nProductData,
74 decayChannel->numberOfProducts );
79 if( !secondTwoBody ) {
81 tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState ) );
82 while( multiplicity > 0 ) {
83 if( n >= nProductData )
break;
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;
92 productDatas[
n].productID = product->productID;
93 productDatas[
n].decayChannel = &(product->decayChannel);
94 if( strcmp( product->genre,
"twoBody_angular" ) == 0 ) {
96 productDatas[n+1].productID = nextProduct->productID;
97 productDatas[
n].genre = product->genre;
100 phi = 2. * M_PI *
tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState );
101 productDatas[
n].isVelocity = decaySamplingInfo->isVelocity;
102 productDatas[
n].frame = decaySamplingInfo->frame;
105 else if( strcmp( product->genre,
"NBody_Legendre" ) == 0 ) {
107 else if( strcmp( product->genre,
"NBody_angular_energy" ) == 0 ) {
110 else if( strcmp( product->genre,
"NBody_uncorrelate_Legendre" ) == 0 ) {
113 else if( strcmp( product->genre,
"unknown" ) == 0 ) {
116 printf(
"Unknown spectral data form product name = %s, genre = %s\n", product->productID->name, product->genre );
118 if( !
smr_isOk( smr ) )
return( -1 );
119 if( secondTwoBody ) {
121 productDatas[
n].productID = nextProduct->productID;
122 productDatas[
n].genre = nextProduct->genre; }
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 );
139 #if defined __cplusplus
int tpia_angular_SampleMu(statusMessageReporting *smr, tpia_angular *angular, tpia_decaySamplingInfo *decaySamplingInfo)
int tpia_frame_setColumns(statusMessageReporting *smr, tpia_data_frame *frame, int nColumns, int *values)
int tpia_Legendre_SampleEp(statusMessageReporting *smr, tpia_Legendre *Legendre, int sampleMu, tpia_decaySamplingInfo *decaySamplingInfo)
tpia_product * tpia_decayChannel_getNextProduct(tpia_product *product)
int tpia_kinetics_2BodyReaction(statusMessageReporting *smr, tpia_decayChannel *decayChannel, double K, double mu, double phi, tpia_productOutgoingData *outgoingData)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
double tpia_misc_drng(double(*rng)(void *), void *rngState)
int tpia_decayChannel_sampleProductsAtE(statusMessageReporting *smr, tpia_decayChannel *decayChannel, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productDatas)
int smr_isOk(statusMessageReporting *smr)
int tpia_angularEnergy_SampleEp(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy, tpia_decaySamplingInfo *decaySamplingInfo)
int tpia_product_sampleMultiplicity(statusMessageReporting *, tpia_product *product, double e_in, double r)
tpia_product * tpia_decayChannel_getFirstProduct(tpia_decayChannel *decayChannel)