51 namespace reco {
namespace tau {
53 template<
class TrackClass>
54 class PFRecoTauChargedHadronFromGenericTrackPlugin :
public PFRecoTauChargedHadronBuilderPlugin
90 template<
class TrackClass>
113 template<
class TrackClass>
120 template<
class TrackClass>
165 double trackPtError = 0.06;
167 if(
track !=
nullptr) {
168 trackPtError =
track->ptError();
171 trackPtError = 0.025;
191 struct Candidate_withDistance
197 bool isSmallerDistance(
const Candidate_withDistance& cand1,
const Candidate_withDistance& cand2)
199 return (cand1.distance_ < cand2.distance_);
203 template<
class TrackClass>
207 edm::LogPrint(
"TauChHFromTrack") <<
"<PFRecoTauChargedHadronFromGenericTrackPlugin::operator()>:" ;
219 float jEta=jet.
eta();
220 float jPhi=jet.
phi();
221 size_t numTracks = tracks->size();
222 for (
size_t iTrack = 0; iTrack < numTracks; ++iTrack ) {
226 double dR =
deltaR(track.eta(), track.phi(), jEta,jPhi);
229 double jetArea = jet.
jetArea();
230 if ( jetArea > 0. ) {
234 edm::LogInfo(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
235 <<
"Jet: Pt = " << jet.
pt() <<
", eta = " << jet.
eta() <<
", phi = " << jet.
phi() <<
" has area = " << jetArea <<
" !!" << std::endl;
241 if ( dR > dRmatch )
continue;
246 if ( track.charge() > 0. ) trackCharge_int = +1;
247 else if ( track.charge() < 0. ) trackCharge_int = -1;
249 const double chargedPionMass = 0.13957;
250 double chargedPionP = track.p();
251 double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass);
276 if ( trackPropagator.getSuccess() != 0 ) {
277 chargedHadron->positionAtECALEntrance_ = trackPropagator.particle().vertex();
279 if ( chargedPionP4.pt() > 2. and
std::abs(chargedPionP4.eta()) < 3. ) {
280 edm::LogWarning(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
281 <<
"Failed to propagate track: Pt = " << track.pt() <<
", eta = " << track.eta() <<
", phi = " << track.phi() <<
" to ECAL entrance !!" << std::endl;
286 std::vector<Candidate_withDistance> neutralJetConstituents_withDistance;
288 int pdgId = jetConstituent->pdgId();
289 if ( !(pdgId == 130 || pdgId == 22) )
continue;
291 double dRmerge = -1.;
294 if ( dR < dRmerge ) {
295 Candidate_withDistance jetConstituent_withDistance;
296 jetConstituent_withDistance.pfCandidate_ = jetConstituent;
297 jetConstituent_withDistance.distance_ = dR;
298 neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
299 chargedHadron->addDaughter(jetConstituent);
302 std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
304 const double caloResolutionCoeff = 1.0;
305 double resolutionTrackP = track.p()*(
getTrackPtError(track)/track.pt());
306 double neutralEnSum = 0.;
307 for ( std::vector<Candidate_withDistance>::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin();
308 nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) {
309 double nextNeutralEn = nextNeutral->pfCandidate_->energy();
310 double resolutionCaloEn = caloResolutionCoeff*
sqrt(neutralEnSum + nextNeutralEn);
311 double resolution =
sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn);
312 if ( (neutralEnSum + nextNeutralEn) < (track.p() + 2.*
resolution) ) {
313 chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
314 neutralEnSum += nextNeutralEn;
326 output.push_back(chargedHadron);
329 return output.release();
CandidatePtr lostTrackCandidate_
void setCharge(float q)
set the MEASURED charge
T getParameter(std::string const &) const
int Charge
electric charge type
const Point & referencePoint() const
Reference point on the track.
math::XYZPointF atECALEntrance(const reco::Candidate *part, double bField)
bool isNonnull() const
Checks for non-null.
double eta() const final
momentum pseudorapidity
RecoTauQualityCuts * qcuts_
bool dRconeLimitedToJetArea_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
reco::CandidatePtr pfCandidate_
Base class for all types of Jets.
Global3DPoint GlobalPoint
PFRecoTauChargedHadronFromGenericTrackPlugin(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
double pt() const final
transverse momentum
void setEvent(const edm::Event &evt)
Load the vertices from the event.
~PFRecoTauChargedHadronFromGenericTrackPlugin() override
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
boost::ptr_vector< PFRecoTauChargedHadron > ChargedHadronVector
void beginEvent() override
Hook called at the beginning of the event.
virtual const daughters & daughterPtrVector() const
references to daughtes
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int charge() const override
electric charge
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
double getTrackPtError(const TrackClass &track) const
const Point & vertex() const override
vertex position
XYZTLorentzVector getTrackPos(const TrackClass &track) const
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Abs< T >::type abs(const T &t)
math::XYZPoint Point
point in the space
const edm::EventSetup * evtSetup() const
edm::EDGetTokenT< std::vector< TrackClass > > Tracks_token
return_type operator()(const reco::Jet &) const override
Build a collection of chargedHadrons from objects in the input jet.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
bool propagateToEcalEntrance(bool first=true)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double eta() const override
momentum pseudorapidity
bool filterChargedCand(const reco::Candidate &cand) const
or a single charged candidate
const edm::Event * evt() const
ParameterSet const & getParameterSet(std::string const &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
PFRecoTauChargedHadronFromGenericTrackPlugin< reco::Track > PFRecoTauChargedHadronFromTrackPlugin
std::auto_ptr< ChargedHadronVector > return_type
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual float jetArea() const
get jet area
reco::VertexRef associatedVertex(const Jet &jet) const
RecoTauVertexAssociator vertexAssociator_
#define DEFINE_EDM_PLUGIN(factory, type, name)
PFRecoTauChargedHadronFromGenericTrackPlugin< pat::PackedCandidate > PFRecoTauChargedHadronFromLostTrackPlugin
math::XYZVector magneticFieldStrength_
double dRmergeNeutralHadron_
void setChargedHadronTrack(PFRecoTauChargedHadron &chargedHadron, const edm::Ptr< TrackClass > &track) const
const std::string & name() const
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
double phi() const final
momentum azimuthal angle
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.
bool filterTrack(const edm::Handle< std::vector< TrackClass > > &, size_t iTrack) const
math::XYZTLorentzVector XYZTLorentzVector