BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtParticleDecayList.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: EvtDecayParm.cc
12//
13// Description: Store decay parameters for one decay.
14//
15// Modification history:
16//
17// RYD April 5, 1997 Module created
18//
19//------------------------------------------------------------------------
20//
22#include "EvtPDL.hh"
23#include "EvtParticle.hh"
24#include "EvtPatches.hh"
25#include "EvtRandom.hh"
26#include "EvtReport.hh"
27#include "EvtStatus.hh"
28#include <ctype.h>
29#include <fstream>
30#include <iostream>
31#include <stdlib.h>
32using std::endl;
33using std::fstream;
34
36 _nmode = o._nmode;
37 _rawbrfrsum = o._rawbrfrsum;
38 _decaylist = new EvtParticleDecayPtr[_nmode];
39
40 int i;
41 for ( i = 0; i < _nmode; i++ )
42 {
43 _decaylist[i] = new EvtParticleDecay;
44
45 EvtDecayBase* tModel = o._decaylist[i]->getDecayModel();
46
47 EvtDecayBase* tModelNew = tModel->clone();
48 if ( tModel->getPHOTOS() ) { tModelNew->setPHOTOS(); }
49 if ( tModel->verbose() ) { tModelNew->setVerbose(); }
50 if ( tModel->summary() ) { tModelNew->setSummary(); }
51 std::vector<std::string> args;
52 int j;
53 for ( j = 0; j < tModel->getNArg(); j++ ) { args.push_back( tModel->getArgStr( j ) ); }
54 tModelNew->saveDecayInfo( tModel->getParentId(), tModel->getNDaug(), tModel->getDaugs(),
55 tModel->getNArg(), args, tModel->getModelName(),
56 tModel->getBranchingFraction() );
57 _decaylist[i]->setDecayModel( tModelNew );
58
59 //_decaylist[i]->setDecayModel(tModel);
60 _decaylist[i]->setBrfrSum( o._decaylist[i]->getBrfrSum() );
61 _decaylist[i]->setMassMin( o._decaylist[i]->getMassMin() );
62 }
63}
64
66
67 int i;
68 for ( i = 0; i < _nmode; i++ ) { delete _decaylist[i]; }
69
70 if ( _decaylist != 0 ) delete[] _decaylist;
71}
72
74
75 int i;
76 for ( i = 0; i < _nmode; i++ ) { _decaylist[i]->printSummary(); }
77}
78
80
81 int i;
82 for ( i = 0; i < _nmode; i++ ) { delete _decaylist[i]; }
83
84 delete[] _decaylist;
85 _decaylist = 0;
86 _nmode = 0;
87 _rawbrfrsum = 0.0;
88}
89
91
92 if ( p->getNDaug() != 0 )
93 {
94 assert( p->getChannel() >= 0 );
95 return getDecay( p->getChannel() ).getDecayModel();
96 }
97 if ( p->getChannel() > ( -1 ) ) { return getDecay( p->getChannel() ).getDecayModel(); }
98
99 if ( getNMode() == 0 ) { return 0; }
100 if ( getRawBrfrSum() < 0.00000001 ) { return 0; }
101
102 if ( getNMode() == 1 )
103 {
104 p->setChannel( 0 );
105 return getDecay( 0 ).getDecayModel();
106 }
107
108 if ( p->getChannel() > ( -1 ) )
109 {
110 report( ERROR, "EvtGen" ) << "Internal error!!!" << endl;
111 ::abort();
112 }
113
114 int j;
115
116 for ( j = 0; j < 1000; j++ )
117 {
118
119 double u = EvtRandom::Flat();
120
121 int i;
122 bool breakL = false;
123 for ( i = 0; i < getNMode(); i++ )
124 {
125
126 if ( breakL ) continue;
127 if ( u < getDecay( i ).getBrfrSum() )
128 {
129 breakL = true;
130 // special case for decay of on particel to another
131 // e.g. K0->K0S
132
133 if ( getDecay( i ).getDecayModel()->getNDaug() == 1 )
134 {
135 p->setChannel( i );
136 return getDecay( i ).getDecayModel();
137 }
138
139 if ( p->hasValidP4() )
140 {
141 // report(INFO,"EvtGen") << "amazing " << EvtPDL::name(p->getId()) << " " <<
142 // getDecay(i).getMassMin() << " "<<p->mass() << " " << i << endl;
143 if ( getDecay( i ).getMassMin() < p->mass() )
144 {
145 p->setChannel( i );
146 return getDecay( i ).getDecayModel();
147 }
148 }
149 else
150 {
151 // Lange apr29-2002 - dont know the mass yet
152 p->setChannel( i );
153 return getDecay( i ).getDecayModel();
154 }
155 }
156 }
157 }
158
159 // Ok, we tried 1000 times above to pick a decay channel that is
160 // kinematically allowed! Now we give up and search all channels!
161 // if that fails, the particle will not be decayed!
162
163 int i;
164
165 for ( i = 0; i < getNMode(); i++ )
166 {
167
168 if ( getDecay( i ).getMassMin() < p->mass() ) { return getDecay( i ).getDecayModel(); }
169 }
170
171 report( ERROR, "EvtGen" ) << "Could not decay:" << EvtPDL::name( p->getId() ).c_str()
172 << " with mass:" << p->mass() << " will throw event away! "
173 << endl;
174
175 // report(ERROR,"EvtGen") << "Will terminate execution."<<endl;
176
177 // ::abort();
179 return 0;
180}
181
183
184 EvtParticleDecayPtr* _decaylist_new = new EvtParticleDecayPtr[nmode];
185
186 if ( _nmode != 0 )
187 {
188 report( ERROR, "EvtGen" ) << "Error _nmode not equal to zero!!!" << endl;
189 ::abort();
190 delete[] _decaylist;
191 }
192 _decaylist = _decaylist_new;
193 _nmode = nmode;
194}
195
197 if ( nchannel >= _nmode )
198 {
199 report( ERROR, "EvtGen" ) << "Error getting channel:" << nchannel << " with only "
200 << _nmode << " stored!" << endl;
201 ::abort();
202 }
203 return *( _decaylist[nchannel] );
204}
205
207
208 _rawbrfrsum = conjDecayList->_rawbrfrsum;
209
210 setNMode( conjDecayList->_nmode );
211
212 int i;
213
214 for ( i = 0; i < _nmode; i++ )
215 {
216 _decaylist[i] = new EvtParticleDecay;
217 _decaylist[i]->chargeConj( conjDecayList->_decaylist[i] );
218 }
219}
220
221void EvtParticleDecayList::addMode( EvtDecayBase* decay, double brfrsum, double massmin ) {
222
223 EvtParticleDecayPtr* newlist = new EvtParticleDecayPtr[_nmode + 1];
224
225 int i;
226 for ( i = 0; i < _nmode; i++ ) { newlist[i] = _decaylist[i]; }
227
228 _rawbrfrsum = brfrsum;
229
230 newlist[_nmode] = new EvtParticleDecay;
231
232 newlist[_nmode]->setDecayModel( decay );
233 newlist[_nmode]->setBrfrSum( brfrsum );
234 newlist[_nmode]->setMassMin( massmin );
235
236 EvtDecayBase* newDec = newlist[_nmode]->getDecayModel();
237 for ( i = 0; i < _nmode; i++ )
238 {
239 if ( newDec->matchingDecay( *( newlist[i]->getDecayModel() ) ) )
240 {
241
242 // sometimes its ok..
243 if ( newDec->getModelName() == "JETSET" || newDec->getModelName() == "PYTHIA" ) continue;
244 if ( newDec->getModelName() == "JSCONT" || newDec->getModelName() == "PYCONT" ) continue;
245 if ( newDec->getModelName() == "PYGAGA" ) continue;
246 report( ERROR, "EvtGen" ) << "Two matching decays with same parent in decay table\n";
247 report( ERROR, "EvtGen" ) << "Please fix that\n";
248 report( ERROR, "EvtGen" ) << "Parent " << EvtPDL::name( newDec->getParentId() ).c_str()
249 << endl;
250 for ( int j = 0; j < newDec->getNDaug(); j++ )
251 report( ERROR, "EvtGen" )
252 << "Daughter " << EvtPDL::name( newDec->getDaug( j ) ).c_str() << endl;
253 assert( 0 );
254 }
255 }
256
257 if ( _nmode != 0 ) { delete[] _decaylist; }
258
259 _nmode++;
260
261 _decaylist = newlist;
262}
263
265
266 if ( _nmode > 0 )
267 {
268 if ( _rawbrfrsum < 0.000001 )
269 {
270 report( ERROR, "EvtGen" ) << "Please give me a "
271 << "branching fraction sum greater than 0\n";
272 assert( 0 );
273 }
274 if ( fabs( _rawbrfrsum - 1.0 ) > 0.0001 )
275 {
276 report( INFO, "EvtGen" )
277 << "Warning, sum of branching fractions for "
278 << EvtPDL::name( _decaylist[0]->getDecayModel()->getParentId() ).c_str() << " is "
279 << _rawbrfrsum << endl;
280 report( INFO, "EvtGen" ) << "rescaled to one! " << endl;
281 }
282
283 int i;
284
285 for ( i = 0; i < _nmode; i++ )
286 {
287 double brfrsum = _decaylist[i]->getBrfrSum() / _rawbrfrsum;
288 _decaylist[i]->setBrfrSum( brfrsum );
289 }
290 }
291}
293 // here we will delete a decay with the same final state particles
294 // and recalculate the branching fractions for the remaining modes
295 int match = -1;
296 int i;
297 double match_bf;
298
299 for ( i = 0; i < _nmode; i++ )
300 {
301 if ( decay->matchingDecay( *( _decaylist[i]->getDecayModel() ) ) ) { match = i; }
302 }
303
304 if ( match < 0 )
305 {
306 report( ERROR, "EvtGen" ) << " Attempt to remove undefined mode for" << endl
307 << "Parent " << EvtPDL::name( decay->getParentId() ).c_str()
308 << endl
309 << "Daughters: ";
310 for ( int j = 0; j < decay->getNDaug(); j++ )
311 report( ERROR, "" ) << EvtPDL::name( decay->getDaug( j ) ).c_str() << " ";
312 report( ERROR, "" ) << endl;
313 ::abort();
314 }
315
316 if ( match == 0 ) { match_bf = _decaylist[match]->getBrfrSum(); }
317 else
318 { match_bf = ( _decaylist[match]->getBrfrSum() - _decaylist[match - 1]->getBrfrSum() ); }
319
320 double divisor = 1 - match_bf;
321 if ( divisor < 0.000001 && _nmode > 1 )
322 {
323 report( ERROR, "EvtGen" ) << "Removing requested mode leaves "
324 << EvtPDL::name( decay->getParentId() ).c_str()
325 << " with zero sum branching fraction," << endl
326 << "but more than one decay mode remains. Aborting." << endl;
327 ::abort();
328 }
329
330 EvtParticleDecayPtr* newlist = new EvtParticleDecayPtr[_nmode - 1];
331
332 for ( i = 0; i < match; i++ )
333 {
334 newlist[i] = _decaylist[i];
335 newlist[i]->setBrfrSum( newlist[i]->getBrfrSum() / divisor );
336 }
337 for ( i = match + 1; i < _nmode; i++ )
338 {
339 newlist[i - 1] = _decaylist[i];
340 newlist[i - 1]->setBrfrSum( ( newlist[i - 1]->getBrfrSum() - match_bf ) / divisor );
341 }
342
343 delete[] _decaylist;
344
345 _nmode--;
346
347 _decaylist = newlist;
348
349 if ( _nmode == 0 ) { delete[] _decaylist; }
350}
EvtParticleDecay * EvtParticleDecayPtr
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
@ INFO
Definition EvtReport.hh:52
virtual EvtDecayBase * clone()=0
virtual bool matchingDecay(const EvtDecayBase &other) const
std::string getModelName()
EvtId getParentId()
void saveDecayInfo(EvtId ipar, int ndaug, EvtId *daug, int narg, std::vector< std::string > &args, std::string name, double brfr)
double getBranchingFraction()
EvtId * getDaugs()
void setSummary()
EvtId getDaug(int i)
void setVerbose()
std::string getArgStr(int j)
static std::string name(EvtId i)
Definition EvtPDL.hh:70
void removeMode(EvtDecayBase *decay)
EvtDecayBase * getDecayModel(EvtParticle *p)
void makeChargeConj(EvtParticleDecayList *conjDecayList)
void addMode(EvtDecayBase *decay, double brfr, double massmin)
EvtParticleDecay & getDecay(int nchannel)
void setDecayModel(EvtDecayBase *decay)
EvtDecayBase * getDecayModel()
void setMassMin(double massmin)
void chargeConj(EvtParticleDecay *decay)
void setBrfrSum(double brfrsum)
EvtId getId() const
bool hasValidP4()
void setChannel(int i)
int getNDaug() const
double mass() const
int getChannel() const
static double Flat()
Definition EvtRandom.cc:69
static void setRejectFlag()
Definition EvtStatus.hh:36