BOSS 7.1.1
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
22#include <stdlib.h>
25#include "EvtGenBase/EvtPDL.hh"
41#include <string>
42#include <cstdlib>
43using namespace std; //::endl;
44
45extern "C"{
46 extern void setamp_(int *);
47}
48
49extern "C" {
50 extern void init_fit_();
51}
52
53extern "C"{
54 extern void initevtgen_();
55}
56
57extern "C" {
58 extern double fdcevtgen_( double*,double*,double*, double*);
59}
60
62
63void EvtFDC::getName(std::string& model_name){
64
65 model_name="FDC";
66
67}
68
70
71 return new EvtFDC;
72
73}
74
75
77 init_fit_();
79 int ndiag = -1; //Feyman diagram number, started from 1, if -1, generate all intermediate states including interference effects
80 if (getNArg()==1) {
81 ndiag = getArg(0);
82 }
83 setamp_( &ndiag );
84
86}
88 noProbMax();
89
90}
91
92
93static int nrun=1;
94static double max_amps=0.0;
95
97 for (int i=0; i<_nd; i++){
98 e[i] = _p4[i].get(0);
99 px[i] = _p4[i].get(1);
100 py[i] = _p4[i].get(2);
101 pz[i] = _p4[i].get(3);
102 }
103}
104
106double amps,SamAmps,rd1;
107// calculated the max amplitude square in 20000 events, is it enough larger?
108 if(nrun==1){
109 int ir,nd;
110 std::cout<<"Wait for a moment for calculation of maxiumal amplitude squared"<<std::endl;
111 for(ir=0;ir<=200000;ir++){
112 loop0:
114 int nd=p->getNDaug();
115 _nd=nd;
116 for(int i=0;i<=nd-1;i++){
117 _p4[i]=p->getDaug(i)->getP4Lab();
118 }
119 for (int i=0; i<_nd; i++){
120 e[i] = _p4[i].get(0);
121 px[i] = _p4[i].get(1);
122 py[i] = _p4[i].get(2);
123 pz[i] = _p4[i].get(3);
124 }
125 //for debuging
126 amps = fdcevtgen_(e,px,py,pz);
127 //std::cout<<"nrun "<<nrun<<std::endl;
128 if(amps<0) goto loop0;
129 if(amps>max_amps) max_amps=amps*1.01;
130 nrun++;
131 }
132 }
133if(max_amps==0.0) {report(ERROR,"EvtGen")<<"The decay amplitude square should be positive number, but it is "<<max_amps<<endl;abort();}
134//cout<<"max_amp="<<max_amps<<endl;
135
136
137loop:
139 int i;
140 for(i=0;i<=p->getNDaug()-1;i++){
141 _p4[i]=p->getDaug(i)->getP4Lab();
142 }
143 setEvtMomentum(_p4);
144// Put phase space results into the daughters.
145 amps = fdcevtgen_(e,px,py,pz);
146 if(amps < 0) goto loop;
147 SamAmps=amps/max_amps;
148 rd1=EvtRandom::Flat(0.0, 1.0);
149 if(rd1>=SamAmps) goto loop;
150 if(amps>max_amps) max_amps=amps*1.01;
151 nrun++;
152}
153
154
void setamp_(int *)
void initevtgen_()
double fdcevtgen_(double *, double *, double *, double *)
void init_fit_()
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:36
@ 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:76
virtual ~EvtFDC()
Definition EvtFDC.cc:61
EvtFDC()
Definition EvtFDC.hh:33
void initProbMax()
Definition EvtFDC.cc:87
void setEvtMomentum(EvtVector4R *p4)
Definition EvtFDC.cc:96
EvtDecayBase * clone()
Definition EvtFDC.cc:69
void decay(EvtParticle *p)
Definition EvtFDC.cc:105
static EvtSpinType::spintype getSpinType(EvtId i)
Definition EvtPDL.hh:61
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:74
double get(int i) const
double double double * p4
Definition qcdloop1.h:77