33 double A0 = std::sqrt(params[0] * (1 - params[2]));
34 double Al = std::sqrt(params[1] * (1 - params[2]));
35 double As = std::sqrt(params[2]);
36 const double &GammaS = params[3];
37 const double &DeltaGamma = params[4];
38 const double &DeltaM = params[5];
39 const double &phiS = params[6];
40 const double &delta_p = params[7];
41 const double &delta_l = params[8];
42 double delta_s = params[7] - params[9];
46 double &tagprob =
x[4];
50 if ( 1. - As*As - A0*A0 - Al*Al >= 0 ) Ap = std::sqrt(1. - As*As - A0*A0 - Al*Al);
54 double A[10], B1[10], B2[10],
C[10];
57 double sinphiS = std::sin(phiS);
58 double cosphiS = std::cos(phiS);
63 A[3] = 0.5 * A0*Al * std::cos(delta_l);
68 A[8] = 0.5 * As*Ap * std::sin(delta_p - delta_s);
74 double gammaH = GammaS - DeltaGamma/2.;
75 double gammaL = GammaS + DeltaGamma/2.;
76 double tauL = 1./gammaL;
77 double tauH = 1./gammaH;
78 double norm1 = (1./(tauL*(1.+cosphiS) + tauH*(1.-cosphiS)));
79 double norm2 = (1./(tauL*(1.-cosphiS) + tauH*(1.+cosphiS)));
80 double norm3 = (1./sqrt((tauL-tauH)*(tauL-tauH)*sinphiS*sinphiS+4.*tauL*tauH));
82 double ExpGSSinMT = 0.0;
83 double ExpGSCosMT = 0.0;
88 double ExpGL = std::exp(-time * gammaL);
91 double ExpGH = std::exp(-time * gammaH);
93 B1[0] = ( (1. + cosphiS) * ExpGL + (1. - cosphiS) * ExpGH ) * norm1;
95 B1[2] = ( (1. - cosphiS) * ExpGL + (1. + cosphiS) * ExpGH ) * norm2;
97 B1[4] = 0.5 * std::cos(delta_p - delta_l) * sinphiS * (ExpGL - ExpGH) * norm3;
98 B1[5] = 0.5 * std::cos(delta_p) * sinphiS * (ExpGL - ExpGH) * norm3;
100 B1[7] = 0.5 * sinphiS * std::sin(delta_l - delta_s) * (ExpGL - ExpGH) * norm3;
102 B1[9] = 0.5 * sinphiS * std::sin(delta_s) * (ExpGH - ExpGL) * norm3;
109 if( std::abs(tagprob - 0.5) > 1e-6 ){
112 ExpGSSinMT = std::exp(-time * GammaS) * std::sin(DeltaM * time);
113 ExpGSCosMT = std::exp(-time * GammaS) * std::cos(DeltaM * time);
116 B2[0] = 2. * ExpGSSinMT * sinphiS * norm1;
118 B2[2] = -2. * ExpGSSinMT * sinphiS * norm2;
120 B2[4] = ( ExpGSCosMT * std::sin(delta_p - delta_l) - cosphiS * std::cos(delta_p - delta_l) * ExpGSSinMT ) * norm3;
121 B2[5] = ( ExpGSCosMT * std::sin(delta_p) - cosphiS * std::cos(delta_p) * ExpGSSinMT ) * norm3;
123 B2[7] = ( ExpGSCosMT * std::cos(delta_l - delta_s) - cosphiS * std::sin(delta_l - delta_s) * ExpGSSinMT ) * norm3;
125 B2[9] = ( ExpGSCosMT * std::cos(delta_s) + cosphiS * std::sin(delta_s) * ExpGSSinMT ) * norm3;
130 for (
int k = 0; k<10; k++) B2[k] = 0;
138 double &costhetal =
x[1];
139 double &costhetak =
x[2];
142 double sinsqthetal = 1. - (costhetal * costhetal);
143 double sinsqthetak = 1. - (costhetak * costhetak);
144 double cossqthetak = costhetak * costhetak;
145 double coschi = std::cos(chi);
146 double cossqchi = coschi * coschi;
147 double sinchi = std::sin(chi);
148 double sinsqchi = sinchi * sinchi;
149 double sin2thetak = 2. * std::sqrt(1. - costhetak * costhetak) * costhetak;
150 double sin2thetal = 2. * std::sqrt(1. - costhetal * costhetal) * costhetal;
151 double sin2chi = std::sin(2. * chi);
152 double sinthetak = std::sqrt(sinsqthetak);
154 C[0] = 2. * cossqthetak * sinsqthetal;
155 C[1] = sinsqthetak * (1 - sinsqthetal * cossqchi);
156 C[2] = sinsqthetak * (1 - sinsqthetal * sinsqchi);
157 C[3] = 1. / std::sqrt(2.) * sin2thetak * sin2thetal * coschi;
158 C[4] = -1. * sinsqthetak * sinsqthetal * sin2chi;
159 C[5] = 1. / std::sqrt(2.) * sin2thetak * sin2thetal * sinchi;
160 C[6] = 2. / 3. * sinsqthetal;
161 C[7] = 1. / 3. * std::sqrt(6.) * sinthetak * sin2thetal * coschi;
162 C[8] = 1. / 3. * std::sqrt(6.) * sinthetak * sin2thetal * sinchi;
163 C[9] = 4. / 3. * std::sqrt(3.) * costhetak * sinsqthetal;
169 double &costheta =
x[1];
170 double &cospsi =
x[2];
173 double sinsqtheta = 1. - (costheta * costheta);
174 double sinsqpsi = 1. - (cospsi * cospsi);
175 double cossqpsi = cospsi * cospsi;
176 double sin2theta = 2. * std::sqrt(1. - costheta * costheta) * costheta;
177 double sin2psi = 2. * std::sqrt(1. - cospsi * cospsi) * cospsi;
178 double cosphi = std::cos(
phi);
179 double cossqphi = cosphi * cosphi;
180 double sinphi = std::sin(
phi);
181 double sinsqphi = sinphi * sinphi;
182 double sin2phi = std::sin(2. *
phi);
183 double sinpsi = std::sqrt(1. - cospsi*cospsi);
185 C[0] = 2. * cossqpsi * (1. - sinsqtheta * cossqphi);
186 C[1] = sinsqpsi * (1.-sinsqtheta * sinsqphi);
187 C[2] = sinsqpsi * sinsqtheta;
188 C[3] = 1. / sqrt(2.) * sin2psi * sinsqtheta * sin2phi;
189 C[4] = -1. * sinsqpsi * sin2theta * sinphi;
190 C[5] = 1. / sqrt(2.) * sin2psi * sin2theta * cosphi;
191 C[6] = 2. / 3. *(1. - sinsqtheta * cossqphi);
192 C[7] = 1. / 3. *sqrt(6.) *sinpsi * sinsqtheta * sin2phi;
193 C[8] = 1. / 3. *sqrt(6.) *sinpsi * sin2theta * cosphi;
194 C[9] = 4. / 3. *sqrt(3.) *cospsi * (1. - sinsqtheta * cossqphi);
205 for (
int i=0; i<10; ++i ) {
207 Wplus +=
A[i] * ( B1[i] + B2[i] ) *
C[i];
208 Wminus +=
A[i] * ( B1[i] - B2[i] ) *
C[i];
212 double value = tagprob * Wplus + (1. - tagprob) * Wminus;
238 const std::vector<double> & userVars) {
240 using CLHEP::HepLorentzVector;
246 if (userString ==
"EXAMPLE" && event.size() > 0 && userVars.size() > 0) {
258 else if (userString ==
"BJPSIINCLUSIVE" && event.size() > 0) {
260 if (userVars.size()==0) {
261 ATH_MSG_INFO(
"User selection BJPSIINCLUSIVE with B-state");
263 if (userVars.size()>0) {
264 if (userVars.size()>1)
ATH_MSG_WARNING(
"User selection BJPSIINCLUSIVE with more than one argument! Check job options");
265 if (userVars.at(0)>0)
ATH_MSG_DEBUG(
"User selection BJPSIINCLUSIVE with B-state");
266 if (userVars.at(0)<0) {
ATH_MSG_DEBUG(
"User selection BJPSIINCLUSIVE with anti-B-state"); chargeConj = -1;}
270 std::vector<int> bToCharmoniaCodes;
271 bToCharmoniaCodes.push_back(511*chargeConj);
272 bToCharmoniaCodes.push_back(521*chargeConj);
273 bToCharmoniaCodes.push_back(531*chargeConj);
274 bToCharmoniaCodes.push_back(541*chargeConj);
275 bToCharmoniaCodes.push_back(-5122*chargeConj);
276 bToCharmoniaCodes.push_back(-5132*chargeConj);
277 bToCharmoniaCodes.push_back(-5232*chargeConj);
278 bToCharmoniaCodes.push_back(-5332*chargeConj);
280 int eventSize =
event.size();
282 bool isBtoJpsi(
false);
283 bool containsB(
false);
285 for (
int i = 0; i < eventSize; i++) {
286 int pdgID =
event[i].id();
287 std::vector < Pythia8::Particle > decayMembers;
290 for (
unsigned int k = 0; k < bToCharmoniaCodes.size(); ++k) {
291 if (pdgID == bToCharmoniaCodes[k]) {
300 const std::vector<int> & pdgCodes =
getCodes(decayMembers);
301 for (
unsigned int k = 0; k < pdgCodes.size(); ++k) {
302 if (pdgCodes[k] == 443)
309 if (containsB && isBtoJpsi)
311 if (containsB && !isBtoJpsi)
322 else if ((userString ==
"BJPSIPHI_TRANS" || userString ==
"BJPSIPHI_HEL")
323 && event.size() > 0) {
325 const bool debug =
false;
343 if (userVars.size() < 13) {
345 "REQUIRED userVARs not provided for BsJpsiPhi pdf defaulting to flat");
348 flat = userVars[0] == 0.0;
367 bool isBsJpsiPhi =
false;
368 int eventSize =
event.size();
369 for (
int i = 0; i < eventSize; i++) {
371 int pID =
event[i].id();
372 if (std::abs(pID) == 531) {
374 std::vector<int> daughterlist =
event.daughterList(i);
376 if (daughterlist.size() != 2)
380 if (event[daughterlist[0]].
id() == 443) {
382 i_Jpsi = daughterlist[0];
384 if (event[daughterlist[1]].
id() == 443) {
386 i_Jpsi = daughterlist[1];
388 if (event[daughterlist[0]].
id() == 333) {
390 i_Phi = daughterlist[0];
392 if (event[daughterlist[1]].
id() == 333) {
394 i_Phi = daughterlist[1];
396 if (!isphi || !isjpsi)
398 std::vector<int> daughterlistJpsi =
event.daughterList(i_Jpsi);
399 std::vector<int> daughterlistPhi =
event.daughterList(i_Phi);
400 if (daughterlistJpsi.size() != 2 || daughterlistPhi.size() != 2)
404 if (event[daughterlistJpsi[0]].
id() == 13)
405 i_Muminus = daughterlistJpsi[0];
406 else if (event[daughterlistJpsi[1]].
id() == 13)
407 i_Muminus = daughterlistJpsi[1];
411 if (event[daughterlistJpsi[0]].
id() == -13)
412 i_Muplus = daughterlistJpsi[0];
413 else if (event[daughterlistJpsi[1]].
id() == -13)
414 i_Muplus = daughterlistJpsi[1];
418 if (event[daughterlistPhi[0]].
id() == 321)
419 i_Kplus = daughterlistPhi[0];
420 else if (event[daughterlistPhi[1]].
id() == 321)
421 i_Kplus = daughterlistPhi[1];
425 if (event[daughterlistPhi[0]].
id() == -321)
426 i_Kminus = daughterlistPhi[0];
427 else if (event[daughterlistPhi[1]].
id() == -321)
428 i_Kminus = daughterlistPhi[1];
431 if (i_Muminus == 0 || i_Muplus == 0 || i_Kminus == 0 || i_Kplus
437 "found entire Bs->Jpsi(mumu)phi(KK) decay ");
449 Pythia8::Particle &p_Bs =
event[i_Bs];
450 Pythia8::Particle &p_Muplus =
event[i_Muplus];
451 Pythia8::Particle &p_Muminus =
event[i_Muminus];
452 Pythia8::Particle &p_Kplus =
event[i_Kplus];
453 Pythia8::Particle &p_Kminus =
event[i_Kminus];
454 Pythia8::Particle &p_Phi =
event[i_Phi];
455 Pythia8::Particle &p_Jpsi =
event[i_Jpsi];
474 const double correctionfactor = 0.299792458;
475 const double gentauCorrect = gentau / correctionfactor;
480 const double Bstau = p_Bs.tau() / correctionfactor;
484 if (userString ==
"BJPSIPHI_TRANS") {
493 }
else if (userString ==
"BJPSIPHI_HEL") {
504 const double prob2 = exp(Bstau / gentauCorrect) * gentauCorrect;
507 const double prob_norm = userVars[1];
512 double rand = Rdmengine->flat() * prob_norm;
513 if (prob1 * prob2 > prob_norm) {
515 "Max prob exceeded, too many of these indicates a problem, a few is fine");
518 std::cout <<
"totalprob " << prob1 * prob2 << std::endl;
519 if (rand < (prob1 * prob2)) {
531 else if(userString ==
"BD_BPLUS_TAUCUT"){
532 const double correctionfactor = 0.299792458;
534 int eventSize =
event.size();
536 for (
int i = 0; i < eventSize; i++) {
537 int pID =
event[i].id();
539 const double Bdtau =
event[i].tau() / correctionfactor;
540 pass &= Bdtau > userVars[0] && Bdtau < userVars[1];
544 const double Bptau =
event[i].tau() / correctionfactor;
545 pass &= Bptau > userVars[0] && Bptau < userVars[1];
549 accept = (foundcount > 0) & pass;
552 else if ((userString ==
"BDJPSIKSTAR_TRANS") && event.size() > 0) {
553 const bool debug =
false;
555 if (userVars.size() < 13) {
557 "REQUIRED userVARs not provided for BdJpsiKstar pdf defaulting to flat");
560 flat = userVars[0] == 0.0;
571 bool isBsJpsiKstar =
false;
572 const int eventSize =
event.size();
573 for (
int i = 0; i < eventSize; i++) {
575 const int pID =
event[i].id();
576 if (std::abs(pID) == 511) {
578 std::vector<int> daughterlist =
event.daughterList(i);
580 if (daughterlist.size() != 2)
583 bool iskstar =
false;
584 if (event[daughterlist[0]].
id() == 443) {
586 i_Jpsi = daughterlist[0];
588 if (event[daughterlist[1]].
id() == 443) {
590 i_Jpsi = daughterlist[1];
592 if (std::abs(event[daughterlist[0]].
id()) == 313) {
594 i_Kstar = daughterlist[0];
596 if (std::abs(event[daughterlist[1]].
id()) == 313) {
598 i_Kstar = daughterlist[1];
600 if (!iskstar || !isjpsi)
602 std::vector<int> daughterlistJpsi =
event.daughterList(i_Jpsi);
603 std::vector<int> daughterlistKstar =
event.daughterList(i_Kstar);
604 if (daughterlistJpsi.size() != 2 || daughterlistKstar.size() != 2)
608 if (event[daughterlistJpsi[0]].
id() == 13)
609 i_Muminus = daughterlistJpsi[0];
610 else if (event[daughterlistJpsi[1]].
id() == 13)
611 i_Muminus = daughterlistJpsi[1];
615 if (event[daughterlistJpsi[0]].
id() == -13)
616 i_Muplus = daughterlistJpsi[0];
617 else if (event[daughterlistJpsi[1]].
id() == -13)
618 i_Muplus = daughterlistJpsi[1];
622 if (std::abs(event[daughterlistKstar[0]].
id()) == 321)
623 i_Kplus = daughterlistKstar[0];
624 else if (std::abs(event[daughterlistKstar[1]].
id()) == 321)
625 i_Kplus = daughterlistKstar[1];
629 if (std::abs(event[daughterlistKstar[0]].
id()) == 211)
630 i_piminus = daughterlistKstar[0];
631 else if (std::abs(event[daughterlistKstar[1]].
id()) == 211)
632 i_piminus = daughterlistKstar[1];
636 if (i_Muminus == 0 || i_Muplus == 0 || i_piminus == 0 || i_Kplus
642 "found entire Bd->Jpsi(mumu)Kstar(KPi) decay ");
643 isBsJpsiKstar =
true;
654 Pythia8::Particle &p_Bd =
event[i_Bd];
655 Pythia8::Particle &p_Muplus =
event[i_Muplus];
656 Pythia8::Particle &p_Muminus =
event[i_Muminus];
657 Pythia8::Particle &p_Kplus =
event[i_Kplus];
659 Pythia8::Particle &p_Kstar =
event[i_Kstar];
660 Pythia8::Particle &p_Jpsi =
event[i_Jpsi];
679 const double correctionfactor = 0.299792458;
680 const double gentauCorrect = gentau / correctionfactor;
685 const double Bdtau = p_Bd.tau() / correctionfactor;
699 const double prob2 = exp(Bdtau / gentauCorrect) * gentauCorrect;
702 const double prob_norm = userVars[1];
707 const double rand = Rdmengine->flat() * prob_norm;
708 if (prob1 * prob2 > prob_norm) {
710 "Max prob exceeded, too many of these indicates a problem, a few is fine");
713 std::cout <<
"totalprob " << prob1 * prob2 << std::endl;
714 if (rand < (prob1 * prob2)) {