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