BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtDecayAmp.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtGen/EvtDecayAmp.cc
12//
13// Description:
14//
15// Modification history:
16//
17// DJL/RYD August 11, 1998 Module created
18//
19//------------------------------------------------------------------------
21
25#include "EvtGenBase/EvtPDL.hh"
28#include "EvtGenBase/EvtAmp.hh"
31#include <vector>
32using std::endl;
33
34
36
37 int ntimes=10000;
38
39 int i,more;
40
42 double prob,prob_max;
43
45// report(INFO,"EvtGen") << "Decaying " << EvtPDL::name(p->getId()) << endl;
46 do{
47
49 _weight = 1.0;
50 decay(p);
51
54 if (prob<0.0) {
55
56 report(ERROR,"EvtGen")<<"Negative prob:"<<p->getId().getId()
57 <<" "<<p->getChannel()<<endl;
58
59 report(ERROR,"EvtGen") << "rho_forward:"<<endl;
60 report(ERROR,"EvtGen") << p->getSpinDensityForward();
61 report(ERROR,"EvtGen") << "rho decay:"<<endl;
62 report(ERROR,"EvtGen") << rho <<endl;
63 }
64
65 if (prob!=prob) {
66
67 report(DEBUG,"EvtGen") << "Forward density matrix:"<<endl;
68 report(ERROR,"EvtGen") << p->getSpinDensityForward();
69
70 report(DEBUG,"EvtGen") << "Decay density matrix:"<<endl;
71 report(ERROR,"EvtGen") << rho;
72
73 report(DEBUG,"EvtGen") << "prob:"<<prob<<endl;
74
75 report(DEBUG,"EvtGen") << "Particle:"
76 <<EvtPDL::name(p->getId()).c_str()<<endl;
77 report(DEBUG,"EvtGen") << "channel :"<<p->getChannel()<<endl;
78 report(DEBUG,"EvtGen") << "Momentum:" << p->getP4() << " " << p->mass() << endl;
79 if( p->getParent()!=0){
80 report(DEBUG,"EvtGen") << "parent:"
82 p->getParent()->getId()).c_str()<<endl;
83 report(DEBUG,"EvtGen") << "parent channel :"
84 <<p->getParent()->getChannel()<<endl;
85
86 int i;
87 report(DEBUG,"EvtGen") << "parent daughters :";
88 for (i=0;i<p->getParent()->getNDaug();i++){
90 p->getParent()->getDaug(i)->getId()).c_str()
91 << " ";
92 }
93 report(DEBUG,"") << endl;
94
95 report(DEBUG,"EvtGen") << "daughters :";
96 for (i=0;i<p->getNDaug();i++){
98 p->getDaug(i)->getId()).c_str()
99 << " ";
100 }
101 report(DEBUG,"") << endl;
102
103 report(DEBUG,"EvtGen") << "daughter momenta :" << endl;;
104 for (i=0;i<p->getNDaug();i++){
105 report(DEBUG,"") << p->getDaug(i)->getP4() << " " << p->getDaug(i)->mass();
106 report(DEBUG,"") << endl;
107 }
108
109 }
110 }
111
112
113 prob/=_weight;
114
115
116 prob_max = getProbMax(prob);
117 p->setDecayProb(prob/prob_max);
118
119 //report(INFO,"EvtGen") << "Prob,prob_max,weight:"<<prob<<" "<<prob_max<<" "<<_weight<<endl;
120
121 more=prob<EvtRandom::Flat(prob_max);
122
123 ntimes--;
124
125 }while(ntimes&&more);
126 //report(INFO,"EvtGen") << "Done\n";
127
128 if (ntimes==0){
129 report(DEBUG,"EvtGen") << "Tried accept/reject:10000"
130 <<" times, and rejected all the times!"<<endl;
131 report(DEBUG,"")<<p->getSpinDensityForward()<<endl;
132 report(DEBUG,"EvtGen") << "Is therefore accepting the last event!"<<endl;
133 report(DEBUG,"EvtGen") << "Decay of particle:"<<
134 EvtPDL::name(p->getId()).c_str()<<"(channel:"<<
135 p->getChannel()<<") with mass "<<p->mass()<<endl;
136
137 int ii;
138 for(ii=0;ii<p->getNDaug();ii++){
139 report(DEBUG,"EvtGen") <<"Daughter "<<ii<<":"<<
140 EvtPDL::name(p->getDaug(ii)->getId()).c_str()<<" with mass "<<
141 p->getDaug(ii)->mass()<<endl;
142 }
143 }
144
145
146 EvtSpinDensity rho_list[10];
147
148 rho_list[0]=p->getSpinDensityForward();
149
150
151 EvtAmp ampcont;
152
153 if (_amp2._pstates!=1){
154 ampcont=_amp2.contract(0,p->getSpinDensityForward()); // J2BB2 bugging here
155
156 }
157 else{
158 ampcont=_amp2;
159 }
160
161
162
163 // it may be that the parent decay model has already
164 // done the decay - this should be rare and the
165 // model better know what it is doing..
166
168
169
170 // report(INFO,"EvtGen") << "Found " << p->getNDaug() << " daughters\n";
171 for(i=0;i<p->getNDaug();i++){
172
173 rho.SetDim(_amp2.dstates[i]);
174
175 if (_amp2.dstates[i]==1) {
176 rho.Set(0,0,EvtComplex(1.0,0.0));
177 }
178 else{
179 rho=ampcont.contract(_amp2._dnontrivial[i],_amp2);
180 }
181
182 if (!rho.Check()) {
183
184 report(ERROR,"EvtGen") << "-------start error-------"<<endl;
185 report(ERROR,"EvtGen")<<"forward rho failed Check:"<<
186 EvtPDL::name(p->getId()).c_str()<<" "<<p->getChannel()<<" "<<i<<endl;
187
188 report(ERROR,"EvtGen")<<"Parent:"<<EvtPDL::name(p->getParent()->getId()).c_str()<<endl;
189 report(ERROR,"EvtGen")<<"GrandParent:"<<EvtPDL::name(p->getParent()->getParent()->getId()).c_str()<<endl;
190 report(ERROR,"EvtGen")<<"GrandGrandParent:"<<EvtPDL::name(p->getParent()->getParent()->getParent()->getId()).c_str()<<endl;
191
192 report(ERROR,"EvtGen") << rho;
193 int ii;
194 _amp2.dump();
195
196 for(ii=0;ii<i+1;ii++){
197 report(ERROR,"EvtGen") << rho_list[ii];
198 }
199 report(ERROR,"EvtGen") << "-------Done with error-------"<<endl;
200 }
201
202
203
204 p->getDaug(i)->setSpinDensityForward(rho);
205
206 //debugging
207 // p->printTree();
208 p->getDaug(i)->decay();
209
210 rho_list[i+1]= p->getDaug(i)->getSpinDensityBackward();
211
212 if (_amp2.dstates[i]!=1){
213 ampcont=ampcont.contract(_amp2._dnontrivial[i],rho_list[i+1]);
214 }
215
216
217 }
218
220
221
222 if (!p->getSpinDensityBackward().Check()) {
223
224 report(ERROR,"EvtGen")<<"rho_backward failed Check"<<
225 p->getId().getId()<<" "<<p->getChannel()<<endl;
226
227 report(ERROR,"EvtGen") << p->getSpinDensityBackward();
228
229 }
230 }
231
234
235 }
236
237}
238
239
240
241
242
243
244
245
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ DEBUG
Definition: EvtReport.hh:53
@ ERROR
Definition: EvtReport.hh:49
Definition: EvtAmp.hh:30
EvtSpinDensity contract(int i, const EvtAmp &a)
Definition: EvtAmp.cc:349
void init(EvtId p, int ndaug, EvtId *daug)
Definition: EvtAmp.cc:70
void dump()
Definition: EvtAmp.cc:425
EvtSpinDensity getBackwardSpinDensity(EvtSpinDensity *rho_list)
Definition: EvtAmp.cc:216
EvtSpinDensity getSpinDensity()
Definition: EvtAmp.cc:149
EvtAmp _amp2
Definition: EvtDecayAmp.hh:66
void makeDecay(EvtParticle *p)
Definition: EvtDecayAmp.cc:35
virtual void decay(EvtParticle *p)=0
double getProbMax(double prob)
Definition: EvtDecayBase.cc:67
EvtId * getDaugs()
Definition: EvtDecayBase.hh:65
bool daugsDecayedByParentModel()
bool _daugsDecayedByParentModel
int getId() const
Definition: EvtId.hh:41
static std::string name(EvtId i)
Definition: EvtPDL.hh:64
void setSpinDensityBackward(const EvtSpinDensity &rho)
Definition: EvtParticle.hh:352
void setSpinDensityForward(const EvtSpinDensity &rho)
Definition: EvtParticle.hh:321
void setDecayProb(double p)
void decay()
Definition: EvtParticle.cc:404
EvtId getId() const
Definition: EvtParticle.cc:113
EvtParticle * getParent()
Definition: EvtParticle.cc:87
const EvtVector4R & getP4() const
Definition: EvtParticle.cc:121
int getNDaug() const
Definition: EvtParticle.cc:125
EvtParticle * getDaug(int i)
Definition: EvtParticle.cc:85
double mass() const
Definition: EvtParticle.cc:127
EvtSpinDensity getSpinDensityBackward()
Definition: EvtParticle.hh:357
int getChannel() const
Definition: EvtParticle.cc:123
EvtSpinDensity getSpinDensityForward()
Definition: EvtParticle.hh:347
static bool alwaysRadCorr()
Definition: EvtRadCorr.cc:65
static void doRadCorr(EvtParticle *p)
Definition: EvtRadCorr.cc:52
static double Flat()
Definition: EvtRandom.cc:74
double NormalizedProb(const EvtSpinDensity &d)
void Set(int i, int j, const EvtComplex &rhoij)
void SetDim(int n)