CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaTrackExtractor.cc
Go to the documentation of this file.
2 
23 
24 using namespace edm;
25 using namespace std;
26 using namespace reco;
27 using namespace egammaisolation;
29 
30 EgammaTrackExtractor::EgammaTrackExtractor( const ParameterSet& par ) :
31  theTrackCollectionTag(par.getParameter<edm::InputTag>("inputTrackCollection")),
32  theDepositLabel(par.getUntrackedParameter<std::string>("DepositLabel")),
33  theDiff_r(par.getParameter<double>("Diff_r")),
34  theDiff_z(par.getParameter<double>("Diff_z")),
35  theDR_Max(par.getParameter<double>("DR_Max")),
36  theDR_Veto(par.getParameter<double>("DR_Veto")),
37  theBeamlineOption(par.getParameter<std::string>("BeamlineOption")),
38  theBeamSpotLabel(par.getParameter<edm::InputTag>("BeamSpotLabel")),
39  theNHits_Min(par.getParameter<unsigned int>("NHits_Min")),
40  theChi2Ndof_Max(par.getParameter<double>("Chi2Ndof_Max")),
41  theChi2Prob_Min(par.getParameter<double>("Chi2Prob_Min")),
42  thePt_Min(par.getParameter<double>("Pt_Min")),
43  dzOptionString(par.getParameter<std::string>("dzOption"))
44 {
45  if( ! dzOptionString.compare("dz") ) dzOption = EgammaTrackSelector::dz;
46  else if( ! dzOptionString.compare("vz") ) dzOption = EgammaTrackSelector::vz;
47  else if( ! dzOptionString.compare("bs") ) dzOption = EgammaTrackSelector::bs;
48  else if( ! dzOptionString.compare("vtx") )dzOption = EgammaTrackSelector::vtx;
50 
51 }
52 
54  const edm::EventSetup & evSetup, const reco::Track & track) const
55 {
56  reco::isodeposit::Direction dir(track.eta(),track.phi());
57  return reco::IsoDeposit::Vetos(1,veto(dir));
58 }
59 
61 {
63  result.vetoDir = dir;
64  result.dR = theDR_Veto;
65  return result;
66 }
67 
68 IsoDeposit EgammaTrackExtractor::deposit(const Event & event, const EventSetup & eventSetup, const Candidate & candTk) const
69 {
70  static std::string metname = "EgammaIsolationAlgos|EgammaTrackExtractor";
71 
73  double dzCut=0;
74 
75  reco::TrackBase::Point beamPoint(0,0, 0);
76  if (theBeamlineOption.compare("BeamSpotFromEvent") == 0){
77  //pick beamSpot
80 
81  event.getByLabel(theBeamSpotLabel,beamSpotH);
82 
83  if (beamSpotH.isValid()){
84  beamPoint = beamSpotH->position();
85  }
86  }
87 
88  Handle<View<Track> > tracksH;
89  event.getByLabel(theTrackCollectionTag, tracksH);
90 
91  if( candTk.isElectron() ){
92  const reco::GsfElectron* elec = dynamic_cast<const reco::GsfElectron*>(&candTk);
93  candDir = reco::isodeposit::Direction(elec->gsfTrack()->eta(), elec->gsfTrack()->phi());
94  } else {
95  candDir = reco::isodeposit::Direction(candTk.eta(), candTk.phi());
96  }
97 
98  IsoDeposit deposit(candDir );
99  deposit.setVeto( veto(candDir) );
100  deposit.addCandEnergy(candTk.et());
101 
102  View<Track>::const_iterator itrTr = tracksH->begin();
103  View<Track>::const_iterator trEnd = tracksH->end();
104  for (itrTr = tracksH->begin();itrTr != trEnd; ++itrTr) {
105 
106  if(candDir.deltaR( reco::isodeposit::Direction(itrTr->eta(),itrTr->phi()) ) > theDR_Max )
107  continue;
108 
109  if(itrTr->normalizedChi2() > theChi2Ndof_Max)
110  continue;
111 
112  if(itrTr->pt() < thePt_Min)
113  continue;
114 
115  if(theChi2Prob_Min > 0 && ChiSquaredProbability(itrTr->chi2(), itrTr->ndof()) < theChi2Prob_Min )
116  continue;
117 
118  if(theNHits_Min > 0 && itrTr->numberOfValidHits() < theNHits_Min)
119  continue;
120 
121  if( candTk.isElectron() ){
122  const reco::GsfElectron* elec = dynamic_cast<const reco::GsfElectron*>(&candTk);
123  switch(dzOption) {
124  case EgammaTrackSelector::dz : dzCut = elec->gsfTrack()->dz() - itrTr->dz() ; break;
125  case EgammaTrackSelector::vz : dzCut = elec->gsfTrack()->vz() - itrTr->vz() ; break;
126  case EgammaTrackSelector::bs : dzCut = elec->gsfTrack()->dz(beamPoint) - itrTr->dz(beamPoint) ; break;
127  case EgammaTrackSelector::vtx: dzCut = itrTr->dz(elec->gsfTrack()->vertex()) ; break;
128  default: dzCut = elec->gsfTrack()->vz() - itrTr->vz() ; break;
129  }
130  } else {
131  switch(dzOption) {
132  case EgammaTrackSelector::dz : dzCut = (*itrTr).dz() - candTk.vertex().z() ; break;
133  case EgammaTrackSelector::vz : dzCut = (*itrTr).vz() - candTk.vertex().z() ; break;
134  case EgammaTrackSelector::bs : dzCut = (*itrTr).dz(beamPoint) - candTk.vertex().z() ; break;
135  case EgammaTrackSelector::vtx: dzCut = (*itrTr).dz(candTk.vertex()); break;
136  default : dzCut = (*itrTr).vz() - candTk.vertex().z(); break;
137  }
138  }
139 
140  if(fabs(dzCut) > theDiff_z)
141  continue;
142 
143  if(fabs(itrTr->dxy(beamPoint) ) > theDiff_r)
144  continue;
145 
146  deposit.addDeposit(reco::isodeposit::Direction(itrTr->eta(), itrTr->phi()), itrTr->pt());
147 
148  }
149 
150  return deposit;
151 }
double theDR_Veto
Maximum cone angle for deposits.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &muon) const
std::string dzOptionString
Endcap requirements to determine if isolated for selective filling.
void setVeto(const Veto &aVeto)
Set veto.
Definition: IsoDeposit.h:80
virtual double et() const =0
transverse energy
const std::string metname
virtual float eta() const =0
momentum pseudorapidity
virtual float phi() const =0
momentum azimuthal angle
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
reco::IsoDeposit::Veto veto(const reco::IsoDeposit::Direction &dir) const
double theChi2Prob_Min
trk.normalizedChi2 &lt; theChi2Ndof_Max
double theDiff_r
minimum candidate et
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:23
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
double thePt_Min
ChiSquaredProbability(trk.chi2,trk.ndof) &gt; theChi2Prob_Min.
tuple result
Definition: query.py:137
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:139
float ChiSquaredProbability(double chiSquared, double nrDOF)
virtual const Point & vertex() const =0
vertex position
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
double theDiff_z
transverse distance to vertex
unsigned int theNHits_Min
BeamSpot name.
virtual reco::IsoDeposit::Vetos vetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
std::vector< Veto > Vetos
Definition: IsoDeposit.h:63
double theDR_Max
z distance to vertex
dbl *** dir
Definition: mlp_gen.cc:35
double theChi2Ndof_Max
trk.numberOfValidHits &gt;= theNHits_Min
virtual bool isElectron() const =0
std::string theBeamlineOption
Veto cone angle.
double deltaR(const Direction &dir2) const
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169