BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtSingleParticle.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: 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 "EvtSingleParticle.hh"
28#include <stdlib.h>
29#include <string>
30using std::endl;
31
33
34void EvtSingleParticle::getName( std::string& model_name ) { model_name = "SINGLE"; }
35
37
39
40 // turn off checks for charge conservation
42
43 if ( ( getNArg() == 6 ) || ( getNArg() == 4 ) || ( getNArg() == 2 ) )
44 {
45
46 if ( getNArg() == 6 )
47 {
48 // copy the arguments into eaiser to remember names!
49
50 pmin = getArg( 0 );
51 pmax = getArg( 1 );
52
53 cthetamin = getArg( 2 );
54 cthetamax = getArg( 3 );
55
56 phimin = getArg( 4 );
57 phimax = getArg( 5 );
58 }
59
60 if ( getNArg() == 4 )
61 {
62 // copy the arguments into eaiser to remember names!
63
64 pmin = getArg( 0 );
65 pmax = getArg( 1 );
66
67 cthetamin = getArg( 2 );
68 cthetamax = getArg( 3 );
69
70 phimin = 0.0;
71 phimax = EvtConst::twoPi;
72 }
73
74 if ( getNArg() == 2 )
75 {
76 // copy the arguments into eaiser to remember names!
77
78 pmin = getArg( 0 );
79 pmax = getArg( 1 );
80
81 cthetamin = -1.0;
82 cthetamax = 1.0;
83
84 phimin = 0.0;
85 phimax = EvtConst::twoPi;
86 }
87 }
88 else
89 {
90
91 report( ERROR, "EvtGen" ) << "EvtSingleParticle generator expected "
92 << " 6, 4, or 2 arguments but found:" << getNArg() << endl;
93 report( ERROR, "EvtGen" ) << "Will terminate execution!" << endl;
94 ::abort();
95 }
96
97 report( INFO, "EvtGen" ) << "The single particle generator has been configured:" << endl;
98 report( INFO, "EvtGen" ) << pmax << " > p > " << pmin << endl;
99 report( INFO, "EvtGen" ) << cthetamax << " > costheta > " << cthetamin << endl;
100 report( INFO, "EvtGen" ) << phimax << " > phi > " << phimin << endl;
101}
102
104
105 EvtParticle* d;
106 EvtVector4R p4;
107
108 double mass = EvtPDL::getMass( getDaug( 0 ) );
109
111 d = p->getDaug( 0 );
112
113 // generate flat distribution in p
114 // we are now in the parents restframe! This means the
115 // restframe of the e+e- collison.
116 double pcm;
117 if ( pmin == pmax ) pcm = pmin; // pingrg, 2008-04-15
118 if ( pmin < pmax ) pcm = EvtRandom::Flat( pmin, pmax );
119
120 // generate flat distribution in phi.
121 double phi;
122 if ( phimin == phimax ) phi = phimin; // pingrg 2008-10-22
123 else phi = EvtRandom::Flat( phimin, phimax );
124
125 double cthetalab;
126
127 do {
128 // generate flat distribution in costheta
129 double ctheta;
130 if ( cthetamin == cthetamax ) ctheta = cthetamin;
131 else ctheta = EvtRandom::Flat( cthetamin, cthetamax );
132 double stheta = sqrt( 1.0 - ctheta * ctheta );
133 p4.set( sqrt( mass * mass + pcm * pcm ), pcm * cos( phi ) * stheta,
134 pcm * sin( phi ) * stheta, pcm * ctheta );
135
136 d->init( getDaug( 0 ), p4 );
137
138 // get 4 vector in the lab frame!
139 EvtVector4R p4lab = d->getP4Lab();
140 cthetalab = p4lab.get( 3 ) / p4lab.d3mag();
141 } while ( cthetalab > cthetamax || cthetalab < cthetamin );
142
143 return;
144}
double mass
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
@ INFO
Definition EvtReport.hh:52
static const double twoPi
Definition EvtConst.hh:28
double getArg(int j)
void disableCheckQ()
EvtId * getDaugs()
EvtId getDaug(int i)
static double getMass(EvtId i)
Definition EvtPDL.hh:44
void makeDaughters(int ndaug, EvtId *id)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
EvtVector4R getP4Lab()
EvtParticle * getDaug(int i)
static double Flat()
Definition EvtRandom.cc:69
EvtDecayBase * clone()
void decay(EvtParticle *p)
void getName(std::string &name)
double get(int i) const
double d3mag() const
void set(int i, double d)