34 #include <TLorentzVector.h>
39 #include <generators/treps/Treps3B.h>
41 #include <framework/logging/Logger.h>
53 TrepsB::TrepsB(
void) :
54 sutool(), w(0.), ntot(0), nsave(0), ebeam(0.), q2max(0.), cost_cut(0.), pt_cut(0.), cost_flag(0), pt_flag(0),
55 qzmin(0.), qptmin(0.), parti(nullptr), parts(nullptr), ephi(0.), etheta(0.), s(0.), imode(0), dmin(0.), dmax(0.),
56 ffmax(0.), rs(0.), vmax(0.), pppp(nullptr), wf(0.), inmode(0), wtcount(0), totalCrossSectionForMC(0.), ndecay(0),
57 pmodel(0), fmodel(0), ievent(0), treh1(nullptr), treh2(nullptr), treh3(nullptr), treh4(nullptr), treh5(nullptr),
58 treh6(nullptr), npart(0), partgen(nullptr), zdis(nullptr), zpdis(nullptr), zsdis(nullptr)
60 for (
int i = 0; i < 5000; ++i) {
69 void TrepsB::initp(
void)
73 B2INFO(
"Treps: Parameters are read from the file, " << parameterFile);
74 B2INFO(
"Treps: W list is read from the file, " << wlistFile);
75 B2INFO(
"Treps: Differential cross section list is read from the file, " << diffcrosssectionFile);
77 partgen =
new Part_gen [30];
78 parti =
new Part_cont [10];
79 parts =
new Part_cont [20];
80 pppp =
new TLorentzVector [30];
82 std::ifstream infile(parameterFile);
84 B2FATAL(
"Can't open input file: " << parameterFile);
87 infile >> ndecay >> pmodel >> fmodel ;
90 B2FATAL(
"decay particles must be >=2 : " << ndecay) ;
97 double pmassx, pchargx, pwidthx ;
99 for (
int i = 0 ; i < ndecay ; i++) {
100 sutool.nextline(infile);
102 infile >> icodex >> pmassx >> pchargx >> ndecx >> pwidthx ;
104 parti[i] = Part_cont(icodex, pmassx, pchargx, ndecx, pwidthx);
106 if (ndecx >= 2) ndecs += ndecx ;
109 for (
int j = 0 ; j < ndecs ; j++) {
110 sutool.nextline(infile);
112 infile >> icodex >> pmassx >> pchargx ;
113 Part_cont _pp = Part_cont(icodex, pmassx, pchargx);
118 double tsws4 = pfeb.Mag() + pfpb.Mag() ;
119 TVector3 tsws = TVector3(-(pfeb + pfpb));
120 double emsys = tsws4 * tsws4 - tsws.Mag2() ;
122 peb = TLorentzVector(pfeb, pfeb.Mag());
124 ppb = TLorentzVector(pfpb, pfpb.Mag());
126 TLorentzVector ppp = peb;
127 ppp.Boost(tsws.x() / tsws4, tsws.y() / tsws4, tsws.z() / tsws4);
129 etheta = ppp.Theta();
132 tswsb = (1. / tsws4) * tsws;
137 B2INFO(
"****** Treps3 Input Parameters in Initialization ******");
138 B2INFO(
" Beam energy in e+e- cm system (GeV): " << ebeam);
139 B2INFO(
" e- lab. momentum: " << pfeb.x() <<
" " << pfeb.y() <<
" " << pfeb.z());
140 B2INFO(
" e+ lab. momentum: " << pfpb.x() <<
" " << pfpb.y() <<
" " << pfpb.z());
141 B2INFO(
" Q2 max (GeV2): " << q2max);
142 B2INFO(
" Save-condition (|cos(theta_cm)|): " << cost_cut <<
", "
144 B2INFO(
" (pt (GeV/c)): " << pt_cut <<
", "
146 B2INFO(
" Number of decay particles: " << ndecay);
147 B2INFO(
" Physics model: " << pmodel);
148 B2INFO(
" Form-factor model: " << fmodel);
151 B2INFO(
" P/S code mass charge decs width");
153 for (
int i = 0 ; i < ndecay ; i++) {
154 B2INFO(
" P " << std::setw(6) << parti[i].icode
155 << std::setw(11) << std::setprecision(4) << parti[i].pmass
156 << std::setw(6) << std::setprecision(2) << parti[i].pcharg
157 << std::setw(4) << parti[i].ndec
158 << std::setw(11) << std::setprecision(4) << parti[i].pwidth
161 for (
int i = 0 ; i < ndecs ; i++) {
162 B2INFO(
" S " << std::setw(6) << parts[i].icode
163 << std::setw(11) << std::setprecision(4) << parts[i].pmass
164 << std::setw(6) << std::setprecision(2) << parts[i].pcharg);
166 B2INFO(
"*******************************************************");
169 if (abs(emsys - 4 * ebeam * ebeam) > 0.001) {
170 B2FATAL(
" Wrong beam fractional momenta ");
175 s = 4.*ebeam * ebeam ;
182 void TrepsB::create_hist(
void)
184 treh1 =
new TH1F(
"PZSUMCM",
"PZSUMCM", 100, -10., 10.);
185 treh2 =
new TH1F(
"PTSUMCM",
"PTSUMCM", 100, 0., 1.);
186 treh3 =
new TH1F(
"EALLCM",
"EALLCM", 100, 0., 20.);
187 treh4 =
new TH1F(
"PZSUMLAB",
"PZSUMLAB", 100, -10., 10.);
188 treh5 =
new TH1F(
"PTSUMLAB",
"PTSUMLAB", 100, 0., 1.);
189 treh6 =
new TH1F(
"WFINAL",
"WFINAL", 100, 0., 5.);
191 zdis =
new TH1F(
"kin3_z",
"kin3_z", 40, -1., 1.);
192 zpdis =
new TH1F(
"kin3_zp",
"kin3_zp", 40, -1., 1.);
193 zsdis =
new TH1F(
"kin3_zs",
"kin3_zs", 40, -1., 1.);
197 void TrepsB::wtable()
199 totalCrossSectionForMC = 0.;
202 std::ifstream infile(diffcrosssectionFile);
204 B2FATAL(
"Can't open W-list input file") ;
207 double diffCrossSection;
209 double previousW = 0.;
210 double previousDCS = 0.;
211 while (infile >> i_w >> diffCrossSection) {
212 if (i_w > 9000. || i_w < 0.)
continue;
213 diffCrossSectionOfW[i_w] = diffCrossSection;
217 if (diffCrossSection > previousDCS and previousDCS != 0) {
219 totalCrossSectionForMC += (i_w - previousW) * diffCrossSection * 1.01;
222 totalCrossSectionForMC += (i_w - previousW) * previousDCS * 1.01;
225 WOfCrossSectionForMC[totalCrossSectionForMC] = i_w;
228 previousDCS = diffCrossSection;
231 B2DEBUG(20,
" wtable loaded");
235 double TrepsB::wtable(
int mode)
242 for (
int i = 0 ; i < 5000 ; i++) {
243 wthead[i] = 999999999;
247 B2DEBUG(20,
" wtable mode=0 initialized");
251 std::ifstream infile(wlistFile);
253 B2FATAL(
"Can't open W-list input file") ;
266 while (!infile.eof() && inmode == 0) {
267 sutool.nextline(infile);
269 if (w1 > 9000. || w1 < 0.)
continue;
271 if (nwpoint == 0) wthead[0] = 1;
272 wtcond[nwpoint] = w1;
275 B2DEBUG(20, w1 <<
" GeV " << n1 <<
" events " << hpoint - 1 <<
"events in total");
276 wthead[nwpoint] = hpoint;
278 while (!infile.eof() && (inmode == 1 || inmode == 2)) {
279 sutool.nextline(infile);
281 if (w1 > 9000. || w1 < 0.)
continue;
286 B2INFO(w <<
" " << twlumi() <<
" //W(GeV) and Two-photon lumi. func.(wide)(1/GeV)");
288 B2INFO(w <<
" " << twlumi_n() <<
" //W(GeV) and Two-photon lumi. func.(narrow)(nb/keV/(2J+1))");
292 B2DEBUG(20, wthead[0] <<
" " << wtcond[0]);
293 B2DEBUG(20,
" wtable mode=0 loaded");
296 }
else if (mode == 1) {
301 if (wtcount >= wthead[i]) prew = wtcond[i];
303 }
while (wthead[i] < 999999999);
308 B2FATAL(
"Undefined mode for wtable. Can be 1 or 0. Called with " << mode) ;
314 void TrepsB::setW(
double ww)
322 void TrepsB::updateW(
void)
324 if (q2max < 0.0) q2max = s - w * w - 2.0 * me * w ;
326 double zmax = 1.0 - me / ebeam ;
327 double ymin = rs / zmax ;
333 double xxx = tpgetd(0, rs, dmin, dmax, q2max);
334 B2DEBUG(20,
"Local variable xxx=" << xxx <<
" created but not used");
337 B2DEBUG(20,
"In Treps, W has been set to be " << std::setprecision(5) <<
341 double TrepsB::twlumi()
345 double xxx = simpsn1(dmin, dmax, 10000);
346 return xxx * w * 0.5 / ebeam / ebeam ;
349 double TrepsB::twlumi_n()
353 return twlumi() * twopi * twopi / w / w * 0.38938 ;
356 double TrepsB::tpgetd(
int mode,
double _rs,
double _dmin,
double _dmax,
364 for (
int i = 1; i <= n ; i++) {
365 double d = _dmin + (_dmax - _dmin) / (
double)n * (double)i;
366 double r = (2.0 + d * d / _rs + sqrt(pow((2.0 + d * d / _rs), 2) - 4.0)) * 0.5 ;
368 r = (2.0 + d * d / _rs - sqrt(pow((2.0 + d * d / _rs), 2) - 4.0)) * 0.5 ;
369 double ff = tpxint(r, _rs, _q2max) / (0.5 * sqrt(_rs / r) * (1.0 + 1.0 / r));
370 if (ff > ffmax) ffmax = ff ;
377 d = _dmin + (_dmax - _dmin) * gRandom->Uniform();
380 r = (2. + d * d / _rs + sqrt((2. + d * d / _rs) * (2. + d * d / _rs) - 4.)) * 0.5 ;
382 r = (2. + d * d / _rs - sqrt((2. + d * d / _rs) * (2. + d * d / _rs) - 4.)) * 0.5 ;
384 ff = tpxint(r, _rs, _q2max) / (0.5 * sqrt(_rs / r) * (1. + 1. / r));
385 }
while (gRandom->Uniform()*ffmax > ff);
390 double TrepsB::tpgetz(
int mode)
397 for (
int i = -1000 ; i <= 1000 ; i++) {
398 z = (double)i * 0.001 ;
399 double v = tpangd(z, w);
400 if (v > vmax) vmax = v;
403 do { z = (gRandom->Uniform() - 0.5) * 2. ; }
404 while (vmax * gRandom->Uniform() >= tpangd(z, w));
410 int TrepsB::event_gen(
int iev)
413 B2DEBUG(20,
"W = " << w);
418 double d = tpgetd(1, rs, dmin, dmax, q2max);
421 r = (2.0 + d * d / rs + sqrt(pow((2.0 + d * d / rs), 2) - 4.0)) * 0.5;
423 r = (2.0 + d * d / rs - sqrt(pow((2.0 + d * d / rs), 2) - 4.0)) * 0.5;
426 double z = sqrt(rs / r);
427 double y = sqrt(rs * r);
429 double q2p, q2m, q2min, sf ;
433 q2p = tpgetq(s, z, q2max) ;
434 q2m = tpgetq(s, z, q2max) ;
435 q2min = me * me * pow(w, 4) / s / (s - w * w);
436 sf = ((s * s + (s - w * w) * (s - w * w)) / 2. / s / s - (s - w * w) * q2min / s / q2p)
437 * ((s * s + (s - w * w) * (s - w * w)) / 2. / s / s - (s - w * w) * q2min / s / q2m);
438 }
while (gRandom->Uniform() > sf);
439 }
while (gRandom->Uniform() > tpform(q2p, w)*tpform(q2m, w));
443 TVector3 tv1, tv2, tv3, tv4;
445 if (q2m < q2zero || q2p < q2zero) {
457 if (q2m < q2zero && q2p < q2zero) {
463 double rk2 = z * ebeam ;
464 double rk1 = 0.25 / rk2 * (w * w + q2 - rk2 * q2 / ebeam);
465 double rk13 = q2 / 2.0 / ebeam + rk1 ;
466 double qqqq = rk1 * rk1 - rk13 * rk13 + q2;
467 if (ivirt == 0) qqqq = 0.0 ;
469 if (qqqq < 0.0) continue ;
471 double rk11 = -sqrt(qqqq);
472 tv1 = TVector3(-rk11, 0., sqrt(ebeam * ebeam - me * me) - rk13);
473 tv2 = TVector3(0., 0., -(sqrt(ebeam * ebeam - me * me) - rk2));
474 tv3 = TVector3(-rk11, 0.,
475 -(sqrt(ebeam * ebeam - me * me) - rk13));
476 tv4 = TVector3(0., 0., sqrt(ebeam * ebeam - me * me) - rk2);
488 double rk2 = z * ebeam ;
489 double aaaa = 4.*rk2 + q2p / ebeam ;
490 double bbbb = w * w + q2m + q2p - q2m * q2p / 2. / ebeam / ebeam - q2m * rk2 / ebeam ;
491 double cccc = 4.*q2m * q2p * (1. - rk2 / ebeam - q2p / 4. / ebeam / ebeam);
492 double rphi = gRandom->Uniform() * twopi;
493 double rsrs = 1. + aaaa / cccc / pow(cos(rphi), 2) *
494 (4.*aaaa * ebeam * ebeam - aaaa * q2m - 4.*bbbb * ebeam);
495 if (rsrs < 0.0) continue ;
496 double rk1 = (2.*aaaa * bbbb + cccc * pow(cos(rphi), 2) / ebeam *
497 (sqrt(rsrs) - 1.)) / 2. / aaaa / aaaa;
498 if ((bbbb - aaaa * rk1)*cos(rphi) > 0.0)
499 rk1 = (2.*aaaa * bbbb + cccc * pow(cos(rphi), 2) / ebeam *
500 (-sqrt(rsrs) - 1.)) / 2. / aaaa / aaaa;
501 if ((bbbb - aaaa * rk1)*cos(rphi) > 0.0)
continue ;
503 tv1 = TVector3(sqrt(q2m * (1. - rk1 / ebeam - q2m / 4. / ebeam / ebeam)),
505 sqrt(ebeam * ebeam - me * me) - (q2m / 2. / ebeam + rk1));
506 tv2 = TVector3(sqrt(q2p * (1. - rk2 / ebeam - q2p / 4. / ebeam / ebeam)) * cos(rphi),
507 sqrt(q2p * (1. - rk2 / ebeam - q2p / 4. / ebeam / ebeam)) * sin(rphi),
508 - (sqrt(ebeam * ebeam - me * me) - (q2p / 2. / ebeam + rk2)));
509 tv3 = TVector3(sqrt(q2m * (1. - rk1 / ebeam - q2m / 4. / ebeam / ebeam)),
511 -(sqrt(ebeam * ebeam - me * me) - (q2m / 2. / ebeam + rk1)));
512 tv4 = TVector3(sqrt(q2p * (1. - rk2 / ebeam - q2p / 4. / ebeam / ebeam)) * cos(rphi),
513 sqrt(q2p * (1. - rk2 / ebeam - q2p / 4. / ebeam / ebeam)) * sin(rphi),
514 sqrt(ebeam * ebeam - me * me) - (q2p / 2. / ebeam + rk2));
518 if (gRandom->Uniform() > 0.5) {
519 pe = TLorentzVector(tv1, sqrt(tv1.Mag2() + me * me));
520 pp = TLorentzVector(tv2, sqrt(tv2.Mag2() + me * me));
522 pp = TLorentzVector(tv3, sqrt(tv3.Mag2() + me * me));
523 pe = TLorentzVector(tv4, sqrt(tv4.Mag2() + me * me));
526 double dphi = gRandom->Uniform() * twopi ;
530 TVector3 ws3 = -(pe + pp).Vect();
531 TLorentzVector ws = TLorentzVector(ws3, sqrt(ws3.Mag2() + w * w));
533 TVector3 wsb = (1. / ws.T()) * ws3 ;
538 tpgetm(parti, ndecay);
543 double zz = tpgetz(1);
544 double phi = twopi * gRandom->Uniform();
546 double m1 = parti[0].pmassp;
547 double m2 = parti[1].pmassp;
548 double pm = sutool.p2bdy(w, m1, m2, jcode);
549 if (jcode == 0) continue ;
550 pppp[0] = TLorentzVector(pm * sqrt(1. - zz * zz) * cos(phi),
551 pm * sqrt(1. - zz * zz) * sin(phi),
552 pm * zz, sqrt(pm * pm + m1 * m1));
554 pppp[1] = TLorentzVector(-(pppp[0].Vect()),
555 sqrt(pm * pm + m2 * m2));
562 double* massa =
new double [ndecay];
563 for (
int i = 0; i < ndecay ; i++) massa[i] = parti[i].pmassp ;
565 int jcode = sutool.pdecy(w, massa , wsb, pppp, ndecay);
566 if (jcode == 0)
continue;
575 for (
int i = 1 ; i <= ndecay ; i++) {
576 if (parti[i - 1].ndec <= 1) {
578 partgen[npoint - 1].part_prop = parti[i - 1];
579 partgen[npoint - 1].p = pppp[i - 1];
585 double* massa =
new double [ parti[i - 1].ndec ];
586 for (
int j = 0; j < parti[i - 1].ndec ; j++)
587 massa[j] = parts[nlist - 1 + j].pmass ;
588 TVector3 pppb = (1. / pppp[i - 1].T()) * pppp[i - 1].Vect();
589 TLorentzVector* ppptmp =
new TLorentzVector [ parti[i - 1].ndec ];
591 jcode = sutool.pdecy(parti[i - 1].pmassp, massa, pppb, ppptmp,
593 for (
int j = 0; j < parti[i - 1].ndec ; j++)
594 partgen[npoint - 1 + j].p = ppptmp[j] ;
599 if (jcode == 0) break ;
601 for (
int k = nlist ; k <= nlist + parti[i - 1].ndec - 1 ; k++) {
602 partgen[npoint - 1].part_prop = parts[k - 1];
605 nlist += parti[i - 1].ndec - 1 ;
610 if (jcode == 0) continue ;
612 int iret = tpuser(pe, pp, partgen, npoint);
613 if (iret <= 0) continue ;
618 TLorentzVector pfinal = TLorentzVector(0., 0., 0., 0.);
619 for (
int i = 0 ; i < npoint ; i++)pfinal += partgen[i].p ;
620 TLorentzVector pcm = pe + pp + pfinal;
621 double ptsumcm = sqrt(pfinal.X() * pfinal.X() + pfinal.Y() * pfinal.Y());
622 double pzsumcm = pfinal.Z();
623 double eall = pcm.T();
624 double wcal = sqrt(pfinal.T() * pfinal.T() -
625 ptsumcm * ptsumcm - pzsumcm * pzsumcm);
626 treh1->Fill((
float)pzsumcm, 1.0);
627 treh2->Fill((
float)ptsumcm, 1.0);
628 treh3->Fill((
float)eall, 1.0);
629 treh6->Fill((
float)wcal, 1.0);
633 for (
int i = 0 ; i < npoint ; i++) {
634 double zz = partgen[i].p.CosTheta();
635 if (abs(zz) > cost_cut && abs(partgen[i].part_prop.pcharg) > qzmin) rcode = 0;
636 double ptp = sqrt(pow(partgen[i].p.X(), 2) + pow(partgen[i].p.Y(), 2));
637 if (ptp < pt_cut && abs(partgen[i].part_prop.pcharg) > qptmin) rcode = 0;
640 sutool.rotate(pe, etheta, ephi);
642 sutool.rotate(pp, etheta, ephi);
644 for (
int i = 0; i < npoint ; i++) {
645 sutool.rotate(partgen[i].p, etheta, ephi);
646 partgen[i].p.Boost(tswsb);
649 TLorentzVector plab(0., 0., 0., 0.);
650 for (
int i = 0; i < npoint ; i++) plab += partgen[i].p ;
652 treh4->Fill((
float)(plab.Z()), 1.0);
653 treh5->Fill((
float)(sqrt(plab.X()*plab.X() + plab.Y()*plab.Y())), 1.0);
659 if (rcode == 0)
return 0;
661 trkpsh(iev, pe, pp, partgen, npoint);
666 double TrepsB::tpgetq(
double _s,
double z,
double _q2max)
668 B2DEBUG(20,
"Parameter _s=" << _s <<
" given but not used");
670 double q2min = me * me * z * z / (1. - z);
671 double rk = 1. / log(_q2max / q2min);
672 double ccc = rk * log(q2min);
673 double rr = gRandom->Uniform();
674 double xx = (rr + ccc) / rk ;
679 void TrepsB::tpgetm(Part_cont* part,
int _ndecay)
683 const double tmax = 1.4289 ;
685 for (
int i = 0; i < _ndecay ; i++) {
686 if (part[i].pwidth < 0.001) {
687 part[i].pmassp = part[i].pmass ;
689 part[i].pmassp = part[i].pmass + 0.5 * part[i].pwidth *
690 tan(2.*tmax * (gRandom->Uniform() - 0.5));
691 if (part[i].pmassp < 0.0) part[i].pmassp = 0.0 ;
701 void TrepsB::terminate()
const
704 B2DEBUG(20, nsave <<
" events saved.");
709 double TrepsB::tpdfnc(
double d)
const
712 const double alpppi = 0.002322816 ;
713 double y0 = (d + sqrt(d * d + 4.*rs)) * 0.5;
715 double xminy = log(me * me * y0 * y0 / (1.0 - y0));
716 double xminz = log(me * me * z0 * z0 / (1.0 - z0));
717 double xmax = log(q2max) ;
718 double integy = simpsny(d, xminy, xmax, 1000);
719 double integz = simpsnz(d, xminz, xmax, 1000);
720 double integrd = (integy + (-1. + y0) / y0) * (integz + (-1. + z0) / z0) / sqrt(d * d + 4.*rs)
726 double TrepsB::simpsny(
double d,
double xl,
double xh,
int n)
const
729 double h = (xh - xl) / (
double)nn ;
730 double _s = tpdfy(d, xl) + tpdfy(d, xh) ;
731 for (
int i = 1 ; i <= nn - 1 ; i += 2) {
732 double x = xl + (double)i * h ;
733 _s += 4.0 * tpdfy(d, x) ;
735 for (
int i = 2 ; i <= nn - 2 ; i += 2) {
736 double x = xl + (double)i * h ;
737 _s += 2.0 * tpdfy(d, x) ;
739 return h * _s / 3.0 ;
742 double TrepsB::tpdfy(
double d,
double x)
const
745 double y = ((d - q2 / s) + sqrt(d * d - 2.*q2 / s * d + 4.*q2 / s + 4.*rs)) * 0.5;
746 double integrq = (1. + (1. - y) * (1. - y)) / y * (1. - (-d + 2.) * q2 / (d * d + 4.*rs) / s) * 0.5;
747 if (y - d >= 1.) integrq = 0.;
748 return integrq * tplogf(x);
751 double TrepsB::simpsnz(
double d,
double xl,
double xh,
int n)
const
754 double h = (xh - xl) / (
double)nn ;
755 double _s = tpdfz(d, xl) + tpdfz(d, xh) ;
756 for (
int i = 1 ; i <= nn - 1 ; i += 2) {
757 double x = xl + (double)i * h ;
758 _s += 4.0 * tpdfz(d, x) ;
760 for (
int i = 2 ; i <= nn - 2 ; i += 2) {
761 double x = xl + (double)i * h ;
762 _s += 2.0 * tpdfz(d, x) ;
764 return h * _s / 3.0 ;
767 double TrepsB::tpdfz(
double d,
double x)
const
770 double z = ((-d - q2 / s) + sqrt(d * d - 2.*q2 / s * d + 4.*q2 / s + 4.*rs)) * 0.5;
771 double integrq = (1. + (1. - z) * (1. - z)) / z * (1. - (-d + 2.) * q2 / (d * d + 4.*rs) / s) * 0.5;
772 if (z + d >= 1.) integrq = 0.;
773 return integrq * tplogf(x);
777 double TrepsB::tpxint(
double r,
double _rs,
double _q2max)
const
781 double y = sqrt(r * _rs);
782 double z = sqrt(_rs / r);
783 return tpf(y, _q2max) * tpf(z, _q2max) * 0.5 / r ;
786 double TrepsB::tpf(
double z,
double _q2max)
const
788 const double alpppi = 0.002322816 ;
791 tpfx = 1. / z * ((1. + (1. - z) * (1. - z)) * log(_q2max * (1. - z) / me / me / z / z) * 0.5
792 - 1.0 + z) * alpppi ;
794 double xmin = log(me * me * z * z / (1.0 - z));
795 double xmax = log(_q2max) ;
796 tpfx = 1. / z * ((1. + (1. - z) * (1. - z)) * simpsn2(xmin, xmax, 1000) * 0.5
797 - 1.0 + z) * alpppi ;
802 double TrepsB::simpsn1(
double xl,
double xh,
int n)
const
805 double h = (xh - xl) / (
double)nn ;
806 double _s = tpdfnc(xl) + tpdfnc(xh) ;
807 for (
int i = 1 ; i <= nn - 1 ; i += 2) {
808 double x = xl + (double)i * h ;
809 _s += 4.0 * tpdfnc(x) ;
811 for (
int i = 2 ; i <= nn - 2 ; i += 2) {
812 double x = xl + (double)i * h ;
813 _s += 2.0 * tpdfnc(x) ;
815 return h * _s / 3.0 ;
818 double TrepsB::simpsn2(
double xl,
double xh,
int n)
const
821 double h = (xh - xl) / (
double)nn ;
822 double _s = tplogf(xl) + tplogf(xh) ;
823 for (
int i = 1 ; i <= nn - 1 ; i += 2) {
824 double x = xl + (double)i * h ;
825 _s += 4.0 * tplogf(x) ;
827 for (
int i = 2 ; i <= nn - 2 ; i += 2) {
828 double x = xl + (double)i * h ;
829 _s += 2.0 * tplogf(x) ;
831 return h * _s / 3.0 ;
834 double TrepsB::tplogf(
double x)
const
837 return tpform(q2, w) ;
841 double TrepsB::tpform(
double _q2,
double _w)
const
844 B2DEBUG(20,
"Parameters _q2=" << _q2 <<
" and _w=" << _w <<
" are given but not used");
849 double TrepsB::tpangd(
double _z,
double _w)
851 B2DEBUG(20,
"Parameters _z=" << _z <<
" and _w=" << _w <<
" are given but not used");
856 int TrepsB::tpuser(TLorentzVector _pe, TLorentzVector _pp,
857 Part_gen* part,
int _npart)
864 B2DEBUG(20,
"User decision routine for extra generation condition is not used."
865 <<
" _pe(" << _pe.Px() <<
"," << _pe.Py() <<
"," << _pe.Pz() <<
"), "
866 <<
" _pp(" << _pp.Px() <<
"," << _pp.Py() <<
"," << _pp.Pz() <<
"), "
867 <<
" *part at " << part <<
" and _npart = " << _npart <<
" are given but not used");
871 void TrepsB::trkpsh(
int iev,
872 TLorentzVector _pe, TLorentzVector _pp,
873 Part_gen* part,
int n)
const
875 B2DEBUG(20,
"iev = " << iev <<
" _pe(" << _pe.Px() <<
"," << _pe.Py() <<
"," << _pe.Pz() <<
"), "
876 <<
" _pp(" << _pp.Px() <<
"," << _pp.Py() <<
"," << _pp.Pz() <<
"), "
877 <<
" *part at " << part <<
" and n = " << n <<
" are given but not used");
880 void TrepsB::print_event()
const
883 const int& iev = ievent;
884 const int& n = npart;
885 const Part_gen* part = partgen;
887 TLorentzVector pf(0., 0., 0., 0.);
888 for (
int i = 0 ; i < n; i++) pf += part[i].p ;
889 TLorentzVector psum = pf + pe + pp ;
891 double q2e = -((pe - peb).Mag2());
892 double q2p = -((pp - ppb).Mag2());
893 double www = pf.Mag();
896 B2DEBUG(20,
"**************** Event# = " << iev <<
" ******************");
897 for (
int i = 0; i < n; i++) {
898 B2DEBUG(20, std::setw(2) << i + 1 << std::setw(11) << std::setprecision(4) << part[i].p.X() <<
899 std::setw(11) << std::setprecision(4) << part[i].p.Y() <<
900 std::setw(11) << std::setprecision(4) << part[i].p.Z() <<
901 std::setw(11) << std::setprecision(4) << part[i].p.T() <<
902 std::setw(7) << part[i].part_prop.icode <<
903 std::setw(11) << std::setprecision(4) << part[i].part_prop.pmass <<
904 std::setw(6) << std::setprecision(2) << part[i].part_prop.pcharg);
906 B2DEBUG(20, std::setw(2) <<
"e-" << std::setw(11) << std::setprecision(4) << pe.X() <<
907 std::setw(11) << std::setprecision(4) << pe.Y() <<
908 std::setw(11) << std::setprecision(4) << pe.Z() <<
909 std::setw(11) << std::setprecision(4) << pe.T() <<
911 std::setw(11) << std::setprecision(4) << me <<
912 std::setw(6) << std::setprecision(2) << -1.0);
914 B2DEBUG(20, std::setw(2) <<
"e+" << std::setw(11) << std::setprecision(4) << pp.X() <<
915 std::setw(11) << std::setprecision(4) << pp.Y() <<
916 std::setw(11) << std::setprecision(4) << pp.Z() <<
917 std::setw(11) << std::setprecision(4) << pp.T() <<
919 std::setw(11) << std::setprecision(4) << me <<
920 std::setw(6) << std::setprecision(2) << 1.0);
922 B2DEBUG(20,
"-----------------------------------------------");
923 B2DEBUG(20, std::setw(2) <<
"S:" << std::setw(11) << std::setprecision(4) << psum.X() <<
924 std::setw(11) << std::setprecision(4) << psum.Y() <<
925 std::setw(11) << std::setprecision(4) << psum.Z() <<
926 std::setw(11) << std::setprecision(4) << psum.T());
927 B2DEBUG(20,
" Q2:(" << q2e <<
", " << q2p <<
")" <<
929 " ptlab: " << sqrt(pf.X()*pf.X() + pf.Y()*pf.Y()) <<
930 " pzlab: " << pf.Z());
933 void TrepsB::tpkin3(Part_gen* part,
934 int index1,
int index2,
int index3,
double& z,
double& m12,
double& zp,
935 double& phip,
double& zs,
double& phis,
double& phi0)
938 TLorentzVector p1, p2, p3;
943 TVector3 tpcm = (-1. / (p1.T() + p2.T() + p3.T())) * (p1 + p2 + p3).Vect();
945 p1.Boost(tpcm); p2.Boost(tpcm); p3.Boost(tpcm);
949 TLorentzVector pa = p1 + p2;
955 sutool.rotate(p1, 0., phi0);
956 sutool.rotate(p2, 0., phi0);
957 sutool.rotate(p3, 0., phi0);
962 TVector3 pacm = (-1. / pa.T()) * pa.Vect();
963 TVector3 az = (1. / (pa.Vect()).Mag()) * pa.Vect();
964 p1.Boost(pacm); p2.Boost(pacm);
968 zp = p1.CosTheta(); phip = p1.Phi();
970 TVector3 ay = TVector3(0., 1., 0.);
971 TVector3 ax = ay.Cross(az);
973 zs = az.Dot(p1.Vect()) / (p1.Vect()).Mag();
974 TVector3 azk = az.Cross(p1.Vect());
975 double cosphis = ay.Dot(azk) * (1. / azk.Mag());
976 double sinphis = ax.Dot(azk) * (-1. / azk.Mag());
977 phis = atan2(sinphis, cosphis);
981 void TrepsB::tpkin4(Part_gen* part,
982 int index1,
int index2,
int index3,
int index4,
983 double& z,
double& m12,
double& zp,
984 double& phip,
double& zs,
double& phis,
985 double& m34,
double& zpp,
986 double& phipp,
double& zss,
double& phiss,
990 TLorentzVector p1, p2, p3, p4;
996 TVector3 tpcm = (-1. / (p1.T() + p2.T() + p3.T() + p4.T())) * (p1 + p2 + p3 + p4).Vect();
998 p1.Boost(tpcm); p2.Boost(tpcm); p3.Boost(tpcm); p4.Boost(tpcm);
1002 TLorentzVector pa = p1 + p2;
1008 sutool.rotate(p1, 0., phi0);
1009 sutool.rotate(p2, 0., phi0);
1010 sutool.rotate(p3, 0., phi0);
1011 sutool.rotate(p4, 0., phi0);
1016 TVector3 pacm = (-1. / pa.T()) * pa.Vect();
1017 TVector3 az = (1. / (pa.Vect()).Mag()) * pa.Vect();
1018 p1.Boost(pacm); p2.Boost(pacm);
1022 zp = p1.CosTheta(); phip = p1.Phi();
1024 TVector3 ay = TVector3(0., 1., 0.);
1025 TVector3 ax = ay.Cross(az);
1027 zs = az.Dot(p1.Vect()) / (p1.Vect()).Mag();
1028 TVector3 azk = az.Cross(p1.Vect());
1029 double cosphis = ay.Dot(azk) * (1. / azk.Mag());
1030 double sinphis = ax.Dot(azk) * (-1. / azk.Mag());
1031 phis = atan2(sinphis, cosphis);
1035 TLorentzVector pb = p3 + p4;
1039 TVector3 pbcm = (-1. / pb.T()) * pb.Vect();
1040 p3.Boost(pbcm); p4.Boost(pbcm);
1044 zpp = p3.CosTheta(); phipp = p3.Phi();
1049 zss = az.Dot(p3.Vect()) / (p3.Vect()).Mag();
1050 TVector3 bzk = az.Cross(p3.Vect());
1051 double cosphiss = ay.Dot(bzk) * (1. / bzk.Mag());
1052 double sinphiss = ax.Dot(bzk) * (-1. / bzk.Mag());
1053 phiss = atan2(sinphiss, cosphiss);
1056 void TrepsB::tpkin5(Part_gen* part,
1057 int index1,
int index2,
int index3,
int index4,
int index5,
1058 double& z,
double& m12,
double& zp,
1059 double& phip,
double& zs,
double& phis,
1060 TVector3& ps3, TVector3& ps4, TVector3& ps5,
1064 TLorentzVector p1, p2, p3, p4, p5;
1065 p1 = part[index1].p;
1066 p2 = part[index2].p;
1067 p3 = part[index3].p;
1068 p4 = part[index4].p;
1069 p5 = part[index5].p;
1071 TVector3 tpcm = (-1. / (p1.T() + p2.T() + p3.T() + p4.T() + p5.T())) * (p1 + p2 + p3 + p4 + p5).Vect();
1073 p1.Boost(tpcm); p2.Boost(tpcm); p3.Boost(tpcm); p4.Boost(tpcm); p5.Boost(tpcm);
1077 TLorentzVector pa = p1 + p2;
1083 sutool.rotate(p1, 0., phi0);
1084 sutool.rotate(p2, 0., phi0);
1085 sutool.rotate(p3, 0., phi0);
1086 sutool.rotate(p4, 0., phi0);
1087 sutool.rotate(p5, 0., phi0);
1090 TVector3 pacm = (-1. / pa.T()) * pa.Vect();
1091 TVector3 az = (1. / pa.Vect().Mag()) * pa.Vect();
1092 p1.Boost(pacm); p2.Boost(pacm);
1096 zp = p1.CosTheta(); phip = p1.Phi();
1098 TVector3 ay = TVector3(0., 1., 0.);
1099 TVector3 ax = ay.Cross(az);
1102 zs = az.Dot(p1.Vect()) / p1.Vect().Mag();
1103 TVector3 azk = az.Cross(p1.Vect());
1104 double cosphis = ay.Dot(azk) * (1. / azk.Mag());
1105 double sinphis = ax.Dot(azk) * (-1. / azk.Mag());
1106 phis = atan2(sinphis, cosphis);
1110 TLorentzVector pb = p3 + p4 + p5;
1113 TVector3 pbcm = (-1. / pb.T()) * pb.Vect();
1114 p3.Boost(pbcm); p4.Boost(pbcm); p5.Boost(pbcm);
1115 ps3 = p3.Vect(); ps4 = p4.Vect(); ps5 = p5.Vect();
Abstract base class for different kinds of events.