CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
pat::PATMETProducer Class Reference

Produces the pat::MET. More...

#include "PhysicsTools/PatAlgos/interface/PATMETProducer.h"

Inheritance diagram for pat::PATMETProducer:
edm::stream::EDProducer<>

Public Member Functions

 PATMETProducer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATMETProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

const reco::METCovMatrix getMETCovMatrix (const edm::Event &event, const edm::EventSetup &iSetup, double &sumPtUnclustered) const
 

Private Attributes

bool addEfficiencies_
 
bool addGenMET_
 
bool addMuonCorr_
 
bool addResolutions_
 
bool calculateMETSignificance_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
GreaterByEt< METeTComparator_
 
edm::EDGetTokenT< edm::View< reco::GenMET > > genMETToken_
 
std::string jetResPhiType_
 
std::string jetResPtType_
 
std::string jetSFType_
 
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
 
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > lepTokens_
 
metsig::METSignificancemetSigAlgo_
 
edm::InputTag metSrc_
 
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
 
edm::InputTag muonSrc_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandToken_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
edm::EDGetTokenT< double > rhoToken_
 
pat::PATUserDataHelper< pat::METuserDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Produces the pat::MET.

The PATMETProducer produces the analysis-level pat::MET starting from a collection of objects of METType.

Author
Steven Lowette
Version
Id
PATMETProducer.h,v 1.10 2009/06/25 23:49:35 gpetrucc Exp

Definition at line 38 of file PATMETProducer.h.

Constructor & Destructor Documentation

PATMETProducer::PATMETProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 18 of file PATMETProducer.cc.

References addEfficiencies_, addGenMET_, addResolutions_, calculateMETSignificance_, efficiencyLoader_, genMETToken_, edm::ParameterSet::getParameter(), jetResPhiType_, jetResPtType_, jetSFType_, jetToken_, lepTokens_, metSigAlgo_, METSignificance_cfi::METSignificance, metSrc_, metToken_, pfCandToken_, resolutionLoader_, rhoToken_, AlCaHLTBitMon_QueryRunRegistry::string, userDataHelper_, and useUserData_.

18  :
19  useUserData_(iConfig.exists("userData"))
20 {
21  // initialize the configurables
22  metSrc_ = iConfig.getParameter<edm::InputTag>("metSource");
23  metToken_ = consumes<edm::View<reco::MET> >(metSrc_);
24  addGenMET_ = iConfig.getParameter<bool> ("addGenMET");
25  genMETToken_ = mayConsume<edm::View<reco::GenMET> >(iConfig.getParameter<edm::InputTag>("genMETSource"));
26  addResolutions_ = iConfig.getParameter<bool> ("addResolutions");
27 
28  // Efficiency configurables
29  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
30  if (addEfficiencies_) {
31  efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
32  }
33 
34  // Resolution configurables
35  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
36  if (addResolutions_) {
38  }
39 
40  // Check to see if the user wants to add user data
41  if ( useUserData_ ) {
42  userDataHelper_ = PATUserDataHelper<MET>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
43  }
44 
45  // MET Significance
46  calculateMETSignificance_ = iConfig.getParameter<bool>("computeMETSignificance");
47  if(calculateMETSignificance_)
48  {
49  metSigAlgo_ = new metsig::METSignificance(iConfig);
50  rhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("srcRho"));
51  jetSFType_ = iConfig.getParameter<std::string>("srcJetSF");
52  jetResPtType_ = iConfig.getParameter<std::string>("srcJetResPt");
53  jetResPhiType_ = iConfig.getParameter<std::string>("srcJetResPhi");
54  jetToken_ = consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("srcJets"));
55  pfCandToken_ = consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("srcPFCands"));
56  std::vector<edm::InputTag> srcLeptonsTags = iConfig.getParameter< std::vector<edm::InputTag> >("srcLeptons");
57  for(std::vector<edm::InputTag>::const_iterator it=srcLeptonsTags.begin();it!=srcLeptonsTags.end();it++) {
58  lepTokens_.push_back( consumes<edm::View<reco::Candidate> >( *it ) );
59  }
60  }
61 
62  // produces vector of mets
63  produces<std::vector<MET> >();
64 }
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
metsig::METSignificance * metSigAlgo_
pat::PATUserDataHelper< pat::MET > userDataHelper_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string jetResPtType_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > lepTokens_
std::string jetSFType_
edm::InputTag metSrc_
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandToken_
edm::EDGetTokenT< double > rhoToken_
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
edm::EDGetTokenT< edm::View< reco::GenMET > > genMETToken_
METSignificance
____________________________________________________________________________||
std::string jetResPhiType_
PATMETProducer::~PATMETProducer ( )
override

Definition at line 67 of file PATMETProducer.cc.

67  {
68 }

Member Function Documentation

void PATMETProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 137 of file PATMETProducer.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), and edm::ParameterSetDescription::setComment().

138 {
140  iDesc.setComment("PAT MET producer module");
141 
142  // input source
143  iDesc.add<edm::InputTag>("metSource", edm::InputTag("no default"))->setComment("input collection");
144 
145  // MC configurations
146  iDesc.add<bool>("addGenMET", false);
147  iDesc.add<edm::InputTag>("genMETSource", edm::InputTag("genMetCalo"));
148 
150 
151  // Efficiency configurables
152  edm::ParameterSetDescription efficienciesPSet;
153  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
154  iDesc.add("efficiencies", efficienciesPSet);
155  iDesc.add<bool>("addEfficiencies", false);
156 
157  // Check to see if the user wants to add user data
158  edm::ParameterSetDescription userDataPSet;
160  iDesc.addOptional("userData", userDataPSet);
161 
162  // muon correction
163  iDesc.add<bool>("addMuonCorrections", false);
164  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("muons"));
165 
166 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
const reco::METCovMatrix PATMETProducer::getMETCovMatrix ( const edm::Event event,
const edm::EventSetup iSetup,
double &  sumPtUnclustered 
) const
private

Definition at line 169 of file PATMETProducer.cc.

References DEFINE_FWK_MODULE, JME::JetResolution::get(), JME::JetResolutionScaleFactor::get(), metsig::METSignificance::getCovariance(), JetEnergyShift_cfi::inputJets, edm::EventBase::isRealData(), jetResPhiType_, jetResPtType_, jetSFType_, jetToken_, lepTokens_, AK4GenJetFlavourInfos_cfi::leptons, metSigAlgo_, pfCandToken_, rhoToken_, and met_cff::sumPtUnclustered.

Referenced by produce().

169  {
170  std::vector< edm::Handle<reco::CandidateView> > leptons;
171  for ( std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_i = lepTokens_.begin();
172  srcLeptons_i != lepTokens_.end(); ++srcLeptons_i ) {
174  event.getByToken(*srcLeptons_i, leptons_i);
175  leptons.push_back( leptons_i );
176  }
177  // jets
179  event.getByToken( jetToken_, inputJets );
180 
181  //candidates
183  event.getByToken( pfCandToken_, inputCands );
184 
186  event.getByToken(rhoToken_, rho);
187 
191 
192  //Compute the covariance matrix and fill it
193  reco::METCovMatrix cov = metSigAlgo_->getCovariance( *inputJets, leptons, inputCands,
194  *rho, resPtObj, resPhiObj, resSFObj, event.isRealData(), sumPtUnclustered);
195 
196  return cov;
197 }
metsig::METSignificance * metSigAlgo_
static const JetResolution get(const edm::EventSetup &, const std::string &)
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:40
std::string jetResPtType_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > lepTokens_
std::string jetSFType_
bool isRealData() const
Definition: EventBase.h:62
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandToken_
edm::EDGetTokenT< double > rhoToken_
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
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)
std::string jetResPhiType_
static const JetResolutionScaleFactor get(const edm::EventSetup &, const std::string &)
sumPtUnclustered
Definition: met_cff.py:20
void PATMETProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 71 of file PATMETProducer.cc.

References addGenMET_, calculateMETSignificance_, efficiencyLoader_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), edm::InputTag::encode(), genMETToken_, edm::Event::getByToken(), getMETCovMatrix(), metsig::METSignificance::getSignificance(), training_settings::idx, TtSemiLepSignalSelMVAComputer_cfi::mets, metSigAlgo_, metSrc_, metToken_, eostools::move(), pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), metProducer_cfi::patMETs, edm::Event::put(), resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::MET::setGenMET(), pat::MET::setMETSignificance(), pat::MET::setMETSumPtUnclustered(), pat::helper::KinResolutionsLoader::setResolutions(), reco::MET::setSignificanceMatrix(), met_cff::sumPtUnclustered, userDataHelper_, and useUserData_.

