1 #ifndef JetMETCorrections_Type1MET_PFJetMETcorrInputProducerT_h
2 #define JetMETCorrections_Type1MET_PFJetMETcorrInputProducerT_h
42 namespace PFJetMETcorrInputProducer_namespace
44 template <
typename T,
typename Textractor>
65 template <
typename T,
typename Textractor>
71 :
moduleLabel_(cfg.getParameter<std::string>(
"@module_label")),
92 std::string skipMuonSelection_string = cfg.
getParameter<std::string>(
"skipMuonSelection");
96 if ( cfg.
exists(
"type2Binning") ) {
97 typedef std::vector<edm::ParameterSet> vParameterSet;
98 vParameterSet cfgType2Binning = cfg.
getParameter<vParameterSet>(
"type2Binning");
99 for ( vParameterSet::const_iterator cfgType2BinningEntry = cfgType2Binning.begin();
100 cfgType2BinningEntry != cfgType2Binning.end(); ++cfgType2BinningEntry ) {
107 produces<CorrMETData>(
"type1");
108 for (
typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry =
type2Binning_.begin();
109 type2BinningEntry !=
type2Binning_.end(); ++type2BinningEntry ) {
110 produces<CorrMETData>((*type2BinningEntry)->getInstanceLabel_full(
"type2"));
111 produces<CorrMETData>((*type2BinningEntry)->getInstanceLabel_full(
"offset"));
118 for (
typename std::vector<type2BinningEntryType*>::const_iterator it =
type2Binning_.begin();
128 std::auto_ptr<CorrMETData> type1Correction(
new CorrMETData());
129 for (
typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry =
type2Binning_.begin();
130 type2BinningEntry !=
type2Binning_.end(); ++type2BinningEntry ) {
131 (*type2BinningEntry)->binUnclEnergySum_ =
CorrMETData();
132 (*type2BinningEntry)->binOffsetEnergySum_ =
CorrMETData();
139 int numJets = jets->size();
140 for (
int jetIndex = 0; jetIndex < numJets; ++jetIndex ) {
141 const T& rawJet = jets->at(jetIndex);
144 checkInputType(rawJet);
146 double emEnergyFraction = rawJet.chargedEmEnergyFraction() + rawJet.neutralEmEnergyFraction();
152 std::vector<reco::PFCandidatePtr> cands = rawJet.getPFConstituents();
153 for ( std::vector<reco::PFCandidatePtr>::const_iterator cand = cands.begin();
154 cand != cands.end(); ++cand ) {
155 if ( (*cand)->muonRef().isNonnull() && (*skipMuonSelection_)(*(*cand)->muonRef()) ) {
170 for (
typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry =
type2Binning_.begin();
171 type2BinningEntry !=
type2Binning_.end(); ++type2BinningEntry ) {
172 if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
173 (*type2BinningEntry)->binOffsetEnergySum_.mex += (rawJetP4.px() - rawJetP4offsetCorr.px());
174 (*type2BinningEntry)->binOffsetEnergySum_.mey += (rawJetP4.py() - rawJetP4offsetCorr.py());
175 (*type2BinningEntry)->binOffsetEnergySum_.sumet += (rawJetP4.Et() - rawJetP4offsetCorr.Et());
182 type1Correction->mex -= (corrJetP4.px() - rawJetP4offsetCorr.px());
183 type1Correction->mey -= (corrJetP4.py() - rawJetP4offsetCorr.py());
184 type1Correction->sumet += (corrJetP4.Et() - rawJetP4offsetCorr.Et());
186 for (
typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry =
type2Binning_.begin();
187 type2BinningEntry !=
type2Binning_.end(); ++type2BinningEntry ) {
188 if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
189 (*type2BinningEntry)->binUnclEnergySum_.mex += rawJetP4.px();
190 (*type2BinningEntry)->binUnclEnergySum_.mey += rawJetP4.py();
191 (*type2BinningEntry)->binUnclEnergySum_.sumet += rawJetP4.Et();
202 evt.
put(type1Correction,
"type1");
203 for (
typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry =
type2Binning_.begin();
204 type2BinningEntry !=
type2Binning_.end(); ++type2BinningEntry ) {
205 evt.
put(std::auto_ptr<CorrMETData>(
new CorrMETData((*type2BinningEntry)->binUnclEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full(
"type2"));
206 evt.
put(std::auto_ptr<CorrMETData>(
new CorrMETData((*type2BinningEntry)->binOffsetEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full(
"offset"));
239 :
binLabel_(cfg.getParameter<std::string>(
"binLabel")),
248 std::string retVal = instanceLabel;
249 if ( instanceLabel !=
"" &&
binLabel_ !=
"" ) retVal.append(
"#");
T getParameter(std::string const &) const
CorrMETData binUnclEnergySum_
std::vector< Jet > JetCollection
math::XYZTLorentzVector LorentzVector
bool exists(std::string const ¶meterName) const
checks if a parameter exists
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
StringCutObjectSelector< reco::Candidate::LorentzVector > * binSelection_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
type2BinningEntryType(const edm::ParameterSet &cfg)
std::string getInstanceLabel_full(const std::string &instanceLabel)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
CorrMETData binOffsetEnergySum_