CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFElectronMaker.cc
Go to the documentation of this file.
2 
6 
7 using namespace reco;
8 using namespace edm;
9 using namespace std;
10 
12 
13  PFElectrons_ = iCollector.consumes<edm::ValueMap<reco::PFCandidatePtr> >(iConfig.getParameter<edm::InputTag>("pfElectronsTag"));
14 
15 }
16 
17 void PFElectronMaker::SetVars(HWW& hww, const edm::Event& iEvent, const edm::EventSetup& iSetup ) {
18 
19  hww.Load_pfels_p4();
20 
21  bool validToken;
22 
23  Handle<PFCandMap > pfCandidatesHandle;
24  validToken = iEvent.getByToken( PFElectrons_, pfCandidatesHandle );
25  if(!validToken) return;
26  const ValueMap<reco::PFCandidatePtr> *pfCandidates = pfCandidatesHandle.product();
27 
28  PFCandMap::const_iterator pf_pit = pfCandidates->begin();
29  unsigned int nC = pf_pit.size();
30  for( unsigned int iC = 0; iC < nC; ++iC ) {
31 
32  const PFCandidatePtr& pf_it = pf_pit[iC];
33  if ( pf_it.isNull() ) continue;
34  int pfflags = 0;
35 
36  for( unsigned int i = 0; i < 17; i++ ) {
37  if(pf_it->flag((PFCandidate::Flags)i)) pfflags |= (1<<i);
38  }
39 
40  hww.pfels_p4() .push_back(LorentzVector(pf_it->px(), pf_it->py(), pf_it->pz(), pf_it->p()) );
41 
42  }
43 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
PFElectronMaker(const edm::ParameterSet &, edm::ConsumesCollector)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
void Load_pfels_p4()
Definition: HWW.cc:1352
std::pair< double, double > Point
Definition: CaloEllipse.h:18
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
int iEvent
Definition: GenABIO.cc:230
std::vector< LorentzVector > & pfels_p4()
Definition: HWW.cc:753
Definition: HWW.h:11
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const_iterator begin() const
Definition: ValueMap.h:195
T const * product() const
Definition: Handle.h:81
bool isNull() const
Checks for null.
Definition: Ptr.h:148
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
edm::ValueMap< reco::PFCandidatePtr > PFCandMap
math::PtEtaPhiELorentzVectorF LorentzVector