59 std::vector<size_t> idx(v.size());
60 for (
size_t i = 0;
i != idx.size(); ++
i) idx[
i] =
i;
61 std::sort(idx.begin(), idx.end(),[&
v,
this](
size_t i1,
size_t i2) {
return candsOrdering(v[i1],v[i2]);});
82 std::vector< edm::EDGetTokenT<edm::View<reco::CompositePtrCandidate> > >
SVWhiteLists_;
87 float calcDxy(
float dx,
float dy,
float phi)
const {
91 return p.Z()-v.Z() - ((p.X()-v.X()) * c.
px() + (p.Y()-v.Y())*c.
py()) * c.
pz()/(c.
pt()*c.
pt());
102 PVAssoQuality_(consumes<edm::ValueMap<int> >(iConfig.getParameter<edm::
InputTag>(
"vertexAssociator"))),
105 PuppiWeight_(usePuppi_ ? consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::
InputTag>(
"PuppiSrc")) : edm::EDGetTokenT< edm::ValueMap<float> >()),
106 PuppiWeightNoLep_(usePuppi_ ? consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::
InputTag>(
"PuppiNoLepSrc")) : edm::EDGetTokenT< edm::ValueMap<float> >()),
108 PuppiCands_(usePuppi_ ? consumes<std::vector<
reco::PFCandidate > >(iConfig.getParameter<edm::
InputTag>(
"PuppiSrc")) : edm::EDGetTokenT<std::vector<
reco::PFCandidate > >() ),
109 PuppiCandsNoLep_(usePuppi_ ? consumes<std::vector<
reco::PFCandidate > >(iConfig.getParameter<edm::
InputTag>(
"PuppiNoLepSrc")) : edm::EDGetTokenT<std::vector<
reco::PFCandidate > >()),
110 minPtForTrackProperties_(iConfig.getParameter<double>(
"minPtForTrackProperties"))
112 std::vector<edm::InputTag> sv_tags = iConfig.
getParameter<std::vector<edm::InputTag> >(
"secondaryVerticesForWhiteList");
113 for(
auto itag : sv_tags){
119 produces< std::vector<pat::PackedCandidate> > ();
120 produces< edm::Association<pat::PackedCandidateCollection> > ();
121 produces< edm::Association<reco::PFCandidateCollection> > ();
132 std::vector<reco::Candidate>::const_iterator cand;
139 std::vector<reco::CandidatePtr> puppiCandsNoLepPtrs;
141 iEvent.
getByToken( PuppiWeight_, puppiWeight );
142 iEvent.
getByToken( PuppiCandsMap_, puppiCandsMap );
144 iEvent.
getByToken( PuppiWeightNoLep_, puppiWeightNoLep );
145 iEvent.
getByToken( PuppiCandsNoLep_, puppiCandsNoLep );
146 for (
auto pup : *puppiCandsNoLep){
147 puppiCandsNoLepPtrs.push_back(pup.sourceCandidatePtr(0));
150 std::vector<int> mappingPuppi(usePuppi_ ? puppiCands->size() : 0);
158 iEvent.
getByToken(PVAssoQuality_,assoQualityHandle);
163 std::set<unsigned int> whiteList;
164 for(
auto itoken : SVWhiteLists_) {
168 for(
unsigned int i=0;
i<svWhiteList.
size();
i++) {
169 for(
unsigned int j=0;
j< svWhiteList[
i].numberOfSourceCandidatePtrs();
j++) {
171 if(c.
id() == cands.
id()) whiteList.insert(c.
key());
186 auto outPtrP = std::make_unique<std::vector<pat::PackedCandidate>>();
187 std::vector<int> mapping(cands->size());
188 std::vector<int> mappingReverse(cands->size());
189 std::vector<int> mappingTk(TKOrigs->size(), -1);
191 for(
unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
202 for(
size_t ii=0;
ii<PVs->size();
ii++){
203 float dz=
std::abs(ctrack->
dz( ((*PVs)[
ii]).position()));
204 if(dz<dist) {pvi=
ii;dist=dz; }
217 float phiAtVtx = ctrack->
phi();
234 outPtrP->back().setLostInnerHits( lostHits );
235 if(outPtrP->back().pt() > minPtForTrackProperties_ || whiteList.find(ic)!=whiteList.end()) {
236 outPtrP->back().setTrackProperties(*ctrack);
243 outPtrP->back().setMuonID(cand.
muonRef()->isStandAloneMuon(), cand.
muonRef()->isGlobalMuon());
249 PVpos = PV->position();
261 outPtrP->back().setHcalFraction(0);
269 float puppiWeightVal = (*puppiWeight)[pkref];
270 float puppiWeightNoLepVal = 0.0;
274 if ( puppiWeightNoLep.
isValid() ) {
276 auto pkrefPtr = pkref->sourceCandidatePtr(0);
278 bool foundNoLep =
false;
279 for (
size_t ipcnl = 0; ipcnl < puppiCandsNoLepPtrs.size(); ipcnl++){
280 if (puppiCandsNoLepPtrs[ipcnl] == pkrefPtr){
282 puppiWeightNoLepVal = puppiCandsNoLep->at(ipcnl).pt()/cand.
pt();
286 if ( !foundNoLep || puppiWeightNoLepVal > 1 ) {
287 puppiWeightNoLepVal = 1.0;
290 outPtrP->back().setPuppiWeight( puppiWeightVal, puppiWeightNoLepVal );
292 mappingPuppi[((*puppiCandsMap)[pkref]).
key()]=ic;
302 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
303 std::vector<size_t> order=sort_indexes(*outPtrP);
304 std::vector<size_t> reverseOrder(order.size());
305 for(
size_t i=0,nc=cands->size();
i<nc;
i++) {
306 outPtrPSorted->push_back((*outPtrP)[order[
i]]);
307 reverseOrder[order[
i]] =
i;
308 mappingReverse[order[
i]]=
i;
312 for(
size_t i=0,ntk=mappingTk.size();
i<ntk;
i++){
313 if(mappingTk[
i] >= 0)
314 mappingTk[
i]=reverseOrder[mappingTk[
i]];
317 for(
size_t i=0,ntk=mappingPuppi.size();
i<ntk;
i++){
318 mappingPuppi[
i]=reverseOrder[mappingPuppi[
i]];
324 auto pf2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
325 auto pc2pf = std::make_unique<edm::Association<reco::PFCandidateCollection>>(cands);
328 pf2pcFiller.insert(cands, mappingReverse.begin(), mappingReverse.end());
329 pc2pfFiller.
insert(oh , order.begin(), order.end());
331 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
332 if(usePuppi_) pf2pcFiller.insert(puppiCands, mappingPuppi.begin(), mappingPuppi.end());
T getParameter(std::string const &) const
double ecalEnergy() const
return corrected Ecal energy
const Point & referencePoint() const
Reference point on the track.
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeight_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
virtual double pz() const =0
z coordinate of momentum vector
void insert(const H &h, I begin, I end)
std::vector< Track > TrackCollection
collection of Tracks
virtual double phi() const final
momentum azimuthal angle
double phi() const
azimuthal angle of momentum vector
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_
virtual double pt() const
transverse momentum
key_type key() const
Accessor for product key.
virtual double eta() const
momentum pseudorapidity
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_
PATPackedCandidateProducer(const edm::ParameterSet &)
Cos< T >::type cos(const T &t)
float calcDxy(float dx, float dy, float phi) const
Abs< T >::type abs(const T &t)
virtual int charge() const
electric charge
virtual const Point & vertex() const
vertex position (overwritten by PF...)
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
virtual double py() const =0
y coordinate of momentum vector
const edm::EDGetTokenT< edm::ValueMap< reco::CandidatePtr > > PuppiCandsMap_
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeightNoLep_
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
virtual void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
reco::MuonRef muonRef() const
virtual double px() const =0
x coordinate of momentum vector
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.
std::vector< edm::EDGetTokenT< edm::View< reco::CompositePtrCandidate > > > SVWhiteLists_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
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 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_
virtual const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
~PATPackedCandidateProducer()
int numberOfLostHits(HitCategory category) const
virtual int pdgId() const final
PDG identifier.
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
double hcalEnergy() const
return corrected Hcal energy
math::XYZPoint Point
point in the space
const edm::EDGetTokenT< edm::Association< reco::VertexCollection > > PVAsso_
const edm::EDGetTokenT< reco::VertexCollection > PVs_
bool candsOrdering(pat::PackedCandidate i, pat::PackedCandidate j) const
virtual double pt() const final
transverse momentum