BOSS 8.0.0
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//------------------------------------------------------------------------
20#include "EvtPatches.hh"
21
22#include "EvtAmp.hh"
23#include "EvtDecayAmp.hh"
24#include "EvtDecayBase.hh"
25#include "EvtPDL.hh"
26#include "EvtParticle.hh"
27#include "EvtRadCorr.hh"
28#include "EvtRandom.hh"
29#include "EvtReport.hh"
30#include "EvtSpinDensity.hh"
31#include <vector>
32using std::endl;
33
35
36 int ntimes = 10000;
37
38 int i, more;
39
41 double prob, prob_max;
42
43 _amp2.init( p->getId(), getNDaug(), getDaugs() );
44 // report(INFO,"EvtGen") << "Decaying " << EvtPDL::name(p->getId()) << endl;
45 do {
46
48 _weight = 1.0;
49 decay( p );
50
51 rho = _amp2.getSpinDensity();
52 prob = p->getSpinDensityForward().NormalizedProb( rho );
53 if ( prob < 0.0 )
54 {
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
68 report( DEBUG, "EvtGen" ) << "Forward density matrix:" << endl;
69 report( ERROR, "EvtGen" ) << p->getSpinDensityForward();
70
71 report( DEBUG, "EvtGen" ) << "Decay density matrix:" << endl;
72 report( ERROR, "EvtGen" ) << rho;
73
74 report( DEBUG, "EvtGen" ) << "prob:" << prob << endl;
75
76 report( DEBUG, "EvtGen" ) << "Particle:" << 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 {
81 report( DEBUG, "EvtGen" )
82 << "parent:" << EvtPDL::name( p->getParent()->getId() ).c_str() << endl;
83 report( DEBUG, "EvtGen" )
84 << "parent channel :" << p->getParent()->getChannel() << endl;
85
86 int i;
87 report( DEBUG, "EvtGen" ) << "parent daughters :";
88 for ( i = 0; i < p->getParent()->getNDaug(); i++ )
89 {
90 report( DEBUG, "" ) << EvtPDL::name( 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++ )
97 { report( DEBUG, "" ) << EvtPDL::name( p->getDaug( i )->getId() ).c_str() << " "; }
98 report( DEBUG, "" ) << endl;
99
100 report( DEBUG, "EvtGen" ) << "daughter momenta :" << endl;
101 ;
102 for ( i = 0; i < p->getNDaug(); i++ )
103 {
104 report( DEBUG, "" ) << p->getDaug( i )->getP4() << " " << p->getDaug( i )->mass();
105 report( DEBUG, "" ) << endl;
106 }
107 }
108 }
109
110 prob /= _weight;
111
112 prob_max = getProbMax( prob );
113 p->setDecayProb( prob / prob_max );
114
115 // report(INFO,"EvtGen") << "Prob,prob_max,weight:"<<prob<<" "<<prob_max<<"
116 // "<<_weight<<endl;
117
118 more = prob < EvtRandom::Flat( prob_max );
119
120 ntimes--;
121
122 } while ( ntimes && more );
123 // report(INFO,"EvtGen") << "Done\n";
124
125 if ( ntimes == 0 )
126 {
127 report( DEBUG, "EvtGen" ) << "Tried accept/reject:10000"
128 << " times, and rejected all the times!" << endl;
129 report( DEBUG, "" ) << p->getSpinDensityForward() << endl;
130 report( DEBUG, "EvtGen" ) << "Is therefore accepting the last event!" << endl;
131 report( DEBUG, "EvtGen" ) << "Decay of particle:" << EvtPDL::name( p->getId() ).c_str()
132 << "(channel:" << p->getChannel() << ") with mass " << p->mass()
133 << endl;
134
135 int ii;
136 for ( ii = 0; ii < p->getNDaug(); ii++ )
137 {
138 report( DEBUG, "EvtGen" ) << "Daughter " << ii << ":"
139 << EvtPDL::name( p->getDaug( ii )->getId() ).c_str()
140 << " with mass " << p->getDaug( ii )->mass() << endl;
141 }
142 }
143
144 EvtSpinDensity rho_list[10];
145
146 rho_list[0] = p->getSpinDensityForward();
147
148 EvtAmp ampcont;
149
150 if ( _amp2._pstates != 1 )
151 {
152 ampcont = _amp2.contract( 0, p->getSpinDensityForward() ); // J2BB2 bugging here
153 }
154 else { ampcont = _amp2; }
155
156 // it may be that the parent decay model has already
157 // done the decay - this should be rare and the
158 // model better know what it is doing..
159
161 {
162
163 // report(INFO,"EvtGen") << "Found " << p->getNDaug() << " daughters\n";
164 for ( i = 0; i < p->getNDaug(); i++ )
165 {
166
167 rho.SetDim( _amp2.dstates[i] );
168
169 if ( _amp2.dstates[i] == 1 ) { rho.Set( 0, 0, EvtComplex( 1.0, 0.0 ) ); }
170 else { rho = ampcont.contract( _amp2._dnontrivial[i], _amp2 ); }
171
172 if ( !rho.Check() )
173 {
174
175 report( ERROR, "EvtGen" ) << "-------start error-------" << endl;
176 report( ERROR, "EvtGen" )
177 << "forward rho failed Check:" << EvtPDL::name( p->getId() ).c_str() << " "
178 << p->getChannel() << " " << i << endl;
179
180 report( ERROR, "EvtGen" )
181 << "Parent:" << EvtPDL::name( p->getParent()->getId() ).c_str() << endl;
182 report( ERROR, "EvtGen" )
183 << "GrandParent:" << EvtPDL::name( p->getParent()->getParent()->getId() ).c_str()
184 << endl;
185 report( ERROR, "EvtGen" )
186 << "GrandGrandParent:"
187 << EvtPDL::name( p->getParent()->getParent()->getParent()->getId() ).c_str()
188 << endl;
189
190 report( ERROR, "EvtGen" ) << rho;
191 int ii;
192 _amp2.dump();
193
194 for ( ii = 0; ii < i + 1; ii++ ) { report( ERROR, "EvtGen" ) << rho_list[ii]; }
195 report( ERROR, "EvtGen" ) << "-------Done with error-------" << endl;
196 }
197
198 p->getDaug( i )->setSpinDensityForward( rho );
199
200 // debugging
201 // p->printTree();
202 p->getDaug( i )->decay();
203
204 rho_list[i + 1] = p->getDaug( i )->getSpinDensityBackward();
205
206 if ( _amp2.dstates[i] != 1 )
207 { ampcont = ampcont.contract( _amp2._dnontrivial[i], rho_list[i + 1] ); }
208 }
209
210 p->setSpinDensityBackward( _amp2.getBackwardSpinDensity( rho_list ) );
211
212 if ( !p->getSpinDensityBackward().Check() )
213 {
214
215 report( ERROR, "EvtGen" ) << "rho_backward failed Check" << p->getId().getId() << " "
216 << p->getChannel() << endl;
217
218 report( ERROR, "EvtGen" ) << p->getSpinDensityBackward();
219 }
220 }
221
223}
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ DEBUG
Definition EvtReport.hh:53
@ ERROR
Definition EvtReport.hh:49
EvtSpinDensity contract(int i, const EvtAmp &a)
Definition EvtAmp.cc:317
void makeDecay(EvtParticle *p)
virtual void decay(EvtParticle *p)=0
double getProbMax(double prob)
EvtId * getDaugs()
bool daugsDecayedByParentModel()
bool _daugsDecayedByParentModel
int getId() const
Definition EvtId.hh:40
static std::string name(EvtId i)
Definition EvtPDL.hh:70
void setSpinDensityBackward(const EvtSpinDensity &rho)
void setSpinDensityForward(const EvtSpinDensity &rho)
void setDecayProb(double p)
EvtId getId() const
EvtParticle * getParent()
const EvtVector4R & getP4() const
int getNDaug() const
EvtParticle * getDaug(int i)
double mass() const
EvtSpinDensity getSpinDensityBackward()
int getChannel() const
EvtSpinDensity getSpinDensityForward()
static bool alwaysRadCorr()
Definition EvtRadCorr.cc:61
static void doRadCorr(EvtParticle *p)
Definition EvtRadCorr.cc:48
static double Flat()
Definition EvtRandom.cc:69
double NormalizedProb(const EvtSpinDensity &d)
void Set(int i, int j, const EvtComplex &rhoij)
void SetDim(int n)