BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtCPUtil.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: EvtCPUtil.cc
12//
13// Description: Utilities needed for generation of CP violating
14// decays.
15//
16// Modification history:
17//
18// RYD March 24, 1998 Module created
19//
20//------------------------------------------------------------------------
21//
28#include "EvtGenBase/EvtPDL.hh"
32
33#include <assert.h>
34#include <stdlib.h>
35using std::endl;
36
37
38//added two functions for finding the fraction of B0 tags for decays into
39//both CP eigenstates and non-CP eigenstates -- NK, Jan. 27th, 1998
40
42 double deltam, double beta, double &fract) {
43//this function returns the number of B0 tags for decays into CP-eigenstates
44//(the "probB0" in the new EvtOtherB)
45
46 //double gamma_B = EvtPDL::getWidth(B0);
47 //double xd = deltam/gamma_B;
48 //double xd = 0.65;
49 double ratio = 1/(1 + 0.65*0.65);
50
51 EvtComplex rf, rbarf;
52
53 rf = EvtComplex(cos(2.0*beta),sin(2.0*beta))*Abarf/Af;
54 rbarf = EvtComplex(1.0)/rf;
55
56 double A2 = real(Af)*real(Af) + imag(Af)*imag(Af);
57 double Abar2 = real(Abarf)*real(Abarf) + imag(Abarf)*imag(Abarf);
58
59 double rf2 = real(rf)*real(rf) + imag(rf)*imag(rf);
60 double rbarf2 = real(rbarf)*real(rbarf) + imag(rbarf)*imag(rbarf);
61
62 fract = (Abar2*(1+ rbarf2 + (1 - rbarf2)*ratio))/(Abar2*(1+ rbarf2 + (1 - rbarf2)*ratio) + A2*(1+ rf2 + (1 - rf2)*ratio));
63 return;
64
65}
67 EvtComplex Afbar, EvtComplex Abarfbar,
68 double deltam, double beta,
69 int flip, double &fract) {
70
71//this function returns the number of B0 tags for decays into non-CP eigenstates
72//(the "probB0" in the new EvtOtherB)
73//this needs more thought...
74
75 //double gamma_B = EvtPDL::getWidth(B0);
76 //report(INFO,"EvtGen") << "gamma " << gamma_B<< endl;
77 //double xd = deltam/gamma_B;
78
79 //why is the width of B0 0 in PDL??
80
81 double xd = 0.65;
82 double gamma_B = deltam/xd;
83 double IAf, IAfbar, IAbarf, IAbarfbar;
84 EvtComplex rf, rfbar, rbarf, rbarfbar;
85 double rf2, rfbar2, rbarf2, rbarfbar2;
86 double Af2, Afbar2, Abarf2, Abarfbar2;
87
88 rf = EvtComplex(cos(2.0*beta),sin(2.0*beta))*Abarf/Af;
89 rfbar = EvtComplex(cos(2.0*beta),sin(2.0*beta))*Abarfbar/Afbar;
90 rbarf = EvtComplex(cos(-2.0*beta),sin(-2.0*beta))*Af/Abarf;
91 rbarfbar = EvtComplex(cos(-2.0*beta),sin(-2.0*beta))*Afbar/Abarfbar;
92
93
94 rf2 = real(rf)*real(rf) + imag(rf)*imag(rf);
95 rfbar2 = real(rfbar)*real(rfbar) + imag(rfbar)*imag(rfbar);
96 rbarf2 = real(rbarf)*real(rbarf) + imag(rbarf)*imag(rbarf);
97 rbarfbar2 = real(rbarfbar)*real(rbarfbar) + imag(rbarfbar)*imag(rbarfbar);
98
99 Af2 = real(Af)*real(Af) + imag(Af)*imag(Af);
100 Afbar2 = real(Afbar)*real(Afbar) + imag(Afbar)*imag(Afbar);
101 Abarf2 = real(Abarf)*real(Abarf) + imag(Abarf)*imag(Abarf);
102 Abarfbar2 = real(Abarfbar)*real(Abarfbar) + imag(Abarfbar)*imag(Abarfbar);
103
104
105//
106//IAf = integral(gamma(B0->f)), etc.
107//
108
109 IAf = (Af2/(2*gamma_B))*(1+rf2+(1-rf2)/(1+xd*xd));
110 IAfbar = (Afbar2/(2*gamma_B))*(1+rfbar2+(1-rfbar2)/(1+xd*xd));
111 IAbarf = (Abarf2/(2*gamma_B))*(1+rbarf2+(1-rbarf2)/(1+xd*xd));
112 IAbarfbar = (Abarfbar2/(2*gamma_B))*(1+rbarfbar2+(1-rbarfbar2)/(1+xd*xd));
113
114//flip specifies the relative fraction of fbar events
115
116 fract = IAbarf/(IAbarf+IAf) + flip*IAbarfbar/(IAfbar+IAbarfbar);
117
118
119 return;
120}
121
122void EvtCPUtil::OtherB( EvtParticle *p,double &t, EvtId &otherb, double probB0){
123
124 //Can not call this recursively!!!
125 static int entryCount=0;
126 entryCount++;
127
128 //added by Lange Jan4,2000
129 static EvtId B0B=EvtPDL::getId("anti-B0");
130 static EvtId B0=EvtPDL::getId("B0");
131
132 int isB0=EvtRandom::Flat(0.0,1.0)<probB0;
133
134 int idaug;
135
136 p->setLifetime();
137
138 // now get the time between the decay of this B and the other B!
139
140 EvtParticle *parent=p->getParent();
141
142 EvtParticle *other;
143
144 if (parent==0) {
145 //report(ERROR,"EvtGen") <<
146 // "Warning CP violation with B having no parent!"<<endl;
147 p->setLifetime();
148 t=p->getLifetime();
149 if (p->getId()==B0) otherb=B0B;
150 if (p->getId()==B0B) otherb=B0;
151 entryCount--;
152 return;
153 }
154 else{
155 if (parent->getDaug(0)!=p){
156 other=parent->getDaug(0);
157 idaug=0;
158 }
159 else{
160 other=parent->getDaug(1);
161 idaug=1;
162 }
163 }
164
165 if (parent != 0 ) {
166
167 //if (entryCount>1){
168 // report(INFO,"EvtGen") << "Double CP decay:"<<entryCount<<endl;
169 //}
170
171 //kludge!! Lange Mar21, 2003
172 // if the other B is an alias... don't change the flavor..
173 if ( other->getId().isAlias() ) {
174 OtherB(p,t,otherb);
175 entryCount--;
176 return;
177
178 }
179
180 if (entryCount==1){
181
182 EvtVector4R p_init=other->getP4();
183 //int decayed=other->getNDaug()>0;
184 bool decayed = other->isDecayed();
185
186 other->deleteTree();
187
188 EvtScalarParticle* scalar_part;
189
190 scalar_part=new EvtScalarParticle;
191 if (isB0) {
192 scalar_part->init(B0,p_init);
193 }
194 else{
195 scalar_part->init(B0B,p_init);
196 }
197 other=(EvtParticle *)scalar_part;
198 // other->set_type(EvtSpinType::SCALAR);
199 other->setDiagonalSpinDensity();
200
201 parent->insertDaugPtr(idaug,other);
202
203 if (decayed){
204 //report(INFO,"EvtGen") << "In CP Util calling decay \n";
205 other->decay();
206 }
207
208 }
209
210 otherb=other->getId();
211
212 other->setLifetime();
213 t=p->getLifetime()-other->getLifetime();
214
215 otherb = other->getId();
216
217 }
218 else {
219 report(INFO,"EvtGen") << "We have an error here!!!!"<<endl;
220 otherb = EvtId(-1,-1);
221 }
222
223 entryCount--;
224 return ;
225}
226
227
228
229void EvtCPUtil::OtherB( EvtParticle *p,double &t, EvtId &otherb){
230
231
232 static EvtId BSB=EvtPDL::getId("anti-B_s0");
233 static EvtId BS0=EvtPDL::getId("B_s0");
234 static EvtId B0B=EvtPDL::getId("anti-B0");
235 static EvtId B0=EvtPDL::getId("B0");
236 static EvtId UPS4=EvtPDL::getId("Upsilon(4S)");
237
238 if (p->getId()==BS0||p->getId()==BSB){
239 static double ctauL=EvtPDL::getctau(EvtPDL::getId("B_s0L"));
240 static double ctauH=EvtPDL::getctau(EvtPDL::getId("B_s0H"));
241 static double ctau=ctauL<ctauH?ctauH:ctauL;
242 t=-log(EvtRandom::Flat())*ctau;
243 EvtParticle* parent=p->getParent();
244 if (parent!=0&&(parent->getId()==BS0||parent->getId()==BSB)){
245 if (parent->getId()==BS0) otherb=BSB;
246 if (parent->getId()==BSB) otherb=BS0;
247 parent->setLifetime(t);
248 return;
249 }
250 if (p->getId()==BS0) otherb=BSB;
251 if (p->getId()==BSB) otherb=BS0;
252 p->setLifetime(t);
253 return;
254 }
255
256
257
258
259 p->setLifetime();
260
261
262// now get the time between the decay of this B and the other B!
263
264 EvtParticle *parent=p->getParent();
265
266 if (parent==0||parent->getId()!=UPS4) {
267 //report(ERROR,"EvtGen") <<
268 // "Warning CP violation with B having no parent!"<<endl;
269 t=p->getLifetime();
270 if (p->getId()==B0) otherb=B0B;
271 if (p->getId()==B0B) otherb=B0;
272 if (p->getId()==BS0) otherb=BSB;
273 if (p->getId()==BSB) otherb=BS0;
274 return;
275 }
276 else{
277 if (parent->getDaug(0)!=p){
278 otherb=parent->getDaug(0)->getId();
279 parent->getDaug(0)->setLifetime();
280 t=p->getLifetime()-parent->getDaug(0)->getLifetime();
281 }
282 else{
283 otherb=parent->getDaug(1)->getId();
284 parent->getDaug(1)->setLifetime();
285 t=p->getLifetime()-parent->getDaug(1)->getLifetime();
286 }
287 }
288
289
290 return ;
291}
292
293
294void EvtCPUtil::incoherentMix(const EvtId id, double &t, int &mix){
295
296 int stdHepNum=EvtPDL::getStdHep(id);
297 stdHepNum=abs(stdHepNum);
298
299 EvtId partId=EvtPDL::evtIdFromStdHep(stdHepNum);
300
301 std::string partName=EvtPDL::name(partId);
302 std::string hname=partName+std::string("H");
303 std::string lname=partName+std::string("L");
304
305 EvtId lId=EvtPDL::getId(lname);
306 EvtId hId=EvtPDL::getId(hname);
307
308 double ctauL=EvtPDL::getctau(lId);
309 double ctauH=EvtPDL::getctau(hId);
310 double ctau=0.5*(ctauL+ctauH);
311 double y=(ctauH-ctauL)/ctau;
312
313 //need to figure out how to get these parameters into the code...
314
315 std::string qoverpParmName=std::string("qoverp_incohMix_")+partName;
316 std::string mdParmName=std::string("dm_incohMix_")+partName;
317 int ierr;
318 double qoverp=atof(EvtSymTable::Get(qoverpParmName,ierr).c_str());
319 double x=atof(EvtSymTable::Get(mdParmName,ierr).c_str())*ctau/EvtConst::c;
320 double fac;
321
322 if(id==partId){
323 fac=1.0/(qoverp*qoverp);
324 }
325 else{
326 fac=qoverp*qoverp;
327 }
328
329 double mixprob=(x*x+y*y)/(x*x+y*y+fac*(2+x*x-y*y));
330
331 int mixsign;
332
333 mixsign=(mixprob>EvtRandom::Flat(0.0,1.0))?-1:1;
334
335 double prob;
336
337 do{
338 t=-log(EvtRandom::Flat())*ctauL;
339 prob=1+exp(y*t/ctau)+mixsign*2*exp(0.5*y*t/ctau)*cos(x*t);
340 }while(prob<4*EvtRandom::Flat());
341
342 mix=0;
343
344 if (mixsign==-1) mix=1;
345
346 return;
347}
348
349
350
351
352
353
354
355
356
357
Double_t x[10]
double imag(const EvtComplex &c)
Definition: EvtComplex.hh:246
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ INFO
Definition: EvtReport.hh:52
double sin(const BesAngle a)
double cos(const BesAngle a)
static void fractB0nonCP(EvtComplex Af, EvtComplex Abarf, EvtComplex Afbar, EvtComplex Abarfbar, double deltam, double beta, int flip, double &fract)
Definition: EvtCPUtil.cc:66
static void fractB0CP(EvtComplex Af, EvtComplex Abarf, double deltam, double beta, double &fract)
Definition: EvtCPUtil.cc:41
static void incoherentMix(const EvtId id, double &t, int &mix)
Definition: EvtCPUtil.cc:294
static void OtherB(EvtParticle *p, double &t, EvtId &otherb)
Definition: EvtCPUtil.cc:229
static const double c
Definition: EvtConst.hh:32
Definition: EvtId.hh:27
static int getStdHep(EvtId id)
Definition: EvtPDL.hh:56
static EvtId evtIdFromStdHep(int stdhep)
Definition: EvtPDL.cc:244
static std::string name(EvtId i)
Definition: EvtPDL.hh:64
static EvtId getId(const std::string &name)
Definition: EvtPDL.cc:287
static double getctau(EvtId i)
Definition: EvtPDL.hh:55
void insertDaugPtr(int idaug, EvtParticle *partptr)
Definition: EvtParticle.hh:220
EvtId getId() const
Definition: EvtParticle.cc:113
EvtParticle * getParent()
Definition: EvtParticle.cc:87
double getLifetime()
Definition: EvtParticle.cc:99
void setLifetime(double tau)
Definition: EvtParticle.cc:89
EvtParticle * getDaug(int i)
Definition: EvtParticle.cc:85
static double Flat()
Definition: EvtRandom.cc:73
void init(EvtId part_n, double e, double px, double py, double pz)
static std::string Get(const std::string &name, int &ierr)
Definition: EvtSymTable.cc:55
int t()
Definition: t.c:1