1 #include "TauSpinner/tau_reweight_lib.h"
2 #include "TauSpinner/Particle.h"
3 #include "TauSpinner/vbfdistr.h"
12 extern int relWTnonSM;
13 extern double WTnonSM;
15 extern double WTamplit;
16 extern double WTamplitP;
17 extern double WTamplitM;
19 extern double f(
double x,
int ID,
double SS,
double cmsene);
30 void (*alphasModif)(double, int, int) = NULL;
43 double (*vbfdistrModif)(int, int, int, int, int, int,
double[6][4], int, double) = NULL;
46 void set_vbfdistrModif(
double (*
function)(
int,
int,
int,
int,
int,
int,
double[6][4],
int,
double) )
52 _QCDdefault=QCDdefault;
53 _QCDvariant=QCDvariant;
56 int getPDFOpt(
int KEY){
57 if (KEY==0 || KEY==1)
return _QCDdefault;
58 else return _QCDvariant;
61 void alphas(
double Q2,
int scalePDFOpt,
int KEY){
68 const double PI=3.14159265358979324;
72 const double AlphasMZ = 0.118;
73 const double MZ =91.1876;
75 double alfas=AlphasMZ / ( 1 + AlphasMZ/(4*PI) * (11 - 2./3 * Nf) * log(Q2/(MZ*MZ)));
77 if(scalePDFOpt==0) alfas = 0.118;
78 if(params_r_.as != alfas){
87 double vbfdistr(
int I1,
int I2,
int I3,
int I4,
int H1,
int H2,
double P[6][4],
int KEY)
90 double original_result = 0.;
92 memcpy(P_copy,P,
sizeof(
double)*6*4);
96 return vbfdistr_(&I1, &I2, &I3, &I4, &H1, &H2, P_copy, &KEY);
99 printf(
"TauSpinner::vbfdistr: User function vbfdistrModif not declared. Setting WT_contrib = 0.0 Failed attempt with KEY = %i5. \n",KEY);
100 return original_result;
105 original_result=
vbfdistr_(&I1, &I2, &I3, &I4, &H1, &H2, P_copy, &KEY_BUF);
106 return vbfdistrModif(I1,I2,I3,I4,H1,H2,P_copy,KEY,original_result);
110 return vbfdistrModif(I1,I2,I3,I4,H1,H2,P_copy,KEY,original_result);
123 Particle p3(p3i.px(),p3i.py(),p3i.pz(),p3i.e(),0);
124 Particle p4(p4i.px(),p4i.py(),p4i.pz(),p4i.e(),0);
125 double mtaul=sqrt(tau1i.e()*tau1i.e()-tau1i.px()*tau1i.px()-tau1i.py()*tau1i.py()-tau1i.pz()*tau1i.pz());
126 Particle tau1(tau1i.px(),tau1i.py(),tau1i.pz(),tau1i.e(),0);
127 Particle tau2(tau2i.px(),tau2i.py(),tau2i.pz(),tau2i.e(),0);
156 Particle P_QQ( p3.px()+p4.px()+tau1.px()+tau2.px()+1e-8*p3.pz(),
157 p3.py()+p4.py()+tau1.py()+tau2.py()-2e-8*p3.pz(),
158 p3.pz()+p4.pz()+tau1.pz()+tau2.pz(),
159 p3.e() +p4.e() +tau1.e() +tau2.e(), 0 );
160 tau1.boostToRestFrame(P_QQ);
161 tau2.boostToRestFrame(P_QQ);
162 p3.boostToRestFrame(P_QQ);
163 p4.boostToRestFrame(P_QQ);
164 v1.boostToRestFrame(P_QQ);
165 v2.boostToRestFrame(P_QQ);
168 double xn1=sqrt(v1.px()*v1.px()+v1.py()*v1.py()+v1.pz()*v1.pz());
169 double xn2=sqrt(v2.px()*v2.px()+v2.py()*v2.py()+v2.pz()*v2.pz());
170 double xn12=sqrt( (v1.px()-v2.px())*(v1.px()-v2.px()) +(v1.py()-v2.py())*(v1.py()-v2.py())+(v1.pz()-v2.pz())*(v1.pz()-v2.pz()));
172 double SS = P_QQ.recalculated_mass()*P_QQ.recalculated_mass();
174 double x1x2 = SS/CMSENE/CMSENE;
175 double x1Mx2 = P_QQ.pz()/CMSENE*2;
177 double x1 = ( x1Mx2 + sqrt(x1Mx2*x1Mx2 + 4*x1x2) )/2;
178 double x2 = ( -x1Mx2 + sqrt(x1Mx2*x1Mx2 + 4*x1x2) )/2;
184 double P[6][4] = { { sqrt(SS)/2, sqrt(SS)/2/xn12*(v1.px()-v2.px()), sqrt(SS)/2/xn12*(v1.py()-v2.py()), sqrt(SS)/2/xn12*(v1.pz()-v2.pz()) },
185 { sqrt(SS)/2, -sqrt(SS)/2/xn12*(v1.px()-v2.px()), -sqrt(SS)/2/xn12*(v1.py()-v2.py()), -sqrt(SS)/2/xn12*(v1.pz()-v2.pz()) },
192 { p3.e(), p3.px(), p3.py(), p3.pz() },
193 { p4.e(), p4.px(), p4.py(), p4.pz() },
194 { tau1.e(), tau1.px(), tau1.py(), tau1.pz() },
195 { tau2.e(), tau2.px(), tau2.py(), tau2.pz() } };
200 double f_x1_ARRAY[11] = { 0.0 };
201 double f_x2_ARRAY[11] = { 0.0 };
202 double *f_x1 = f_x1_ARRAY+5;
203 double *f_x2 = f_x2_ARRAY+5;
205 Particle P_tautau( tau1.px()+tau2.px(), tau1.py()+tau2.py(), tau1.pz()+tau2.pz(), tau1.e()+tau2.e(),0 );
207 double Q2 = P_tautau.recalculated_mass()*P_tautau.recalculated_mass();
208 double QQ2 = P_QQ.recalculated_mass()*P_QQ.recalculated_mass();
209 double PT2 = P_QQ.px() * P_QQ.px() + P_QQ.py()* P_QQ.py();
211 double sumET = p3.e()*sqrt( p3.px()*p3.px()+p3.py()*p3.py())/sqrt( p3.px()*p3.px()+p3.py()*p3.py()+p3.pz()*p3.pz())
212 + p4.e()*sqrt( p4.px()*p4.px()+p4.py()*p4.py())/sqrt( p4.px()*p4.px()+p4.py()*p4.py()+p4.pz()*p4.pz())
213 + tau1.e()*sqrt( tau1.px()*tau1.px()+tau1.py()*tau1.py())/sqrt( tau1.px()*tau1.px()+tau1.py()*tau1.py()+tau1.pz()*tau1.pz() )
214 + tau2.e()*sqrt( tau2.px()*tau2.px()+tau2.py()*tau2.py())/sqrt( tau2.px()*tau2.px()+tau2.py()*tau2.py()+tau2.pz()*tau2.pz() ) ;
216 double sumMT = sqrt( p3.recalculated_mass()*p3.recalculated_mass() + p3.px()*p3.px()+p3.py()*p3.py() )
217 + sqrt( p4.recalculated_mass()*p4.recalculated_mass() + p4.px()*p4.px()+p4.py()*p4.py() )
218 + sqrt( tau1.recalculated_mass()*tau1.recalculated_mass() + tau1.px()*tau1.px()+tau1.py()*tau1.py() )
219 + sqrt( tau2.recalculated_mass()*tau2.recalculated_mass() + tau2.px()*tau2.px()+tau2.py()*tau2.py() );
221 double fixed_scale = 91.17;
223 scalePDFOpt=getPDFOpt(KEY);
224 double Q2pdf = fixed_scale*fixed_scale;
225 if(scalePDFOpt == 0){
227 alphas(Q2pdf,scalePDFOpt,KEY);
228 }
else if (scalePDFOpt == 1) {
230 alphas(Q2pdf,scalePDFOpt,KEY);
231 }
else if (scalePDFOpt == 2) {
233 alphas(Q2pdf,scalePDFOpt,KEY);
234 }
else if (scalePDFOpt == 3) {
236 alphas(Q2pdf,scalePDFOpt,KEY);
237 }
else if (scalePDFOpt == 4) {
239 alphas(Q2pdf,scalePDFOpt,KEY);
242 for(
int i=-5;i<=5;++i) {
243 f_x1[i] = f(x1,i,Q2pdf,CMSENE);
244 f_x2[i] = f(x2,i,Q2pdf,CMSENE);
254 std::cout <<
" " << std::endl;
255 std::cout <<
"---podstawiamy 4-pedy na jakies ---" << std::endl;
256 std::cout <<
"ERW: ----------------------------- " << std::endl;
257 double P1[6][4] = {{ 0.5000000E+03, 0.0, 0.0, 0.5000000E+03 },
258 { 0.5000000E+03, 0.0, 0.0, -0.5000000E+03 },
259 { 0.8855009E+02, -0.2210038E+02, 0.4007979E+02, -0.7580437E+02 },
260 { 0.3283248E+03, -0.1038482E+03, -0.3019295E+03, 0.7649385E+02 },
261 { 0.1523663E+03, -0.1058795E+03, -0.9770827E+02, 0.4954769E+02 },
262 { 0.4307588E+03, 0.2318280E+03, 0.3595580E+03, -0.5023717E+02 } };
263 std::cout <<
"ERW: ----------------------------- " << std::endl;
264 double P2[6][4] = {{ 0.5000000E+03, 0.0, 0.0, 0.5000000E+03 },
265 { 0.5000000E+03, 0.0, 0.0, -0.5000000E+03 },
266 { 0.1177462E+03, -0.6070512E+02, 0.7123011E+02, 0.7145150E+02 },
267 { 0.3509495E+03, -0.3178775E+02, 0.8393832E+02, 0.3392779E+03 },
268 { 0.3493321E+03, 0.1840069E+03, -0.5152712E+02, -0.2924315E+03 },
269 { 0.1819722E+03, -0.9151401E+02, -0.1036413E+03, -0.1182978E+03 } };
271 std::cout <<
"ERW: ----------------------------- " << std::endl;
272 double P3[6][4] = {{ 0.5000000E+03, 0.0, 0.0, 0.5000000E+03 },
273 { 0.5000000E+03, 0.0, 0.0, -0.5000000E+03 },
274 { 0.2586900E+03, 0.1324670E+03, -0.1696171E+03, -0.1435378E+03 },
275 { 0.1084567E+03, -0.5735712E+02, -0.2162482E+02, -0.8947281E+02 },
276 { 0.4005742E+03, -0.1580760E+03, 0.3563160E+03, 0.9223569E+02 },
277 { 0.2322791E+03, 0.8296613E+02, -0.1650741E+03, 0.1407749E+03 } };
278 std::cout <<
"ERW: ----------------------------- " << std::endl;
279 double P4[6][4] = {{ 0.5000000E+03, 0.0, 0.0, 0.5000000E+03 },
280 { 0.5000000E+03, 0.0, 0.0, -0.5000000E+03 },
281 { 0.1595700E+03, -0.6917808E+02, -0.1395175E+03, -0.3481123E+02 },
282 { 0.2247758E+03, -0.1360140E+03, 0.1650340E+03, -0.6919641E+02 },
283 { 0.2508802E+03, 0.1447863E+01, 0.2499830E+03, -0.2107335E+02 },
284 { 0.3647740E+03, 0.2037442E+03, -0.2754995E+03, 0.1250810E+03 } };
286 for (
int I1=0;I1<=5;I1++){
for (
int I2=0;I2<=3;I2++){
287 P[I1][I2]=P1[I1][I2];
290 printf(
" our event : P[0,i]= %16.10f %16.10f %16.10f %16.10f \n",P[0][0],P[0][1],P[0][2],P[0][3]);
292 printf(
" P[1,i]= %16.10f %16.10f %16.10f %16.10f \n",P[II][0],P[II][1],P[II][2],P[II][3]);
294 printf(
" P[2,i]= %16.10f %16.10f %16.10f %16.10f \n",P[II][0],P[II][1],P[II][2],P[II][3]);
296 printf(
" P[3,i]= %16.10f %16.10f %16.10f %16.10f \n",P[II][0],P[II][1],P[II][2],P[II][3]);
298 printf(
" P[4,i]= %16.10f %16.10f %16.10f %16.10f \n",P[II][0],P[II][1],P[II][2],P[II][3]);
300 printf(
" P[4,i]= %16.10f %16.10f %16.10f %16.10f \n",P[II][0],P[II][1],P[II][2],P[II][3]);
301 printf(
" ===========================\n");
305 printf(
" ============== KEY= %2i ==\n",KEY);
306 printf(
" ===========================\n");
308 printf(
" ===========================================================\n");
309 printf(
" ============== non-zero contributions to <|ME|^2>_spin ==\n");
310 printf(
" ===========================================================\n");
316 for(
int I1=-5;I1<=5;I1++){
317 for(
int I2=-5;I2<=5;I2++){
318 for(
int I3=-5;I3<=5;I3++){
319 for(
int I4=-5;I4<=5;I4++){
321 int ID1 = I1;
if( ID1 == 0 ) ID1 = 21;
322 int ID2 = I2;
if( ID2 == 0 ) ID2 = 21;
323 int ID3 = I3;
if( ID3 == 0 ) ID3 = 21;
324 int ID4 = I4;
if( ID4 == 0 ) ID4 = 21;
326 W[0][0] += f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4, 1, -1, P, KEY);
327 W[0][1] += f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4, 1, 1, P, KEY);
328 W[1][0] += f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4,-1, -1, P, KEY);
329 W[1][1] += f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4,-1, 1, P, KEY);
332 if (ID1==51 && ID2==-1 && ID3==4 && ID4==-4 )
334 double cosik=
vbfdistr(ID1,ID2,ID3,ID4, 1, -1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, 1, 1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4,-1, -1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4,-1, 1, P, KEY);
335 std::cout <<
" ID-s = " <<ID1 <<
" "<<ID2 <<
" "<<ID3 <<
" "<<ID4 <<
" "<<
" KEY="<<KEY<<std::endl;
336 std::cout <<
" " << std::endl;
337 std::cout <<
" ME^2 summed over spin = " << cosik << std::endl;
338 std::cout <<
"---------" << std::endl;
339 std::cout <<
" " << std::endl;
342 if( ( W[0][0] > 10) || (W[0][1] > 10) || (W[1][0] > 10) || ( W[1][1] > 10)) {
343 std::cout <<
"ERWxxx: ID= " <<ID1 <<
" " << ID2 <<
" " << ID3 <<
" " << ID4 <<
" W[]= "
344 << f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4, 1, -1, P, KEY) <<
" "
345 << f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4, 1, 1, P, KEY) <<
" "
346 << f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4,-1, -1, P, KEY) <<
" "
347 << f_x1[I1]*f_x2[I2]*
vbfdistr(ID1,ID2,ID3,ID4,-1, 1, P, KEY)
350 if(
vbfdistr(ID1,ID2,ID3,ID4, 1, -1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, -1, 1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, 1, 1, P, KEY) +
vbfdistr(ID1,ID2,ID3,ID4, -1, -1, P, KEY)> 0) {
351 float check =
vbfdistr(ID1,ID2,ID4,ID3, 1, -1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, -1, 1, P, KEY);
352 if( check != 0 || check == 0){
354 printf(
" ID-s= %2i %2i %2i %2i CP used= %1i ## VALUE: %16.10e ## Spin contr.: (+-)= %9.3e (-+)= %9.3e (--)= %9.3e (++)= %9.3e \n", ID1, ID2, ID3,ID4, cpstatus_.icp,
355 vbfdistr(ID1,ID2,ID3,ID4, 1, -1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, -1, 1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, -1, -1, P, KEY)+
vbfdistr(ID1,ID2,ID3,ID4, 1, 1, P, KEY),
356 vbfdistr(ID1,ID2,ID3,ID4, 1, -1, P, KEY),
357 vbfdistr(ID1,ID2,ID3,ID4, -1, 1, P, KEY),
358 vbfdistr(ID1,ID2,ID3,ID4, -1, -1, P, KEY),
359 vbfdistr(ID1,ID2,ID3,ID4, 1, 1, P, KEY) );
395 double calculateWeightFromParticlesVBF(SimpleParticle &p3, SimpleParticle &p4,SimpleParticle &sp_X, SimpleParticle &sp_tau1, SimpleParticle &sp_tau2, vector<SimpleParticle> &sp_tau1_daughters, vector<SimpleParticle> &sp_tau2_daughters)
397 SimpleParticle sp_tau;
398 SimpleParticle sp_nu_tau;
399 vector<SimpleParticle> sp_tau_daughters;
402 if(sp_X.pdgid()==25) KEY=1;
405 if (sp_tau1.pdgid() == -15 )
409 sp_tau_daughters = sp_tau1_daughters;
415 sp_tau_daughters = sp_tau2_daughters;
424 Particle X ( sp_X.px(), sp_X.py(), sp_X.pz(), sp_X.e(), sp_X.pdgid() );
425 Particle tau ( sp_tau.px(), sp_tau.py(), sp_tau.pz(), sp_tau.e(), sp_tau.pdgid() );
426 Particle nu_tau( sp_nu_tau.px(), sp_nu_tau.py(), sp_nu_tau.pz(), sp_nu_tau.e(), sp_nu_tau.pdgid() );
428 vector<Particle> tau_daughters;
431 int tau_pdgid = sp_tau.pdgid();
434 for(
unsigned int i=0; i<sp_tau_daughters.size(); i++)
436 Particle pp(sp_tau_daughters[i].px(),
437 sp_tau_daughters[i].py(),
438 sp_tau_daughters[i].pz(),
439 sp_tau_daughters[i].e(),
440 sp_tau_daughters[i].pdgid() );
442 tau_daughters.push_back(pp);
445 double phi2 = 0.0, theta2 = 0.0;
454 HHp =
calculateHH(tau_pdgid, tau_daughters, phi2, theta2);
458 cout<<tau_pdgid<<
" -> ";
459 for(
unsigned int i=0;i<tau_daughters.size();i++) cout<<tau_daughters[i].pdgid()<<
" ";
460 cout<<
" (HHp: "<<HHp[0]<<
" "<<HHp[1]<<
" "<<HHp[2]<<
" "<<HHp[3]<<
") ";
464 WTamplitP = WTamplit;
468 if(sp_tau1.pdgid() == 15 )
472 sp_tau_daughters = sp_tau1_daughters;
478 sp_tau_daughters = sp_tau2_daughters;
485 Particle X ( sp_X.px(), sp_X.py(), sp_X.pz(), sp_X.e(), sp_X.pdgid() );
486 Particle tau ( sp_tau.px(), sp_tau.py(), sp_tau.pz(), sp_tau.e(), sp_tau.pdgid() );
487 Particle nu_tau( sp_nu_tau.px(), sp_nu_tau.py(), sp_nu_tau.pz(), sp_nu_tau.e(), sp_nu_tau.pdgid() );
489 vector<Particle> tau_daughters;
492 int tau_pdgid = sp_tau.pdgid();
495 for(
unsigned int i=0; i<sp_tau_daughters.size(); i++)
497 Particle pp(sp_tau_daughters[i].px(),
498 sp_tau_daughters[i].py(),
499 sp_tau_daughters[i].pz(),
500 sp_tau_daughters[i].e(),
501 sp_tau_daughters[i].pdgid() );
503 tau_daughters.push_back(pp);
506 double phi2 = 0.0, theta2 = 0.0;
515 HHm =
calculateHH(tau_pdgid, tau_daughters, phi2, theta2);
519 cout<<tau_pdgid<<
" -> ";
520 for(
unsigned int i=0;i<tau_daughters.size();i++) cout<<tau_daughters[i].pdgid()<<
" ";
521 cout<<
" (HHm: "<<HHm[0]<<
" "<<HHm[1]<<
" "<<HHm[2]<<
" "<<HHm[3]<<
") ";
525 WTamplitM = WTamplit;
529 double W[2][2] = { { 0.25, 0.25 },
537 getME2VBF(p3, p4, sp_X, sp_nu_tau, sp_tau, W, KEY);
542 double sum=(W[0][0]+W[0][1]+ W[1][0]+W[1][1]);
547 if(relWTnonSM==0) WTnonSM=sum;
552 getME2VBF(p3, p4, sp_X, sp_nu_tau, sp_tau, W, KEY+2);
554 double sum2=(W[0][0]+W[0][1]+ W[1][0]+W[1][1]);
557 if(relWTnonSM==0) WTnonSM=sum2;
561 double WT = W[0][0]*(1+HHp[2])*(1+HHm[2])+W[0][1]*(1+HHp[2])*(1-HHm[2])+ W[1][0]*(1-HHp[2])*(1+HHm[2])+W[1][1]*(1-HHp[2])*(1-HHm[2]);
562 WT = WT/(W[0][0]+W[0][1]+ W[1][0]+W[1][1]);
567 double RRR = Tauola::randomDouble();
569 if (RRR<(W[0][0]*(1+HHp[2])*(1+HHm[2])+W[0][1]*(1+HHp[2])*(1-HHm[2]))/(W[0][0]*(1+HHp[2])*(1+HHm[2])+W[0][1]*(1+HHp[2])*(1-HHm[2])+W[1][0]*(1-HHp[2])*(1+HHm[2])+W[1][1]*(1-HHp[2])*(1-HHm[2]))) Polari=-1.0;
574 DEBUG( cout<<
" WT: "<<WT<<endl; )
577 printf(
"WT is: %13.10f. Setting WT = 0.0\n",WT);
582 printf(
"WT is: %13.10f. Setting WT = 4.0\n",WT);
double vbfdistr_(int *I1, int *I2, int *I3, int *I4, int *H1, int *H2, double P[6][4], int *KEY)
void set_vbfdistrModif(double(*function)(int, int, int, int, int, int, double[6][4], int, double))
Set vbfdistrModif function.
void setPDFOpt(int QCDdefault, int QCDvariant)
void set_alphasModif(void(*function)(double, int, int))
Set vbfdistrModif function.
double * calculateHH(int tau_pdgid, vector< Particle > &tau_daughters, double phi, double theta)
void(* alphasModif)(double, int, int)
Pointer to a function that modify rezult of alpha_ calc. in vbfdist.
void vbf_reinit_(int *key)
double vbfdistr(int I1, int I2, int I3, int I4, int H1, int H2, SimpleParticle &p1, SimpleParticle &p2, SimpleParticle &tau1, SimpleParticle &tau2, int KEY)
void prepareKinematicForHH(Particle &tau, Particle &nu_tau, vector< Particle > &tau_daughters, double *phi2, double *theta2)
void getME2VBF(SimpleParticle &p3, SimpleParticle &p4, SimpleParticle &sp_X, SimpleParticle &tau1, SimpleParticle &tau2, double(&W)[2][2], int KEY)
double(* vbfdistrModif)(int, int, int, int, int, int, double[6][4], int, double)
Pointer to a function that modify rezult of Matrix Element calc. in vbfdist.