CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelTrackExtractor.cc
Go to the documentation of this file.
1 #include "PixelTrackExtractor.h"
2 
5 #include "TrackSelector.h"
12 
16 
17 
18 using namespace edm;
19 using namespace std;
20 using namespace reco;
21 using namespace muonisolation;
23 
24 PixelTrackExtractor::PixelTrackExtractor( const ParameterSet& par ) :
25  theTrackCollectionTag(par.getParameter<edm::InputTag>("inputTrackCollection")),
26  theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
27  theDiff_r(par.getParameter<double>("Diff_r")),
28  theDiff_z(par.getParameter<double>("Diff_z")),
29  theDR_Max(par.getParameter<double>("DR_Max")),
30  theDR_Veto(par.getParameter<double>("DR_Veto")),
31  theBeamlineOption(par.getParameter<string>("BeamlineOption")),
32  theBeamSpotLabel(par.getParameter<edm::InputTag>("BeamSpotLabel")),
33  theNHits_Min(par.getParameter<unsigned int>("NHits_Min")),
34  theChi2Ndof_Max(par.getParameter<double>("Chi2Ndof_Max")),
35  theChi2Prob_Min(par.getParameter<double>("Chi2Prob_Min")),
36  thePt_Min(par.getParameter<double>("Pt_Min")),
37  thePropagateTracksToRadius(par.getParameter<bool>("PropagateTracksToRadius")),
38  theReferenceRadius(par.getParameter<double>("ReferenceRadius")),
39  theVetoLeadingTrack(par.getParameter<bool>("VetoLeadingTrack")),
40  thePtVeto_Min(par.getParameter<double>("PtVeto_Min")),
41  theDR_VetoPt(par.getParameter<double>("DR_VetoPt"))
42 {
43 }
44 
46  const edm::EventSetup & evSetup, const reco::Track & track) const
47 {
48  Direction dir(track.eta(),track.phi());
49  return reco::IsoDeposit::Vetos(1,veto(dir));
50 }
51 
53 {
55  result.vetoDir = dir;
56  result.dR = theDR_Veto;
57  return result;
58 }
59 
62  return Direction(tk.eta(), tk.phi());
63  }
64 
65  // this should represent a cylinder in global frame at R=refRadius cm, roughly where mid-layer of pixels is
66  double psRadius = theReferenceRadius;
67  double tkDxy = tk.dxy();
68  double s2D = fabs(tk.dxy()) < psRadius ? sqrt(psRadius*psRadius - tkDxy*tkDxy) : 0;
69 
70  // the field we get from the caller is already in units of GeV/cm
71  double dPhi = -s2D*tk.charge()*bz/tk.pt();
72 
73  return Direction(tk.eta(), tk.phi()+dPhi);
74 }
75 
76 IsoDeposit PixelTrackExtractor::deposit(const Event & event, const EventSetup & eventSetup, const Track & muon) const
77 {
78  static std::string metname = "MuonIsolation|PixelTrackExtractor";
79 
81  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
82  double bz = bField->inInverseGeV(GlobalPoint(0.,0.,0.)).z();
83 
84  Direction muonDir(directionAtPresetRadius(muon, bz));
85  IsoDeposit deposit(muonDir );
87  deposit.setVeto( veto(muonDir) );
88 
89  deposit.addCandEnergy(muon.pt());
90 
91  Handle<View<Track> > tracksH;
92  event.getByLabel(theTrackCollectionTag, tracksH);
93  // const TrackCollection tracks = *(tracksH.product());
94  LogTrace(metname)<<"***** TRACK COLLECTION SIZE: "<<tracksH->size();
95 
96  double vtx_z = muon.vz();
97  LogTrace(metname)<<"***** Muon vz: "<<vtx_z;
98  reco::TrackBase::Point beamPoint(0,0, 0);
99 
100  if (theBeamlineOption.compare("BeamSpotFromEvent") == 0){
101  //pick beamSpot
103  edm::Handle<reco::BeamSpot> beamSpotH;
104 
105  event.getByLabel(theBeamSpotLabel,beamSpotH);
106 
107  if (beamSpotH.isValid()){
108  beamPoint = beamSpotH->position();
109  LogTrace(metname)<<"Extracted beam point at "<<beamPoint<<std::endl;
110  }
111  }
112 
113  LogTrace(metname)<<"Using beam point at "<<beamPoint<<std::endl;
114 
116  theDiff_r, muonDir, theDR_Max, beamPoint);
117 
118  pars.nHitsMin = theNHits_Min;
119  pars.chi2NdofMax = theChi2Ndof_Max;
120  pars.chi2ProbMin = theChi2Prob_Min;
121  pars.ptMin = thePt_Min;
122 
123  TrackSelector selection(pars);
124  TrackSelector::result_type sel_tracks = selection(*tracksH);
125  LogTrace(metname)<<"all tracks: "<<tracksH->size()<<" selected: "<<sel_tracks.size();
126 
127 
128  double maxPt = -1;
129  Direction maxPtDir;
130  TrackSelector::result_type::const_iterator tkI = sel_tracks.begin();
131  for (; tkI != sel_tracks.end(); ++tkI) {
132  const reco::Track* tk = *tkI;
133  LogTrace(metname) << "This track has: pt= " << tk->pt() << ", eta= "
134  << tk->eta() <<", phi= "<<tk->phi();
135  Direction dirTrk(directionAtPresetRadius(*tk, bz));
136  deposit.addDeposit(dirTrk, tk->pt());
137  double tkDr = (muonDir-dirTrk).deltaR;
138  double tkPt = tk->pt();
139  if (theVetoLeadingTrack && tkPt > thePtVeto_Min
140  && tkDr < theDR_VetoPt
141  && maxPt < tkPt ){
142  maxPt = tkPt;
143  maxPtDir = dirTrk;
144  }
145  }
146  if (maxPt > 0){
147  deposit.setVeto(veto(maxPtDir));
148  LogTrace(metname)<<" Set track veto the leading track with pt "
149  <<maxPt<<" in direction (eta,phi) "
150  <<maxPtDir.eta()<<", "<<maxPtDir.phi();
151  }
152 
153  return deposit;
154 }
double theReferenceRadius
If set to true will compare track eta-phi at ...
void setVeto(const Veto &aVeto)
Set veto.
Definition: IsoDeposit.h:75
double theChi2Ndof_Max
trk.numberOfValidHits &gt;= 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:17
selection
main part
Definition: corrVsCorr.py:98
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
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:23
bool thePropagateTracksToRadius
min track pt to include into iso deposit
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
vector< ParameterSet > Parameters
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
double thePtVeto_Min
will veto leading track if
T sqrt(T t)
Definition: SSEVec.h:46
double pt() const
track transverse momentum
Definition: TrackBase.h:131
tuple result
Definition: query.py:137
double theDR_Max
z distance to vertex
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:134
double thePt_Min
ChiSquaredProbability(trk.chi2,trk.ndof) &gt; theChi2Prob_Min.
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
#define LogTrace(id)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:147
const T & get() const
Definition: EventSetup.h:55
double theDiff_z
transverse distance to vertex
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &muon) const
std::string theBeamlineOption
Veto cone angle.
reco::isodeposit::Direction directionAtPresetRadius(const reco::Track &tk, double bz) const
std::vector< Veto > Vetos
Definition: IsoDeposit.h:58
double theDR_VetoPt
.. it is above this threshold
unsigned int theNHits_Min
BeamSpot name.
muonisolation::Range< float > Range
Definition: TrackSelector.h:16
int charge() const
track electric charge
Definition: TrackBase.h:113
double theChi2Prob_Min
trk.normalizedChi2 &lt; theChi2Ndof_Max
dbl *** dir
Definition: mlp_gen.cc:35
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:121
edm::InputTag theBeamSpotLabel
&quot;NONE&quot;, &quot;BeamSpotFromEvent&quot;