CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
METSignificanceProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METProducers
4 // Class: METSignificanceProducer
5 //
6 //
7 
8 //____________________________________________________________________________||
10 
11 
12 //____________________________________________________________________________||
13 namespace cms
14 {
15 
16 //____________________________________________________________________________||
18  {
19 
20  std::vector<edm::InputTag> srcLeptonsTags = iConfig.getParameter< std::vector<edm::InputTag> >("srcLeptons");
21  for(std::vector<edm::InputTag>::const_iterator it=srcLeptonsTags.begin();it!=srcLeptonsTags.end();it++) {
22  lepTokens_.push_back( consumes<edm::View<reco::Candidate> >( *it ) );
23  }
24 
25  pfjetsToken_ = consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("srcPfJets"));
26 
27  metToken_ = consumes<edm::View<reco::MET> >(iConfig.getParameter<edm::InputTag>("srcMet"));
28  pfCandidatesToken_ = consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("srcPFCandidates"));
29 
30  jetSFType_ = iConfig.getParameter<std::string>("srcJetSF");
31  jetResPtType_ = iConfig.getParameter<std::string>("srcJetResPt");
32  jetResPhiType_ = iConfig.getParameter<std::string>("srcJetResPhi");
33  rhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("srcRho"));
34 
35  metSigAlgo_ = new metsig::METSignificance(iConfig);
36 
37  produces<double>("METSignificance");
38  produces<math::Error<2>::type>("METCovariance");
39 
40  }
41 
43  {
44  delete metSigAlgo_;
45  }
46 
47 //____________________________________________________________________________||
49  {
50  //
51  // met
52  //
54  event.getByToken(metToken_, metHandle);
55  const reco::MET& met = (*metHandle)[0];
56 
57  //
58  // candidates
59  //
61  event.getByToken( pfCandidatesToken_, pfCandidates );
62 
63  //
64  // leptons
65  //
66  std::vector< edm::Handle<reco::CandidateView> > leptons;
67  for ( std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_i = lepTokens_.begin();
68  srcLeptons_i != lepTokens_.end(); ++srcLeptons_i ) {
69 
71  event.getByToken(*srcLeptons_i, leptons_i);
72  leptons.push_back( leptons_i );
73 
74  }
75 
76  //
77  // jets
78  //
80  event.getByToken( pfjetsToken_, jets );
81 
83  event.getByToken(rhoToken_, rho);
84 
88 
89  //
90  // compute the significance
91  //
92  const reco::METCovMatrix cov = metSigAlgo_->getCovariance( *jets, leptons, *pfCandidates, *rho, resPtObj, resPhiObj, resSFObj, event.isRealData() );
93  double sig = metSigAlgo_->getSignificance(cov, met);
94 
95  std::auto_ptr<double> significance (new double);
96  (*significance) = sig;
97 
99  (*covPtr)(0,0) = cov(0,0);
100  (*covPtr)(1,0) = cov(1,0);
101  (*covPtr)(1,1) = cov(1,1);
102 
103  event.put( covPtr, "METCovariance" );
104  event.put( significance, "METSignificance" );
105 
106  }
107 
108 //____________________________________________________________________________||
110 }
111 
112 //____________________________________________________________________________||
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
static const JetResolution get(const edm::EventSetup &, const std::string &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesToken_
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:40
ErrorD< N >::type type
Definition: Error.h:33
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > lepTokens_
bool isRealData() const
Definition: EventBase.h:63
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
tuple METSignificance
____________________________________________________________________________||
edm::EDGetTokenT< double > rhoToken_
Definition: MET.h:42
vector< PseudoJet > jets
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
METSignificanceProducer(const edm::ParameterSet &)
static const JetResolutionScaleFactor get(const edm::EventSetup &, const std::string &)
metsig::METSignificance * metSigAlgo_
edm::EDGetTokenT< edm::View< reco::Jet > > pfjetsToken_
double getSignificance(const reco::METCovMatrix &cov, const reco::MET &met) const
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
reco::METCovMatrix getCovariance(const edm::View< reco::Jet > &jets, const std::vector< edm::Handle< reco::CandidateView > > &leptons, const edm::View< reco::Candidate > &pfCandidates, double rho, JME::JetResolution &resPtObj, JME::JetResolution &resPhiObj, JME::JetResolutionScaleFactor &resSFObj, bool isRealData)