CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
LowPtConversion Class Reference

#include <LowPtConversion.h>

Public Member Functions

void addExtraUserVars (pat::Electron &ele) const
 
void addUserVars (pat::Electron &ele) const
 
 LowPtConversion ()=default
 
bool match (const reco::BeamSpot &beamSpot, const reco::ConversionCollection &conversions, const pat::Electron &ele)
 
bool wpLoose () const
 
bool wpOpen () const
 
bool wpTight () const
 
 ~LowPtConversion ()=default
 

Static Public Member Functions

static float mee (float ipx1, float ipy1, float ipz1, float ipx2, float ipy2, float ipz2)
 

Private Attributes

float chi2prob_ = -1.
 
float delta_cot_from_Pin_ = -1.
 
int delta_expected_nhits_inner_ = 0
 
int ilead_ = -1
 
int itrail_ = -1
 
float l_xy_ = -1.
 
uint lead_nhits_before_vtx_ = 0
 
float mass_after_fit_ = -1.
 
float mass_before_fit_ = -1.
 
float mass_from_conv_ = -1.
 
float mass_from_Pin_ = -1.
 
bool matched_ = false
 
edm::RefToBase< reco::Trackmatched_lead_
 
edm::RefToBase< reco::Trackmatched_trail_
 
uint max_nhits_before_vtx_ = 0
 
float min_trk_pt_ = -1.
 
uint ntracks_ = 0
 
bool quality_high_efficiency_ = false
 
bool quality_high_purity_ = false
 
uint sum_nhits_before_vtx_ = 0
 
uint trail_nhits_before_vtx_ = 0
 
bool valid_ = false
 
float vtx_radius_ = -1.
 

Detailed Description

Definition at line 13 of file LowPtConversion.h.

Constructor & Destructor Documentation

◆ LowPtConversion()

LowPtConversion::LowPtConversion ( )
default

◆ ~LowPtConversion()

LowPtConversion::~LowPtConversion ( )
default

Member Function Documentation

◆ addExtraUserVars()

void LowPtConversion::addExtraUserVars ( pat::Electron ele) const

Definition at line 38 of file LowPtConversion.cc.

References pat::PATObject< ObjectType >::addUserFloat(), pat::PATObject< ObjectType >::addUserInt(), chi2prob_, delta_cot_from_Pin_, delta_expected_nhits_inner_, ilead_, itrail_, l_xy_, lead_nhits_before_vtx_, mass_after_fit_, mass_before_fit_, mass_from_conv_, mass_from_Pin_, max_nhits_before_vtx_, min_trk_pt_, ntracks_, quality_high_efficiency_, quality_high_purity_, sum_nhits_before_vtx_, trail_nhits_before_vtx_, valid_, and vtx_radius_.

38  {
39  // Flag that indicates if extra variables are added to electron userData
40  ele.addUserInt("convExtra", 1, true); // overwrite
41 
42  // quality
43  ele.addUserInt("convValid", valid_ ? 1 : 0);
44  ele.addUserFloat("convChi2Prob", chi2prob_);
45  ele.addUserInt("convQualityHighPurity", quality_high_purity_ ? 1 : 0);
46  ele.addUserInt("convQualityHighEff", quality_high_efficiency_ ? 1 : 0);
47 
48  // tracks
49  ele.addUserInt("convTracksN", ntracks_);
50  ele.addUserFloat("convMinTrkPt", min_trk_pt_);
51  ele.addUserInt("convLeadIdx", ilead_);
52  ele.addUserInt("convTrailIdx", itrail_);
53 
54  // displacement
55  ele.addUserFloat("convLxy", l_xy_);
56  ele.addUserFloat("convVtxRadius", vtx_radius_);
57 
58  // invariant mass
59  ele.addUserFloat("convMass", mass_from_conv_);
60  ele.addUserFloat("convMassFromPin", mass_from_Pin_);
61  ele.addUserFloat("convMassBeforeFit", mass_before_fit_);
62  ele.addUserFloat("convMassAfterFit", mass_after_fit_);
63 
64  // hits before vertex
65  ele.addUserInt("convLeadNHitsBeforeVtx", lead_nhits_before_vtx_);
66  ele.addUserInt("convTrailNHitsBeforeVtx", trail_nhits_before_vtx_);
67  ele.addUserInt("convMaxNHitsBeforeVtx", max_nhits_before_vtx_);
68  ele.addUserInt("convSumNHitsBeforeVtx", sum_nhits_before_vtx_);
69  ele.addUserInt("convDeltaExpectedNHitsInner", delta_expected_nhits_inner_);
70 
71  // opening angle
72  ele.addUserFloat("convDeltaCotFromPin", delta_cot_from_Pin_);
73 }
int delta_expected_nhits_inner_
bool quality_high_efficiency_
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:892
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:929
uint trail_nhits_before_vtx_

