CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackExtractor.cc
Go to the documentation of this file.
1 #include "TrackExtractor.h"
2 
5 #include "TrackSelector.h"
8 
9 using namespace edm;
10 using namespace std;
11 using namespace reco;
12 using namespace muonisolation;
14 
15 TrackExtractor::TrackExtractor( const ParameterSet& par, edm::ConsumesCollector && iC ) :
16  theTrackCollectionToken(iC.consumes<View<Track> >(par.getParameter<edm::InputTag>("inputTrackCollection"))),
17  theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
18  theDiff_r(par.getParameter<double>("Diff_r")),
19  theDiff_z(par.getParameter<double>("Diff_z")),
20  theDR_Max(par.getParameter<double>("DR_Max")),
21  theDR_Veto(par.getParameter<double>("DR_Veto")),
22  theBeamlineOption(par.getParameter<string>("BeamlineOption")),
23  theBeamSpotToken(iC.consumes<reco::BeamSpot>(par.getParameter<edm::InputTag>("BeamSpotLabel"))),
24  theNHits_Min(par.getParameter<unsigned int>("NHits_Min")),
25  theChi2Ndof_Max(par.getParameter<double>("Chi2Ndof_Max")),
26  theChi2Prob_Min(par.getParameter<double>("Chi2Prob_Min")),
27  thePt_Min(par.getParameter<double>("Pt_Min"))
28 {
29 }
30 
32  const edm::EventSetup & evSetup, const reco::Track & track) const
33 {
34  reco::isodeposit::Direction dir(track.eta(),track.phi());
35  return reco::IsoDeposit::Vetos(1,veto(dir));
36 }
37 
39 {
41  result.vetoDir = dir;
42  result.dR = theDR_Veto;
43  return result;
44 }
45 
46 IsoDeposit TrackExtractor::deposit(const Event & event, const EventSetup & eventSetup, const Track & muon) const
47 {
48  static const std::string metname = "MuonIsolation|TrackExtractor";
49 
50  reco::isodeposit::Direction muonDir(muon.eta(), muon.phi());
51  IsoDeposit deposit(muonDir );
52  deposit.setVeto( veto(muonDir) );
53  deposit.addCandEnergy(muon.pt());
54 
55  Handle<View<Track> > tracksH;
56  event.getByToken(theTrackCollectionToken, tracksH);
57  // const TrackCollection tracks = *(tracksH.product());
58  LogTrace(metname)<<"***** TRACK COLLECTION SIZE: "<<tracksH->size();
59 
60  double vtx_z = muon.vz();
61  LogTrace(metname)<<"***** Muon vz: "<<vtx_z;
62  reco::TrackBase::Point beamPoint(0,0, 0);
63 
64  if (theBeamlineOption.compare("BeamSpotFromEvent") == 0){
65  //pick beamSpot
68 
69  event.getByToken(theBeamSpotToken,beamSpotH);
70 
71  if (beamSpotH.isValid()){
72  beamPoint = beamSpotH->position();
73  LogTrace(metname)<<"Extracted beam point at "<<beamPoint<<std::endl;
74  }
75  }
76 
77  LogTrace(metname)<<"Using beam point at "<<beamPoint<<std::endl;
78 
80  theDiff_r, muonDir, theDR_Max, beamPoint);
81 
82  pars.nHitsMin = theNHits_Min;
83  pars.chi2NdofMax = theChi2Ndof_Max;
84  pars.chi2ProbMin = theChi2Prob_Min;
85  pars.ptMin = thePt_Min;
86 
88  TrackSelector::result_type sel_tracks = selection(*tracksH);
89  LogTrace(metname)<<"all tracks: "<<tracksH->size()<<" selected: "<<sel_tracks.size();
90 
91 
92  TrackSelector::result_type::const_iterator tkI = sel_tracks.begin();
93  for (; tkI != sel_tracks.end(); ++tkI) {
94  const reco::Track* tk = *tkI;
95  LogTrace(metname) << "This track has: pt= " << tk->pt() << ", eta= "
96  << tk->eta() <<", phi= "<<tk->phi();
97  reco::isodeposit::Direction dirTrk(tk->eta(), tk->phi());
98  deposit.addDeposit(dirTrk, tk->pt());
99  }
100 
101  return deposit;
102 }
const std::string metname
std::list< const reco::Track * > result_type
Definition: TrackSelector.h:17
selection
main part
Definition: corrVsCorr.py:98
unsigned int theNHits_Min
BeamSpot name.
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:632
bool ev
double theDR_Max
z distance to vertex
reco::IsoDeposit::Veto veto(const reco::IsoDeposit::Direction &dir) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:638
vector< ParameterSet > Parameters
edm::EDGetTokenT< edm::View< reco::Track > > theTrackCollectionToken
double theDiff_r
name for deposit
double pt() const
track transverse momentum
Definition: TrackBase.h:608
tuple result
Definition: query.py:137
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
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:75
#define LogTrace(id)
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:656
double theChi2Ndof_Max
trk.numberOfValidHits &gt;= theNHits_Min
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.
double thePt_Min
ChiSquaredProbability(trk.chi2,trk.ndof) &gt; theChi2Prob_Min.
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
&quot;NONE&quot;, &quot;BeamSpotFromEvent&quot;
std::vector< Veto > Vetos
Definition: IsoDeposit.h:63
double theDR_Veto
Maximum cone angle for deposits.
muonisolation::Range< float > Range
Definition: TrackSelector.h:16
dbl *** dir
Definition: mlp_gen.cc:35
double theChi2Prob_Min
trk.normalizedChi2 &lt; theChi2Ndof_Max
virtual reco::IsoDeposit::Vetos vetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const