BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtParticle.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: EvtParticle.cc
12//
13// Description: Class to describe all particles
14//
15// Modification history:
16//
17// DJL/RYD September 25, 1996 Module created
18//
19//------------------------------------------------------------------------
20//
22#include <iostream>
23#include <math.h>
24#include <fstream>
25#include <stdio.h>
26#include <stdlib.h>
27#include <sys/stat.h>
28#include <strstream>
30#include "EvtGenBase/EvtId.hh"
33#include "EvtGenBase/EvtPDL.hh"
40#include "EvtGenBase/EvtRaritaSchwingerParticle.hh" //Pingrg 2007.3.15
50
51using std::endl;
52using std::fstream;
53using std::strstream;
54
56 delete _decayProb;
57}
58
60 _ndaug=0;
61 _parent=0;
62 _channel=-10;
63 _t=0.0;
64 _genlifetime=1;
65 _first=1;
66 _isInit=false;
67 _validP4=false;
68 _isDecayed=false;
69 _decayProb=0;
70 // _mix=false;
71}
72
74 _first=0;
75}
77 _first=1;
78}
79
81 _channel=i;
82}
83
84EvtParticle *EvtParticle::getDaug(int i) { return _daug[i]; }
85
87
88void EvtParticle::setLifetime(double tau){
89 _t=tau;
90}
91
93 if (_genlifetime){
95 }
96}
97
99
100 return _t;
101}
102
104 node->_daug[node->_ndaug++]=this;
105 _ndaug=0;
106 _parent=node;
107}
108
109
110int EvtParticle::firstornot() const { return _first;}
111
112EvtId EvtParticle::getId() const { return _id;}
113
116
119
120const EvtVector4R& EvtParticle::getP4() const { return _p;}
121
122int EvtParticle::getChannel() const { return _channel;}
123
124int EvtParticle::getNDaug() const { return _ndaug;}
125
126double EvtParticle::mass() const {
127
128 return _p.mass();
129}
130
131
133
134 _rhoForward.SetDiag(getSpinStates());
135}
136
138
139 if (getSpinStates()!=3) {
140 report(ERROR,"EvtGen")<<"Error in EvtParticle::setVectorSpinDensity"<<endl;
141 report(ERROR,"EvtGen")<<"spin_states:"<<getSpinStates()<<endl;
142 report(ERROR,"EvtGen")<<"particle:"<<EvtPDL::name(_id).c_str()<<endl;
143 ::abort();
144 }
145
146 EvtSpinDensity rho;
147
148 //Set helicity +1 and -1 to 1.
149 rho.SetDiag(getSpinStates());
150 rho.Set(1,1,EvtComplex(0.0,0.0));
152
153}
154
155
156void EvtParticle::setPolarizedSpinDensity(double r00,double r11,double r22){
157
158 if (getSpinStates()!=3) {
159 report(ERROR,"EvtGen")<<"Error in EvtParticle::setVectorSpinDensity"<<endl;
160 report(ERROR,"EvtGen")<<"spin_states:"<<getSpinStates()<<endl;
161 report(ERROR,"EvtGen")<<"particle:"<<EvtPDL::name(_id).c_str()<<endl;
162 ::abort();
163 }
164
165 EvtSpinDensity rho;
166
167 //Set helicity +1 and -1 to 1.
168 rho.SetDiag(getSpinStates());
169 rho.Set(0,0,EvtComplex(r00,0.));
170 rho.Set(1,1,EvtComplex(r11,0.));
171 rho.Set(2,2,EvtComplex(r22,0.));
173
174}
175
176
178
180
181 assert(R.GetDim()==rho.GetDim());
182
183 int n=rho.GetDim();
184
185 _rhoForward.SetDim(n);
186
187 int i,j,k,l;
188
189 for(i=0;i<n;i++){
190 for(j=0;j<n;j++){
191 EvtComplex tmp=0.0;
192 for(k=0;k<n;k++){
193 for(l=0;l<n;l++){
194 tmp+=R.Get(l,i)*rho.Get(l,k)*conj(R.Get(k,j));
195 }
196 }
197 _rhoForward.Set(i,j,tmp);
198 }
199 }
200
201 //report(INFO,"EvtGen") << "_rhoForward:"<<_rhoForward<<endl;
202
203}
204
206 double alpha,
207 double beta,
208 double gamma){
209
211
212 assert(R.GetDim()==rho.GetDim());
213
214 int n=rho.GetDim();
215
216 _rhoForward.SetDim(n);
217
218 int i,j,k,l;
219
220 for(i=0;i<n;i++){
221 for(j=0;j<n;j++){
222 EvtComplex tmp=0.0;
223 for(k=0;k<n;k++){
224 for(l=0;l<n;l++){
225 tmp+=R.Get(l,i)*rho.Get(l,k)*conj(R.Get(k,j));
226 }
227 }
228 _rhoForward.Set(i,j,tmp);
229 }
230 }
231
232 //report(INFO,"EvtGen") << "_rhoForward:"<<_rhoForward<<endl;
233
234}
235
236void EvtParticle::initDecay(bool useMinMass) {
237
238 EvtParticle* p=this;
239 // carefull - the parent mass might be fixed in stone..
240 EvtParticle* par=p->getParent();
241 double parMass=-1.;
242 if ( par != 0 ) {
243 if ( par->hasValidP4() ) parMass=par->mass();
244 int i;
245 for ( i=0;i<par->getNDaug();i++) {
246 EvtParticle *tDaug=par->getDaug(i);
247 if ( p != tDaug )
248 parMass-=EvtPDL::getMinMass(tDaug->getId());
249 }
250 }
251
252 if ( _isInit ) {
253 //we have already been here - just reroll the masses!
254 if ( _ndaug>0) {
255 int ii;
256 for(ii=0;ii<_ndaug;ii++){
257 if ( _ndaug==1 || EvtPDL::getWidth(p->getDaug(ii)->getId()) > 0.0000001)
258 p->getDaug(ii)->initDecay(useMinMass);
259 else p->getDaug(ii)->setMass(EvtPDL::getMeanMass(p->getDaug(ii)->getId()));
260 }
261 }
262
263 int j;
264 EvtId *dauId=0;
265 double *dauMasses=0;
266 if ( _ndaug > 0) {
267 dauId=new EvtId[_ndaug];
268 dauMasses=new double[_ndaug];
269 for (j=0;j<_ndaug;j++) {
270 dauId[j]=p->getDaug(j)->getId();
271 dauMasses[j]=p->getDaug(j)->mass();
272 }
273 }
274 EvtId *parId=0;
275 EvtId *othDauId=0;
276 EvtParticle *tempPar=p->getParent();
277 if (tempPar) {
278 parId=new EvtId(tempPar->getId());
279 if ( tempPar->getNDaug()==2 ) {
280 if ( tempPar->getDaug(0) == this ) othDauId=new EvtId(tempPar->getDaug(1)->getId());
281 else othDauId=new EvtId(tempPar->getDaug(0)->getId());
282 }
283 }
284 if ( p->getParent() && _validP4==false ) {
285 if ( !useMinMass ) p->setMass(EvtPDL::getRandMass(p->getId(),parId,_ndaug,dauId,othDauId,parMass,dauMasses));
286 else p->setMass(EvtPDL::getMinMass(p->getId()));
287 }
288 if ( parId) delete parId;
289 if ( othDauId) delete othDauId;
290 if ( dauId) delete [] dauId;
291 if ( dauMasses) delete [] dauMasses;
292 return;
293 }
294
295
296 //Will include effects of mixing here
297 //added by Lange Jan4,2000
298 static EvtId BS0=EvtPDL::getId("B_s0");
299 static EvtId BSB=EvtPDL::getId("anti-B_s0");
300 static EvtId BD0=EvtPDL::getId("B0");
301 static EvtId BDB=EvtPDL::getId("anti-B0");
302
303 //only makes sense if there is no parent particle
304 if ( (getNDaug()==0 && getParent()==0) && (getId()==BS0||getId()==BSB||getId()==BD0||getId()==BDB)){
305 double t;
306 int mix;
308 setLifetime(t);
309
310 if (mix) {
311
312 EvtScalarParticle* scalar_part;
313
314 scalar_part=new EvtScalarParticle;
315 if (getId()==BS0) {
316 EvtVector4R p_init(EvtPDL::getMass(BSB),0.0,0.0,0.0);
317 scalar_part->init(BSB,p_init);
318 }
319 else if (getId()==BSB) {
320 EvtVector4R p_init(EvtPDL::getMass(BS0),0.0,0.0,0.0);
321 scalar_part->init(BS0,p_init);
322 }
323 else if (getId()==BD0) {
324 EvtVector4R p_init(EvtPDL::getMass(BDB),0.0,0.0,0.0);
325 scalar_part->init(BDB,p_init);
326 }
327 else if (getId()==BDB) {
328 EvtVector4R p_init(EvtPDL::getMass(BD0),0.0,0.0,0.0);
329 scalar_part->init(BD0,p_init);
330 }
331
332 scalar_part->setLifetime(0);
333
334 scalar_part->setDiagonalSpinDensity();
335
336 insertDaugPtr(0,scalar_part);
337
338 _ndaug=1;
339 _isInit=true;
340 p=scalar_part;
341 p->initDecay(useMinMass);
342 return;
343
344
345 }
346 }
347 if ( _ndaug==1 ) std::cout << "hi " << EvtPDL::name(this->getId()) << std::endl;
348
349 EvtDecayBase *decayer;
350 decayer = EvtDecayTable::getDecayFunc(p);
351
352 if ( decayer ) {
353 p->makeDaughters(decayer->nRealDaughters(),decayer->getDaugs());
354 // report(INFO,"EvtGen") << "has found decay " << decayer->nRealDaughters() << endl;
355 //then loop over the daughters and init their decay
356 int i;
357 for(i=0;i<p->getNDaug();i++){
358 if ( EvtPDL::getWidth(p->getDaug(i)->getId()) > 0.0000001)
359 p->getDaug(i)->initDecay(useMinMass);
360 else p->getDaug(i)->setMass(EvtPDL::getMeanMass(p->getDaug(i)->getId()));
361 // report(INFO,"EvtGen") << "has inited " << EvtPDL::name(p->getDaug(i)->getId()) <<
362 // " " << EvtPDL::name(p->getId()) << endl;
363 }
364 }
365 //figure masses in separate step...
366 // if ( p->getParent() && _validP4==false ) EvtDecayBase::findMass(p);
367
368 int j;
369 EvtId *dauId=0;
370 double *dauMasses=0;
371 int nDaugT=p->getNDaug();
372 if ( nDaugT > 0) {
373 dauId=new EvtId[nDaugT];
374 dauMasses=new double[nDaugT];
375 for (j=0;j<nDaugT;j++) {
376 dauId[j]=p->getDaug(j)->getId();
377 dauMasses[j]=p->getDaug(j)->mass();
378 }
379 }
380
381 EvtId *parId=0;
382 EvtId *othDauId=0;
383 EvtParticle *tempPar=p->getParent();
384 if (tempPar) {
385 parId=new EvtId(tempPar->getId());
386 if ( tempPar->getNDaug()==2 ) {
387 if ( tempPar->getDaug(0) == this ) othDauId=new EvtId(tempPar->getDaug(1)->getId());
388 else othDauId=new EvtId(tempPar->getDaug(0)->getId());
389 }
390 }
391 if ( p->getParent() && p->hasValidP4()==false ) {
392 if ( !useMinMass ) p->setMass(EvtPDL::getRandMass(p->getId(),parId,p->getNDaug(),dauId,othDauId,parMass,dauMasses));
393 else p->setMass(EvtPDL::getMinMass(p->getId()));
394 }
395 if ( parId) delete parId;
396 if ( othDauId) delete othDauId;
397 if ( dauId) delete [] dauId;
398 if ( dauMasses) delete [] dauMasses;
399 _isInit=true;
400}
401
402
404
405 //P is particle to decay, typically 'this' but sometime
406 //modified by mixing
407 EvtParticle* p=this;
408 //Did it mix?
409 //if ( p->getMixed() ) {
410 //should take C(p) - this should only
411 //happen the first time we call decay for this
412 //particle
413 //p->takeCConj();
414 // p->setUnMixed();
415 //}
416 EvtSpinDensity myRho; //pingrg test code
417 EvtDecayBase *decayer;
418 decayer = EvtDecayTable::getDecayFunc(p);
419 // if ( decayer ) {
420 // report(INFO,"EvtGen") << "calling decay for " << EvtPDL::name(p->getId()) << " " << p->mass() << " " << p->getP4() << " " << p->getNDaug() << " " << p << endl;
421 // report(INFO,"EvtGen") << "NDaug= " << decayer->getNDaug() << endl;
422 // int ti;
423 // for ( ti=0; ti<decayer->getNDaug(); ti++)
424 // report(INFO,"EvtGen") << "Daug " << ti << " " << EvtPDL::name(decayer->getDaug(ti)) << endl;
425 // }
426 //if (p->_ndaug>0) {
427 // report(INFO,"EvtGen") <<"Is decaying particle with daughters!!!!!"<<endl;
428 // ::abort();
429 //return;
430 //call initdecay first - April 29,2002 - Lange
431 //}
432
433 //if there are already daughters, then this step is already done!
434 // figure out the masses
435 if ( _ndaug == 0 ) generateMassTree();
436 static EvtId BS0=EvtPDL::getId("B_s0");
437 static EvtId BSB=EvtPDL::getId("anti-B_s0");
438 static EvtId BD0=EvtPDL::getId("B0");
439 static EvtId BDB=EvtPDL::getId("anti-B0");
440 if ( _ndaug==1 && (getId()==BS0||getId()==BSB||getId()==BD0||getId()==BDB) )
441 {getDaug(0)->decay();
442 std::cout<<"if ( _ndaug==1 && (getId()==BS0||getId()==BSB||getId()==BD0||getId()==BDB) )"<<endl;
443 }
444
445 else{
446 //now we have accepted a set of masses - time
447 if ( decayer ) {
448 decayer->makeDecay(p);
449 //p->printTree(); //for debugging
450 }
451 else{
452 p->_rhoBackward.SetDiag(p->getSpinStates());
453
454 }
455 }
456 _isDecayed=true;
457 return;
458}
459
461 double massProb=1.;
462 double ranNum=2.;
463 int counter=0;
464 EvtParticle *p=this;
465 while (massProb<ranNum) {
466 //check it out the first time.
467 p->initDecay();
468 //report(INFO,"EvtGen") << "calling massProb \n";
469 massProb=p->compMassProb();
470 ranNum=EvtRandom::Flat();
471 // report(INFO,"EvtGen") << "end of iter " << massProb <<endl;
472 counter++;
473
474 if ( counter > 10000 ) {
475 if ( counter == 10001 ) {
476 report(INFO,"EvtGen") << "Too many iterations to determine the mass tree. Parent mass= "<< p->mass() << _p<<" " << massProb <<endl;
477 p->printTree();
478 report(INFO,"EvtGen") << "will take next combo with non-zero likelihood\n";
479 }
480 if ( massProb>0. ) massProb=2.0;
481 if ( counter > 20000 ) {
482 // one last try - take the minimum masses
483 p->initDecay(true);
484 p->printTree();
485 massProb=p->compMassProb();
486 if ( massProb>0. ) {
487 massProb=2.0;
488 report(INFO,"EvtGen") << "Taking the minimum mass of all particles in the chain\n";
489 }
490 else {
491 report(INFO,"EvtGen") << "Sorry, no luck finding a valid set of masses. This may be a pathological combo\n";
492 std::cout<<EvtPDL::name(p->getId())<<": Parent mass "<<p->getP4().mass()<<" with momentum "<<p->getP4()<<std::endl;
493 if(EvtGlobalSet::ConExcPythia){EvtGlobalSet::ConExcPythia=0;return;}else{abort();}
494 //assert(0);
495 }
496 }
497 }
498 }
499 // report(INFO,"EvtGen") << counter << endl;
500 // p->printTree();
501}
502
504
505 EvtParticle *p=this;
506 //report(INFO,"EvtGen") << "compMassProb " << endl;
507 //p->printTree();
508 double mass=p->mass();
509 double parMass=0.;
510 if ( p->getParent()) {
511 parMass=p->getParent()->mass();
512 }
513
514 int nDaug=p->getNDaug();
515 double *dMasses=0;
516
517 int i;
518 if ( nDaug>0 ) {
519 dMasses=new double[nDaug];
520 for (i=0; i<nDaug; i++) dMasses[i]=p->getDaug(i)->mass();
521 }
522
523 double temp=1.0;
524 temp=EvtPDL::getMassProb(p->getId(), mass, parMass, nDaug, dMasses);
525
526 //report(INFO,"EvtGen") << temp << " " << EvtPDL::name(p->getId()) << endl;
527 //If the particle already has a mass, we dont need to include
528 //it in the probability calculation
529 if ( (!p->getParent() || _validP4 ) && temp>0.0 ) temp=1.;
530
531 delete [] dMasses;
532 // if ( temp < 0.9999999 )
533 for (i=0; i<nDaug; i++) {
534 temp*=p->getDaug(i)->compMassProb();
535 }
536 return temp;
537}
538
539void EvtParticle::deleteDaughters(bool keepChannel){
540 int i;
541
542 for(i=0;i<_ndaug;i++){
543 _daug[i]->deleteTree();
544 }
545
546 _ndaug=0;
547 //if ( keepChannel ) report(INFO,"EvtGen") << "keeping \n";
548 if ( !keepChannel) _channel=-10;
549 //_t=0.0;
550 //_genlifetime=1;
551 _first=1;
552 _isInit=false;
553 //report(INFO,"EvtGen") << "calling deletedaughters " << EvtPDL::name(this->getId()) <<endl;
554}
555
557
558 this->deleteDaughters();
559
560 delete this;
561
562}
563
565 EvtVector4C temp;
567 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
568 <<"th polarization vector."
569 <<" I.e. you thought it was a"
570 <<" vector particle!" << endl;
571 ::abort();
572 return temp;
573}
574
576 EvtVector4C temp;
578 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
579 <<"th polarization vector."
580 <<" I.e. you thought it was a"
581 <<" vector particle!" << endl;
582 ::abort();
583 return temp;
584}
585
587 EvtVector4C temp;
589 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
590 <<"th polarization vector of photon."
591 <<" I.e. you thought it was a"
592 <<" photon particle!" << endl;
593 ::abort();
594 return temp;
595}
596
598 EvtVector4C temp;
600 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
601 <<"th polarization vector of a photon."
602 <<" I.e. you thought it was a"
603 <<" photon particle!" << endl;
604 ::abort();
605 return temp;
606}
607
609 EvtDiracSpinor tempD;
610 int temp;
611 temp = i;
613 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
614 <<"th dirac spinor."
615 <<" I.e. you thought it was a"
616 <<" Dirac particle!" << endl;
617 ::abort();
618 return tempD;
619}
620
622 EvtDiracSpinor tempD;
623 int temp;
624 temp = i;
626 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
627 <<"th dirac spinor."
628 <<" I.e. you thought it was a"
629 <<" Dirac particle!" << endl;
630 ::abort();
631 return tempD;
632}
633
635 EvtDiracSpinor tempD;
637 report(ERROR,"EvtGen") << "and you have asked for the "
638 <<"dirac spinor."
639 <<" I.e. you thought it was a"
640 <<" neutrino particle!" << endl;
641 ::abort();
642 return tempD;
643}
644
646 EvtDiracSpinor tempD;
648 report(ERROR,"EvtGen") << "and you have asked for the "
649 <<"dirac spinor."
650 <<" I.e. you thought it was a"
651 <<" neutrino particle!" << endl;
652 ::abort();
653 return tempD;
654}
655
657 int temp;
658 temp = i;
659 EvtTensor4C tempC;
661 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
662 <<"th tensor."
663 <<" I.e. you thought it was a"
664 <<" Tensor particle!" << endl;
665 ::abort();
666 return tempC;
667}
668
670 int temp;
671 temp = i;
672 EvtTensor4C tempC;
674 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
675 <<"th tensor."
676 <<" I.e. you thought it was a"
677 <<" Tensor particle!" << endl;
678 ::abort();
679 return tempC;
680}
681
682
683
685 EvtVector4R temp,mom;
686 EvtParticle *ptemp;
687
688 temp=this->getP4();
689 ptemp=this;
690
691 while (ptemp->getParent()!=0) {
692 ptemp=ptemp->getParent();
693 mom=ptemp->getP4();
694 temp=boostTo(temp,mom);
695 }
696 return temp;
697}
698
700
701 return EvtVector4R(mass(),0.0,0.0,0.0);
702
703}
704
706
707 EvtVector4R temp,mom;
708 EvtParticle *ptemp;
709
710 temp.set(0.0,0.0,0.0,0.0);
711 ptemp=getParent();
712
713 if (ptemp==0) return temp;
714
715 temp=(ptemp->_t/ptemp->mass())*(ptemp->getP4());
716
717 while (ptemp->getParent()!=0) {
718 ptemp=ptemp->getParent();
719 mom=ptemp->getP4();
720 temp=boostTo(temp,mom);
721 temp=temp+(ptemp->_t/ptemp->mass())*(ptemp->getP4());
722 }
723
724 return temp;
725}
726
727
729
730 EvtParticle *bpart;
731 EvtParticle *current;
732
733 current=this;
734 int i;
735
736 if (_ndaug!=0) return _daug[0];
737
738 do{
739 bpart=current->_parent;
740 if (bpart==0) return 0;
741 i=0;
742 while (bpart->_daug[i]!=current) {i++;}
743
744 if ( bpart==rootOfTree ) {
745 if ( i== bpart->_ndaug-1 ) return 0;
746 }
747
748 i++;
749 current=bpart;
750
751 }while(i>=bpart->_ndaug);
752
753 return bpart->_daug[i];
754
755}
756
757
759 EvtId *list_of_stable){
760
761 //first add particle to the stdhep list;
762 stdhep.createParticle(getP4Lab(),get4Pos(),-1,-1,
764
765 int ii=0;
766
767 //lets see if this is a longlived particle and terminate the
768 //list building!
769
770 while (list_of_stable[ii]!=EvtId(-1,-1)) {
771 if (getId()==list_of_stable[ii]){
772 secondary.createSecondary(0,this);
773 return;
774 }
775 ii++;
776 }
777
778
779
780
781 int i;
782 for(i=0;i<_ndaug;i++){
783 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),0,0,
784 EvtPDL::getStdHep(_daug[i]->getId()));
785 }
786
787 for(i=0;i<_ndaug;i++){
788 _daug[i]->makeStdHepRec(1+i,1+i,stdhep,secondary,list_of_stable);
789 }
790 return;
791
792}
793
795
796 //first add particle to the stdhep list;
797 stdhep.createParticle(getP4Lab(),get4Pos(),-1,-1,
799
800 int i;
801 for(i=0;i<_ndaug;i++){
802 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),0,0,
803 EvtPDL::getStdHep(_daug[i]->getId()));
804 }
805
806 for(i=0;i<_ndaug;i++){
807 _daug[i]->makeStdHepRec(1+i,1+i,stdhep);
808 }
809 return;
810
811}
812
813
814void EvtParticle::makeStdHepRec(int firstparent,int lastparent,
815 EvtStdHep& stdhep,
816 EvtSecondary& secondary,
817 EvtId *list_of_stable){
818
819
820 int ii=0;
821
822 //lets see if this is a longlived particle and terminate the
823 //list building!
824
825 while (list_of_stable[ii]!=EvtId(-1,-1)) {
826 if (getId()==list_of_stable[ii]){
827 secondary.createSecondary(firstparent,this);
828 return;
829 }
830 ii++;
831 }
832
833
834
835 int i;
836 int parent_num=stdhep.getNPart();
837 for(i=0;i<_ndaug;i++){
838 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),
839 firstparent,lastparent,
840 EvtPDL::getStdHep(_daug[i]->getId()));
841 }
842
843 for(i=0;i<_ndaug;i++){
844 _daug[i]->makeStdHepRec(parent_num+i,parent_num+i,stdhep,
845 secondary,list_of_stable);
846 }
847 return;
848
849}
850
851void EvtParticle::makeStdHepRec(int firstparent,int lastparent,
852 EvtStdHep& stdhep){
853
854 int i;
855 int parent_num=stdhep.getNPart();
856 for(i=0;i<_ndaug;i++){
857 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),
858 firstparent,lastparent,
859 EvtPDL::getStdHep(_daug[i]->getId()));
860 }
861
862 for(i=0;i<_ndaug;i++){
863 _daug[i]->makeStdHepRec(parent_num+i,parent_num+i,stdhep);
864 }
865 return;
866
867}
868
869void EvtParticle::printTreeRec(int level) const {
870
871 int newlevel,i;
872 newlevel = level +1;
873
874
875 if (_ndaug!=0) {
876 if ( level > 0 ) {
877 for (i=0;i<(5*level);i++) {
878 report(INFO,"") <<" ";
879 }
880 }
881 report(INFO,"") << EvtPDL::name(_id).c_str();
882 report(INFO,"") << " -> ";
883 for(i=0;i<_ndaug;i++){
884 report(INFO,"") << EvtPDL::name(_daug[i]->getId()).c_str()<<" ";
885 }
886 for(i=0;i<_ndaug;i++){
887 report(INFO,"") << _daug[i]->mass()<<" ";
888 }
889 report(INFO,"")<<endl;
890 for(i=0;i<_ndaug;i++){
891 _daug[i]->printTreeRec(newlevel);
892 }
893 }
894}
895
897
898 report(INFO,"EvtGen") << "This is the current decay chain"<<endl;
899 report(INFO,"") << "This top particle is "<<
900 EvtPDL::name(_id).c_str()<<endl;
901
902 this->printTreeRec(0);
903 report(INFO,"EvtGen") << "End of decay chain."<<endl;
904
905}
906
907std::string EvtParticle::treeStrRec(int level) const {
908
909 int newlevel,i;
910 newlevel = level +1;
911
912 std::string retval="";
913
914 for(i=0;i<_ndaug;i++){
915 retval+=EvtPDL::name(_daug[i]->getId());
916 if ( _daug[i]->getNDaug() > 0 ) {
917 retval+= " (";
918 retval+= _daug[i]->treeStrRec(newlevel);
919 retval+= ") ";
920 }
921 else{
922 if ( i!=_ndaug-1) retval+=" ";
923 }
924 }
925
926 return retval;
927}
928
929std::string EvtParticle::writeTreeRec(std::string resonance) const { //pingrg, Jun. 6, 2008
930 std::string retval="";
931
932 if (resonance == EvtPDL::name(_id).c_str() && _ndaug!=0) {
933 retval=resonance+": "+IntToStr(_ndaug)+" ";
934 for(int i=0;i<_ndaug;i++){
935 retval += EvtPDL::name(_daug[i]->getId()).c_str();
936 retval += " ";
937 }
938 }
939
940 for(int i=0;i<_ndaug;i++){
941 _daug[i]->writeTreeRec(resonance);
942 }
943 std::cout<<retval;
944 return retval;
945}
946
947void EvtParticle::dumpTreeRec(int level,int dj) const { //pingrg, Mar. 25,2008
948
949 int newlevel,i;
950 newlevel = level +1;
951
952
953 if (_ndaug!=0) {
954
955 int Ids= EvtPDL::getStdHep(_id);
956 std::string c1,cid;
957 if(Ids>0) c1="p";
958 if(Ids<0) {
959 c1="m";Ids=-1*Ids;
960 }
961
962 cid=c1+IntToStr(Ids);
963
964 report(INFO,"") <<newlevel<<" "<< cid<<" "<<dj;
965 report(INFO,"") << " = ";
966
967 int Nchannel=this->getChannel()+1;
968 report(INFO,"") <<Nchannel<<endl;
969
970 for(i=0;i<_ndaug;i++){
971 _daug[i]->dumpTreeRec(newlevel,i);
972 }
973 }
974}
975
976
977void EvtParticle::dumpTree() const { //pingrg, Mar. 25,2008
978
979 report(INFO,"EvtGen") << "This is the current decay chain to dump"<<endl;
980 report(INFO,"") << "This top particle is "<<
981 EvtPDL::name(_id).c_str()<<endl;
982
983 this->dumpTreeRec(0,0);
984 report(INFO,"EvtGen") << "End of decay chain."<<endl;
985
986}
987
988
989std::string EvtParticle::treeStr() const {
990
991 std::string retval=EvtPDL::name(_id);
992 retval+=" -> ";
993
994 retval+=treeStrRec(0);
995
996 return retval;
997}
998
1000
1001 switch (EvtPDL::getSpinType(_id)){
1003 report(INFO,"EvtGen") << "This is a scalar particle:"<<EvtPDL::name(_id).c_str()<<"\n";
1004 break;
1006 report(INFO,"EvtGen") << "This is a vector particle:"<<EvtPDL::name(_id).c_str()<<"\n";
1007 break;
1009 report(INFO,"EvtGen") << "This is a tensor particle:"<<EvtPDL::name(_id).c_str()<<"\n";
1010 break;
1011 case EvtSpinType::DIRAC:
1012 report(INFO,"EvtGen") << "This is a dirac particle:"<<EvtPDL::name(_id).c_str()<<"\n";
1013 break;
1015 report(INFO,"EvtGen") << "This is a photon:"<<EvtPDL::name(_id).c_str()<<"\n";
1016 break;
1018 report(INFO,"EvtGen") << "This is a neutrino:"<<EvtPDL::name(_id).c_str()<<"\n";
1019 break;
1021 report(INFO,"EvtGen") << "This is a raritaschwinger:"<<EvtPDL::name(_id).c_str()<<"\n";
1022 break;
1024 report(INFO,"EvtGen") << "This is a string:"<<EvtPDL::name(_id).c_str()<<"\n";
1025 break;
1026 default:
1027 report(INFO,"EvtGen") <<"Unknown particle type in EvtParticle::printParticle()"<<endl;
1028 break;
1029 }
1030 report(INFO,"EvtGen") << "Number of daughters:"<<_ndaug<<"\n";
1031
1032
1033}
1034
1035
1036
1038 *part = (EvtParticle *) new EvtVectorParticle;
1039}
1040
1041
1043 *part = (EvtParticle *) new EvtScalarParticle;
1044}
1045
1047 *part = (EvtParticle *) new EvtTensorParticle;
1048}
1049
1051 *part = (EvtParticle *) new EvtDiracParticle;
1052}
1053
1055 *part = (EvtParticle *) new EvtPhotonParticle;
1056}
1057
1060}
1061
1063 *part = (EvtParticle *) new EvtNeutrinoParticle;
1064}
1065
1067 *part = (EvtParticle *) new EvtStringParticle;
1068}
1069
1071 int numdaughter,EvtId *daughters, double poleSize,
1072 int whichTwo1, int whichTwo2) {
1073
1074 double m_b;
1075 int i;
1076 //lange
1077 // this->makeDaughters(numdaughter,daughters);
1078
1079 static EvtVector4R p4[100];
1080 static double mass[100];
1081
1082 m_b = this->mass();
1083
1084 //lange - Jan2,2002 - Need to check to see if the daughters of the parent
1085 // have changed. If so, delete them and start over.
1086 //report(INFO,"EvtGen") << "the parent is\n";
1087 //if ( this->getParent() ) {
1088 // if ( this->getParent()->getParent() ) this->getParent()->getParent()->printTree();
1089 // this->getParent()->printTree();
1090 //}
1091 //report(INFO,"EvtGen") << "and this is\n";
1092 //if ( this) this->printTree();
1093 bool resetDaughters=false;
1094 if ( numdaughter != this->getNDaug() && this->getNDaug() > 0 ) resetDaughters=true;
1095 if ( numdaughter == this->getNDaug() )
1096 for (i=0; i<numdaughter;i++) {
1097 if ( this->getDaug(i)->getId() != daughters[i] ) resetDaughters=true;
1098 //report(INFO,"EvtGen") << this->getDaug(i)->getId() << " " << daughters[i] << endl;
1099 }
1100
1101 if ( resetDaughters ) {
1102 // report(INFO,"EvtGen") << "reseting daughters\n";
1103 //for (i=0; i<numdaughter;i++) {
1104 // report(INFO,"EvtGen") << "reset " <<i<< " "<< EvtPDL::name(this->getDaug(i)->getId()) << " " << EvtPDL::name(daughters[i]) << endl;
1105 //}
1106 bool t1=true;
1107 //but keep the decay channel of the parent.
1108 this->deleteDaughters(t1);
1109 this->makeDaughters(numdaughter,daughters);
1110 this->generateMassTree();
1111 }
1112
1113 double weight=0.;
1114 // EvtDecayBase::findMasses( this, numdaughter, daughters, mass );
1115 //get the list of masses
1116 //report(INFO,"EvtGen") << "mpar= " << m_b << " " << this <<endl;
1117 for (i=0; i<numdaughter;i++) {
1118 mass[i]=this->getDaug(i)->mass();
1119 // report(INFO,"EvtGen") << "mass " << i << " " << mass[i] << " " << this->getDaug(i) << endl;
1120 }
1121
1122 if ( poleSize<-0.1) {
1123 EvtGenKine::PhaseSpace( numdaughter, mass, p4, m_b );
1124 for(i=0;i<numdaughter;i++){
1125 this->getDaug(i)->init(daughters[i],p4[i]);
1126 }
1127
1128 }
1129 else {
1130 if ( numdaughter != 3 ) {
1131 report(ERROR,"EvtGen") << "Only can generate pole phase space "
1132 << "distributions for 3 body final states"
1133 << endl<<"Will terminate."<<endl;
1134 ::abort();
1135 }
1136 bool ok=false;
1137 if ( (whichTwo1 == 1 && whichTwo2 == 0 ) ||
1138 (whichTwo1 == 0 && whichTwo2 == 1 ) ) {
1140 poleSize, p4);
1141 //report(INFO,"EvtGen") << "here " << weight << " " << poleSize << endl;
1142 this->getDaug(0)->init(daughters[0],p4[0]);
1143 this->getDaug(1)->init(daughters[1],p4[1]);
1144 this->getDaug(2)->init(daughters[2],p4[2]);
1145 ok=true;
1146 }
1147 if ( (whichTwo1 == 1 && whichTwo2 == 2 ) ||
1148 (whichTwo1 == 2 && whichTwo2 == 1 ) ) {
1150 poleSize, p4);
1151 this->getDaug(0)->init(daughters[0],p4[2]);
1152 this->getDaug(1)->init(daughters[1],p4[1]);
1153 this->getDaug(2)->init(daughters[2],p4[0]);
1154 ok=true;
1155 }
1156 if ( (whichTwo1 == 0 && whichTwo2 == 2 ) ||
1157 (whichTwo1 == 2 && whichTwo2 == 0 ) ) {
1159 poleSize, p4);
1160 this->getDaug(0)->init(daughters[0],p4[1]);
1161 this->getDaug(1)->init(daughters[1],p4[0]);
1162 this->getDaug(2)->init(daughters[2],p4[2]);
1163 ok=true;
1164 }
1165 if ( !ok) {
1166 report(ERROR,"EvtGen") << "Invalid pair of particle to generate a pole dist"
1167 << whichTwo1 << " " << whichTwo2
1168 << endl<<"Will terminate."<<endl;
1169 ::abort();
1170 }
1171 }
1172
1173 return weight;
1174}
1175
1176void EvtParticle::makeDaughters( int ndaugstore, EvtId *id){
1177
1178 int i;
1179 if ( _channel < 0 ) {
1180 //report(INFO,"EvtGen") << "setting channel " << EvtPDL::name(this->getId()) << endl;
1181 setChannel(0);
1182 }
1183 EvtParticle* pdaug;
1184 if (_ndaug!=0 ){
1185 if (_ndaug!=ndaugstore){
1186 report(ERROR,"EvtGen") << "Asking to make a different number of "
1187 << "daughters than what was previously created."
1188 << endl<<"Will terminate."<<endl;
1189 ::abort();
1190 }
1191 }
1192 else{
1193 for(i=0;i<ndaugstore;i++){
1195 pdaug->setId(id[i]);
1196 pdaug->addDaug(this);
1197 }
1198
1199 } //else
1200} //makeDaughters
1201
1202
1203void EvtParticle::setDecayProb(double prob) {
1204
1205 if ( _decayProb == 0 ) _decayProb=new double;
1206 *_decayProb=prob;
1207}
1208
1209// ---------- pingrg;2008-03-24
1210std::string IntToStr( int a)
1211 {
1212 std::string ans;
1213 std::string ans1;
1214 int k = 10 ;
1215 while (a > 0 )
1216 {
1217 ans += char (a % 10 + 48 );
1218 a /= 10 ;
1219 }
1220 for ( int i = ans.size() - 1 ; i >= 0 ; i -- )
1221 {
1222 ans1 += ans[i];
1223 }
1224 return ans1;
1225}
const Int_t n
Evt3Rank3C conj(const Evt3Rank3C &t2)
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void init_photon(EvtParticle **part)
void init_dirac(EvtParticle **part)
void init_neutrino(EvtParticle **part)
std::string IntToStr(int a)
void init_vector(EvtParticle **part)
void init_raritaschinger(EvtParticle **part)
void init_tensor(EvtParticle **part)
void init_scalar(EvtParticle **part)
void init_string(EvtParticle **part)
std::string IntToStr(int a)
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:36
@ ERROR
Definition EvtReport.hh:49
@ INFO
Definition EvtReport.hh:52
const double alpha
*********DOUBLE PRECISION m_pi INTEGER m_lenwt !max no of aux weights INTEGER m_phmax !maximum photon multiplicity ISR FSR *DOUBLE COMPLEX m_Pauli4 DOUBLE COMPLEX m_AmpBorn DOUBLE COMPLEX m_AmpBoxy DOUBLE COMPLEX m_AmpBorn1 DOUBLE COMPLEX m_AmpBorn2 DOUBLE COMPLEX m_AmpExpo2p DOUBLE COMPLEX m_Rmat DOUBLE COMPLEX m_BoxGZut !DOUBLE COMPLEX m_F1finPair2 !DOUBLE PRECISION m_Vcut DOUBLE PRECISION m_Alfinv DOUBLE PRECISION m_Lorin1 DOUBLE PRECISION m_Lorin2 DOUBLE PRECISION m_b
Definition GPS.h:30
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared dimensionless $ !dummy photon IR regulator $ !crude photon multiplicity enhancement factor *EVENT $ !MC crude volume of PhhSpace *Sfactors $ !YFS formfactor IR part only $ !YFS formfactor non IR finite part $ !mass weight
Definition KarFin.h:34
TTree * t
Definition binning.cxx:23
static void incoherentMix(const EvtId id, double &t, int &mix)
Definition EvtCPUtil.cc:294
virtual int nRealDaughters()
virtual void makeDecay(EvtParticle *p)=0
EvtId * getDaugs()
static EvtDecayBase * getDecayFunc(EvtParticle *)
static double PhaseSpacePole(double M, double m1, double m2, double m3, double a, EvtVector4R p4[10])
static double PhaseSpace(int ndaug, double mass[30], EvtVector4R p4[30], double mp)
Definition EvtGenKine.cc:50
static bool ConExcPythia
Definition EvtId.hh:27
static double getWidth(EvtId i)
Definition EvtPDL.hh:54
static int getStdHep(EvtId id)
Definition EvtPDL.hh:56
static double getRandMass(EvtId i, EvtId *parId, int nDaug, EvtId *dauId, EvtId *othDaugId, double maxMass, double *dauMasses)
Definition EvtPDL.hh:47
static double getMeanMass(EvtId i)
Definition EvtPDL.hh:45
static std::string name(EvtId i)
Definition EvtPDL.hh:64
static double getMassProb(EvtId i, double mass, double massPar, int nDaug, double *massDau)
Definition EvtPDL.hh:48
static double getMinMass(EvtId i)
Definition EvtPDL.hh:51
static EvtSpinType::spintype getSpinType(EvtId i)
Definition EvtPDL.hh:61
static double getMass(EvtId i)
Definition EvtPDL.hh:46
static EvtId getId(const std::string &name)
Definition EvtPDL.cc:287
static double getctau(EvtId i)
Definition EvtPDL.hh:55
static EvtParticle * particleFactory(EvtSpinType::spintype spinType)
virtual EvtVector4C epsPhoton(int i)
void setMass(double m)
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
void setDecayProb(double p)
void makeDaughters(int ndaug, EvtId *id)
virtual ~EvtParticle()
virtual EvtVector4C epsParent(int i) const
void initDecay(bool useMinMass=false)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void insertDaugPtr(int idaug, EvtParticle *partptr)
EvtVector4R getP4Lab()
virtual EvtTensor4C epsTensorParent(int i) const
virtual EvtVector4C epsParentPhoton(int i)
void printTreeRec(int level) const
EvtId getId() const
EvtParticle * getParent()
virtual EvtDiracSpinor spParentNeutrino() const
virtual EvtDiracSpinor spParent(int) const
void setVectorSpinDensity()
bool hasValidP4()
void printParticle() const
virtual EvtDiracSpinor spNeutrino() const
int getSpinStates() const
EvtVector4R getP4Restframe()
void setLifetime()
void setPolarizedSpinDensity(double r00, double r11, double r22)
double getLifetime()
void setDiagonalSpinDensity()
double compMassProb()
EvtSpinType::spintype getSpinType() const
void setChannel(int i)
const EvtVector4R & getP4() const
void printTree() const
void setLifetime(double tau)
virtual EvtSpinDensity rotateToHelicityBasis() const =0
void resetFirstOrNot()
int getNDaug() const
EvtParticle * getDaug(int i)
void dumpTreeRec(int level, int dj) const
void deleteDaughters(bool keepChannel=false)
double mass() const
virtual EvtDiracSpinor sp(int) const
void makeStdHep(EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
int firstornot() const
EvtVector4R get4Pos()
virtual EvtVector4C eps(int i) const
void addDaug(EvtParticle *node)
void dumpTree() const
std::string treeStr() const
std::string treeStrRec(int level) const
int getChannel() const
virtual EvtTensor4C epsTensor(int i) const
void setId(EvtId id)
std::string writeTreeRec(std::string) const
void setFirstOrNot()
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
EvtParticle * nextIter(EvtParticle *rootOfTree=0)
void generateMassTree()
void deleteTree()
static double Flat()
Definition EvtRandom.cc:74
void init(EvtId part_n, double e, double px, double py, double pz)
void createSecondary(int stdhepindex, EvtParticle *prnt)
int GetDim() const
void SetDiag(int n)
const EvtComplex & Get(int i, int j) const
void Set(int i, int j, const EvtComplex &rhoij)
void SetDim(int n)
static int getSpinStates(spintype stype)
void createParticle(EvtVector4R p4, EvtVector4R x, int prntfirst, int prntlast, int id)
Definition EvtStdHep.cc:41
int getNPart()
Definition EvtStdHep.cc:37
double mass() const
void set(int i, double d)
double double double * p4
Definition qcdloop1.h:77