◆ addUserVars()

void LowPtConversion::addUserVars ( pat::Electron ele) const

Definition at line 25 of file LowPtConversion.cc.

References pat::PATObject< ObjectType >::addUserInt(), pat::PATObject< ObjectType >::hasUserInt(), edm::RefToBase< T >::isNonnull(), matched_, matched_lead_, matched_trail_, wpLoose(), and wpTight().

25  {
26  ele.addUserInt("convOpen", matched_ ? 1 : 0);
27  ele.addUserInt("convLoose", wpLoose() ? 1 : 0);
28  ele.addUserInt("convTight", wpTight() ? 1 : 0);
29  ele.addUserInt("convLead", matched_lead_.isNonnull() ? 1 : 0);
30  ele.addUserInt("convTrail", matched_trail_.isNonnull() ? 1 : 0);
31  if (ele.hasUserInt("convExtra") == false) {
32  ele.addUserInt("convExtra", 0);
33  }
34 }
bool hasUserInt(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:390
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:301
edm::RefToBase< reco::Track > matched_trail_
bool wpTight() const
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:929
edm::RefToBase< reco::Track > matched_lead_
bool wpLoose() const

◆ match()

bool LowPtConversion::match ( const reco::BeamSpot beamSpot,
const reco::ConversionCollection conversions,
const pat::Electron ele 
)

Definition at line 77 of file LowPtConversion.cc.

References pwdgSkimBPark_cfi::beamSpot, chi2prob_, ChiSquaredProbability(), conv, pwdgSkimBPark_cfi::conversions, pat::Electron::core(), delta_cot_from_Pin_, delta_expected_nhits_inner_, PVValHelper::dx, PVValHelper::dy, ntupleEnum::gsf, pat::Electron::gsfTrack(), reco::Conversion::highEfficiency, reco::Conversion::highPurity, edm::RefToBase< T >::id(), edm::Ref< C, T, F >::id(), ilead_, edm::RefToBase< T >::isAvailable(), edm::RefToBase< T >::isNonnull(), edm::RefToBase< T >::isNull(), itrail_, edm::RefToBase< T >::key(), edm::Ref< C, T, F >::key(), l_xy_, lead_nhits_before_vtx_, mass_after_fit_, mass_before_fit_, mass_from_conv_, mass_from_Pin_, matched_, matched_lead_, matched_trail_, SiStripPI::max, max_nhits_before_vtx_, mee(), min_trk_pt_, reco::HitPattern::MISSING_INNER_HITS, nHits, ntracks_, reco::TrackBase::pt(), quality_high_efficiency_, quality_high_purity_, mathSSE::sqrt(), sum_nhits_before_vtx_, funct::tan(), trail_nhits_before_vtx_, parallelization::uint, valid_, and vtx_radius_.

79  {
80  // Iterate through conversions and calculate quantities (requirement from Nancy)
81  for (const auto& conv : conversions) {
82  // Filter
83  if (conv.tracks().size() != 2) {
84  continue;
85  }
86 
87  // Quality
88  valid_ = conv.conversionVertex().isValid(); // (=true)
89  chi2prob_ = ChiSquaredProbability(conv.conversionVertex().chi2(), conv.conversionVertex().ndof()); // (<0.005)
92 
93  // Tracks
94  ntracks_ = conv.tracks().size(); // (=2)
95  min_trk_pt_ = -1.; // (>0.5)
96  for (const auto& trk : conv.tracks()) {
97  if (trk.isNonnull() && trk.isAvailable() && (min_trk_pt_ < 0. || trk->pt() < min_trk_pt_)) {
98  min_trk_pt_ = trk->pt();
99  }
100  }
101  ilead_ = -1;
102  itrail_ = -1;
103  if (conv.tracks().size() == 2) {
104  const edm::RefToBase<reco::Track>& trk1 = conv.tracks().front();
105  const edm::RefToBase<reco::Track>& trk2 = conv.tracks().back();
106  if (trk1.isNonnull() && trk1.isAvailable() && trk2.isNonnull() && trk2.isAvailable()) {
107  if (trk1->pt() > trk2->pt()) {
108  ilead_ = 0;
109  itrail_ = 1;
110  } else {
111  ilead_ = 1;
112  itrail_ = 0;
113  }
114  }
115  }
116 
117  // Transverse displacement (with respect to beamspot) and vertex radius
118  math::XYZVectorF p_refitted = conv.refittedPairMomentum();
119  float dx = conv.conversionVertex().x() - beamSpot.x0();
120  float dy = conv.conversionVertex().y() - beamSpot.y0();
121  l_xy_ = (p_refitted.x() * dx + p_refitted.y() * dy) / p_refitted.rho();
122  vtx_radius_ = sqrt(conv.conversionVertex().position().perp2()); // (1.5<r<4.)
123 
124  // invariant mass from track pair from conversion
125  mass_from_conv_ = conv.pairInvariantMass();
126 
127  // Invariant mass from Pin before fit to common vertex
128  if (conv.tracksPin().size() >= 2 && ilead_ > -1 && itrail_ > -1) {
129  math::XYZVectorF lead_Pin = conv.tracksPin().at(ilead_);
130  math::XYZVectorF trail_Pin = conv.tracksPin().at(itrail_);
131  mass_from_Pin_ = mee(lead_Pin.x(), lead_Pin.y(), lead_Pin.z(), trail_Pin.x(), trail_Pin.y(), trail_Pin.z());
132  // Opening angle
133  delta_cot_from_Pin_ = 1. / tan(trail_Pin.theta()) - 1. / tan(lead_Pin.theta());
134  }
135 
136  // Invariant mass before fit to common vertex
137  if (conv.tracks().size() >= 2 && ilead_ > -1 && itrail_ > -1) {
138  auto lead_before_vtx_fit = conv.tracks().at(ilead_)->momentum();
139  auto trail_before_vtx_fit = conv.tracks().at(itrail_)->momentum();
140  mass_before_fit_ = mee(lead_before_vtx_fit.x(),
141  lead_before_vtx_fit.y(),
142  lead_before_vtx_fit.z(),
143  trail_before_vtx_fit.x(),
144  trail_before_vtx_fit.y(),
145  trail_before_vtx_fit.z());
146  }
147 
148  // Invariant mass after the fit to common vertex
149  if (conv.conversionVertex().refittedTracks().size() >= 2 && ilead_ > -1 && itrail_ > -1) {
150  auto const& lead_after_vtx_fit = conv.conversionVertex().refittedTracks().at(ilead_);
151  auto const& trail_after_vtx_fit = conv.conversionVertex().refittedTracks().at(itrail_);
152  mass_after_fit_ = mee(lead_after_vtx_fit.px(),
153  lead_after_vtx_fit.py(),
154  lead_after_vtx_fit.pz(),
155  trail_after_vtx_fit.px(),
156  trail_after_vtx_fit.py(),
157  trail_after_vtx_fit.pz());
158  // Difference in expeted hits
160  lead_after_vtx_fit.hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) -
161  trail_after_vtx_fit.hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
162  }
163 
164  // Hits prior to vertex
165  if (ilead_ > -1 && itrail_ > -1) {
166  auto const& nHits = conv.nHitsBeforeVtx();
167  bool enoughTracks = nHits.size() > 1;
168  lead_nhits_before_vtx_ = enoughTracks ? nHits.at(ilead_) : 0;
169  trail_nhits_before_vtx_ = enoughTracks ? nHits.at(itrail_) : 0;
170  max_nhits_before_vtx_ = enoughTracks ? std::max(nHits[0], nHits[1]) : 0;
171  sum_nhits_before_vtx_ = enoughTracks ? nHits[0] + nHits[1] : 0;
172  }
173 
174  // Attempt to match conversion track to electron
175  for (uint itrk = 0; itrk < conv.tracks().size(); ++itrk) {
176  const edm::RefToBase<reco::Track> trk = conv.tracks()[itrk];
177  if (trk.isNull()) {
178  continue;
179  }
180  reco::GsfTrackRef ref = ele.core()->gsfTrack();
182  if (gsf.isNull()) {
183  continue;
184  }
185  if (ref.id() == trk.id() && ref.key() == trk.key()) {
186  matched_ = true;
187  if (static_cast<int>(itrk) == ilead_) {
188  matched_lead_ = trk;
189  }
190  if (static_cast<int>(itrk) == itrail_) {
191  matched_trail_ = trk;
192  }
193  }
194  } // track loop
195  } // conversions loop
196 
197  return matched_;
198 }
bool isAvailable() const
Definition: RefToBase.h:119
int delta_expected_nhits_inner_
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:301
bool quality_high_efficiency_
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
key_type key() const
Accessor for product key.
Definition: Ref.h:250
ProductID id() const
Definition: RefToBase.h:214
double pt() const
track transverse momentum
Definition: TrackBase.h:637
edm::RefToBase< reco::Track > matched_trail_
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
float ChiSquaredProbability(double chiSquared, double nrDOF)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:16
bool isNull() const
Checks for null.
Definition: RefToBase.h:295
size_t key() const
Definition: RefToBase.h:219
edm::RefToBase< reco::Track > matched_lead_
EPOS::IO_EPOS conv
uint trail_nhits_before_vtx_
static float mee(float ipx1, float ipy1, float ipz1, float ipx2, float ipy2, float ipz2)
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
reco::GsfElectronCoreRef core() const override
override the virtual reco::GsfElectron::core method, so that the embedded core can be used by GsfElec...

