2 #include "TMatrixTSym.h"
6 using namespace tauImpactParameter;
11 if(R<0){isReal=
false;}
12 x_minus=(-b+
sqrt(fabs(R)))/(2.0*a);
13 x_plus=(-b-
sqrt(fabs(R)))/(2.0*a);
17 double a=(A1.Pz()*A1.Pz())/(A1.E()*A1.E())-1.0;
19 double b=2.0*K*A1.Pz()/A1.E();
20 double c=K*K-A1.Pt()*A1.Pt();
21 double z_plus(0),z_minus(0);
23 nu_plus=TLorentzVector(-A1.Px(),-A1.Py(),z_plus,
sqrt(z_plus*z_plus+A1.Pt()*A1.Pt()));
24 nu_minus=TLorentzVector(-A1.Px(),-A1.Py(),z_minus,
sqrt(z_minus*z_minus+A1.Pt()*A1.Pt()));
30 TLorentzVector nu,
tau;
31 for(
int i=0;
i<=(int)(rmax-rmin)/
step;
i++){
32 nu.SetPxPyPzE(-A1.Px(),-A1.Py(),
z,
sqrt(z*z+A1.Pt()*A1.Pt()));
35 if(m2-mtau2<0 && prev-mtau2>=0) z1=
z;
36 if(m2-mtau2>0 && prev-mtau2<=0) z2=
z;
41 if(z1!=-999 && z2!=-999){
42 nu_plus=TLorentzVector(-A1.Px(),-A1.Py(),z1,
sqrt(z1*z1+A1.Pt()*A1.Pt()));
43 nu_minus=TLorentzVector(-A1.Px(),-A1.Py(),z2,
sqrt(z2*z2+A1.Pt()*A1.Pt()));
46 nu_plus=TLorentzVector(-A1.Px(),-A1.Py(),
zmin,
sqrt(
zmin*
zmin+A1.Pt()*A1.Pt()));
47 nu_minus=TLorentzVector(-A1.Px(),-A1.Py(),
zmin,
sqrt(
zmin*
zmin+A1.Pt()*A1.Pt()));
52 TLorentzVector &nu_plus,TLorentzVector &nu_minus,
bool &isReal,
bool rotateback){
53 TLorentzVector A1rot=A1;
54 double phi(TauDir.Phi()),
theta(TauDir.Theta());
56 A1rot.RotateY(-
theta);
62 nu_plus.RotateY(
theta);
66 nu_minus.RotateY(
theta);
67 nu_minus.RotateZ(
phi);
68 Tau_minus=A1+nu_minus;
71 Tau_plus=A1rot+nu_plus;
72 Tau_minus=A1rot+nu_minus;
78 TVector3 a1v(a1.Vect());
if(a1v.Mag()!=0) a1v*=1/a1v.Mag();
80 double dphitheta=acos(a1v.Dot(tau)/(a1v.Mag()*tau.Mag()));
81 if(thetaGJMaxvar<dphitheta || scale<0){
82 if(scale<0) scale=1.0;
83 double a=(thetaGJMaxvar/dphitheta)-(1-scale);
84 double b=1-(thetaGJMaxvar/dphitheta)+(1-scale);
85 edm::LogInfo(
"RecoTauTag/ImpactParameter") <<
"SetTauDirectionatThetaGJMax before GF " << thetaGJMaxvar <<
" dot " << acos(a1v.Dot(tau)/(a1v.Mag()*tau.Mag())) <<
" a1 phi " << a1v.Phi() <<
" tau phi " << tau.Phi() <<
" a1 theta " <<a1v.Theta() <<
" tau theta " << tau.Theta() ;
91 edm::LogInfo(
"RecoTauTag/ImpactParameter") <<
"SetTauDirectionatThetaGJMax GF " << thetaGJMaxvar <<
" dot " << acos(a1v.Dot(tau)/(a1v.Mag()*tau.Mag())) <<
" phi " << phi <<
" theta " <<
theta ;
102 TLorentzVector lorentzA1=a1.
p4();
104 TVector3 tauFlghtDir=sv-
pv;
105 TLorentzVector nuGuess;
107 TVector3 startingtauFlghtDir=tauFlghtDir.Unit();
109 double theta=tauFlghtDir.Theta();
110 double phi=tauFlghtDir.Phi();
112 startingtauFlghtDir=TVector3(
sin(theta)*
cos(phi),
sin(theta)*
sin(phi),
cos(theta));
114 TLorentzVector tau1,tau2,nu1,nu2;
116 solveByRotation(startingtauFlghtDir,lorentzA1,tau1,tau2,nu1,nu2,isReal);
117 if(ambiguity==
plus){ nuGuess=nu1; tau=tau1; }
118 if(ambiguity==
minus){ nuGuess=nu2; tau=tau1; }
119 if(ambiguity==
zero){ nuGuess=nu1; tau=tau1; }
129 TMatrixTSym<double> pvCov=a1.
vertexCov();
131 for(
int j=0;
j<=
i;
j++){
137 if(v<1000.0) v=1000.0;
144 TVectorT<double> outpar(3);
145 TVector3 res(inpar(0),inpar(1),inpar(2));
146 TVector3 Uz(
sin(inpar(4))*
cos(inpar(3)),
sin(inpar(4))*
sin(inpar(3)),
cos(inpar(4)));
TMatrixTSym< double > vertexCov() const
static void analyticESolver(TLorentzVector &nu_plus, TLorentzVector &nu_minus, const TLorentzVector &A1, bool &isReal)
TLorentzVector p4() const
Sin< T >::type sin(const T &t)
static TVectorT< double > rotateToTauFrame(const TVectorT< double > &inpar)
Geom::Theta< T > theta() const
static bool setTauDirectionatThetaGJMax(const TLorentzVector &a1, double &theta, double &phi, double scale=1.0)
static double thetaGJMax(const TLorentzVector &a1)
static LorentzVectorParticle estimateNu(const LorentzVectorParticle &a1, const TVector3 &pv, int ambiguity, TLorentzVector &tau)
Cos< T >::type cos(const T &t)
virtual double parameter(int i) const
virtual double bField() const
static void solveByRotation(const TVector3 &TauDir, const TLorentzVector &A1, TLorentzVector &Tau_plus, TLorentzVector &Tau_minus, TLorentzVector &nu_plus, TLorentzVector &nu_minus, bool &isReal, bool rotateback=true)
static void numericalESolver(TLorentzVector &nu_plus, TLorentzVector &nu_minus, const TLorentzVector &A1, bool &isReal)
static void quadratic(double &x_plus, double &x_minus, double a, double b, double c, bool &isReal)