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