CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
pat::PATPackedCandidateProducer Class Reference
Inheritance diagram for pat::PATPackedCandidateProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATPackedCandidateProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~PATPackedCandidateProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

float calcDxy (float dx, float dy, float phi)
 
float calcDz (reco::Candidate::Point p, reco::Candidate::Point v, const reco::Candidate &c)
 

Private Attributes

edm::EDGetTokenT
< reco::PFCandidateCollection
Cands_
 
edm::EDGetTokenT
< reco::PFCandidateFwdPtrVector
CandsFromPVLoose_
 
edm::EDGetTokenT
< reco::PFCandidateFwdPtrVector
CandsFromPVTight_
 
double minPtForTrackProperties_
 
edm::EDGetTokenT
< reco::VertexCollection
PVOrigs_
 
edm::EDGetTokenT
< reco::VertexCollection
PVs_
 
edm::EDGetTokenT
< reco::TrackCollection
TKOrigs_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file PATPackedCandidateProducer.cc.

Constructor & Destructor Documentation

pat::PATPackedCandidateProducer::PATPackedCandidateProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 51 of file PATPackedCandidateProducer.cc.

51  :
52  Cands_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("inputCollection"))),
53  CandsFromPVLoose_(consumes<reco::PFCandidateFwdPtrVector>(iConfig.getParameter<edm::InputTag>("inputCollectionFromPVLoose"))),
54  CandsFromPVTight_(consumes<reco::PFCandidateFwdPtrVector>(iConfig.getParameter<edm::InputTag>("inputCollectionFromPVTight"))),
55  PVs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("inputVertices"))),
56  PVOrigs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("originalVertices"))),
57  TKOrigs_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("originalTracks"))),
58  minPtForTrackProperties_(iConfig.getParameter<double>("minPtForTrackProperties"))
59 {
60  produces< std::vector<pat::PackedCandidate> > ();
61  produces< edm::Association<pat::PackedCandidateCollection> > ();
62  produces< edm::Association<reco::PFCandidateCollection> > ();
63 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PFCandidateFwdPtrVector > CandsFromPVLoose_
edm::EDGetTokenT< reco::TrackCollection > TKOrigs_
edm::EDGetTokenT< reco::PFCandidateCollection > Cands_
edm::EDGetTokenT< reco::VertexCollection > PVs_
edm::EDGetTokenT< reco::PFCandidateFwdPtrVector > CandsFromPVTight_
edm::EDGetTokenT< reco::VertexCollection > PVOrigs_
pat::PATPackedCandidateProducer::~PATPackedCandidateProducer ( )

Definition at line 65 of file PATPackedCandidateProducer.cc.

65 {}

Member Function Documentation

float pat::PATPackedCandidateProducer::calcDxy ( float  dx,
float  dy,
float  phi 
)
inlineprivate

Definition at line 42 of file PATPackedCandidateProducer.cc.

References funct::cos(), and funct::sin().

42  {
43  return - dx * std::sin(phi) + dy * std::cos(phi);
44  }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: DDAxes.h:10
float pat::PATPackedCandidateProducer::calcDz ( reco::Candidate::Point  p,
reco::Candidate::Point  v,
const reco::Candidate c 
)
inlineprivate

Definition at line 45 of file PATPackedCandidateProducer.cc.

References reco::Candidate::pt(), reco::Candidate::px(), reco::Candidate::py(), and reco::Candidate::pz().

45  {
46  return p.Z()-v.Z() - ((p.X()-v.X()) * c.px() + (p.Y()-v.Y())*c.py()) * c.pz()/(c.pt()*c.pt());
47  }
virtual double pz() const =0
z coordinate of momentum vector
virtual float pt() const =0
transverse momentum
virtual double py() const =0
y coordinate of momentum vector
virtual double px() const =0
x coordinate of momentum vector
void pat::PATPackedCandidateProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 67 of file PATPackedCandidateProducer.cc.

References funct::abs(), reco::CompositePtrCandidate::daughterPtrVector(), edm::hlt::Exception, edm::helper::Filler< Map >::fill(), edm::Event::getByLabel(), edm::Event::getByToken(), reco::PFCandidate::gsfTrackRef(), reco::HitPattern::hasValidHitInFirstPixelBarrel(), reco::TrackBase::highPurity, reco::TrackBase::hitPattern(), i, edm::HandleBase::id(), edm::Ref< C, T, F >::id(), edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNonnull(), metsig::jet, fwrapper::jets, combine::key, edm::Ref< C, T, F >::key(), pat::PackedCandidate::moreLostInnerHits, reco::PFCandidate::muonRef(), pat::PackedCandidate::noLostInnerHits, pat::PackedCandidate::NoPV, reco::HitPattern::numberOfLostHits(), pat::PackedCandidate::oneLostInnerHit, reco::LeafCandidate::pdgId(), reco::TrackBase::phi(), reco::LeafCandidate::phi(), reco::LeafCandidate::polarP4(), RecoTauCleanerPlugins::pt, edm::Event::put(), pat::PackedCandidate::PVLoose, pat::PackedCandidate::PVTight, pat::PackedCandidate::PVUsedInFit, reco::TrackBase::referencePoint(), reco::TrackBase::trackerExpectedHitsInner(), reco::PFCandidate::trackRef(), reco::Vertex::trackWeight(), pat::PackedCandidate::validHitInFirstPixelBarrelLayer, and reco::PFCandidate::vertex().

67  {
68 
69 #ifdef CRAZYSORT
71  iEvent.getByLabel("selectedPatJets", jets);
72 #endif
73 
74 
76  iEvent.getByToken( Cands_, cands );
77  std::vector<reco::Candidate>::const_iterator cand;
78 
80  iEvent.getByToken( CandsFromPVLoose_, candsFromPVLoose );
82  iEvent.getByToken( CandsFromPVTight_, candsFromPVTight );
83 
84  std::vector<pat::PackedCandidate::PVAssoc> fromPV(cands->size(), pat::PackedCandidate::NoPV);
85  for (const reco::PFCandidateFwdPtr &ptr : *candsFromPVLoose) {
86  if (ptr.ptr().id() == cands.id()) {
87  fromPV[ptr.ptr().key()] = pat::PackedCandidate::PVLoose;
88  } else if (ptr.backPtr().id() == cands.id()) {
89  fromPV[ptr.backPtr().key()] = pat::PackedCandidate::PVLoose;
90  } else {
91  throw cms::Exception("Configuration", "The elements from 'inputCollectionFromPVLoose' don't point to 'inputCollection'\n");
92  }
93  }
94  for (const reco::PFCandidateFwdPtr &ptr : *candsFromPVTight) {
95  if (ptr.ptr().id() == cands.id()) {
96  fromPV[ptr.ptr().key()] = pat::PackedCandidate::PVTight;
97  } else if (ptr.backPtr().id() == cands.id()) {
98  fromPV[ptr.backPtr().key()] = pat::PackedCandidate::PVTight;
99  } else {
100  throw cms::Exception("Configuration", "The elements from 'inputCollectionFromPVTight' don't point to 'inputCollection'\n");
101  }
102  }
103 
105  iEvent.getByToken( PVOrigs_, PVOrigs );
106  const reco::Vertex & PVOrig = (*PVOrigs)[0];
108  iEvent.getByToken( PVs_, PVs );
109  reco::VertexRef PV(PVs.id());
110  math::XYZPoint PVpos;
111  if (!PVs->empty()) {
112  PV = reco::VertexRef(PVs, 0);
113  PVpos = PV->position();
114  }
115 
117  iEvent.getByToken( TKOrigs_, TKOrigs );
118 
119  std::auto_ptr< std::vector<pat::PackedCandidate> > outPtrP( new std::vector<pat::PackedCandidate> );
120  std::vector<int> mapping(cands->size());
121  std::vector<int> mappingTk(TKOrigs->size(), -1);
122 #ifdef CRAZYSORT
123  std::vector<int> jetOrder;
124  std::vector<int> jetOrderReverse;
125  for(unsigned int i=0;i<cands->size();i++) jetOrderReverse.push_back(-1);
126  for (edm::View<pat::Jet>::const_iterator it = jets->begin(), ed = jets->end(); it != ed; ++it) {
127  const pat::Jet & jet = *it;
129  for(unsigned int i=0;i<dau.size();i++)
130  {
131  if((*cands)[dau[i].key()].trackRef().isNonnull() && (*cands)[dau[i].key()].pt() > minPtForTrackProperties_){
132  jetOrder.push_back(dau[i].key());
133  jetOrderReverse[jetOrder.back()]=jetOrder.size()-1;
134  }
135  }
136  for(unsigned int i=0;i<dau.size();i++)
137  {
138  if(!((*cands)[dau[i].key()].trackRef().isNonnull() && (*cands)[dau[i].key()].pt() > minPtForTrackProperties_)){
139  jetOrder.push_back(dau[i].key());
140  jetOrderReverse[jetOrder.back()]=jetOrder.size()-1;
141  }
142  }
143 
144  }
145  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
146  if(jetOrderReverse[ic]==-1 && (*cands)[ic].trackRef().isNonnull() && (*cands)[ic].pt() > minPtForTrackProperties_)
147  {
148  jetOrder.push_back(ic);
149  jetOrderReverse[jetOrder.back()]=jetOrder.size()-1;
150  }
151 
152  }
153  //all what's left
154  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
155  if(jetOrderReverse[ic]==-1)
156  {
157  jetOrder.push_back(ic);
158  jetOrderReverse[jetOrder.back()]=jetOrder.size()-1;
159  }
160 
161  }
162 #endif //CRAZYSORT
163 
164 
165  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
166 #ifdef CRAZYSORT
167  const reco::PFCandidate &cand=(*cands)[jetOrder[ic]];
168 #else
169  const reco::PFCandidate &cand=(*cands)[ic];
170 #endif
171  float phiAtVtx = cand.phi();
172  const reco::Track *ctrack = 0;
173  if ((abs(cand.pdgId()) == 11 || cand.pdgId() == 22) && cand.gsfTrackRef().isNonnull()) {
174  ctrack = &*cand.gsfTrackRef();
175  } else if (cand.trackRef().isNonnull()) {
176  ctrack = &*cand.trackRef();
177  }
178  if (ctrack) {
179  math::XYZPoint vtx = cand.vertex();
181  vtx = ctrack->referencePoint();
182  phiAtVtx = ctrack->phi();
183  int nlost = ctrack->trackerExpectedHitsInner().numberOfLostHits();
184  if (nlost == 0) {
185  if ( ctrack->hitPattern().hasValidHitInFirstPixelBarrel()) {
187  }
188  } else {
190  }
191  outPtrP->push_back( pat::PackedCandidate(cand.polarP4(), vtx, phiAtVtx, cand.pdgId(), PV));
192 
193  // properties of the best track
194  outPtrP->back().setLostInnerHits( lostHits );
195  if(outPtrP->back().pt() > minPtForTrackProperties_) {
196  outPtrP->back().setTrackProperties(*ctrack);
197  }
198 
199  // these things are always for the CKF track
200  if(cand.trackRef().isNonnull() && PVOrig.trackWeight(cand.trackRef()) > 0.5) {
201  outPtrP->back().setFromPV(pat::PackedCandidate::PVUsedInFit);
202  } else {
203  outPtrP->back().setFromPV( fromPV[ic] );
204  }
205  outPtrP->back().setTrackHighPurity( cand.trackRef().isNonnull() && cand.trackRef()->quality(reco::Track::highPurity) );
206  if (cand.muonRef().isNonnull()) {
207  outPtrP->back().setMuonID(cand.muonRef()->isStandAloneMuon(), cand.muonRef()->isGlobalMuon());
208  }
209  } else {
210  outPtrP->push_back( pat::PackedCandidate(cand.polarP4(), PVpos, cand.phi(), cand.pdgId(), PV));
211  outPtrP->back().setFromPV( fromPV[ic] );
212  }
213 
214  mapping[ic] = ic; // trivial at the moment!
215  if (cand.trackRef().isNonnull() && cand.trackRef().id() == TKOrigs.id()) {
216  mappingTk[cand.trackRef().key()] = ic;
217  }
218 
219  }
220 
221 
223 
224  // now build the two maps
225  std::auto_ptr<edm::Association<pat::PackedCandidateCollection> > pf2pc(new edm::Association<pat::PackedCandidateCollection>(oh ));
226  std::auto_ptr<edm::Association<reco::PFCandidateCollection > > pc2pf(new edm::Association<reco::PFCandidateCollection >(cands));
229 #ifdef CRAZYSORT
230  pf2pcFiller.insert(cands, jetOrderReverse.begin(), jetOrderReverse.end());
231  pc2pfFiller.insert(oh , jetOrder.begin(), jetOrder.end());
232 #else
233  pf2pcFiller.insert(cands, mapping.begin(), mapping.end());
234  pc2pfFiller.insert(oh , mapping.begin(), mapping.end());
235 #endif
236  // include also the mapping track -> packed PFCand
237  pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
238 
239  pf2pcFiller.fill();
240  pc2pfFiller.fill();
241  iEvent.put(pf2pc);
242  iEvent.put(pc2pf);
243 
244 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::PFCandidateFwdPtrVector > CandsFromPVLoose_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual int pdgId() const GCC11_FINAL
PDG identifier.
int numberOfLostHits() const
Definition: HitPattern.h:646
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:137
const Point & referencePoint() const
Reference point on the track.
Definition: TrackBase.h:151
edm::EDGetTokenT< reco::TrackCollection > TKOrigs_
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:429
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
edm::EDGetTokenT< reco::PFCandidateCollection > Cands_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
vector< PseudoJet > jets
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:643
const HitPattern & trackerExpectedHitsInner() const
Access the hit pattern counting (in the Tracker) the number of expected crossed layers before the fir...
Definition: TrackBase.h:223
edm::EDGetTokenT< reco::VertexCollection > PVs_
edm::EDGetTokenT< reco::PFCandidateFwdPtrVector > CandsFromPVTight_
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:221
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:446
LostInnerHits
Enumerator specifying the.
std::vector< CandidatePtr > daughters
collection of references to daughters
virtual const PolarLorentzVector & polarP4() const GCC11_FINAL
four-momentum Lorentz vector
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
key_type key() const
Accessor for product key.
Definition: Ref.h:266
Analysis-level calorimeter jet class.
Definition: Jet.h:73
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
list key
Definition: combine.py:13
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:467
const daughters & daughterPtrVector() const
references to daughtes
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
bool hasValidHitInFirstPixelBarrel() const
Definition: HitPattern.cc:181
edm::EDGetTokenT< reco::VertexCollection > PVOrigs_

