1 #ifndef JetMETCorrections_Type1MET_JetCleanerForType1METT_h 2 #define JetMETCorrections_Type1MET_JetCleanerForType1METT_h 40 #include <type_traits> 45 template <
typename T,
typename Textractor>
72 template <
typename T,
typename Textractor>
78 moduleLabel_(cfg.getParameter<
std::
string>(
"@module_label")),
85 offsetCorrToken_ = consumes<reco::JetCorrector>(offsetCorrLabel_);
89 jetCorrToken_ = mayConsume<reco::JetCorrector>(jetCorrLabel_);
90 jetCorrResToken_ = mayConsume<reco::JetCorrector>(jetCorrLabelRes_);
92 jetCorrEtaMax_ = cfg.
getParameter<
double>(
"jetCorrEtaMax");
94 type1JetPtThreshold_ = cfg.
getParameter<
double>(
"type1JetPtThreshold");
98 skipEMfractionThreshold_ = cfg.
getParameter<
double>(
"skipEMfractionThreshold");
107 calcMuonSubtrRawPtAsValueMap_ = cfg.
getParameter<
bool>(
"calcMuonSubtrRawPtAsValueMap");
109 produces<std::vector<T> >();
110 if (calcMuonSubtrRawPtAsValueMap_) produces<edm::ValueMap<float>>(
"MuonSubtrRawPt");
120 desc.
add<
double>(
"jetCorrEtaMax",9.9);
121 desc.
add<
double>(
"type1JetPtThreshold");
122 desc.
add<
bool>(
"skipEM");
123 desc.
add<
double>(
"skipEMfractionThreshold");
124 desc.
add<
bool>(
"skipMuons");
126 desc.
add<
bool>(
"calcMuonSubtrRawPtAsValueMap",
false)->setComment(
"calculate muon-subtracted raw pt as a ValueMap for the input collection (only for selected jets, zero for others)");
138 jetCorrLabel_ = jetCorrLabelRes_;
149 std::unique_ptr< std::vector<T> > cleanedJets(
new std::vector<T>() );
151 int numJets = jets->size();
152 std::vector<float> muonSubtrRawPt(numJets,0);
154 for(
int jetIndex=0;jetIndex<numJets; ++jetIndex ) {
155 const T&
jet = jets->at(jetIndex);
160 double emEnergyFraction = jet.chargedEmEnergyFraction() + jet.neutralEmEnergyFraction();
161 if(skipEM_&&emEnergyFraction>skipEMfractionThreshold_ )
continue;
167 const std::vector<reco::CandidatePtr> &
cands = jet.daughterPtrVector();
168 for ( std::vector<reco::CandidatePtr>::const_iterator
cand = cands.begin();
172 if ( mu !=
nullptr && (*skipMuonSelection_)(*mu) ) {
180 if ( checkInputType.isPatJet(jet) ) {
181 corrJetP4 = jetCorrExtractor_(jet, jetCorrLabel_.label(), jetCorrEtaMax_, &rawJetP4);
184 corrJetP4 = jetCorrExtractor_(jet, jetCorr.
product(), jetCorrEtaMax_, &rawJetP4);
185 if(corrJetP4.pt()<type1JetPtThreshold_)
continue;
188 if(corrJetP4.pt()<type1JetPtThreshold_)
continue;
190 cleanedJets->push_back(jet);
191 if (calcMuonSubtrRawPtAsValueMap_) muonSubtrRawPt[jetIndex]=rawJetP4.Pt();
197 if (calcMuonSubtrRawPtAsValueMap_) {
200 fillerMuonSubtrRawPt.
insert(jets,muonSubtrRawPt.begin(),muonSubtrRawPt.end());
201 fillerMuonSubtrRawPt.
fill();
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Textractor jetCorrExtractor_
std::vector< Jet > JetCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::InputTag jetCorrLabelRes_
void insert(const H &h, I begin, I end)
edm::InputTag offsetCorrLabel_
bool calcMuonSubtrRawPtAsValueMap_
double type1JetPtThreshold_
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
JetCleanerForType1METT(const edm::ParameterSet &cfg)
T const * get() const
Returns C++ pointer to the item.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::Event &evt, const edm::EventSetup &es) override
reco::MuonRef muonRef() const
T const * product() const
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
edm::EDGetTokenT< std::vector< T > > token_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::unique_ptr< StringCutObjectSelector< reco::Candidate > > skipMuonSelection_
Particle reconstructed by the particle flow algorithm.
edm::InputTag jetCorrLabel_
double skipEMfractionThreshold_
edm::EDGetTokenT< reco::JetCorrector > jetCorrResToken_