Line data Source code
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: EvtSingleParticle.cc
12 : //
13 : // Description: Special model to generate single particles.
14 : //
15 : // Modification history:
16 : //
17 : // RYD Febuary 17,1998 Module created
18 : //
19 : //------------------------------------------------------------------------
20 : //
21 : #include "EvtGenBase/EvtPatches.hh"
22 : #include <stdlib.h>
23 : #include "EvtGenBase/EvtParticle.hh"
24 : #include "EvtGenBase/EvtRandom.hh"
25 : #include "EvtGenBase/EvtPDL.hh"
26 : #include "EvtGenModels/EvtSingleParticle.hh"
27 : #include "EvtGenBase/EvtReport.hh"
28 : #include <string>
29 : #include "EvtGenBase/EvtConst.hh"
30 : using std::endl;
31 :
32 0 : EvtSingleParticle::~EvtSingleParticle() {}
33 :
34 : std::string EvtSingleParticle::getName(){
35 :
36 0 : return "SINGLE";
37 :
38 : }
39 :
40 : EvtDecayBase* EvtSingleParticle::clone(){
41 :
42 0 : return new EvtSingleParticle();
43 :
44 0 : }
45 :
46 : void EvtSingleParticle::init(){
47 :
48 :
49 : //turn off checks for charge conservation
50 0 : disableCheckQ();
51 :
52 0 : if ((getNArg()==6)||(getNArg()==4)||(getNArg()==2)) {
53 :
54 0 : if (getNArg()==6){
55 : //copy the arguments into eaiser to remember names!
56 :
57 0 : pmin=getArg(0);
58 0 : pmax=getArg(1);
59 :
60 0 : cthetamin=getArg(2);
61 0 : cthetamax=getArg(3);
62 :
63 0 : phimin=getArg(4);
64 0 : phimax=getArg(5);
65 :
66 0 : }
67 :
68 0 : if (getNArg()==4){
69 : //copy the arguments into eaiser to remember names!
70 :
71 0 : pmin=getArg(0);
72 0 : pmax=getArg(1);
73 :
74 0 : cthetamin=getArg(2);
75 0 : cthetamax=getArg(3);
76 :
77 0 : phimin=0.0;
78 0 : phimax=EvtConst::twoPi;
79 :
80 0 : }
81 :
82 0 : if (getNArg()==2){
83 : //copy the arguments into eaiser to remember names!
84 :
85 0 : pmin=getArg(0);
86 0 : pmax=getArg(1);
87 :
88 0 : cthetamin=-1.0;
89 0 : cthetamax=1.0;
90 :
91 0 : phimin=0.0;
92 0 : phimax=EvtConst::twoPi;
93 :
94 0 : }
95 :
96 :
97 : }else{
98 :
99 0 : report(Severity::Error,"EvtGen") << "EvtSingleParticle generator expected "
100 0 : << " 6, 4, or 2 arguments but found:"<<getNArg()<<endl;
101 0 : report(Severity::Error,"EvtGen") << "Will terminate execution!"<<endl;
102 0 : ::abort();
103 :
104 : }
105 :
106 :
107 0 : report(Severity::Info,"EvtGen") << "The single particle generator has been configured:"
108 0 : <<endl;
109 0 : report(Severity::Info,"EvtGen") << pmax << " > p > " << pmin <<endl;
110 0 : report(Severity::Info,"EvtGen") << cthetamax << " > costheta > " << cthetamin <<endl;
111 0 : report(Severity::Info,"EvtGen") << phimax << " > phi > " << phimin <<endl;
112 :
113 0 : }
114 :
115 : void EvtSingleParticle::decay( EvtParticle *p ){
116 :
117 : EvtParticle *d;
118 0 : EvtVector4R p4;
119 :
120 0 : double mass=EvtPDL::getMass(getDaug(0));
121 :
122 0 : p->makeDaughters(getNDaug(),getDaugs());
123 0 : d=p->getDaug(0);
124 :
125 : //generate flat distribution in p
126 : //we are now in the parents restframe! This means the
127 : //restframe of the e+e- collison.
128 0 : double pcm=EvtRandom::Flat(pmin,pmax);
129 : //generate flat distribution in phi.
130 0 : double phi=EvtRandom::Flat(phimin,phimax);
131 :
132 : double cthetalab;
133 :
134 0 : do{
135 : //generate flat distribution in costheta
136 0 : double ctheta=EvtRandom::Flat(cthetamin,cthetamax);
137 0 : double stheta=sqrt(1.0-ctheta*ctheta);
138 0 : p4.set(sqrt(mass*mass+pcm*pcm),pcm*cos(phi)*stheta,
139 0 : pcm*sin(phi)*stheta,pcm*ctheta);
140 :
141 0 : d->init( getDaug(0),p4);
142 :
143 : //get 4 vector in the lab frame!
144 0 : EvtVector4R p4lab=d->getP4Lab();
145 0 : cthetalab=p4lab.get(3)/p4lab.d3mag();
146 0 : }while (cthetalab>cthetamax||cthetalab<cthetamin);
147 :
148 : return ;
149 0 : }
150 :
151 :
152 :
|