Member Data Documentation

edm::EDGetTokenT<reco::PFCandidateCollection> pat::PATPackedCandidateProducer::Cands_
private

Definition at line 34 of file PATPackedCandidateProducer.cc.

edm::EDGetTokenT<reco::PFCandidateFwdPtrVector> pat::PATPackedCandidateProducer::CandsFromPVLoose_
private

Definition at line 35 of file PATPackedCandidateProducer.cc.

edm::EDGetTokenT<reco::PFCandidateFwdPtrVector> pat::PATPackedCandidateProducer::CandsFromPVTight_
private

Definition at line 36 of file PATPackedCandidateProducer.cc.

double pat::PATPackedCandidateProducer::minPtForTrackProperties_
private

Definition at line 40 of file PATPackedCandidateProducer.cc.

edm::EDGetTokenT<reco::VertexCollection> pat::PATPackedCandidateProducer::PVOrigs_
private

Definition at line 38 of file PATPackedCandidateProducer.cc.

edm::EDGetTokenT<reco::VertexCollection> pat::PATPackedCandidateProducer::PVs_
private

Definition at line 37 of file PATPackedCandidateProducer.cc.

edm::EDGetTokenT<reco::TrackCollection> pat::PATPackedCandidateProducer::TKOrigs_
private

Definition at line 39 of file PATPackedCandidateProducer.cc.