44 namespace reco {
namespace tau {
81 vertexAssociator_(pset.getParameter<edm::
ParameterSet>(
"qualityCuts"),std::move(iC)),
119 struct PFCandidate_withDistance
125 bool isSmallerDistance(
const PFCandidate_withDistance& cand1,
const PFCandidate_withDistance& cand2)
127 return (cand1.distance_ < cand2.distance_);
147 size_t numTracks = tracks->size();
148 for (
size_t iTrack = 0; iTrack < numTracks; ++iTrack ) {
152 double dR =
deltaR(track->eta(), track->phi(), jet.
eta(), jet.
phi());
155 double jetArea = jet.
jetArea();
156 if ( jetArea > 0. ) {
161 <<
"Jet: Pt = " << jet.
pt() <<
", eta = " << jet.
eta() <<
", phi = " << jet.
phi() <<
" has area = " << jetArea <<
" !!" << std::endl;
167 if ( dR > dRmatch )
continue;
173 if ( track->charge() > 0. ) trackCharge_int = +1;
174 else if ( track->charge() < 0. ) trackCharge_int = -1;
176 const double chargedPionMass = 0.13957;
177 double chargedPionP = track->p();
178 double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass);
197 XYZTLorentzVector chargedPionPos(track->referencePoint().x(), track->referencePoint().y(), track->referencePoint().z(), 0.);
199 trackPropagator.
setCharge(track->charge());
200 trackPropagator.propagateToEcalEntrance(
false);
201 if ( trackPropagator.getSuccess() != 0 ) {
202 chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex();
204 if ( chargedPionP4.pt() > 2. ) {
206 <<
"Failed to propagate track: Pt = " << track->pt() <<
", eta = " << track->eta() <<
", phi = " << track->phi() <<
" to ECAL entrance !!" << std::endl;
211 std::vector<PFCandidate_withDistance> neutralJetConstituents_withDistance;
213 for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
214 jetConstituent != jetConstituents.end(); ++jetConstituent ) {
217 double dR =
deltaR((*jetConstituent)->positionAtECALEntrance(), chargedHadron->positionAtECALEntrance_);
218 double dRmerge = -1.;
221 if ( dR < dRmerge ) {
222 PFCandidate_withDistance jetConstituent_withDistance;
223 jetConstituent_withDistance.pfCandidate_ = (*jetConstituent);
224 jetConstituent_withDistance.distance_ =
dR;
225 neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
226 chargedHadron->addDaughter(*jetConstituent);
229 std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
231 const double caloResolutionCoeff = 1.0;
232 double resolutionTrackP = track->p()*(track->ptError()/track->pt());
233 double neutralEnSum = 0.;
234 for ( std::vector<PFCandidate_withDistance>::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin();
235 nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) {
236 double nextNeutralEn = nextNeutral->pfCandidate_->energy();
237 double resolutionCaloEn = caloResolutionCoeff*
sqrt(neutralEnSum + nextNeutralEn);
238 double resolution =
sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn);
239 if ( (neutralEnSum + nextNeutralEn) < (track->p() + 2.*
resolution) ) {
240 chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
241 neutralEnSum += nextNeutralEn;
253 output.push_back(chargedHadron);
256 return output.release();
RecoTauVertexAssociator vertexAssociator_
void setCharge(float q)
set the MEASURED charge
T getParameter(std::string const &) const
reco::VertexRef associatedVertex(const PFJet &tau) const
int Charge
electric charge type
return_type operator()(const reco::PFJet &) const
Build a collection of chargedHadrons from objects in the input jet.
ParticleType
particle types
RecoTauQualityCuts * qcuts_
PFRecoTauChargedHadronFromTrackPlugin(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
reco::PFCandidatePtr pfCandidate_
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void setEvent(const edm::Event &evt)
Load the vertices from the event.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
virtual void beginEvent()
Hook called at the beginning of the event.
boost::ptr_vector< PFRecoTauChargedHadron > ChargedHadronVector
edm::EDGetTokenT< reco::TrackCollection > Tracks_token
Jets made from PFObjects.
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool isNonnull() const
Checks for non-null.
virtual ~PFRecoTauChargedHadronFromTrackPlugin()
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
bool dRconeLimitedToJetArea_
std::vector< reco::PFCandidatePtr > PFCandPtrs
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
math::XYZPoint Point
point in the space
const edm::EventSetup * evtSetup() const
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
math::XYZVector magneticFieldStrength_
const edm::Event * evt() const
ParameterSet const & getParameterSet(std::string const &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
std::auto_ptr< ChargedHadronVector > return_type
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual float jetArea() const
get jet area
double dRmergeNeutralHadron_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
#define DEFINE_EDM_PLUGIN(factory, type, name)
virtual float pt() const GCC11_FINAL
transverse momentum
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.