71  {
72 
73  // Get the vector of MET's from the event
75  iEvent.getByToken(metToken_, mets);
76 
77  if (mets->size() != 1) throw cms::Exception("Corrupt Data") << "The input MET collection " << metSrc_.encode() << " has size " << mets->size() << " instead of 1 as it should.\n";
79  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
80 
81  // Get the vector of generated met from the event if needed
83  if (addGenMET_) {
84  iEvent.getByToken(genMETToken_, genMETs);
85  }
86 
87  // loop over mets
88  std::vector<MET> * patMETs = new std::vector<MET>();
89  for (edm::View<reco::MET>::const_iterator itMET = mets->begin(); itMET != mets->end(); itMET++) {
90  // construct the MET from the ref -> save ref to original object
91  unsigned int idx = itMET - mets->begin();
92  edm::RefToBase<reco::MET> metsRef = mets->refAt(idx);
93  edm::Ptr<reco::MET> metsPtr = mets->ptrAt(idx);
94  MET amet(metsRef);
95  // add the generated MET
96  if (addGenMET_) amet.setGenMET((*genMETs)[idx]);
97 
98 
99  //add the MET significance
101  double sumPtUnclustered=0;
102  const reco::METCovMatrix& sigcov = getMETCovMatrix(iEvent, iSetup, sumPtUnclustered);
103  amet.setSignificanceMatrix(sigcov);
104  double metSig=metSigAlgo_->getSignificance(sigcov, amet);
105  amet.setMETSignificance(metSig);
106  amet.setMETSumPtUnclustered(sumPtUnclustered);
107  }
108 
109  if (efficiencyLoader_.enabled()) {
110  efficiencyLoader_.setEfficiencies( amet, metsRef );
111  }
112 
113  if (resolutionLoader_.enabled()) {
115  }
116 
117 
118  if ( useUserData_ ) {
119  userDataHelper_.add( amet, iEvent, iSetup );
120  }
121 
122  // correct for muons if demanded... never more: it's now done by JetMETCorrections
123  // add the MET to the vector of METs
124  patMETs->push_back(amet);
125  }
126 
127  // sort MET in ET .. don't mess with this
128  // std::sort(patMETs->begin(), patMETs->end(), eTComparator_);
129 
130  // put genEvt object in Event
131  std::unique_ptr<std::vector<MET> > myMETs(patMETs);
132  iEvent.put(std::move(myMETs));
133 
134 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
Analysis-level MET class.
Definition: MET.h:40
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
metsig::METSignificance * metSigAlgo_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
static double getSignificance(const reco::METCovMatrix &cov, const reco::MET &met)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
pat::PATUserDataHelper< pat::MET > userDataHelper_
const reco::METCovMatrix getMETCovMatrix(const edm::Event &event, const edm::EventSetup &iSetup, double &sumPtUnclustered) const
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:40
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
edm::InputTag metSrc_
std::string encode() const
Definition: InputTag.cc:159
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
edm::EDGetTokenT< edm::View< reco::GenMET > > genMETToken_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
sumPtUnclustered
Definition: met_cff.py:20
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool pat::PATMETProducer::addEfficiencies_
private

Definition at line 63 of file PATMETProducer.h.

Referenced by PATMETProducer().

bool pat::PATMETProducer::addGenMET_
private

Definition at line 54 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

bool pat::PATMETProducer::addMuonCorr_
private

Definition at line 58 of file PATMETProducer.h.

bool pat::PATMETProducer::addResolutions_
private

Definition at line 56 of file PATMETProducer.h.

Referenced by PATMETProducer().

bool pat::PATMETProducer::calculateMETSignificance_
private

Definition at line 70 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

pat::helper::EfficiencyLoader pat::PATMETProducer::efficiencyLoader_
private

Definition at line 64 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

GreaterByEt<MET> pat::PATMETProducer::eTComparator_
private

Definition at line 61 of file PATMETProducer.h.

edm::EDGetTokenT<edm::View<reco::GenMET> > pat::PATMETProducer::genMETToken_
private

Definition at line 55 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

std::string pat::PATMETProducer::jetResPhiType_
private

Definition at line 77 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

std::string pat::PATMETProducer::jetResPtType_
private

Definition at line 76 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

std::string pat::PATMETProducer::jetSFType_
private

Definition at line 78 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

edm::EDGetTokenT<edm::View<reco::Jet> > pat::PATMETProducer::jetToken_
private

Definition at line 72 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

std::vector< edm::EDGetTokenT<edm::View<reco::Candidate> > > pat::PATMETProducer::lepTokens_
private

Definition at line 74 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

metsig::METSignificance* pat::PATMETProducer::metSigAlgo_
private

Definition at line 71 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), PATMETProducer(), and produce().

edm::InputTag pat::PATMETProducer::metSrc_
private

Definition at line 52 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

edm::EDGetTokenT<edm::View<reco::MET> > pat::PATMETProducer::metToken_
private

Definition at line 53 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

edm::InputTag pat::PATMETProducer::muonSrc_
private

Definition at line 59 of file PATMETProducer.h.

edm::EDGetTokenT<edm::View<reco::Candidate> > pat::PATMETProducer::pfCandToken_
private

Definition at line 73 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

pat::helper::KinResolutionsLoader pat::PATMETProducer::resolutionLoader_
private

Definition at line 57 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

edm::EDGetTokenT<double> pat::PATMETProducer::rhoToken_
private

Definition at line 75 of file PATMETProducer.h.

Referenced by getMETCovMatrix(), and PATMETProducer().

pat::PATUserDataHelper<pat::MET> pat::PATMETProducer::userDataHelper_
private

Definition at line 67 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

bool pat::PATMETProducer::useUserData_
private

Definition at line 66 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().