CMS 3D CMS Logo

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