CMS 3D CMS Logo

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 namespace cms {
13 
14  //____________________________________________________________________________||
16  std::vector<edm::InputTag> srcLeptonsTags = iConfig.getParameter<std::vector<edm::InputTag>>("srcLeptons");
17  for (std::vector<edm::InputTag>::const_iterator it = srcLeptonsTags.begin(); it != srcLeptonsTags.end(); it++) {
18  lepTokens_.push_back(consumes<edm::View<reco::Candidate>>(*it));
19  }
20 
21  pfjetsToken_ = consumes<edm::View<reco::Jet>>(iConfig.getParameter<edm::InputTag>("srcPfJets"));
22 
23  metToken_ = consumes<edm::View<reco::MET>>(iConfig.getParameter<edm::InputTag>("srcMet"));
24  pfCandidatesToken_ = consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("srcPFCandidates"));
25 
26  jetSFType_ = iConfig.getParameter<std::string>("srcJetSF");
27  jetResPtType_ = iConfig.getParameter<std::string>("srcJetResPt");
28  jetResPhiType_ = iConfig.getParameter<std::string>("srcJetResPhi");
29  rhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("srcRho"));
30 
31  edm::InputTag srcWeights = iConfig.getParameter<edm::InputTag>("srcWeights");
32  if (!srcWeights.label().empty())
34 
35  metSigAlgo_ = new metsig::METSignificance(iConfig);
36 
37  produces<double>("METSignificance");
38  produces<math::Error<2>::type>("METCovariance");
39  }
40 
42 
43  //____________________________________________________________________________||
45  //
46  // met
47  //
49  event.getByToken(metToken_, metHandle);
50  const reco::MET& met = (*metHandle)[0];
51 
52  //
53  // candidates
54  //
56  event.getByToken(pfCandidatesToken_, pfCandidates);
57 
58  //
59  // leptons
60  //
61  std::vector<edm::Handle<reco::CandidateView>> leptons;
62  for (std::vector<edm::EDGetTokenT<edm::View<reco::Candidate>>>::const_iterator srcLeptons_i = lepTokens_.begin();
63  srcLeptons_i != lepTokens_.end();
64  ++srcLeptons_i) {
66  event.getByToken(*srcLeptons_i, leptons_i);
67  leptons.push_back(leptons_i);
68  }
69 
70  //
71  // jets
72  //
74  event.getByToken(pfjetsToken_, jets);
75 
77  event.getByToken(rhoToken_, rho);
78 
81  event.getByToken(weightsToken_, weights);
82 
86 
87  //
88  // compute the significance
89  //
90  double sumPtUnclustered = 0;
91  const edm::ValueMap<float>* weightsPtr = nullptr;
92  if (met.isWeighted()) {
94  throw cms::Exception("InvalidInput")
95  << "MET is weighted (e.g. PUPPI), but no weights given in METSignificanceProducer\n";
96  weightsPtr = &*weights;
97  }
99  leptons,
100  pfCandidates,
101  *rho,
102  resPtObj,
103  resPhiObj,
104  resSFObj,
105  event.isRealData(),
107  weightsPtr);
108  double sig = metSigAlgo_->getSignificance(cov, met);
109 
110  auto significance = std::make_unique<double>();
111  (*significance) = sig;
112 
113  auto covPtr = std::make_unique<math::Error<2>::type>();
114  (*covPtr)(0, 0) = cov(0, 0);
115  (*covPtr)(1, 0) = cov(1, 0);
116  (*covPtr)(1, 1) = cov(1, 1);
117 
118  event.put(std::move(covPtr), "METCovariance");
119  event.put(std::move(significance), "METSignificance");
120  }
121 
122  //____________________________________________________________________________||
124 } // namespace cms
125 
126 //____________________________________________________________________________||
met_cff.sumPtUnclustered
sumPtUnclustered
Definition: met_cff.py:19
JME::JetResolution
Definition: JetResolution.h:17
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
cms::METSignificanceProducer::~METSignificanceProducer
~METSignificanceProducer() override
Definition: METSignificanceProducer.cc:41
cms::METSignificanceProducer::METSignificanceProducer
METSignificanceProducer(const edm::ParameterSet &)
Definition: METSignificanceProducer.cc:15
HLT_FULL_cff.leptons
leptons
Definition: HLT_FULL_cff.py:26281
cms::METSignificanceProducer::jetResPhiType_
std::string jetResPhiType_
Definition: METSignificanceProducer.h:62
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
cms::METSignificanceProducer::lepTokens_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > lepTokens_
Definition: METSignificanceProducer.h:58
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
cms::METSignificanceProducer::metToken_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
Definition: METSignificanceProducer.h:56
METSignificance_cfi.METSignificance
METSignificance
____________________________________________________________________________||
Definition: METSignificance_cfi.py:6
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
reco::MET
Definition: MET.h:41
cms::METSignificanceProducer::pfCandidatesToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesToken_
Definition: METSignificanceProducer.h:57
cms::METSignificanceProducer::jetResPtType_
std::string jetResPtType_
Definition: METSignificanceProducer.h:61
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cms::METSignificanceProducer
Definition: METSignificanceProducer.h:46
cms::METSignificanceProducer::jetSFType_
std::string jetSFType_
Definition: METSignificanceProducer.h:60
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99170
cms::METSignificanceProducer::rhoToken_
edm::EDGetTokenT< double > rhoToken_
Definition: METSignificanceProducer.h:59
METSignificanceProducer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::METSignificanceProducer::pfjetsToken_
edm::EDGetTokenT< edm::View< reco::Jet > > pfjetsToken_
Definition: METSignificanceProducer.h:55
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
cms::METSignificanceProducer::metSigAlgo_
metsig::METSignificance * metSigAlgo_
Definition: METSignificanceProducer.h:65
cms::METSignificanceProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: METSignificanceProducer.cc:44
JME::JetResolutionScaleFactor
Definition: JetResolution.h:40
HLT_FULL_cff.srcWeights
srcWeights
Definition: HLT_FULL_cff.py:8647
JME::JetResolutionScaleFactor::get
static const JetResolutionScaleFactor get(const edm::EventSetup &, const std::string &)
Definition: JetResolution.cc:48
eostools.move
def move(src, dest)
Definition: eostools.py:511
cms::METSignificanceProducer::weightsToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Definition: METSignificanceProducer.h:63
edm::ValueMap< float >
metsig::METSignificance::getCovariance
reco::METCovMatrix getCovariance(const edm::View< reco::Jet > &jets, const std::vector< edm::Handle< reco::CandidateView > > &leptons, const edm::Handle< edm::View< reco::Candidate > > &pfCandidates, double rho, JME::JetResolution &resPtObj, JME::JetResolution &resPhiObj, JME::JetResolutionScaleFactor &resSFObj, bool isRealData, double &sumPtUnclustered, edm::ValueMap< float > const *weights=nullptr)
Definition: METSignificance.cc:46
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
metsig::METSignificance::getSignificance
static double getSignificance(const reco::METCovMatrix &cov, const reco::MET &met)
Definition: METSignificance.cc:183
JME::JetResolution::get
static const JetResolution get(const edm::EventSetup &, const std::string &)
Definition: JetResolution.cc:23
cms::Exception
Definition: Exception.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::METCovMatrix
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:39
met_cff.significance
significance
Definition: met_cff.py:18
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21