Defining lorentzvector in CMSSW

Can someone tell me if there is a member function in GsfElectron to get the four-vector instead of extracting, the information of E, px, py, pz separately?

Yes, if you dig deep in the CMSSW reference documentation for reco::GsfElectron, down to the member functions inherited from reco::LeafCandidate, you’ll find that there’s p4() which is of type LorentzVector.

Define the type of the object as reco::Candidate::LorentzVector.


for the CMS open data team