CMS 3D CMS Logo

PFDisplacedVertex.cc
Go to the documentation of this file.
2 
3 #include "TMath.h"
4 
5 using namespace std;
6 using namespace reco;
7 
8 PFDisplacedVertex::PFDisplacedVertex() : Vertex(), vertexType_(ANY), primaryDirection_(0, 0, 0) {}
9 
10 PFDisplacedVertex::PFDisplacedVertex(Vertex& v) : Vertex(v), vertexType_(ANY), primaryDirection_(0, 0, 0) {}
11 
13  const Track& refTrack,
14  const PFTrackHitFullInfo& hitInfo,
16  float w) {
17  add(r, refTrack, w);
18  trackTypes_.push_back(trackType);
19  trackHitFullInfos_.push_back(hitInfo);
20 }
21 
23  removeTracks();
24  trackTypes_.clear();
25  trackHitFullInfos_.clear();
26 }
27 
29  vector<VertexTrackType>::const_iterator iter = find(trackTypes_.begin(), trackTypes_.end(), T);
30  return (iter != trackTypes_.end());
31 }
32 
34  return count(trackTypes_.begin(), trackTypes_.end(), T);
35 }
36 
37 const size_t PFDisplacedVertex::trackPosition(const reco::TrackBaseRef& originalTrack) const {
38  size_t pos = -1;
39 
41 
42  std::vector<Track> refitTrks = refittedTracks();
43  for (size_t i = 0; i < refitTrks.size(); i++) {
44  if (fabs(refitTrks[i].pt() - refittedTrack.pt()) < 1.e-5) {
45  pos = i;
46  continue;
47  }
48  }
49  // cout << "pos = " << pos << endl;
50 
51  return pos;
52 }
53 
56  math::XYZVector vtx(pvtx.x(), pvtx.y(), pvtx.z());
57 
59  primaryDirection_ /= (sqrt(primaryDirection_.Mag2()) + 1e-10);
60 }
61 
63  switch (vertexType_) {
64  case ANY:
65  return "ANY";
66  case FAKE:
67  return "FAKE";
68  case LOOPER:
69  return "LOOPER";
70  case NUCL:
71  return "NUCL";
72  case NUCL_LOOSE:
73  return "NUCL_LOOSE";
74  case NUCL_KINK:
75  return "NUCL_KINK";
76  case CONVERSION:
77  return "CONVERSION";
78  case CONVERSION_LOOSE:
79  return "CONVERSION_LOOSE";
80  case CONVERTED_BREMM:
81  return "CONVERTED_BREMM";
82  case K0_DECAY:
83  return "K0_DECAY";
84  case LAMBDA_DECAY:
85  return "LAMBDA_DECAY";
86  case LAMBDABAR_DECAY:
87  return "LAMBDABAR_DECAY";
88  case KPLUS_DECAY:
89  return "KPLUS_DECAY";
90  case KMINUS_DECAY:
91  return "KMINUS_DECAY";
92  case KPLUS_DECAY_LOOSE:
93  return "KPLUS_DECAY_LOOSE";
94  case KMINUS_DECAY_LOOSE:
95  return "KMINUS_DECAY_LOOSE";
96  case BSM_VERTEX:
97  return "BSM_VERTEX";
98  default:
99  return "?";
100  }
101  return "?";
102 }
103 
105  VertexTrackType T,
106  bool useRefitted,
107  double mass) const {
108  M_Hypo mHypo = M_CUSTOM;
109 
110  if (massHypo.find("PI") != string::npos)
111  mHypo = M_PION;
112  else if (massHypo.find("KAON") != string::npos)
113  mHypo = M_KAON;
114  else if (massHypo.find("LAMBDA") != string::npos)
115  mHypo = M_LAMBDA;
116  else if (massHypo.find("MASSLESS") != string::npos)
117  mHypo = M_MASSLESS;
118  else if (massHypo.find("CUSTOM") != string::npos)
119  mHypo = M_CUSTOM;
120 
121  return momentum(mHypo, T, useRefitted, mass);
122 }
123 
126  bool useRefitted,
127  double mass) const {
128  const double m2 = getMass2(massHypo, mass);
129 
131 
132  for (size_t i = 0; i < tracksSize(); i++) {
133  bool bType = (trackTypes_[i] == T);
134  if (T == T_TO_VERTEX || T == T_MERGED)
135  bType = (trackTypes_[i] == T_TO_VERTEX || trackTypes_[i] == T_MERGED);
136 
137  if (bType) {
138  if (!useRefitted) {
140 
141  double p2 = trackRef->momentum().Mag2();
143  trackRef->momentum().x(), trackRef->momentum().y(), trackRef->momentum().z(), sqrt(m2 + p2));
144  } else {
145  // cout << "m2 " << m2 << endl;
146 
147  double p2 = refittedTracks()[i].momentum().Mag2();
149  refittedTracks()[i].momentum().y(),
150  refittedTracks()[i].momentum().z(),
151  sqrt(m2 + p2));
152  }
153  }
154  }
155 
156  return P;
157 }
158 
160  int charge = 0;
161 
162  for (size_t i = 0; i < tracksSize(); i++) {
163  if (trackTypes_[i] == T_TO_VERTEX)
164  charge += refittedTracks()[i].charge();
165  else if (trackTypes_[i] == T_FROM_VERTEX)
166  charge -= refittedTracks()[i].charge();
167  }
168 
169  return charge;
170 }
171 
172 const double PFDisplacedVertex::angle_io() const {
173  math::XYZTLorentzVector momentumSec = secondaryMomentum((string) "PI", true);
174 
175  math::XYZVector p_out = momentumSec.Vect();
176 
178 
179  if (p_in.Mag2() < 1e-10)
180  return -1;
181  return acos(p_in.Dot(p_out) / sqrt(p_in.Mag2() * p_out.Mag2())) / TMath::Pi() * 180.0;
182 }
183 
185  math::XYZTLorentzVector momentumPrim = primaryMomentum((string) "PI", true);
186  math::XYZTLorentzVector momentumSec = secondaryMomentum((string) "PI", true);
187 
188  math::XYZVector p_in;
189 
190  if ((isThereKindTracks(T_TO_VERTEX) || isThereKindTracks(T_MERGED)) && momentumPrim.E() > momentumSec.E()) {
191  p_in = momentumPrim.Vect() / sqrt(momentumPrim.Vect().Mag2() + 1e-10);
192  } else {
193  p_in = primaryDirection_;
194  }
195 
196  return p_in;
197 }
198 
199 const double PFDisplacedVertex::getMass2(M_Hypo massHypo, double mass) const {
200  // pion_mass = 0.1396 GeV
201  double pion_mass2 = 0.0194;
202  // k0_mass = 0.4976 GeV
203  double kaon_mass2 = 0.2476;
204  // lambda0_mass = 1.116 GeV
205  double lambda_mass2 = 1.267;
206 
207  if (massHypo == M_PION)
208  return pion_mass2;
209  else if (massHypo == M_KAON)
210  return kaon_mass2;
211  else if (massHypo == M_LAMBDA)
212  return lambda_mass2;
213  else if (massHypo == M_MASSLESS)
214  return 0;
215  else if (massHypo == M_CUSTOM)
216  return mass * mass;
217 
218  cout << "Warning: undefined mass hypothesis" << endl;
219  return 0;
220 }
221 
222 void PFDisplacedVertex::Dump(ostream& out) const {
223  if (!out)
224  return;
225 
226  out << "" << endl;
227  out << "==================== This is a Displaced Vertex type " << nameVertexType() << " ===============" << endl;
228 
229  out << " Vertex chi2 = " << chi2() << " ndf = " << ndof() << " normalised chi2 = " << normalizedChi2() << endl;
230 
231  out << " The vertex Fitted Position is: x = " << position().x() << " y = " << position().y()
232  << " rho = " << position().rho() << " z = " << position().z() << endl;
233 
234  out << "\t--- Structure --- " << endl;
235  out << "Number of tracks: " << nTracks() << " nPrimary " << nPrimaryTracks() << " nMerged " << nMergedTracks()
236  << " nSecondary " << nSecondaryTracks() << endl;
237 
238  vector<PFDisplacedVertex::PFTrackHitFullInfo> pattern = trackHitFullInfos();
239  vector<PFDisplacedVertex::VertexTrackType> trackType = trackTypes();
240  for (unsigned i = 0; i < pattern.size(); i++) {
241  out << "track " << i << " type = " << trackType[i] << " nHit BeforeVtx = " << pattern[i].first.first
242  << " AfterVtx = " << pattern[i].second.first << " MissHit BeforeVtx = " << pattern[i].first.second
243  << " AfterVtx = " << pattern[i].second.second << endl;
244  }
245 
246  math::XYZTLorentzVector mom_prim = primaryMomentum((string) "PI", true);
247  math::XYZTLorentzVector mom_sec = secondaryMomentum((string) "PI", true);
248 
249  // out << "Primary P:\t E " << setprecision(3) << setw(5) << mom_prim.E()
250  out << "Primary P:\t E " << mom_prim.E() << "\tPt = " << mom_prim.Pt() << "\tPz = " << mom_prim.Pz()
251  << "\tM = " << mom_prim.M() << "\tEta = " << mom_prim.Eta() << "\tPhi = " << mom_prim.Phi() << endl;
252 
253  out << "Secondary P:\t E " << mom_sec.E() << "\tPt = " << mom_sec.Pt() << "\tPz = " << mom_sec.Pz()
254  << "\tM = " << mom_sec.M() << "\tEta = " << mom_sec.Eta() << "\tPhi = " << mom_sec.Phi() << endl;
255 
256  out << " The vertex Direction is x = " << primaryDirection().x() << " y = " << primaryDirection().y()
257  << " z = " << primaryDirection().z() << " eta = " << primaryDirection().eta()
258  << " phi = " << primaryDirection().phi() << endl;
259 
260  out << " Angle_io = " << angle_io() << " deg" << endl << endl;
261 }
reco::PFDisplacedVertex::Dump
void Dump(std::ostream &out=std::cout) const
cout function
Definition: PFDisplacedVertex.cc:222
reco::Vertex::originalTrack
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:96
reco::PFDisplacedVertex::KPLUS_DECAY
Definition: PFDisplacedVertex.h:53
reco::PFDisplacedVertex::nKindTracks
const int nKindTracks(VertexTrackType) const
Common tool used to get the number of tracks of a given Kind.
Definition: PFDisplacedVertex.cc:33
reco::PFDisplacedVertex::LOOPER
Definition: PFDisplacedVertex.h:43
mps_fire.i
i
Definition: mps_fire.py:428
reco::PFDisplacedVertex::T_TO_VERTEX
Definition: PFDisplacedVertex.h:36
reco::PFDisplacedVertex::T_FROM_VERTEX
Definition: PFDisplacedVertex.h:36
reco::PFDisplacedVertex::nSecondaryTracks
const int nSecondaryTracks() const
Number of secondary tracks was identified.
Definition: PFDisplacedVertex.h:146
reco::PFDisplacedVertex::KMINUS_DECAY
Definition: PFDisplacedVertex.h:54
reco::PFDisplacedVertex::T_MERGED
Definition: PFDisplacedVertex.h:36
reco::PFDisplacedVertex::primaryMomentum
const math::XYZTLorentzVector primaryMomentum(std::string massHypo="PI", bool useRefitted=true, double mass=0.0) const
Momentum of primary or merged track calculated with a mass hypothesis.
Definition: PFDisplacedVertex.h:166
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
reco::Vertex::z
double z() const
z coordinate
Definition: Vertex.h:120
reco::PFDisplacedVertex::M_LAMBDA
Definition: PFDisplacedVertex.h:30
reco::Vertex::refittedTrack
Track refittedTrack(const TrackBaseRef &track) const
Definition: Vertex.cc:106
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
reco::PFDisplacedVertex::M_KAON
Definition: PFDisplacedVertex.h:30
reco::PFDisplacedVertex::PFTrackHitFullInfo
std::pair< PFTrackHitInfo, PFTrackHitInfo > PFTrackHitFullInfo
Definition: PFDisplacedVertex.h:27
reco::PFDisplacedVertex::KMINUS_DECAY_LOOSE
Definition: PFDisplacedVertex.h:56
reco::PFDisplacedVertex::LAMBDABAR_DECAY
Definition: PFDisplacedVertex.h:52
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::PFDisplacedVertex::NUCL
Definition: PFDisplacedVertex.h:44
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:637
reco::PFDisplacedVertex::trackTypes
const std::vector< VertexTrackType > trackTypes() const
Definition: PFDisplacedVertex.h:88
reco::PFDisplacedVertex::angle_io
const double angle_io() const
Definition: PFDisplacedVertex.cc:172
reco::PFDisplacedVertex::totalCharge
const int totalCharge() const
Total Charge.
Definition: PFDisplacedVertex.cc:159
reco::PFDisplacedVertex::trackPosition
const size_t trackPosition(const reco::TrackBaseRef &originalTrack) const
Definition: PFDisplacedVertex.cc:37
reco::PFDisplacedVertex::nTracks
const int nTracks() const
Number of tracks.
Definition: PFDisplacedVertex.h:152
reco::PFDisplacedVertex::trackHitFullInfos_
std::vector< PFTrackHitFullInfo > trackHitFullInfos_
Information on the distance between track's hits and the Vertex.
Definition: PFDisplacedVertex.h:257
reco::PFDisplacedVertex::secondaryMomentum
const math::XYZTLorentzVector secondaryMomentum(std::string massHypo="PI", bool useRefitted=true, double mass=0.0) const
Definition: PFDisplacedVertex.h:159
w
const double w
Definition: UKUtility.cc:23
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::PFDisplacedVertex::nPrimaryTracks
const int nPrimaryTracks() const
Number of primary tracks was identified.
Definition: PFDisplacedVertex.h:140
reco::Vertex::add
void add(const TrackBaseRef &r, float w=1.0)
add a reference to a Track
Definition: Vertex.cc:79
reco::PFDisplacedVertex::M_PION
Definition: PFDisplacedVertex.h:30
reco::Track
Definition: Track.h:27
p2
double p2[4]
Definition: TauolaWrapper.h:90
reco::PFDisplacedVertex::primaryDirection
const math::XYZVector primaryDirection() const
Primary Direction.
Definition: PFDisplacedVertex.cc:184
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
reco::Vertex::refittedTracks
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
Definition: Vertex.h:183
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::PFDisplacedVertex::vertexType_
VertexType vertexType_
-----— MEMBERS -----— ///
Definition: PFDisplacedVertex.h:251
reco::PFDisplacedVertex::NUCL_LOOSE
Definition: PFDisplacedVertex.h:45
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::PFDisplacedVertex::addElement
void addElement(const TrackBaseRef &r, const Track &refTrack, const PFTrackHitFullInfo &hitInfo, VertexTrackType trackType=T_NOT_FROM_VERTEX, float w=1.0)
Add a new track to the vertex.
Definition: PFDisplacedVertex.cc:12
reco::PFDisplacedVertex::trackHitFullInfos
const std::vector< PFTrackHitFullInfo > trackHitFullInfos() const
Definition: PFDisplacedVertex.h:86
reco::PFDisplacedVertex::LAMBDA_DECAY
Definition: PFDisplacedVertex.h:51
reco::PFDisplacedVertex::BSM_VERTEX
Definition: PFDisplacedVertex.h:57
PFDisplacedVertex.h
reco::Vertex::x
double x() const
x coordinate
Definition: Vertex.h:116
reco::PFDisplacedVertex::getMass2
const double getMass2(M_Hypo, double) const
Get the mass with a given hypothesis.
Definition: PFDisplacedVertex.cc:199
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::Vertex::tracksSize
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:69
reco::PFDisplacedVertex::PFDisplacedVertex
PFDisplacedVertex()
Default constructor.
Definition: PFDisplacedVertex.cc:8
reco::PFDisplacedVertex::primaryDirection_
math::XYZVector primaryDirection_
Definition: PFDisplacedVertex.h:259
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
reco::PFDisplacedVertex::isThereKindTracks
const bool isThereKindTracks(VertexTrackType) const
------— TOOLS -----------— ///
Definition: PFDisplacedVertex.cc:28
reco::PFDisplacedVertex::nMergedTracks
const int nMergedTracks() const
Number of merged tracks was identified.
Definition: PFDisplacedVertex.h:143
reco::PFDisplacedVertex::trackTypes_
std::vector< VertexTrackType > trackTypes_
Types of the tracks associated to the vertex.
Definition: PFDisplacedVertex.h:254
reco::PFDisplacedVertex::VertexTrackType
VertexTrackType
Definition: PFDisplacedVertex.h:36
reco::Vertex::chi2
double chi2() const
chi-squares
Definition: Vertex.h:103
PbPb_ZMuSkimMuonDPG_cff.trackType
trackType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:36
alignCSCRings.r
r
Definition: alignCSCRings.py:93
reco::PFDisplacedVertex::momentum
const math::XYZTLorentzVector momentum(std::string, VertexTrackType, bool, double mass) const
Common tool to calculate the momentum vector of tracks with a given Kind.
reco::PFDisplacedVertex::M_MASSLESS
Definition: PFDisplacedVertex.h:30
reco::PFDisplacedVertex::cleanTracks
void cleanTracks()
Clean the tracks collection and all the associated collections.
Definition: PFDisplacedVertex.cc:22
std
Definition: JetResolutionObject.h:76
reco::Vertex::y
double y() const
y coordinate
Definition: Vertex.h:118
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
cscdqm::ANY
Definition: CSCDQM_DCSBase.h:35
T
long double T
Definition: Basic3DVectorLD.h:48
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::PFDisplacedVertex::nameVertexType
std::string nameVertexType() const
Definition: PFDisplacedVertex.cc:62
reco::Vertex::normalizedChi2
double normalizedChi2() const
chi-squared divided by n.d.o.f.
Definition: Vertex.h:112
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
reco::PFDisplacedVertex::CONVERSION_LOOSE
Definition: PFDisplacedVertex.h:48
edm::RefToBase< reco::Track >
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
reco::PFDisplacedVertex::NUCL_KINK
Definition: PFDisplacedVertex.h:46
reco::PFDisplacedVertex::setPrimaryDirection
void setPrimaryDirection(const math::XYZPoint &pvtx)
Definition: PFDisplacedVertex.cc:54
reco::PFDisplacedVertex::K0_DECAY
Definition: PFDisplacedVertex.h:50
reco::Vertex::removeTracks
void removeTracks()
Definition: Vertex.cc:90
reco::PFDisplacedVertex::KPLUS_DECAY_LOOSE
Definition: PFDisplacedVertex.h:55
reco::TrackBase::momentum
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
P
std::pair< OmniClusterRef, TrackingParticleRef > P
Definition: BDHadronTrackMonitoringAnalyzer.cc:202
reco::PFDisplacedVertex::M_Hypo
M_Hypo
Mass hypothesis enum.
Definition: PFDisplacedVertex.h:30
reco::PFDisplacedVertex::CONVERSION
Definition: PFDisplacedVertex.h:47
reco::Vertex::ndof
double ndof() const
Definition: Vertex.h:110
reco::Vertex
Definition: Vertex.h:35
reco::PFDisplacedVertex::ANY
Definition: PFDisplacedVertex.h:41
reco::PFDisplacedVertex::FAKE
Definition: PFDisplacedVertex.h:42
reco::PFDisplacedVertex::M_CUSTOM
Definition: PFDisplacedVertex.h:30
reco::PFDisplacedVertex::CONVERTED_BREMM
Definition: PFDisplacedVertex.h:49
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37