BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtFDC.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of models developed at BES collaboration
5// based on the EvtGen framework. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/BesCopyright
9// Copyright (A) 2006 Ping Rong-Gang @IHEP
10//
11// Module: EvtFDC.cc
12//
13// Description: Model provided by user, see the mannual
14//
15// Modification history:
16//
17// Ping R.-G. December, 2006 Module created
18//
19//------------------------------------------------------------------------
20
21#include "EvtFDC.hh"
40#include <cstdlib>
41#include <stdlib.h>
42#include <string>
43using namespace std; //::endl;
44
45extern "C" {
46extern void setamp_( int* );
47}
48
49extern "C" {
50extern void init_fit_();
51}
52
53extern "C" {
54extern void initevtgen_();
55}
56
57extern "C" {
58extern double fdcevtgen_( double*, double*, double*, double* );
59}
60
62
63void EvtFDC::getName( std::string& model_name ) { model_name = "FDC"; }
64
66
68 init_fit_();
70 int ndiag = -1; // Feyman diagram number, started from 1, if -1, generate all intermediate
71 // states including interference effects
72 if ( getNArg() == 1 ) { ndiag = getArg( 0 ); }
73 setamp_( &ndiag );
74
76}
78
79static int nrun = 1;
80static double max_amps = 0.0;
81
83 for ( int i = 0; i < _nd; i++ )
84 {
85 e[i] = _p4[i].get( 0 );
86 px[i] = _p4[i].get( 1 );
87 py[i] = _p4[i].get( 2 );
88 pz[i] = _p4[i].get( 3 );
89 }
90}
91
93 double amps, SamAmps, rd1;
94 // calculated the max amplitude square in 20000 events, is it enough larger?
95 if ( nrun == 1 )
96 {
97 int ir, nd;
98 std::cout << "Wait for a moment for calculation of maxiumal amplitude squared"
99 << std::endl;
100 for ( ir = 0; ir <= 200000; ir++ )
101 {
102 loop0:
104 int nd = p->getNDaug();
105 _nd = nd;
106 for ( int i = 0; i <= nd - 1; i++ ) { _p4[i] = p->getDaug( i )->getP4Lab(); }
107 for ( int i = 0; i < _nd; i++ )
108 {
109 e[i] = _p4[i].get( 0 );
110 px[i] = _p4[i].get( 1 );
111 py[i] = _p4[i].get( 2 );
112 pz[i] = _p4[i].get( 3 );
113 }
114 // for debuging
115 amps = fdcevtgen_( e, px, py, pz );
116 // std::cout<<"nrun "<<nrun<<std::endl;
117 if ( amps < 0 ) goto loop0;
118 if ( amps > max_amps ) max_amps = amps * 1.01;
119 nrun++;
120 }
121 }
122 if ( max_amps == 0.0 )
123 {
124 report( ERROR, "EvtGen" )
125 << "The decay amplitude square should be positive number, but it is " << max_amps
126 << endl;
127 abort();
128 }
129 // cout<<"max_amp="<<max_amps<<endl;
130
131loop:
133 int i;
134 for ( i = 0; i <= p->getNDaug() - 1; i++ ) { _p4[i] = p->getDaug( i )->getP4Lab(); }
135 setEvtMomentum( _p4 );
136 // Put phase space results into the daughters.
137 amps = fdcevtgen_( e, px, py, pz );
138 if ( amps < 0 ) goto loop;
139 SamAmps = amps / max_amps;
140 rd1 = EvtRandom::Flat( 0.0, 1.0 );
141 if ( rd1 >= SamAmps ) goto loop;
142 if ( amps > max_amps ) max_amps = amps * 1.01;
143 nrun++;
144}
void setamp_(int *)
void initevtgen_()
double fdcevtgen_(double *, double *, double *, double *)
void init_fit_()
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
double getArg(int j)
EvtId getParentId()
EvtId * getDaugs()
void getName(std::string &name)
Definition EvtFDC.cc:63
void init()
Definition EvtFDC.cc:67
virtual ~EvtFDC()
Definition EvtFDC.cc:61
EvtFDC()
Definition EvtFDC.hh:32
void initProbMax()
Definition EvtFDC.cc:77
void setEvtMomentum(EvtVector4R *p4)
Definition EvtFDC.cc:82
EvtDecayBase * clone()
Definition EvtFDC.cc:65
void decay(EvtParticle *p)
Definition EvtFDC.cc:92
static EvtSpinType::spintype getSpinType(EvtId i)
Definition EvtPDL.hh:66
EvtVector4R getP4Lab()
int getNDaug() const
EvtParticle * getDaug(int i)
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
static double Flat()
Definition EvtRandom.cc:69