CMS 3D CMS Logo

PixelTrackExtractor.cc
Go to the documentation of this file.
1 #include "PixelTrackExtractor.h"
2 
5 #include "TrackSelector.h"
10 
14 
15 using namespace edm;
16 using namespace std;
17 using namespace reco;
18 using namespace muonisolation;
20 
21 PixelTrackExtractor::PixelTrackExtractor(const ParameterSet& par, edm::ConsumesCollector&& iC)
22  : theTrackCollectionToken(iC.consumes<TrackCollection>(par.getParameter<edm::InputTag>("inputTrackCollection"))),
23  theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
24  theDiff_r(par.getParameter<double>("Diff_r")),
25  theDiff_z(par.getParameter<double>("Diff_z")),
26  theDR_Max(par.getParameter<double>("DR_Max")),
27  theDR_Veto(par.getParameter<double>("DR_Veto")),
28  theBeamlineOption(par.getParameter<string>("BeamlineOption")),
29  theBeamSpotToken(iC.mayConsume<BeamSpot>(par.getParameter<edm::InputTag>("BeamSpotLabel"))),
30  theNHits_Min(par.getParameter<unsigned int>("NHits_Min")),
31  theChi2Ndof_Max(par.getParameter<double>("Chi2Ndof_Max")),
32  theChi2Prob_Min(par.getParameter<double>("Chi2Prob_Min")),
33  thePt_Min(par.getParameter<double>("Pt_Min")),
34  thePropagateTracksToRadius(par.getParameter<bool>("PropagateTracksToRadius")),
35  theReferenceRadius(par.getParameter<double>("ReferenceRadius")),
36  theVetoLeadingTrack(par.getParameter<bool>("VetoLeadingTrack")),
37  thePtVeto_Min(par.getParameter<double>("PtVeto_Min")),
38  theDR_VetoPt(par.getParameter<double>("DR_VetoPt"))
39 {}
40 
42  const edm::EventSetup& evSetup,
43  const reco::Track& track) const {
44  Direction dir(track.eta(), track.phi());
45  return reco::IsoDeposit::Vetos(1, veto(dir));
46 }
47 
50  result.vetoDir = dir;
51  result.dR = theDR_Veto;
52  return result;
53 }
54 
57  return Direction(tk.eta(), tk.phi());
58  }
59 
60  // this should represent a cylinder in global frame at R=refRadius cm, roughly where mid-layer of pixels is
61  double psRadius = theReferenceRadius;
62  double tkDxy = tk.dxy();
63  double s2D = fabs(tk.dxy()) < psRadius ? sqrt(psRadius * psRadius - tkDxy * tkDxy) : 0;
64 
65  // the field we get from the caller is already in units of GeV/cm
66  double dPhi = -s2D * tk.charge() * bz / tk.pt();
67 
68  return Direction(tk.eta(), tk.phi() + dPhi);
69 }
70 
71 IsoDeposit PixelTrackExtractor::deposit(const Event& event, const EventSetup& eventSetup, const Track& muon) const {
72  static const std::string metname = "MuonIsolation|PixelTrackExtractor";
73 
75  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
76  double bz = bField->inInverseGeV(GlobalPoint(0., 0., 0.)).z();
77 
78  Direction muonDir(directionAtPresetRadius(muon, bz));
79  IsoDeposit deposit(muonDir);
81  deposit.setVeto(veto(muonDir));
82 
83  deposit.addCandEnergy(muon.pt());
84 
86  event.getByToken(theTrackCollectionToken, tracksH);
87  // const TrackCollection tracks = *(tracksH.product());
88  LogTrace(metname) << "***** TRACK COLLECTION SIZE: " << tracksH->size();
89 
90  double vtx_z = muon.vz();
91  LogTrace(metname) << "***** Muon vz: " << vtx_z;
92  reco::TrackBase::Point beamPoint(0, 0, 0);
93 
94  if (theBeamlineOption == "BeamSpotFromEvent") {
95  //pick beamSpot
98 
99  event.getByToken(theBeamSpotToken, beamSpotH);
100 
101  if (beamSpotH.isValid()) {
102  beamPoint = beamSpotH->position();
103  LogTrace(metname) << "Extracted beam point at " << beamPoint << std::endl;
104  }
105  }
106 
107  LogTrace(metname) << "Using beam point at " << beamPoint << std::endl;
108 
110  TrackSelector::Range(vtx_z - theDiff_z, vtx_z + theDiff_z), theDiff_r, muonDir, theDR_Max, beamPoint);
111 
112  pars.nHitsMin = theNHits_Min;
113  pars.chi2NdofMax = theChi2Ndof_Max;
114  pars.chi2ProbMin = theChi2Prob_Min;
115  pars.ptMin = thePt_Min;
116 
117  TrackSelector selection(pars);
118  TrackSelector::result_type sel_tracks = selection(*tracksH);
119  LogTrace(metname) << "all tracks: " << tracksH->size() << " selected: " << sel_tracks.size();
120 
121  double maxPt = -1;
122  Direction maxPtDir;
123  TrackSelector::result_type::const_iterator tkI = sel_tracks.begin();
124  for (; tkI != sel_tracks.end(); ++tkI) {
125  const reco::Track* tk = *tkI;
126  LogTrace(metname) << "This track has: pt= " << tk->pt() << ", eta= " << tk->eta() << ", phi= " << tk->phi();
127  Direction dirTrk(directionAtPresetRadius(*tk, bz));
128  deposit.addDeposit(dirTrk, tk->pt());
129  double tkDr = (muonDir - dirTrk).deltaR;
130  double tkPt = tk->pt();
131  if (theVetoLeadingTrack && tkPt > thePtVeto_Min && tkDr < theDR_VetoPt && maxPt < tkPt) {
132  maxPt = tkPt;
133  maxPtDir = dirTrk;
134  }
135  }
136  if (maxPt > 0) {
137  deposit.setVeto(veto(maxPtDir));
138  LogTrace(metname) << " Set track veto the leading track with pt " << maxPt << " in direction (eta,phi) "
139  << maxPtDir.eta() << ", " << maxPtDir.phi();
140  }
141 
142  return deposit;
143 }
double theReferenceRadius
If set to true will compare track eta-phi at ...
void setVeto(const Veto &aVeto)
Set veto.
Definition: IsoDeposit.h:82
double theChi2Ndof_Max
trk.numberOfValidHits >= theNHits_Min
reco::IsoDeposit::Veto veto(const reco::IsoDeposit::Direction &dir) const
const std::string metname
double theDR_Veto
Maximum cone angle for deposits.
std::list< const reco::Track * > result_type
Definition: TrackSelector.h:16
selection
main part
Definition: corrVsCorr.py:100
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:614
bool ev
virtual reco::IsoDeposit::Vetos vetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:19
bool thePropagateTracksToRadius
min track pt to include into iso deposit
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:36
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &muon) const override
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
vector< ParameterSet > Parameters
double thePtVeto_Min
will veto leading track if
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
"NONE", "BeamSpotFromEvent"
double pt() const
track transverse momentum
Definition: TrackBase.h:602
T z() const
Definition: PV3DBase.h:61
double theDR_Max
z distance to vertex
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:132
edm::EDGetTokenT< reco::TrackCollection > theTrackCollectionToken
double thePt_Min
ChiSquaredProbability(trk.chi2,trk.ndof) > theChi2Prob_Min.
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:626
double theDiff_z
transverse distance to vertex
std::string theBeamlineOption
Veto cone angle.
reco::isodeposit::Direction directionAtPresetRadius(const reco::Track &tk, double bz) const
std::vector< Veto > Vetos
Definition: IsoDeposit.h:65
fixed size matrix
HLT enums.
double theDR_VetoPt
.. it is above this threshold
T get() const
Definition: EventSetup.h:73
unsigned int theNHits_Min
BeamSpot name.
muonisolation::Range< float > Range
Definition: TrackSelector.h:15
int charge() const
track electric charge
Definition: TrackBase.h:575
const Point & position() const
position
Definition: BeamSpot.h:59
double theChi2Prob_Min
trk.normalizedChi2 < theChi2Ndof_Max
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:587
Definition: event.py:1