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_);
134 edm::LogPrint(
"TauChHFromTrack") <<
"<PFRecoTauChargedHadronFromTrackPlugin::operator()>:" ;
146 float jEta=jet.
eta();
147 float jPhi=jet.
phi();
148 size_t numTracks = tracks->size();
149 for (
size_t iTrack = 0; iTrack < numTracks; ++iTrack ) {
153 double dR =
deltaR(track->eta(), track->phi(), jEta,jPhi);
156 double jetArea = jet.
jetArea();
157 if ( jetArea > 0. ) {
162 <<
"Jet: Pt = " << jet.
pt() <<
", eta = " << jet.
eta() <<
", phi = " << jet.
phi() <<
" has area = " << jetArea <<
" !!" << std::endl;
168 if ( dR > dRmatch )
continue;
174 if ( track->charge() > 0. ) trackCharge_int = +1;
175 else if ( track->charge() < 0. ) trackCharge_int = -1;
177 const double chargedPionMass = 0.13957;
178 double chargedPionP = track->p();
179 double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass);
198 XYZTLorentzVector chargedPionPos(track->referencePoint().x(), track->referencePoint().y(), track->referencePoint().z(), 0.);
200 trackPropagator.
setCharge(track->charge());
201 trackPropagator.propagateToEcalEntrance(
false);
202 if ( trackPropagator.getSuccess() != 0 ) {
203 chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex();
205 if ( chargedPionP4.pt() > 2. ) {
207 <<
"Failed to propagate track: Pt = " << track->pt() <<
", eta = " << track->eta() <<
", phi = " << track->phi() <<
" to ECAL entrance !!" << std::endl;
212 std::vector<PFCandidate_withDistance> neutralJetConstituents_withDistance;
214 for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
215 jetConstituent != jetConstituents.end(); ++jetConstituent ) {
218 double dR =
deltaR((*jetConstituent)->positionAtECALEntrance(), chargedHadron->positionAtECALEntrance_);
219 double dRmerge = -1.;
222 if ( dR < dRmerge ) {
223 PFCandidate_withDistance jetConstituent_withDistance;
224 jetConstituent_withDistance.pfCandidate_ = (*jetConstituent);
225 jetConstituent_withDistance.distance_ =
dR;
226 neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
227 chargedHadron->addDaughter(*jetConstituent);
230 std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
232 const double caloResolutionCoeff = 1.0;
233 double resolutionTrackP = track->p()*(track->ptError()/track->pt());
234 double neutralEnSum = 0.;
235 for ( std::vector<PFCandidate_withDistance>::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin();
236 nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) {
237 double nextNeutralEn = nextNeutral->pfCandidate_->energy();
238 double resolutionCaloEn = caloResolutionCoeff*
sqrt(neutralEnSum + nextNeutralEn);
239 double resolution =
sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn);
240 if ( (neutralEnSum + nextNeutralEn) < (track->p() + 2.*
resolution) ) {
241 chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
242 neutralEnSum += nextNeutralEn;
254 output.push_back(chargedHadron);
257 return output.release();
RecoTauVertexAssociator vertexAssociator_
void setCharge(float q)
set the MEASURED charge
T getParameter(std::string const &) 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
bool isNonnull() const
Checks for non-null.
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
reco::VertexRef associatedVertex(const PFJet &jet) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void setEvent(const edm::Event &evt)
Load the vertices from the event.
double deltaR(const T1 &t1, const T2 &t2)
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.
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual ~PFRecoTauChargedHadronFromTrackPlugin()
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
bool dRconeLimitedToJetArea_
std::vector< reco::PFCandidatePtr > PFCandPtrs
math::XYZPoint Point
point in the space
const edm::EventSetup * evtSetup() const
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)
const std::string & name() const
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
virtual double phi() const
momentum azimuthal angle
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.