CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFRecoTauDiscriminationByIsolation.cc
Go to the documentation of this file.
1 #include <functional>
2 #include <boost/foreach.hpp>
7 
8 /* class PFRecoTauDiscriminationByIsolation
9  * created : Jul 23 2007,
10  * revised : Thu Aug 13 14:44:40 PDT 2009
11  * contributors : Ludovic Houchu (Ludovic.Houchu@cern.ch ; IPHC, Strasbourg),
12  * Christian Veelken (veelken@fnal.gov ; UC Davis),
13  * Evan K. Friis (friis@physics.ucdavis.edu ; UC Davis)
14  */
15 
16 using namespace reco;
17 using namespace std;
18 
21  public:
23  const edm::ParameterSet& pset):
25  qualityCuts_(pset.getParameter<edm::ParameterSet>("qualityCuts")) {
26  includeTracks_ = pset.getParameter<bool>(
27  "ApplyDiscriminationByTrackerIsolation");
28  includeGammas_ = pset.getParameter<bool>(
29  "ApplyDiscriminationByECALIsolation");
30 
31  applyOccupancyCut_ = pset.getParameter<bool>("applyOccupancyCut");
32  maximumOccupancy_ = pset.getParameter<uint32_t>("maximumOccupancy");
33 
34  applySumPtCut_ = pset.getParameter<bool>("applySumPtCut");
35  maximumSumPt_ = pset.getParameter<double>("maximumSumPtCut");
36 
37  applyRelativeSumPtCut_ = pset.getParameter<bool>(
38  "applyRelativeSumPtCut");
39  maximumRelativeSumPt_ = pset.getParameter<double>(
40  "relativeSumPtCut");
41 
42  pvProducer_ = pset.getParameter<edm::InputTag>("PVProducer");
43 
44  if (pset.exists("customOuterCone")) {
45  customIsoCone_ = pset.getParameter<double>("customOuterCone");
46  } else {
47  customIsoCone_ = -1;
48  }
49  }
50 
52 
53  void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup);
54  double discriminate(const PFTauRef& pfTau);
55 
56  private:
58 
61 
64 
66  double maximumSumPt_;
67 
70 
72 
74 
76 };
77 
79  const edm::EventSetup& eventSetup) {
80 
81  // NB: The use of the PV in this context is necessitated by its use in
82  // applying quality cuts to the different objects in the isolation cone
83 
84  // get the PV for this event
85  edm::Handle<VertexCollection> primaryVertices;
86  event.getByLabel(pvProducer_, primaryVertices);
87 
88  // take the highest pt primary vertex in the event
89  if( primaryVertices->size() ) {
90  currentPV_ = *(primaryVertices->begin());
91  } else {
92  const double smearedPVsigmaY = 0.0015;
93  const double smearedPVsigmaX = 0.0015;
94  const double smearedPVsigmaZ = 0.005;
95  Vertex::Error SimPVError;
96  SimPVError(0,0) = smearedPVsigmaX*smearedPVsigmaX;
97  SimPVError(1,1) = smearedPVsigmaY*smearedPVsigmaY;
98  SimPVError(2,2) = smearedPVsigmaZ*smearedPVsigmaZ;
99  Vertex::Point blankVertex(0, 0, 0);
100 
101  // note that the PFTau has its vertex set as the associated PV. So if it
102  // doesn't exist, a fake vertex has already been created (about 0, 0, 0) w/
103  // the above width (gaussian)
104  currentPV_ = Vertex(blankVertex, SimPVError,1,1,1);
105  }
106 }
107 
109  // collect the objects we are working with (ie tracks, tracks+gammas, etc)
110  std::vector<LeafCandidate> isoObjects;
111 
112  if (includeTracks_) {
113  qualityCuts_.isolationChargedObjects(*pfTau, currentPV_, isoObjects);
114  }
115 
116  if (includeGammas_) {
117  qualityCuts_.isolationGammaObjects(*pfTau, isoObjects);
118  }
119 
121 
122  // Check if we want a custom iso cone
123  if (customIsoCone_ >= 0.) {
124  DRFilter filter(pfTau->p4(), 0, customIsoCone_);
125  // Remove all the objects not in our iso cone
126  std::remove_if(isoObjects.begin(), isoObjects.end(), std::not1(filter));
127  }
128 
129  bool failsOccupancyCut = false;
130  bool failsSumPtCut = false;
131  bool failsRelativeSumPtCut = false;
132 
133  //--- nObjects requirement
134  failsOccupancyCut = ( isoObjects.size() > maximumOccupancy_ );
135 
136  //--- Sum PT requirement
137  if( applySumPtCut_ || applyRelativeSumPtCut_ ) {
139  BOOST_FOREACH(const LeafCandidate& isoObject, isoObjects) {
140  totalP4 += isoObject.p4();
141  }
142 
143  failsSumPtCut = (totalP4.pt() > maximumSumPt_);
144 
145  //--- Relative Sum PT requirement
146  failsRelativeSumPtCut = (
147  (pfTau->pt() > 0 ? totalP4.pt()/pfTau->pt() : 0 )
148  > maximumRelativeSumPt_ );
149  }
150 
151  bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
152  (applySumPtCut_ && failsSumPtCut) ||
153  (applyRelativeSumPtCut_ && failsRelativeSumPtCut) ;
154 
155  return (fails ? 0. : 1.);
156 }
157 
PFRecoTauDiscriminationByIsolation(const edm::ParameterSet &pset)
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
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
void beginEvent(const edm::Event &evt, const edm::EventSetup &evtSetup)
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26