59 std::vector<size_t>
idx(v.size());
60 for (
size_t i = 0;
i !=
idx.size(); ++
i)
idx[
i] =
i;
77 std::vector< edm::EDGetTokenT<edm::View<reco::CompositePtrCandidate> > >
SVWhiteLists_;
81 float calcDxy(
float dx,
float dy,
float phi)
const {
85 return p.Z()-v.Z() - ((p.X()-v.X()) * c.
px() + (p.Y()-v.Y())*c.
py()) * c.
pz()/(c.
pt()*c.
pt());
94 PVAssoQuality_(consumes<edm::ValueMap<int> >(iConfig.getParameter<edm::
InputTag>(
"vertexAssociator"))),
97 PuppiWeight_(consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::
InputTag>(
"PuppiSrc"))),
98 PuppiWeightNoLep_(consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::
InputTag>(
"PuppiNoLepSrc"))),
100 PuppiCands_(consumes<std::vector<
reco::PFCandidate > >(iConfig.getParameter<edm::
InputTag>(
"PuppiSrc"))),
101 PuppiCandsNoLep_(consumes<std::vector<
reco::PFCandidate > >(iConfig.getParameter<edm::
InputTag>(
"PuppiNoLepSrc"))),
102 minPtForTrackProperties_(iConfig.getParameter<double>(
"minPtForTrackProperties"))
104 std::vector<edm::InputTag> sv_tags = iConfig.
getParameter<std::vector<edm::InputTag> >(
"secondaryVerticesForWhiteList");
105 for(
auto itag : sv_tags){
111 produces< std::vector<pat::PackedCandidate> > ();
112 produces< edm::Association<pat::PackedCandidateCollection> > ();
113 produces< edm::Association<reco::PFCandidateCollection> > ();
124 std::vector<reco::Candidate>::const_iterator cand;
127 iEvent.
getByToken( PuppiWeight_, puppiWeight );
129 iEvent.
getByToken( PuppiCandsMap_, puppiCandsMap );
132 std::vector<int> mappingPuppi(puppiCands->size());
135 iEvent.
getByToken( PuppiWeightNoLep_, puppiWeightNoLep );
137 iEvent.
getByToken( PuppiCandsNoLep_, puppiCandsNoLep );
139 std::vector<reco::CandidatePtr> puppiCandsNoLepPtrs;
140 if (puppiCandsNoLep.
isValid()){
141 for (
auto pup : *puppiCandsNoLep){
142 puppiCandsNoLepPtrs.push_back(pup.sourceCandidatePtr(0));
145 auto const& puppiCandsNoLepV = puppiCandsNoLep.
product();
153 iEvent.
getByToken(PVAssoQuality_,assoQualityHandle);
158 std::set<unsigned int> whiteList;
159 for(
auto itoken : SVWhiteLists_) {
163 for(
unsigned int i=0;
i<svWhiteList.
size();
i++) {
164 for(
unsigned int j=0;
j< svWhiteList[
i].numberOfSourceCandidatePtrs();
j++) {
166 if(c.
id() == cands.
id()) whiteList.insert(c.
key());
181 std::auto_ptr< std::vector<pat::PackedCandidate> > outPtrP(
new std::vector<pat::PackedCandidate> );
182 std::vector<int> mapping(cands->size());
183 std::vector<int> mappingReverse(cands->size());
184 std::vector<int> mappingTk(TKOrigs->size(), -1);
186 for(
unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
188 float phiAtVtx = cand.
phi();
198 for(
size_t ii=0;
ii<PVs->size();
ii++){
199 float dz=
std::abs(ctrack->
dz( ((*PVs)[
ii]).position()));
200 if(dz<dist) {pvi=
ii;dist=dz; }
213 phiAtVtx = ctrack->
phi();
230 outPtrP->back().setLostInnerHits( lostHits );
231 if(outPtrP->back().pt() > minPtForTrackProperties_ || whiteList.find(ic)!=whiteList.end()) {
232 outPtrP->back().setTrackProperties(*ctrack);
239 outPtrP->back().setMuonID(cand.
muonRef()->isStandAloneMuon(), cand.
muonRef()->isGlobalMuon());
245 PVpos = PV->position();
257 outPtrP->back().setHcalFraction(0);
265 float puppiWeightVal = (*puppiWeight)[pkref];
266 float puppiWeightNoLepVal = 0.0;
271 if ( puppiWeightNoLep.isValid() ) {
273 auto pkrefPtr = pkref->sourceCandidatePtr(0);
275 bool foundNoLep =
false;
276 for (
size_t ipcnl = 0; ipcnl < puppiCandsNoLepPtrs.size(); ipcnl++){
277 if (puppiCandsNoLepPtrs[ipcnl] == pkrefPtr){
279 puppiWeightNoLepVal = puppiCandsNoLepV->at(ipcnl).pt()/cand.
pt();
283 if ( !foundNoLep || puppiWeightNoLepVal > 1 ) {
284 puppiWeightNoLepVal = 1.0;
287 outPtrP->back().setPuppiWeight( puppiWeightVal, puppiWeightNoLepVal );
289 mappingPuppi[((*puppiCandsMap)[pkref]).
key()]=ic;
299 std::auto_ptr< std::vector<pat::PackedCandidate> > outPtrPSorted(
new std::vector<pat::PackedCandidate> );
300 std::vector<size_t> order=sort_indexes(*outPtrP);
301 std::vector<size_t> reverseOrder(order.size());
302 for(
size_t i=0,nc=cands->size();
i<nc;
i++) {
303 outPtrPSorted->push_back((*outPtrP)[order[
i]]);
304 reverseOrder[order[
i]] =
i;
305 mappingReverse[order[
i]]=
i;
309 for(
size_t i=0,ntk=mappingTk.size();
i<ntk;
i++){
310 if(mappingTk[
i] >= 0)
311 mappingTk[
i]=reverseOrder[mappingTk[
i]];
314 for(
size_t i=0,ntk=mappingPuppi.size();
i<ntk;
i++){
315 mappingPuppi[
i]=reverseOrder[mappingPuppi[
i]];
325 pf2pcFiller.
insert(cands, mappingReverse.begin(), mappingReverse.end());
326 pc2pfFiller.
insert(oh , order.begin(), order.end());
328 pf2pcFiller.
insert(TKOrigs, mappingTk.begin(), mappingTk.end());
329 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.
virtual int pdgId() const
PDG identifier.
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeight_
bool isNonnull() const
Checks for non-null.
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
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
virtual double pt() const
transverse momentum
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 &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
ProductID id() const
Accessor for product ID.
const edm::EDGetTokenT< reco::VertexCollection > PVOrigs_
~PATPackedCandidateProducer()
int numberOfLostHits(HitCategory category) const
Particle reconstructed by the particle flow algorithm.
virtual const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
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_
bool hasValidHitInFirstPixelBarrel() const
const edm::EDGetTokenT< reco::VertexCollection > PVs_
virtual double phi() const
momentum azimuthal angle
bool candsOrdering(pat::PackedCandidate i, pat::PackedCandidate j) const