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