54 template <
class TrackClass>
55 class PFRecoTauChargedHadronFromGenericTrackPlugin :
public PFRecoTauChargedHadronBuilderPlugin {
72 std::unique_ptr<RecoTauQualityCuts>
qcuts_;
91 template <
class TrackClass>
94 template <
class TrackClass>
101 edm::ParameterSet qcuts_pset =
pset.getParameterSet(
"qualityCuts").getParameterSet(
"signalQualityCuts");
102 qcuts_ = std::make_unique<RecoTauQualityCuts>(qcuts_pset);
115 template <
class TrackClass>
119 template <
class TrackClass>
121 vertexAssociator_.setEvent(*this->evt());
123 magneticFieldStrength_ = evtSetup()->getData(magneticFieldToken_).inTesla(
GlobalPoint(0., 0., 0.));
131 return qcuts_->filterTrack(trackRef);
136 const edm::Handle<std::vector<pat::PackedCandidate> >&
tracks,
size_t iTrack)
const {
139 if (
cand.charge() == 0)
142 return qcuts_->filterChargedCand(
cand);
159 return track.ptError();
165 double trackPtError =
168 if (
track !=
nullptr) {
169 trackPtError =
track->ptError();
172 trackPtError = 0.025;
192 struct Candidate_withDistance {
197 bool isSmallerDistance(
const Candidate_withDistance& cand1,
const Candidate_withDistance& cand2) {
198 return (cand1.distance_ < cand2.distance_);
202 template <
class TrackClass>
206 edm::LogPrint(
"TauChHFromTrack") <<
"<PFRecoTauChargedHadronFromGenericTrackPlugin::operator()>:";
217 qcuts_->setPV(vertexAssociator_.associatedVertex(
jet));
218 float jEta =
jet.eta();
219 float jPhi =
jet.phi();
220 size_t numTracks =
tracks->size();
221 for (
size_t iTrack = 0; iTrack < numTracks; ++iTrack) {
226 double dRmatch = dRcone_;
227 if (dRconeLimitedToJetArea_) {
228 double jetArea =
jet.jetArea();
232 if (numWarnings_ < maxWarnings_) {
233 edm::LogInfo(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
234 <<
"Jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi()
235 <<
" has area = " << jetArea <<
" !!" << std::endl;
244 if (!this->filterTrack(
tracks, iTrack))
248 if (
track.charge() > 0.)
249 trackCharge_int = +1;
250 else if (
track.charge() < 0.)
251 trackCharge_int = -1;
253 const double chargedPionMass = 0.13957;
254 double chargedPionP =
track.p();
255 double chargedPionEn = TMath::Sqrt(chargedPionP * chargedPionP + chargedPionMass * chargedPionMass);
259 if (vertexAssociator_.associatedVertex(
jet).isNonnull())
260 vtx = vertexAssociator_.associatedVertex(
jet)->position();
262 auto chargedHadron = std::make_unique<PFRecoTauChargedHadron>(
279 p.setCharge(
track.charge());
282 if (trackPropagator.getSuccess() != 0) {
283 chargedHadron->positionAtECALEntrance_ = trackPropagator.particle().vertex();
285 if (chargedPionP4.pt() > 2. and
std::abs(chargedPionP4.eta()) < 3.) {
286 edm::LogWarning(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
287 <<
"Failed to propagate track: Pt = " <<
track.pt() <<
", eta = " <<
track.eta()
288 <<
", phi = " <<
track.phi() <<
" to ECAL entrance !!" << std::endl;
293 std::vector<Candidate_withDistance> neutralJetConstituents_withDistance;
294 for (
const auto& jetConstituent :
jet.daughterPtrVector()) {
295 int pdgId = jetConstituent->pdgId();
300 double dRmerge = -1.;
302 dRmerge = dRmergeNeutralHadron_;
303 else if (
pdgId == 22)
304 dRmerge = dRmergePhoton_;
306 Candidate_withDistance jetConstituent_withDistance;
307 jetConstituent_withDistance.pfCandidate_ = jetConstituent;
308 jetConstituent_withDistance.distance_ =
dR;
309 neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
314 neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
316 const double caloResolutionCoeff =
318 double resolutionTrackP =
track.p() * (getTrackPtError(
track) /
track.pt());
319 double neutralEnSum = 0.;
320 for (std::vector<Candidate_withDistance>::const_iterator nextNeutral =
321 neutralJetConstituents_withDistance.begin();
322 nextNeutral != neutralJetConstituents_withDistance.end();
324 double nextNeutralEn = nextNeutral->pfCandidate_->energy();
325 double resolutionCaloEn = caloResolutionCoeff *
sqrt(neutralEnSum + nextNeutralEn);
326 double resolution =
sqrt(resolutionTrackP * resolutionTrackP + resolutionCaloEn * resolutionCaloEn);
328 chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
329 neutralEnSum += nextNeutralEn;
357 "PFRecoTauChargedHadronFromTrackPlugin");
360 "PFRecoTauChargedHadronFromLostTrackPlugin");
int Charge
electric charge type
static constexpr unsigned int maxWarnings_
std::vector< std::unique_ptr< PFRecoTauChargedHadron > > ChargedHadronVector
math::XYZPointF atECALEntrance(const reco::Candidate *part, double bField)
bool dRconeLimitedToJetArea_
ChargedHadronVector return_type
reco::CandidatePtr pfCandidate_
bool filterTrack(const edm::Handle< std::vector< TrackClass > > &, size_t iTrack) const
Base class for all types of Jets.
Global3DPoint GlobalPoint
PFRecoTauChargedHadronFromGenericTrackPlugin(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
XYZTLorentzVector getTrackPos(const TrackClass &track) const
void setChargedHadronTrack(PFRecoTauChargedHadron &chargedHadron, const edm::Ptr< TrackClass > &track) const
~PFRecoTauChargedHadronFromGenericTrackPlugin() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
void beginEvent() override
Hook called at the beginning of the event.
double getTrackPtError(const TrackClass &track) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::unique_ptr< RecoTauQualityCuts > qcuts_
static std::atomic< unsigned int > numWarnings_
Abs< T >::type abs(const T &t)
return_type operator()(const reco::Jet &) const override
Build a collection of chargedHadrons from objects in the input jet.
math::XYZPoint Point
point in the space
edm::EDGetTokenT< std::vector< TrackClass > > Tracks_token
Log< level::Warning, true > LogPrint
bool propagateToEcalEntrance(bool first=true)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Log< level::Info, false > LogInfo
XYZVectorD XYZVector
spatial vector with cartesian internal representation
PFRecoTauChargedHadronFromGenericTrackPlugin< reco::Track > PFRecoTauChargedHadronFromTrackPlugin
math::XYZTLorentzVector LorentzVector
Lorentz vector.
RecoTauVertexAssociator vertexAssociator_
#define DEFINE_EDM_PLUGIN(factory, type, name)
PFRecoTauChargedHadronFromGenericTrackPlugin< pat::PackedCandidate > PFRecoTauChargedHadronFromLostTrackPlugin
math::XYZVector magneticFieldStrength_
Log< level::Warning, false > LogWarning
double dRmergeNeutralHadron_
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
math::XYZTLorentzVector XYZTLorentzVector