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 }
PPSTools::LimitedBeamInfo::fBeamMomentum
double fBeamMomentum
Definition: PPSUtilities.h:25
HLT_FULL_cff.beta
beta
Definition: HLT_FULL_cff.py:8686
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PPSTools::LorentzVector2HectorParticle
H_BeamParticle LorentzVector2HectorParticle(TLorentzVector p)
Definition: PPSUtilities.cc:16
PPSTools::HectorParticle2LorentzVector
TLorentzVector HectorParticle2LorentzVector(H_BeamParticle hp, int)
Definition: PPSUtilities.cc:6
PPSTools::LorentzBoost
void LorentzBoost(H_BeamParticle &h_p, int dir, const std::string &frame, FullBeamInfo const &bi)
PPSUtilities.h
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
trackingPlots.hp
hp
Definition: trackingPlots.py:1230
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
ProtonMassSQ
static const double ProtonMassSQ
Definition: PPSUnitConversion.h:6
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
urad
static const double urad
Definition: PPSUnitConversion.h:10
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
protons_cff.xi
xi
Definition: protons_cff.py:35
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
PPSTools::Get_t_and_xi
void Get_t_and_xi(const TLorentzVector *proton, double &t, double &xi, LimitedBeamInfo const &bi)
Definition: PPSUtilities.cc:72
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
PPSTools::LimitedBeamInfo::fBeamEnergy
double fBeamEnergy
Definition: PPSUtilities.h:26
PPSTools::LimitedBeamInfo
Definition: PPSUtilities.h:24
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23