CMS 3D CMS Logo

PPSUtilities.cc
Go to the documentation of this file.
2 #include "HepMC/GenParticle.h"
3 #include "H_BeamParticle.h"
4 #include "TLorentzVector.h"
5 
6 TLorentzVector PPSTools::HectorParticle2LorentzVector(H_BeamParticle hp,int direction)
7 {
8  double partP = sqrt(pow(hp.getE(),2)-ProtonMassSQ);
9  double theta = sqrt(pow(hp.getTX(),2)+pow(hp.getTY(),2))*urad;
10  double pz = partP*cos(theta);
11  double px = tan((double)hp.getTX()*urad)*pz;//it is equivalente to PartP*sin(theta)*cos(phi);
12  double py = tan((double)hp.getTY()*urad)*pz;//it is equivalente to partP*sin(theta)*sin(phi);
13  pz*=direction;
14  return TLorentzVector(px,py,pz,hp.getE());
15 }
16 
17 H_BeamParticle PPSTools::LorentzVector2HectorParticle(TLorentzVector p)
18 {
19  H_BeamParticle h_p;
20  h_p.set4Momentum(p.Px(),p.Py(),abs(p.Pz()),p.E());
21  return h_p;
22 }
23 void PPSTools::LorentzBoost(HepMC::GenParticle& p, const string& frame, FullBeamInfo const& bi)
24 {
25  TLorentzVector p_out;
26  p_out.SetPx(p.momentum().px());
27  p_out.SetPy(p.momentum().py());
28  p_out.SetPz(p.momentum().pz());
29  LorentzBoost(p_out,frame, bi);
30  p.set_momentum(HepMC::FourVector(p_out.Px(),p_out.Py(),p_out.Pz(),p_out.E()));
31 }
32 void PPSTools::LorentzBoost(H_BeamParticle& h_p, int dir , const string& frame, FullBeamInfo const& bi)
33 {
34  TLorentzVector p_out=HectorParticle2LorentzVector(h_p,dir);
35  LorentzBoost(p_out,frame, bi);
37 }
38 void PPSTools::LorentzBoost(TLorentzVector& p_out, const string& frame, FullBeamInfo const& bi)
39 {
40  const long double microrad = 1.e-6;
41  //
42  double px_P, py_P,pz_P;
43  double px_N, py_N,pz_N;
44  double fBoostAngle1=0.;
45  double fBoostAngle2=0.;
46  if (frame=="LAB") {fBoostAngle1=bi.fCrossingAngleBeam1;fBoostAngle2=bi.fCrossingAngleBeam2;}
47  if (frame=="MC") {fBoostAngle1=-bi.fCrossingAngleBeam1;fBoostAngle2=-bi.fCrossingAngleBeam2;}
48  px_P = bi.fBeamMomentum*sin(fBoostAngle2*microrad);
49  px_N = bi.fBeamMomentum*sin(fBoostAngle1*microrad);
50  pz_P = bi.fBeamMomentum*cos(fBoostAngle2*microrad);
51  pz_N = bi.fBeamMomentum*cos(fBoostAngle1*microrad);
52  py_P = 0.;
53  py_N = 0.;
54 
55  TLorentzVector BeamP, BeamN, projVect;
56  BeamP.SetPx(px_P);BeamP.SetPy(py_P);BeamP.SetPz(pz_P);BeamP.SetE(bi.fBeamEnergy);
57  BeamN.SetPx(px_N);BeamN.SetPy(py_N);BeamN.SetPz(-pz_N);BeamN.SetE(bi.fBeamEnergy);
58  projVect = BeamP + BeamN;
59  TVector3 beta;
60  TLorentzVector boosted = p_out;
61  beta = projVect.BoostVector();
62  boosted.Boost(beta);
63  p_out=boosted;
64 }
65 void PPSTools::Get_t_and_xi(const TLorentzVector* proton,double& t,double& xi, LimitedBeamInfo const& bi) {
66  t = 0.;
67  xi = -1.;
68  if (!proton) return;
69  double mom = sqrt((proton->Px())*(proton->Px())+(proton->Py())*(proton->Py())+(proton->Pz())*(proton->Pz()));
70  if (mom>bi.fBeamMomentum) mom=bi.fBeamMomentum;
71  double energy = proton->E();
72  double theta = (proton->Pz()>0)?proton->Theta():TMath::Pi()-proton->Theta();
73  t = -2.*(ProtonMassSQ-bi.fBeamEnergy*energy+bi.fBeamMomentum*mom*cos(theta));
74  xi = (1.0-energy/bi.fBeamEnergy);
75 }
void LorentzBoost(H_BeamParticle &h_p, int dir, const std::string &frame, FullBeamInfo const &bi)
const double Pi
TLorentzVector HectorParticle2LorentzVector(H_BeamParticle hp, int)
Definition: PPSUtilities.cc:6
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
H_BeamParticle LorentzVector2HectorParticle(TLorentzVector p)
Definition: PPSUtilities.cc:17
static const double urad
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dbl *** dir
Definition: mlp_gen.cc:35
static const double ProtonMassSQ
void Get_t_and_xi(const TLorentzVector *proton, double &t, double &xi, LimitedBeamInfo const &bi)
Definition: PPSUtilities.cc:65
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40