CMS 3D CMS Logo

PFMETProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METProducers
4 // Class: PFMETProducer
5 //
6 //
7 
8 //____________________________________________________________________________||
12 
13 //____________________________________________________________________________||
14 namespace cms {
15 
16  //____________________________________________________________________________||
18  : src_(iConfig.getParameter<edm::InputTag>("src")),
19  inputToken_(consumes<edm::View<reco::Candidate>>(src_)),
20  calculateSignificance_(iConfig.getParameter<bool>("calculateSignificance")),
21  globalThreshold_(iConfig.getParameter<double>("globalThreshold")),
22  applyWeight_(iConfig.getParameter<bool>("applyWeight")),
23  weights_(nullptr) {
24  if (applyWeight_) {
25  edm::InputTag srcWeights = iConfig.getParameter<edm::InputTag>("srcWeights");
26  if (srcWeights.label().empty())
27  throw cms::Exception("InvalidInput") << "applyWeight set to True, but no weights given in PFMETProducer\n";
28  if (srcWeights.label() == src_.label())
29  edm::LogWarning("PFMETProducer")
30  << "Particle and weights collection have the same label. You may be applying the same weights twice.\n";
31  weightsToken_ = consumes<edm::ValueMap<float>>(srcWeights);
32  }
34  metSigAlgo_ = new metsig::METSignificance(iConfig);
35 
36  jetToken_ = mayConsume<edm::View<reco::Jet>>(iConfig.getParameter<edm::InputTag>("srcJets"));
37  std::vector<edm::InputTag> srcLeptonsTags = iConfig.getParameter<std::vector<edm::InputTag>>("srcLeptons");
38  for (std::vector<edm::InputTag>::const_iterator it = srcLeptonsTags.begin(); it != srcLeptonsTags.end(); it++) {
39  lepTokens_.push_back(mayConsume<edm::View<reco::Candidate>>(*it));
40  }
41 
42  jetSFType_ = iConfig.getParameter<std::string>("srcJetSF");
43  jetResPtType_ = iConfig.getParameter<std::string>("srcJetResPt");
44  jetResPhiType_ = iConfig.getParameter<std::string>("srcJetResPhi");
45  rhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("srcRho"));
46  }
47 
48  std::string alias = iConfig.exists("alias") ? iConfig.getParameter<std::string>("alias") : "";
49 
50  produces<reco::PFMETCollection>().setBranchAlias(alias);
51  }
52 
53  //____________________________________________________________________________||
56  event.getByToken(inputToken_, input);
57 
58  if (applyWeight_)
59  weights_ = &event.get(weightsToken_);
60 
61  METAlgo algo;
62  CommonMETData commonMETdata;
63  commonMETdata = algo.run(*input.product(), globalThreshold_, weights_);
64 
65  const math::XYZTLorentzVector p4(commonMETdata.mex, commonMETdata.mey, 0.0, commonMETdata.met);
66  const math::XYZPoint vtx(0.0, 0.0, 0.0);
67 
70  specific = pf.run(*input.product(), weights_);
71 
72  reco::PFMET pfmet(specific, commonMETdata.sumet, p4, vtx);
74 
77  pfmet.setSignificanceMatrix(sigcov);
78  }
79 
80  auto pfmetcoll = std::make_unique<reco::PFMETCollection>();
81 
82  pfmetcoll->push_back(pfmet);
83  event.put(std::move(pfmetcoll));
84  }
85 
87  const edm::EventSetup& setup,
88  const edm::Handle<edm::View<reco::Candidate>>& candInput) const {
89  // leptons
90  std::vector<edm::Handle<reco::CandidateView>> leptons;
91  for (std::vector<edm::EDGetTokenT<edm::View<reco::Candidate>>>::const_iterator srcLeptons_i = lepTokens_.begin();
92  srcLeptons_i != lepTokens_.end();
93  ++srcLeptons_i) {
95  event.getByToken(*srcLeptons_i, leptons_i);
96  leptons.push_back(leptons_i);
97  /*
98  for ( reco::CandidateView::const_iterator lepton = leptons_i->begin();
99  lepton != leptons_i->end(); ++lepton ) {
100  leptons.push_back(*lepton);
101  }
102  */
103  }
104 
105  // jets
107  event.getByToken(jetToken_, inputJets);
108 
112 
114  event.getByToken(rhoToken_, rho);
115 
116  //Compute the covariance matrix and fill it
117  double sumPtUnclustered = 0;
119  leptons,
120  candInput,
121  *rho,
122  resPtObj,
123  resPhiObj,
124  resSFObj,
125  event.isRealData(),
127  weights_);
128 
129  return cov;
130  }
131 
134  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
135  desc.add<double>("globalThreshold", 0.);
136  desc.add<std::string>("alias", "@module_label");
137  desc.add<bool>("calculateSignificance", false);
138  desc.addOptional<edm::InputTag>("srcJets");
139  desc.addOptional<std::vector<edm::InputTag>>("srcLeptons");
140  desc.addOptional<std::string>("srcJetSF");
141  desc.addOptional<std::string>("srcJetResPt");
142  desc.addOptional<std::string>("srcJetResPhi");
143  desc.addOptional<edm::InputTag>("srcRho");
145  params.setAllowAnything(); // FIXME: This still needs to be defined in METSignficance
146  desc.addOptional<edm::ParameterSetDescription>("parameters", params);
149  desc1.add<bool>("applyWeight", false);
150  desc1.add<edm::InputTag>("srcWeights", edm::InputTag(""));
151  descriptions.add("pfMet", desc1);
152  desc2.add<bool>("applyWeight", true);
153  desc2.add<edm::InputTag>("srcWeights", edm::InputTag("puppiNoLep"));
154  descriptions.add("pfMetPuppi", desc2);
155  }
156 
157  //____________________________________________________________________________||
159 } // namespace cms
160 
161 //____________________________________________________________________________||
CommonMETData::met
double met
Definition: CommonMETData.h:14
met_cff.sumPtUnclustered
sumPtUnclustered
Definition: met_cff.py:19
JME::JetResolution
Definition: JetResolution.h:17
METAlgo
Definition: METAlgo.h:29
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
input
static const std::string input
Definition: EdmProvDump.cc:48
reco::MET::setIsWeighted
void setIsWeighted(bool isWeighted)
Set boolean if weights were applied by algorithm (e.g. PUPPI weights)
Definition: MET.h:77
MessageLogger.h
HLT_FULL_cff.inputJets
inputJets
Definition: HLT_FULL_cff.py:98546
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
cms::PFMETProducer::globalThreshold_
double globalThreshold_
Definition: PFMETProducer.h:74
sistrip::View
View
Definition: ConstantsForView.h:26
SpecificPFMETData
MET made from Particle Flow Candidates.
Definition: SpecificPFMETData.h:12
HLT_FULL_cff.leptons
leptons
Definition: HLT_FULL_cff.py:26349
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
cms::PFMETProducer::lepTokens_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > lepTokens_
Definition: PFMETProducer.h:78
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::PFMETProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFMETProducer.cc:132
EmptyGroupDescription.h
cms::PFMETProducer::applyWeight_
bool applyWeight_
Definition: PFMETProducer.h:83
cms::PFMETProducer::metSigAlgo_
metsig::METSignificance * metSigAlgo_
Definition: PFMETProducer.h:72
CommonMETData
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
METSignificance_cfi.METSignificance
METSignificance
____________________________________________________________________________||
Definition: METSignificance_cfi.py:6
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
cmsdt::algo
algo
Definition: constants.h:164
reco::MET::setSignificanceMatrix
void setSignificanceMatrix(const reco::METCovMatrix &matrix)
Definition: MET.cc:142
cms::PFMETProducer::weightsToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Definition: PFMETProducer.h:84
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CommonMETData::mex
double mex
Definition: CommonMETData.h:15
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
timingPdfMaker.specific
specific
Definition: timingPdfMaker.py:78
cms::PFMETProducer::inputToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > inputToken_
Definition: PFMETProducer.h:69
cms::PFMETProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PFMETProducer.cc:54
cms::PFMETProducer
Definition: PFMETProducer.h:57
cms::PFMETProducer::jetResPhiType_
std::string jetResPhiType_
Definition: PFMETProducer.h:81
cms::PFMETProducer::jetSFType_
std::string jetSFType_
Definition: PFMETProducer.h:79
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::PFMETProducer::rhoToken_
edm::EDGetTokenT< double > rhoToken_
Definition: PFMETProducer.h:82
CommonMETData::sumet
double sumet
Definition: CommonMETData.h:18
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
edm::View
Definition: CaloClusterFwd.h:14
cms::PFMETProducer::PFMETProducer
PFMETProducer(const edm::ParameterSet &)
Definition: PFMETProducer.cc:17
reco::PFMET
Definition: PFMET.h:18
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
cms::PFMETProducer::weights_
edm::ValueMap< float > const * weights_
Definition: PFMETProducer.h:85
p4
double p4[4]
Definition: TauolaWrapper.h:92
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
cms::PFMETProducer::getMETCovMatrix
reco::METCovMatrix getMETCovMatrix(const edm::Event &event, const edm::EventSetup &, const edm::Handle< edm::View< reco::Candidate >> &input) const
Definition: PFMETProducer.cc:86
edm::EventSetup
Definition: EventSetup.h:57
JME::JetResolutionScaleFactor
Definition: JetResolution.h:40
HLT_FULL_cff.srcWeights
srcWeights
Definition: HLT_FULL_cff.py:8713
edm::ValueMap::get
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:144
JME::JetResolutionScaleFactor::get
static const JetResolutionScaleFactor get(const edm::EventSetup &, const std::string &)
Definition: JetResolution.cc:48
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:128
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
PFSpecificAlgo
Definition: PFSpecificAlgo.h:28
JME::JetResolution::get
static const JetResolution get(const edm::EventSetup &, const std::string &)
Definition: JetResolution.cc:23
cms::Exception
Definition: Exception.h:70
cms::PFMETProducer::src_
edm::InputTag src_
Definition: PFMETProducer.h:68
cms::PFMETProducer::jetToken_
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
Definition: PFMETProducer.h:77
cms::PFMETProducer::calculateSignificance_
bool calculateSignificance_
Definition: PFMETProducer.h:71
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
PFMETProducer.h
edm::Log
Definition: MessageLogger.h:70
CommonMETData::mey
double mey
Definition: CommonMETData.h:16
edm::InputTag
Definition: InputTag.h:15
cms::PFMETProducer::jetResPtType_
std::string jetResPtType_
Definition: PFMETProducer.h:80
reco::METCovMatrix
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:39
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21