29 <<
"Invalid Configuration Parameter 'jetIdSelection' = " << jetIdSelection_string <<
" !!\n";
42 cfgPFJetIdAlgo.addParameter<
std::string>(
"quality",
"LOOSE");
54 produces<reco::PUSubMETCandInfoCollection>(
"jetInfos");
55 produces<reco::PUSubMETCandInfoCollection>(
"pfCandInfos");
69 int& numWarnings,
int maxWarnings,
70 std::vector<const reco::PFJet*>* pfCandidateToJetAssociations =
nullptr) {
73 if(!pfCandidateCollection.
empty()) {
74 viewProductID = pfCandidateCollection.
ptrAt(0).
id();
78 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfJetConstituent = pfConsts.begin(); pfJetConstituent != pfConsts.end(); ++pfJetConstituent ) {
79 std::vector<int> idxs;
80 if (!pfCandidateCollection.
empty() && pfJetConstituent->id() == viewProductID) {
81 idxs.push_back(pfJetConstituent->key());
83 bool isMatched_fast =
false;
84 if ( pfJetConstituent->key() < pfCandidateCollection.
size() ) {
86 double dR2 =
deltaR2( (*pfJetConstituent)->p4(), pfCandidatePtr->p4());
88 idxs.push_back(pfCandidatePtr.
key());
89 isMatched_fast =
true;
93 if ( !isMatched_fast ) {
94 size_t numPFCandidates = pfCandidateCollection.
size();
95 for (
size_t iPFCandidate = 0; iPFCandidate < numPFCandidates; ++iPFCandidate ) {
97 double dR2 =
deltaR2( (*pfJetConstituent)->p4(), pfCandidatePtr->p4());
99 idxs.push_back(pfCandidatePtr.
key());
102 if ( numWarnings < maxWarnings ) {
104 <<
" The productIDs of PFJetConstituent and PFCandidateCollection passed as function arguments don't match.\n"
105 <<
"NOTE: The return value will be unaffected, but the code will run MUCH slower !!";
111 for ( std::vector<int>::const_iterator
idx = idxs.begin();
112 idx != idxs.end(); ++
idx ) {
113 if ( (*
idx) >= (int)flags.size() ) flags.resize(2*flags.size());
115 if ( pfCandidateToJetAssociations!=
nullptr ) (*pfCandidateToJetAssociations)[*
idx] = &
pfJet;
119 <<
" Failed to associated PFJetConstituent with index = " << pfJetConstituent->key() <<
" to any PFCandidate !!";
128 <<
"<NoPileUpPFMEtDataProducer::produce>:\n"
147 std::vector<int> pfCandidateFlags(pfCandidates->size());
148 std::vector<const reco::PFJet*> pfCandidateToJetAssociations(pfCandidates->size());
168 if ( !jetEnOffsetCorrector )
173 size_t numJets = jets->size();
174 for (
size_t iJet = 0; iJet < numJets; ++iJet ) {
176 if ( !(jet->pt() >
minJetPt_) )
continue;
178 bool passesLooseJetId = (*looseJetIdAlgo_)(*jet);
179 if ( !passesLooseJetId ) {
185 jetInfo.
setP4( jet->p4() );
186 int jetId = (*jetIds)[
jet];
188 jetInfo.
setType( ( jetIdSelection_passed ) ?
191 double jetEnergy_uncorrected =
192 jet->chargedHadronEnergy()
193 + jet->neutralHadronEnergy()
194 + jet->photonEnergy()
195 + jet->electronEnergy()
197 + jet->HFHadronEnergy()
199 double jetPx_uncorrected =
cos(jet->phi())*
sin(jet->theta())*jetEnergy_uncorrected;
200 double jetPy_uncorrected =
sin(jet->phi())*
sin(jet->theta())*jetEnergy_uncorrected;
201 double jetPz_uncorrected =
cos(jet->theta())*jetEnergy_uncorrected;
204 rawJet.
setP4(rawJetP4);
205 double jetNeutralEnFrac = ( jetEnergy_uncorrected > 0. ) ?
206 (jet->neutralEmEnergy() + jet->neutralHadronEnergy())/jetEnergy_uncorrected : -1.;
209 rawJet.
energy()*(1. - jetEnOffsetCorrector->
correction(rawJet, evt, es)) : 0.);
212 jetInfos->push_back(jetInfo);
214 LogDebug (
"produce") <<
"#jetInfos = " << jetInfos->size() << std::endl;
216 for ( reco::PFJetCollection::const_iterator
jet = jets->begin();
217 jet != jets->end(); ++
jet ) {
223 size_t numPFCandidates = pfCandidates->size();
224 for (
size_t iPFCandidate = 0; iPFCandidate < numPFCandidates; ++iPFCandidate ) {
227 int idx = pfCandidatePtr.
key();
229 pfCandInfo.
setP4( pfCandidatePtr->p4() );
230 pfCandInfo.
setCharge( pfCandidatePtr->charge() );
248 const reco::PFJet* jet_matched = pfCandidateToJetAssociations[
idx];
264 pfCandInfos->push_back(pfCandInfo);
267 LogDebug (
"produce") <<
"#pfCandInfos = " << pfCandInfos->size() << std::endl;
269 evt.
put(jetInfos,
"jetInfos");
270 evt.
put(pfCandInfos,
"pfCandInfos");
T getParameter(std::string const &) const
edm::EDGetTokenT< PFCandToVertexAssMap > srcPFCandToVertexAssociations_
const int flag_isWithinSelectedJet
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
#define DEFINE_FWK_MODULE(type)
T const * get() const
Returns C++ pointer to the item.
Sin< T >::type sin(const T &t)
void setP4(const reco::Candidate::LorentzVector p4)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual void setP4(const LorentzVector &p4)
set 4-momentum
std::vector< Variable::Flags > flags
edm::EDGetTokenT< reco::PFJetCollection > srcJetsForMEtCov_
const int flag_isWithinFakeJet
noPuUtils::reversedPFCandToVertexAssMap reversePFCandToVertexAssociation(const PFCandToVertexAssMap &)
edm::EDGetTokenT< reco::VertexCollection > srcHardScatterVertex_
Jets made from PFObjects.
edm::EDGetTokenT< edm::View< reco::PFCandidate > > srcPFCandidatesView_
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
virtual double energy() const
energy
static bool passJetId(int flag, Id level)
const int flag_isWithinJetForMEtCov
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
~NoPileUpPFMEtDataProducer()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void addParameter(std::string const &name, T const &value)
Cos< T >::type cos(const T &t)
std::vector< reco::PUSubMETCandInfo > PUSubMETCandInfoCollection
double deltaR2(const T1 &t1, const T2 &t2)
void setIsWithinJet(bool isWJ)
edm::EDGetTokenT< reco::PFJetCollection > srcJets_
double minJetPtForMEtCov_
NoPileUpPFMEtDataProducer(const edm::ParameterSet &)
PFJetIDSelectionFunctor * looseJetIdAlgo_
PFMEtSignInterfaceBase * pfMEtSignInterface_
PF Jet selector for pat::Jets.
void setPassesLooseJetId(float jetId)
void setCharge(int charge)
edm::EDGetTokenT< edm::ValueMap< int > > srcJetIds_
void setChargedEnFrac(float chEnF)
std::string jetEnOffsetCorrLabel_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
ProductID id() const
Accessor for product ID.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
int isVertexAssociated_fast(const reco::PFCandidateRef &, const noPuUtils::reversedPFCandToVertexAssMap &, const reco::VertexCollection &, double, int &, int)
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
PileupJetIdentifier::Id jetIdSelection_
bool isUninitialized() const
metsig::SigInputObj compResolution(const T *particle) const
void setMEtSignObj(metsig::SigInputObj msig)
void setOffsetEnCorr(float offset)
void produce(edm::Event &, const edm::EventSetup &)