C++InterfacetoTauola
nonSM.cxx
1 #include <iostream>
2 #include "TauSpinner/nonSM.h"
3 #include "TauSpinner/EWtables.h"
4 using std::cout;
5 using std::endl;
6 
7 namespace TauSpinner {
8 
9 /***** GLOBAL VARIABLES *****/
10 
11 double (*nonSM_bornZ)(int, double, double, int, int, int) = default_nonSM_bornZ;
12 double (*nonSM_bornH)(int, double, double, int, int, int) = default_nonSM_bornH;
13 
14 extern int nonSM2;
15 extern int nonSMN;
16 extern double WTnonSM;
17 extern bool IfHiggs;
18 /********************************/
19 
20 double nonSM_born(int ID, double S, double cost, int H1, int H2, int key)
21 {
22  if(IfHiggs) return nonSM_bornH(ID,S,cost,H1,H2,key);
23  else return nonSM_bornZ(ID,S,cost,H1,H2,key);
24 }
25 
26 /************
27 In broad spectrum of applications default_nonSM_bornZ is supposed to be user replaced
28 (by redefinition at the execution time of the pointer *nonSM_bornZ).
29 Since Jan 2020 the default for nonSM_born is set as born extension:
30 the Electroweak Improved Born of the Drell Yanpartonic process. If the electroweak tables are available,
31 default_nonSM_born will be executed. If not, program will stop with exit(-1);
32 ************/
33 double default_nonSM_bornZ(int ID, double S, double cost, int H1, int H2, int key)
34 {
35  if (ID < 0)
36  {
37  ID = -ID;
38  cost = -cost;
39  }
40 
41  if (ID == 3 || ID == 5)
42  {
43  ID = 1;
44  }
45  else if (ID == 4)
46  {
47  ID = 2;
48  }
49 
50  if (ID >= 3 )
51  {
52  cout << "WARNING: default_nonSM_bornZ: unexpected ID continue debugging: " << ID << endl;
53  }
54 
55  if (initEWff(ID,S,cost,key) == 1){ // initEWff check if initialization
56  // init() was executed
57  // and only if ID,S,cost changed
58  // interpolate what bornew needs.
59  // chyba juz wiem co ze zmiennymi
60  // smiecoiwymi sigbornswdelt,
61  // lokalnie inicjalizowanymi jak:
62  // AMZi GAMMZi, SWeff, DeltSQ
63  // DeltV, Gmu, alfinv
64  // ktore przynajmniej po czesci sa pod
65  // innymi nazwami i z (prawie) takimi
66  // samymi wartosciami.
67  // If no intialization for bornew then
68  // exit(-1) and program stop.
69  int Bmode=1; // locally defined const., to change user may pointer-activate his own nonSM_born()
70  int keyGSW=1; // locally defined const, see T_BORNEW_ header, note that keGSW 1/2 is distinguished only by init
71  keyGSWGet(&keyGSW); // if available it will be overwritten with appropriate value.
72  // for comments and meaning of these two parameters
73  // at present used for some specialized test plots.
74 
75  double H1d = H1;
76  double H2d = H2;
77  int zero = 0;
78  if(key!=0){ //cout<<" key!0 " << H1<<" " << H2 << " " << t_bornew_(&Bmode, &keyGSW, &S, &cost, &H1d , &H2d) <<endl;
79  return t_bornew_(&Bmode, &keyGSW, &S, &cost, &H1d , &H2d);}
80  else { // cout<<" key=0 " << H1<< H2 << " " << t_born_ (&zero, &S, &cost, &H1d , &H2d) <<endl;
81  return t_born_ (&zero, &S, &cost, &H1d , &H2d);}
82  }
83  else
84  {
85  cout<<"TauSpinner::default_nonSM_bornZ: EW tables were not initialize\n"<<endl;
86  cout<<" and user has not provided his own nonSM_bornZ too"<<endl;
87  cout<<" see eg. nonSM_adopt() and set_nonSM_born( NULL ) of tau-reweight-test.cxx"<<endl;
88  cout<<" in TauSpinner/examples/tau-reweight-test.cxx for details"<<endl;
89  exit(-1);
90  return 1.0;
91  }
92 }
93 
94 
95 double default_nonSM_bornH(int ID, double S, double cost, int H1, int H2, int key)
96 {
97  cout<<"TauSpinner::default_nonSM_bornH: this function is dummy\n"<<endl;
98  cout<<" user must provide his own nonSM_bornH"<<endl;
99  cout<<" see eg. nonSM_adopt() and set_nonSM_bornH( NULL ) of tau-reweight-test.cxx"<<endl;
100  cout<<" in TauSpinner/examples/tau-reweight-test.cxx for details"<<endl;
101  exit(-1);
102  return 1.0;
103 }
104  /*******
105  case of Drell Yan
106  ******/
107 int set_nonSM_born( double (*fun)(int, double, double, int, int, int) )
108 {
109  if(fun==NULL) {nonSM_bornZ = default_nonSM_bornZ; return 0;}
110  else {nonSM_bornZ = fun; return 1;}
111 }
112 
113  /*******
114  case of scalar/Higgs
115  ******/
116 int set_nonSM_bornH( double (*fun)(int, double, double, int, int, int) )
117 {
118  if(fun==NULL) {nonSM_bornH = default_nonSM_bornH; return 0;}
119  else {nonSM_bornH = fun; return 1;}
120 }
121 
122 /*******************************************************************************
123  Probability of the helicity state
124 *******************************************************************************/
125 double plzap2(int ide, int idf, double svar, double costhe)
126 {
127  if(ide!=0)
128  {
129  if(idf > 0) initwk_(&ide,&idf,&svar);
130  else
131  {
132  int mide=-ide;
133  int midf=-idf;
134 
135  initwk_(&mide,&midf,&svar);
136  }
137  }
138 
139  int zero = 0;
140  double one = 1.0;
141  double mone = -1.0;
142  double ret = 0.0;
143 
144  if(nonSM2==0)
145  {
146  ret = t_born_(&zero,&svar,&costhe, &one, &one)
147  /(t_born_(&zero,&svar,&costhe, &one, &one)
148  +t_born_(&zero,&svar,&costhe,&mone,&mone));
149  }
150  else if(nonSM2==1)
151  {
152  ret = nonSM_born(ide,svar,costhe, 1, 1, nonSM2)
153  /(nonSM_born(ide,svar,costhe, 1, 1, nonSM2)
154  +nonSM_born(ide,svar,costhe,-1,-1, nonSM2));
155 
156  // test of user prepared born cross section can be prepared here.
157  // convention between t_born and nonSM_born in choice of flavours
158  // sign of costhe helicity signs etc have to be performed using SM version
159  // of nonSM_born. Matching (up to may be overall s-dependent factor) between
160  // t_born and nonSM_born must be achieved, see Section 4 for details
161  // on technical tests.
162  DEBUG(
163  double sm= t_born_(&zero,&svar,&costhe, &one, &one)
164  /(t_born_(&zero,&svar,&costhe, &one, &one)
165  +t_born_(&zero,&svar,&costhe,&mone,&mone));
166  double nsm= nonSM_born(ide,svar,costhe, 1, 1, nonSM2)
167  /(nonSM_born(ide,svar,costhe, 1, 1, nonSM2)
168  +nonSM_born(ide,svar,costhe,-1,-1, nonSM2));
169  double smn= nonSM_born(ide,svar,costhe, 1, 1, 0 )
170  /(nonSM_born(ide,svar,costhe, 1, 1, 0 )
171  +nonSM_born(ide,svar,costhe,-1,-1, 0 ));
172 
173  cout<<"test of nonSM Born nonsm2="<<nonSM2 << endl;
174  cout<<"ide,svar,costhe="<<ide <<" " << svar <<" " << costhe << endl;
175  cout<<"sm="<<sm <<" sm (new)="<<smn <<" nsm="<<nsm << endl;
176  cout<<"sm and sm (new) should be essentially equal" << endl << endl;
177  if (IfHiggs) cout << "(for Higgs we need to improve algorithm)" << endl;
178 
179  )
180 
181  }
182  return ret;
183 }
184 
185 double plweight(int ide, double svar, double costhe)
186 {
187  if(nonSM2==0) return 1.0;
188  if (ide==0 && !IfHiggs) return 1.0;
189 
190  double ret =( nonSM_born(ide,svar,costhe, 1, 1, nonSM2)/svar
191  +nonSM_born(ide,svar,costhe,-1,-1, nonSM2)/svar);
192  double retm =( nonSM_born(ide,svar,costhe, 1, 1, 0)/svar
193  +nonSM_born(ide,svar,costhe,-1,-1, 0)/svar); // svar is introduced for future use
194  // another option angular dependence only. Effect on x-section removed
195  if(nonSMN==1) ret = ret * plnorm(ide,svar);
196  return ret/retm;
197 }
198 
199 double plnorm(int ide, double svar)
200 {
201  if(nonSMN==0) return 1.0;
202 
203  double c1 = 1.0/sqrt(3.0);
204  double c2 = sqrt(2.0/3.0);
205 
206  double alpha = 2*nonSM_born(ide,svar,0.0, 1, 1,0)+
207  2*nonSM_born(ide,svar,0.0,-1,-1,0);
208  double beta = nonSM_born(ide,svar, c1, 1, 1,0) + nonSM_born(ide,svar,-c1, 1, 1,0)+
209  nonSM_born(ide,svar, c1,-1,-1,0) + nonSM_born(ide,svar,-c1,-1,-1,0);
210  double gamma = nonSM_born(ide,svar, c2, 1, 1,0) + nonSM_born(ide,svar,-c2, 1, 1,0)+
211  nonSM_born(ide,svar, c2,-1,-1,0) + nonSM_born(ide,svar,-c2,-1,-1,0);
212  double ret = ( alpha + 0.9*(gamma+alpha-2*beta) + 0.5*(4*beta-3*alpha-gamma) );
213 
214  alpha = 2*nonSM_born(ide,svar,0.0, 1, 1,nonSM2)+
215  2*nonSM_born(ide,svar,0.0,-1,-1,nonSM2);
216  beta = nonSM_born(ide,svar, c1, 1, 1,nonSM2) + nonSM_born(ide,svar,-c1, 1, 1,nonSM2)+
217  nonSM_born(ide,svar, c1,-1,-1,nonSM2) + nonSM_born(ide,svar,-c1,-1,-1,nonSM2);
218  gamma = nonSM_born(ide,svar, c2, 1, 1,nonSM2) + nonSM_born(ide,svar,-c2, 1, 1,nonSM2)+
219  nonSM_born(ide,svar, c2,-1,-1,nonSM2) + nonSM_born(ide,svar,-c2,-1,-1,nonSM2);
220 
221  ret = ret / ( alpha + 0.9*(gamma+alpha-2*beta) + 0.5*(4*beta-3*alpha-gamma) );
222 
223  return ret;
224 }
225 
226 void nonSMHcorrPol(double S, SimpleParticle &tau1, SimpleParticle &tau2,
227  double *corrX2, double *polX2)
228 { // tau+ and tau- in lab frame
229  Particle tau_plus ( tau1.px(), tau1.py(), tau1.pz(), tau1.e(), tau1.pdgid() );
230  Particle tau_minus( tau2.px(), tau2.py(), tau2.pz(), tau2.e(), tau2.pdgid() );
231 
232  // P_QQ = sum of tau+ and tau- in lab frame
233  Particle P_QQ( tau_plus.px()+tau_minus.px(), tau_plus.py()+tau_minus.py(), tau_plus.pz()+tau_minus.pz(), tau_plus.e()+tau_minus.e(), 0 );
234 
235  Particle P_B1(0, 0, 1, 1, 0);
236  Particle P_B2(0, 0,-1, 1, 0);
237 
238  tau_plus. boostToRestFrame(P_QQ);
239  tau_minus.boostToRestFrame(P_QQ);
240  P_B1. boostToRestFrame(P_QQ);
241  P_B2. boostToRestFrame(P_QQ);
242 
243  double costheta1 = (tau_plus.px()*P_B1.px() +tau_plus.py()*P_B1.py() +tau_plus.pz()*P_B1.pz() ) /
244  sqrt(tau_plus.px()*tau_plus.px()+tau_plus.py()*tau_plus.py()+tau_plus.pz()*tau_plus.pz()) /
245  sqrt(P_B1.px() *P_B1.px() +P_B1.py() *P_B1.py() +P_B1.pz() *P_B1.pz() );
246 
247  double costheta2 = (tau_minus.px()*P_B2.px() +tau_minus.py()*P_B2.py() +tau_minus.pz()*P_B2.pz() ) /
248  sqrt(tau_minus.px()*tau_minus.px()+tau_minus.py()*tau_minus.py()+tau_minus.pz()*tau_minus.pz()) /
249  sqrt(P_B2.px() *P_B2.px() +P_B2.py() *P_B2.py() +P_B2.pz() *P_B2.pz() );
250 
251  double sintheta1 = sqrt(1-costheta1*costheta1);
252  double sintheta2 = sqrt(1-costheta2*costheta2);
253 
254  // Cosine of hard scattering
255  double costhe = (costheta1*sintheta2 + costheta2*sintheta1) / (sintheta1 + sintheta2);
256 
257  // Invariant mass of tau+tau- pair
258  double SS = S; // other option is for tests: P_QQ.recalculated_mass()*P_QQ.recalculated_mass();
259 
260 
261  // corrX2 calculation
262  // polX2 calculation
263  // WTnonSM calculation
264  *corrX2 = -1.0; // default
265  *polX2 = 0.0; // default
266  WTnonSM = 1.0; // default
267 }
268 
269 } // namespace TauSpinner
double default_nonSM_bornZ(int ID, double S, double cost, int H1, int H2, int key)
Definition: nonSM.cxx:33
double plzap2(int ide, int idf, double svar, double costhe)
Definition: nonSM.cxx:125
int set_nonSM_bornH(double(*fun)(int, double, double, int, int, int))
Definition: nonSM.cxx:116
double default_nonSM_bornH(int ID, double S, double cost, int H1, int H2, int key)
Definition: nonSM.cxx:95
double nonSM_born(int ID, double S, double cost, int H1, int H2, int key)
Definition: nonSM.cxx:20
double plweight(int ide, double svar, double costhe)
Definition: nonSM.cxx:185
void nonSMHcorrPol(double S, SimpleParticle &tau1, SimpleParticle &tau2, double *corrX2, double *polX2)
Definition: nonSM.cxx:226
int initEWff(int ID, double S, double cost, int key)
Definition: EWtables.cxx:574
void keyGSWGet(int *keyGSW)
Definition: EWtables.cxx:542
double plnorm(int ide, double svar)
Definition: nonSM.cxx:199
int set_nonSM_born(double(*fun)(int, double, double, int, int, int))
Definition: nonSM.cxx:107