62 std::vector<size_t>
idx(v.size());
63 for (
size_t i = 0;
i !=
idx.size(); ++
i)
idx[
i] =
i;
64 std::sort(
idx.begin(),
idx.end(),[&
v,
this](
size_t i1,
size_t i2) {
return candsOrdering(v[i1],v[i2]);});
85 std::vector< edm::EDGetTokenT<edm::View<reco::Candidate> > >
SVWhiteLists_;
101 return p.Z()-v.Z() - ((p.X()-v.X()) * c.
px() + (p.Y()-v.Y())*c.
py()) * c.
pz()/(c.
pt()*c.
pt());
108 !iConfig.getParameter<
edm::InputTag>(
"PuppiNoLepSrc").
encode().
empty()),
128 std::vector<edm::InputTag> sv_tags = iConfig.
getParameter<std::vector<edm::InputTag> >(
"secondaryVerticesForWhiteList");
129 for(
auto itag : sv_tags){
135 produces< std::vector<pat::PackedCandidate> > ();
136 produces< edm::Association<pat::PackedCandidateCollection> > ();
137 produces< edm::Association<reco::PFCandidateCollection> > ();
148 std::vector<reco::Candidate>::const_iterator
cand;
155 std::vector<reco::CandidatePtr> puppiCandsNoLepPtrs;
162 for (
auto pup : *puppiCandsNoLep){
163 puppiCandsNoLepPtrs.push_back(pup.sourceCandidatePtr(0));
166 std::vector<int> mappingPuppi(
usePuppi_ ? puppiCands->size() : 0);
182 std::set<unsigned int> whiteList;
183 std::set<reco::TrackRef> whiteListTk;
188 for(
unsigned int i=0;
i<svWhiteList.
size();
i++) {
190 for(
unsigned int j=0; j< svWhiteList[
i].numberOfSourceCandidatePtrs(); j++) {
192 if(c.
id() == cands.
id()) whiteList.insert(c.
key());
196 for(
auto dau = svWhiteList[
i].
begin(); dau != svWhiteList[
i].
end() ; dau++){
198 if(chCand!=
nullptr) {
199 whiteListTk.insert(chCand->
track());
215 auto outPtrP = std::make_unique<std::vector<pat::PackedCandidate>>();
216 std::vector<int>
mapping(cands->size());
217 std::vector<int> mappingReverse(cands->size());
218 std::vector<int> mappingTk(TKOrigs->size(), -1);
220 for(
unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
231 for(
size_t ii=0;
ii<PVs->size();
ii++){
233 if(dz<dist) {pvi=
ii;dist=
dz; }
246 float ptTrk = ctrack->
pt();
247 float etaAtVtx = ctrack->
eta();
248 float phiAtVtx = ctrack->
phi();
267 outPtrP->back().setLostInnerHits( lostHits );
270 whiteList.find(ic)!=whiteList.end() ||
274 if(
abs(outPtrP->back().pdgId())==22) {
285 if(outPtrP->back().pt() > 0.5 ){
294 outPtrP->back().setMuonID(cand.
muonRef()->isStandAloneMuon(), cand.
muonRef()->isGlobalMuon());
300 PVpos =
PV->position();
309 bool isIsolatedChargedHadron =
false;
313 outPtrP->back().setIsIsolatedChargedHadron(isIsolatedChargedHadron);
318 }
else if(isIsolatedChargedHadron) {
322 outPtrP->back().setHcalFraction(0);
327 outPtrP->back().setGoodEgamma();
334 float puppiWeightVal = (*puppiWeight)[pkref];
335 float puppiWeightNoLepVal = 0.0;
339 if ( puppiWeightNoLep.
isValid() ) {
341 auto pkrefPtr = pkref->sourceCandidatePtr(0);
343 bool foundNoLep =
false;
344 for (
size_t ipcnl = 0; ipcnl < puppiCandsNoLepPtrs.size(); ipcnl++){
345 if (puppiCandsNoLepPtrs[ipcnl] == pkrefPtr){
347 puppiWeightNoLepVal = puppiCandsNoLep->at(ipcnl).pt()/cand.
pt();
351 if ( !foundNoLep || puppiWeightNoLepVal > 1 ) {
352 puppiWeightNoLepVal = 1.0;
355 outPtrP->back().setPuppiWeight( puppiWeightVal, puppiWeightNoLepVal );
357 mappingPuppi[((*puppiCandsMap)[pkref]).
key()]=ic;
371 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
373 std::vector<size_t> reverseOrder(order.size());
374 for(
size_t i=0,nc=cands->size();
i<nc;
i++) {
375 outPtrPSorted->push_back((*outPtrP)[order[
i]]);
376 reverseOrder[order[
i]] =
i;
377 mappingReverse[order[
i]]=
i;
381 for(
size_t i=0,ntk=mappingTk.size();
i<ntk;
i++){
382 if(mappingTk[
i] >= 0)
383 mappingTk[
i]=reverseOrder[mappingTk[
i]];
386 for(
size_t i=0,ntk=mappingPuppi.size();
i<ntk;
i++){
387 mappingPuppi[
i]=reverseOrder[mappingPuppi[
i]];
393 auto pf2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
394 auto pc2pf = std::make_unique<edm::Association<reco::PFCandidateCollection>>(
cands);
397 pf2pcFiller.insert(cands, mappingReverse.begin(), mappingReverse.end());
398 pc2pfFiller.
insert(oh , order.begin(), order.end());
400 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
401 if(
usePuppi_) pf2pcFiller.insert(puppiCands, mappingPuppi.begin(), mappingPuppi.end());
T getParameter(std::string const &) const
double ecalEnergy() const
return corrected Ecal energy
int pdgId() const final
PDG identifier.
const Point & referencePoint() const
Reference point on the track.
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeight_
virtual double pz() const =0
z coordinate of momentum vector
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
double eta() const final
momentum pseudorapidity
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
double rawEcalEnergy() const
return corrected Ecal energy
int covarianceSchema() const
bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const
~PATPackedCandidateProducer() override
float mva_nothing_gamma() const
mva for gamma detection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
void insert(const H &h, I begin, I end)
std::vector< Track > TrackCollection
collection of Tracks
double phi() const
azimuthal angle of momentum vector
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
static const int qualityMap[8]
conversion map from quality flags used in PV association and miniAOD one
const edm::EDGetTokenT< reco::PFCandidateCollection > Cands_
key_type key() const
Accessor for product key.
const reco::VertexRef vertexRef() const
ProductID id() const
Accessor for product ID.
const edm::EDGetTokenT< edm::ValueMap< int > > PVAssoQuality_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
reco::TrackRef trackRef() const
const double minPtForTrackProperties_
const Point & vertex() const override
vertex position (overwritten by PF...)
bool isTimeValid() const
do we have a valid time information
virtual double py() const =0
y coordinate of momentum vector
int charge() const override
electric charge
PATPackedCandidateProducer(const edm::ParameterSet &)
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
Cos< T >::type cos(const T &t)
double energy() const final
energy
float calcDxy(float dx, float dy, float phi) const
Abs< T >::type abs(const T &t)
const bool storeChargedHadronIsolation_
reco::TrackRef track() const override
reference to a track
const edm::EDGetTokenT< reco::TrackCollection > TKOrigs_
const edm::EDGetTokenT< std::vector< reco::PFCandidate > > PuppiCands_
std::vector< size_t > sort_indexes(const std::vector< T > &v) const
const edm::EDGetTokenT< edm::ValueMap< reco::CandidatePtr > > PuppiCandsMap_
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeightNoLep_
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
const int covarianceVersion_
reco::MuonRef muonRef() const
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
LostInnerHits
Enumerator specifying the.
double eta() const override
momentum pseudorapidity
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
const edm::EDGetTokenT< edm::ValueMap< bool > > ChargedHadronIsolation_
float calcDz(reco::Candidate::Point p, reco::Candidate::Point v, const reco::Candidate &c) const
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
T const * product() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
const std::vector< int > covariancePackingSchemas_
virtual double pt() const =0
transverse momentum
const edm::EDGetTokenT< std::vector< reco::PFCandidate > > PuppiCandsNoLep_
XYZPointD XYZPoint
point in space with cartesian internal representation
ProductID id() const
Accessor for product ID.
const edm::EDGetTokenT< reco::VertexCollection > PVOrigs_
int numberOfLostHits(HitCategory category) const
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > SVWhiteLists_
double hcalEnergy() const
return corrected Hcal energy
int numberOfValidPixelHits() const
math::XYZPoint Point
point in the space
const_iterator end() const
const edm::EDGetTokenT< edm::Association< reco::VertexCollection > > PVAsso_
const edm::EDGetTokenT< reco::VertexCollection > PVs_
virtual double px() const =0
x coordinate of momentum vector
virtual ParticleType particleId() const
uint16_t getHitPattern(HitCategory category, int position) const
double phi() const final
momentum azimuthal angle
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const double minPtForChargedHadronProperties_
double rawHcalEnergy() const
return raw Hcal energy
bool candsOrdering(pat::PackedCandidate i, pat::PackedCandidate j) const