◆ mee()

float LowPtConversion::mee ( float  ipx1,
float  ipy1,
float  ipz1,
float  ipx2,
float  ipy2,
float  ipz2 
)
static

Definition at line 202 of file LowPtConversion.cc.

References MillePedeFileConverter_cfg::e, visualization-live-secondInstance_cfg::m, EgHLTOffHistBins_cfi::mass, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, and mathSSE::sqrt().

Referenced by match().

202  {
203  const float m = 0.000511;
204  const float px = px1 + px2;
205  const float py = py1 + py2;
206  const float pz = pz1 + pz2;
207  const float p1 = px1 * px1 + py1 * py1 + pz1 * pz1;
208  const float p2 = px2 * px2 + py2 * py2 + pz2 * pz2;
209  const float e = sqrt(p1 + m * m) + sqrt(p2 + m * m);
210  const float mass = (e * e - px * px - py * py - pz * pz);
211  return mass > 0. ? sqrt(mass) : -1.;
212 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ wpLoose()

bool LowPtConversion::wpLoose ( ) const

Definition at line 11 of file LowPtConversion.cc.

References chi2prob_, ntracks_, quality_high_purity_, valid_, and wpOpen().

Referenced by addUserVars(), and wpTight().

11  {
12  return (wpOpen() && ntracks_ == 2 && valid_ && quality_high_purity_ && chi2prob_ > 0.0005);
13 }
bool wpOpen() const

◆ wpOpen()

bool LowPtConversion::wpOpen ( ) const

Definition at line 6 of file LowPtConversion.cc.

References matched_.

Referenced by wpLoose().

6 { return matched_; }

◆ wpTight()

bool LowPtConversion::wpTight ( ) const

Definition at line 18 of file LowPtConversion.cc.

References mass_from_conv_, and wpLoose().

Referenced by addUserVars().

18  {
19  return (wpLoose() && sum_nhits_before_vtx_ <= 1 && l_xy_ > 0. && mass_from_conv_ > 0. && // sanity check
20  mass_from_conv_ < 0.05);
21 }
bool wpLoose() const

Member Data Documentation

◆ chi2prob_

float LowPtConversion::chi2prob_ = -1.
private

Definition at line 32 of file LowPtConversion.h.

Referenced by addExtraUserVars(), match(), and wpLoose().

◆ delta_cot_from_Pin_

float LowPtConversion::delta_cot_from_Pin_ = -1.
private

Definition at line 60 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ delta_expected_nhits_inner_

int LowPtConversion::delta_expected_nhits_inner_ = 0
private

Definition at line 57 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ ilead_

int LowPtConversion::ilead_ = -1
private

Definition at line 39 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ itrail_

int LowPtConversion::itrail_ = -1
private

Definition at line 40 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ l_xy_

float LowPtConversion::l_xy_ = -1.
private

Definition at line 43 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ lead_nhits_before_vtx_

uint LowPtConversion::lead_nhits_before_vtx_ = 0
private

Definition at line 53 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ mass_after_fit_

float LowPtConversion::mass_after_fit_ = -1.
private

Definition at line 50 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ mass_before_fit_

float LowPtConversion::mass_before_fit_ = -1.
private

Definition at line 49 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ mass_from_conv_

float LowPtConversion::mass_from_conv_ = -1.
private

Definition at line 47 of file LowPtConversion.h.

Referenced by addExtraUserVars(), match(), and wpTight().

◆ mass_from_Pin_

float LowPtConversion::mass_from_Pin_ = -1.
private

Definition at line 48 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ matched_

bool LowPtConversion::matched_ = false
private

Definition at line 63 of file LowPtConversion.h.

Referenced by addUserVars(), match(), and wpOpen().

◆ matched_lead_

edm::RefToBase<reco::Track> LowPtConversion::matched_lead_
private

Definition at line 64 of file LowPtConversion.h.

Referenced by addUserVars(), and match().

◆ matched_trail_

edm::RefToBase<reco::Track> LowPtConversion::matched_trail_
private

Definition at line 65 of file LowPtConversion.h.

Referenced by addUserVars(), and match().

◆ max_nhits_before_vtx_

uint LowPtConversion::max_nhits_before_vtx_ = 0
private

Definition at line 55 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ min_trk_pt_

float LowPtConversion::min_trk_pt_ = -1.
private

Definition at line 38 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ ntracks_

uint LowPtConversion::ntracks_ = 0
private

Definition at line 37 of file LowPtConversion.h.

Referenced by addExtraUserVars(), match(), and wpLoose().

◆ quality_high_efficiency_

bool LowPtConversion::quality_high_efficiency_ = false
private

Definition at line 34 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ quality_high_purity_

bool LowPtConversion::quality_high_purity_ = false
private

Definition at line 33 of file LowPtConversion.h.

Referenced by addExtraUserVars(), match(), and wpLoose().

◆ sum_nhits_before_vtx_

uint LowPtConversion::sum_nhits_before_vtx_ = 0
private

Definition at line 56 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ trail_nhits_before_vtx_

uint LowPtConversion::trail_nhits_before_vtx_ = 0
private

Definition at line 54 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().

◆ valid_

bool LowPtConversion::valid_ = false
private

Definition at line 31 of file LowPtConversion.h.

Referenced by addExtraUserVars(), match(), and wpLoose().

◆ vtx_radius_

float LowPtConversion::vtx_radius_ = -1.
private

Definition at line 44 of file LowPtConversion.h.

Referenced by addExtraUserVars(), and match().