14 #include "CLHEP/Vector/LorentzVector.h"
18 CLHEP::HepLorentzVector vect;
34 double As = std::sqrt(
params[2]);
35 double &GammaS =
params[3];
36 double &DeltaGamma =
params[4];
37 double &DeltaM =
params[5];
39 double &delta_p =
params[7];
40 double &delta_l =
params[8];
45 double &tagprob =
x[4];
49 if ( 1. - As*As - A0*A0 - Al*Al >= 0 ) Ap = std::sqrt(1. - As*As - A0*A0 - Al*Al);
53 double A[10], B1[10], B2[10],
C[10];
67 A[8] = 0.5 * As*Ap *
std::sin(delta_p - delta_s);
73 double gammaH = GammaS - DeltaGamma/2.;
74 double gammaL = GammaS + DeltaGamma/2.;
75 double tauL = 1./gammaL;
76 double tauH = 1./gammaH;
77 double norm1 = (1./(tauL*(1.+cosphiS) + tauH*(1.-cosphiS)));
78 double norm2 = (1./(tauL*(1.-cosphiS) + tauH*(1.+cosphiS)));
79 double norm3 = (1./sqrt((tauL-tauH)*(tauL-tauH)*sinphiS*sinphiS+4.*tauL*tauH));
81 double ExpGSSinMT = 0.0;
82 double ExpGSCosMT = 0.0;
92 B1[0] = ( (1. + cosphiS) * ExpGL + (1. - cosphiS) * ExpGH ) * norm1;
94 B1[2] = ( (1. - cosphiS) * ExpGL + (1. + cosphiS) * ExpGH ) * norm2;
96 B1[4] = 0.5 *
std::cos(delta_p - delta_l) * sinphiS * (ExpGL - ExpGH) * norm3;
97 B1[5] = 0.5 *
std::cos(delta_p) * sinphiS * (ExpGL - ExpGH) * norm3;
99 B1[7] = 0.5 * sinphiS *
std::sin(delta_l - delta_s) * (ExpGL - ExpGH) * norm3;
101 B1[9] = 0.5 * sinphiS *
std::sin(delta_s) * (ExpGH - ExpGL) * norm3;
108 if( std::abs(tagprob - 0.5) > 1
e-6 ){
115 B2[0] = 2. * ExpGSSinMT * sinphiS * norm1;
117 B2[2] = -2. * ExpGSSinMT * sinphiS * norm2;
119 B2[4] = ( ExpGSCosMT *
std::sin(delta_p - delta_l) - cosphiS *
std::cos(delta_p - delta_l) * ExpGSSinMT ) * norm3;
120 B2[5] = ( ExpGSCosMT *
std::sin(delta_p) - cosphiS *
std::cos(delta_p) * ExpGSSinMT ) * norm3;
122 B2[7] = ( ExpGSCosMT *
std::cos(delta_l - delta_s) - cosphiS *
std::sin(delta_l - delta_s) * ExpGSSinMT ) * norm3;
124 B2[9] = ( ExpGSCosMT *
std::cos(delta_s) + cosphiS *
std::sin(delta_s) * ExpGSSinMT ) * norm3;
129 for (
int k = 0;
k<10;
k++) B2[
k] = 0;
137 double &costhetal =
x[1];
138 double &costhetak =
x[2];
141 double sinsqthetal = 1. - (costhetal * costhetal);
142 double sinsqthetak = 1. - (costhetak * costhetak);
143 double cossqthetak = costhetak * costhetak;
145 double cossqchi = coschi * coschi;
147 double sinsqchi = sinchi * sinchi;
148 double sin2thetak = 2. * std::sqrt(1. - costhetak * costhetak) * costhetak;
149 double sin2thetal = 2. * std::sqrt(1. - costhetal * costhetal) * costhetal;
150 double sin2chi =
std::sin(2. * chi);
151 double sinthetak = std::sqrt(sinsqthetak);
153 C[0] = 2. * cossqthetak * sinsqthetal;
154 C[1] = sinsqthetak * (1 - sinsqthetal * cossqchi);
155 C[2] = sinsqthetak * (1 - sinsqthetal * sinsqchi);
156 C[3] = 1. / std::sqrt(2.) * sin2thetak * sin2thetal * coschi;
157 C[4] = -1. * sinsqthetak * sinsqthetal * sin2chi;
158 C[5] = 1. / std::sqrt(2.) * sin2thetak * sin2thetal * sinchi;
159 C[6] = 2. / 3. * sinsqthetal;
160 C[7] = 1. / 3. * std::sqrt(6.) * sinthetak * sin2thetal * coschi;
161 C[8] = 1. / 3. * std::sqrt(6.) * sinthetak * sin2thetal * sinchi;
162 C[9] = 4. / 3. * std::sqrt(3.) * costhetak * sinsqthetal;
168 double &costheta =
x[1];
169 double &cospsi =
x[2];
172 double sinsqtheta = 1. - (costheta * costheta);
173 double sinsqpsi = 1. - (cospsi * cospsi);
174 double cossqpsi = cospsi * cospsi;
175 double sin2theta = 2. * std::sqrt(1. - costheta * costheta) * costheta;
176 double sin2psi = 2. * std::sqrt(1. - cospsi * cospsi) * cospsi;
178 double cossqphi = cosphi * cosphi;
180 double sinsqphi = sinphi * sinphi;
182 double sinpsi = std::sqrt(1. - cospsi*cospsi);
184 C[0] = 2. * cossqpsi * (1. - sinsqtheta * cossqphi);
185 C[1] = sinsqpsi * (1.-sinsqtheta * sinsqphi);
186 C[2] = sinsqpsi * sinsqtheta;
187 C[3] = 1. / sqrt(2.) * sin2psi * sinsqtheta * sin2phi;
188 C[4] = -1. * sinsqpsi * sin2theta * sinphi;
189 C[5] = 1. / sqrt(2.) * sin2psi * sin2theta * cosphi;
190 C[6] = 2. / 3. *(1. - sinsqtheta * cossqphi);
191 C[7] = 1. / 3. *sqrt(6.) *sinpsi * sinsqtheta * sin2phi;
192 C[8] = 1. / 3. *sqrt(6.) *sinpsi * sin2theta * cosphi;
193 C[9] = 4. / 3. *sqrt(3.) *cospsi * (1. - sinsqtheta * cossqphi);
204 for (
int i=0;
i<10; ++
i ) {
206 Wplus +=
A[
i] * ( B1[
i] + B2[
i] ) *
C[
i];
207 Wminus +=
A[
i] * ( B1[
i] - B2[
i] ) *
C[
i];
211 double value = tagprob * Wplus + (1. - tagprob) * Wminus;
237 std::vector<double> userVars) {
239 using CLHEP::HepLorentzVector;
245 if (userString ==
"EXAMPLE" &&
event.size() > 0 && userVars.size() > 0) {
257 else if (userString ==
"BJPSIINCLUSIVE" &&
event.size() > 0) {
259 if (userVars.size()==0) {
260 ATH_MSG_INFO(
"User selection BJPSIINCLUSIVE with B-state");
262 if (userVars.size()>0) {
263 if (userVars.size()>1)
ATH_MSG_WARNING(
"User selection BJPSIINCLUSIVE with more than one argument! Check job options");
264 if (userVars.at(0)>0)
ATH_MSG_DEBUG(
"User selection BJPSIINCLUSIVE with B-state");
265 if (userVars.at(0)<0) {
ATH_MSG_DEBUG(
"User selection BJPSIINCLUSIVE with anti-B-state"); chargeConj = -1;}
269 std::vector<int> bToCharmoniaCodes;
270 bToCharmoniaCodes.push_back(511*chargeConj);
271 bToCharmoniaCodes.push_back(521*chargeConj);
272 bToCharmoniaCodes.push_back(531*chargeConj);
273 bToCharmoniaCodes.push_back(541*chargeConj);
274 bToCharmoniaCodes.push_back(-5122*chargeConj);
275 bToCharmoniaCodes.push_back(-5132*chargeConj);
276 bToCharmoniaCodes.push_back(-5232*chargeConj);
277 bToCharmoniaCodes.push_back(-5332*chargeConj);
279 int eventSize =
event.size();
281 bool isBtoJpsi(
false);
282 bool containsB(
false);
284 for (
int i = 0;
i < eventSize;
i++) {
285 int pdgID =
event[
i].id();
286 std::vector < Pythia8::Particle > decayMembers;
289 for (
unsigned int k = 0;
k < bToCharmoniaCodes.size(); ++
k) {
290 if (pdgID == bToCharmoniaCodes[
k]) {
299 std::vector<int> pdgCodes =
getCodes(decayMembers);
300 for (
unsigned int k = 0;
k < pdgCodes.size(); ++
k) {
301 if (pdgCodes[
k] == 443)
308 if (containsB && isBtoJpsi)
310 if (containsB && !isBtoJpsi)
321 else if ((userString ==
"BJPSIPHI_TRANS" || userString ==
"BJPSIPHI_HEL")
322 &&
event.size() > 0) {
324 const bool debug =
false;
342 if (userVars.size() < 13) {
344 "REQUIRED userVARs not provided for BsJpsiPhi pdf defaulting to flat");
347 flat = userVars[0] == 0.0;
366 bool isBsJpsiPhi =
false;
367 int eventSize =
event.size();
368 for (
int i = 0;
i < eventSize;
i++) {
370 int pID =
event[
i].id();
371 if (std::abs(pID) == 531) {
373 std::vector<int> daughterlist =
event.daughterList(
i);
375 if (daughterlist.size() != 2)
379 if (
event[daughterlist[0]].
id() == 443) {
381 i_Jpsi = daughterlist[0];
383 if (
event[daughterlist[1]].
id() == 443) {
385 i_Jpsi = daughterlist[1];
387 if (
event[daughterlist[0]].
id() == 333) {
389 i_Phi = daughterlist[0];
391 if (
event[daughterlist[1]].
id() == 333) {
393 i_Phi = daughterlist[1];
395 if (!isphi || !isjpsi)
397 std::vector<int> daughterlistJpsi =
event.daughterList(i_Jpsi);
398 std::vector<int> daughterlistPhi =
event.daughterList(i_Phi);
399 if (daughterlistJpsi.size() != 2 || daughterlistPhi.size() != 2)
403 if (
event[daughterlistJpsi[0]].
id() == 13)
404 i_Muminus = daughterlistJpsi[0];
405 else if (
event[daughterlistJpsi[1]].
id() == 13)
406 i_Muminus = daughterlistJpsi[1];
410 if (
event[daughterlistJpsi[0]].
id() == -13)
411 i_Muplus = daughterlistJpsi[0];
412 else if (
event[daughterlistJpsi[1]].
id() == -13)
413 i_Muplus = daughterlistJpsi[1];
417 if (
event[daughterlistPhi[0]].
id() == 321)
418 i_Kplus = daughterlistPhi[0];
419 else if (
event[daughterlistPhi[1]].
id() == 321)
420 i_Kplus = daughterlistPhi[1];
424 if (
event[daughterlistPhi[0]].
id() == -321)
425 i_Kminus = daughterlistPhi[0];
426 else if (
event[daughterlistPhi[1]].
id() == -321)
427 i_Kminus = daughterlistPhi[1];
430 if (i_Muminus == 0 || i_Muplus == 0 || i_Kminus == 0 || i_Kplus
436 "found entire Bs->Jpsi(mumu)phi(KK) decay ");
473 const double correctionfactor = 0.299792458;
474 const double gentauCorrect = gentau / correctionfactor;
479 const double Bstau = p_Bs.tau() / correctionfactor;
483 if (userString ==
"BJPSIPHI_TRANS") {
492 }
else if (userString ==
"BJPSIPHI_HEL") {
503 const double prob2 =
exp(Bstau / gentauCorrect) * gentauCorrect;
506 const double prob_norm = userVars[1];
511 double rand = Rdmengine->flat() * prob_norm;
512 if (prob1 * prob2 > prob_norm) {
514 "Max prob exceeded, too many of these indicates a problem, a few is fine");
517 std::cout <<
"totalprob " << prob1 * prob2 << std::endl;
518 if (
rand < (prob1 * prob2)) {
530 else if(userString ==
"BD_BPLUS_TAUCUT"){
531 const double correctionfactor = 0.299792458;
533 int eventSize =
event.size();
535 for (
int i = 0;
i < eventSize;
i++) {
536 int pID =
event[
i].id();
538 const double Bdtau =
event[
i].tau() / correctionfactor;
539 pass &= Bdtau > userVars[0] && Bdtau < userVars[1];
543 const double Bptau =
event[
i].tau() / correctionfactor;
544 pass &= Bptau > userVars[0] && Bptau < userVars[1];
548 accept = (foundcount > 0) & pass;
551 else if ((userString ==
"BDJPSIKSTAR_TRANS") &&
event.size() > 0) {
552 const bool debug =
false;
554 if (userVars.size() < 13) {
556 "REQUIRED userVARs not provided for BdJpsiKstar pdf defaulting to flat");
559 flat = userVars[0] == 0.0;
570 bool isBsJpsiKstar =
false;
571 const int eventSize =
event.size();
572 for (
int i = 0;
i < eventSize;
i++) {
574 const int pID =
event[
i].id();
575 if (std::abs(pID) == 511) {
577 std::vector<int> daughterlist =
event.daughterList(
i);
579 if (daughterlist.size() != 2)
582 bool iskstar =
false;
583 if (
event[daughterlist[0]].
id() == 443) {
585 i_Jpsi = daughterlist[0];
587 if (
event[daughterlist[1]].
id() == 443) {
589 i_Jpsi = daughterlist[1];
591 if (std::abs(
event[daughterlist[0]].
id()) == 313) {
593 i_Kstar = daughterlist[0];
595 if (std::abs(
event[daughterlist[1]].
id()) == 313) {
597 i_Kstar = daughterlist[1];
599 if (!iskstar || !isjpsi)
601 std::vector<int> daughterlistJpsi =
event.daughterList(i_Jpsi);
602 std::vector<int> daughterlistKstar =
event.daughterList(i_Kstar);
603 if (daughterlistJpsi.size() != 2 || daughterlistKstar.size() != 2)
607 if (
event[daughterlistJpsi[0]].
id() == 13)
608 i_Muminus = daughterlistJpsi[0];
609 else if (
event[daughterlistJpsi[1]].
id() == 13)
610 i_Muminus = daughterlistJpsi[1];
614 if (
event[daughterlistJpsi[0]].
id() == -13)
615 i_Muplus = daughterlistJpsi[0];
616 else if (
event[daughterlistJpsi[1]].
id() == -13)
617 i_Muplus = daughterlistJpsi[1];
621 if (std::abs(
event[daughterlistKstar[0]].
id()) == 321)
622 i_Kplus = daughterlistKstar[0];
623 else if (std::abs(
event[daughterlistKstar[1]].
id()) == 321)
624 i_Kplus = daughterlistKstar[1];
628 if (std::abs(
event[daughterlistKstar[0]].
id()) == 211)
629 i_piminus = daughterlistKstar[0];
630 else if (std::abs(
event[daughterlistKstar[1]].
id()) == 211)
631 i_piminus = daughterlistKstar[1];
635 if (i_Muminus == 0 || i_Muplus == 0 || i_piminus == 0 || i_Kplus
641 "found entire Bd->Jpsi(mumu)Kstar(KPi) decay ");
642 isBsJpsiKstar =
true;
678 const double correctionfactor = 0.299792458;
679 const double gentauCorrect = gentau / correctionfactor;
684 const double Bdtau = p_Bd.tau() / correctionfactor;
698 const double prob2 =
exp(Bdtau / gentauCorrect) * gentauCorrect;
701 const double prob_norm = userVars[1];
706 const double rand = Rdmengine->flat() * prob_norm;
707 if (prob1 * prob2 > prob_norm) {
709 "Max prob exceeded, too many of these indicates a problem, a few is fine");
712 std::cout <<
"totalprob " << prob1 * prob2 << std::endl;
713 if (
rand < (prob1 * prob2)) {