55 template <
class TrackClass>
56 class PFRecoTauChargedHadronFromGenericTrackPlugin :
public PFRecoTauChargedHadronBuilderPlugin {
91 template <
class TrackClass>
94 template <
class TrackClass>
100 edm::ParameterSet qcuts_pset =
pset.getParameterSet(
"qualityCuts").getParameterSet(
"signalQualityCuts");
114 template <
class TrackClass>
120 template <
class TrackClass>
122 vertexAssociator_.setEvent(*this->evt());
135 return qcuts_->filterTrack(trackRef);
140 const edm::Handle<std::vector<pat::PackedCandidate> >&
tracks,
size_t iTrack)
const {
143 if (
cand.charge() == 0)
146 return qcuts_->filterChargedCand(
cand);
163 return track.ptError();
169 double trackPtError =
172 if (
track !=
nullptr) {
173 trackPtError =
track->ptError();
176 trackPtError = 0.025;
196 struct Candidate_withDistance {
201 bool isSmallerDistance(
const Candidate_withDistance& cand1,
const Candidate_withDistance& cand2) {
202 return (cand1.distance_ < cand2.distance_);
206 template <
class TrackClass>
210 edm::LogPrint(
"TauChHFromTrack") <<
"<PFRecoTauChargedHadronFromGenericTrackPlugin::operator()>:";
221 qcuts_->setPV(vertexAssociator_.associatedVertex(
jet));
222 float jEta =
jet.eta();
223 float jPhi =
jet.phi();
224 size_t numTracks =
tracks->size();
225 for (
size_t iTrack = 0; iTrack < numTracks; ++iTrack) {
230 double dRmatch = dRcone_;
231 if (dRconeLimitedToJetArea_) {
232 double jetArea =
jet.jetArea();
236 if (numWarnings_ < maxWarnings_) {
237 edm::LogInfo(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
238 <<
"Jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi()
239 <<
" has area = " << jetArea <<
" !!" << std::endl;
248 if (!this->filterTrack(
tracks, iTrack))
252 if (
track.charge() > 0.)
253 trackCharge_int = +1;
254 else if (
track.charge() < 0.)
255 trackCharge_int = -1;
257 const double chargedPionMass = 0.13957;
258 double chargedPionP =
track.p();
259 double chargedPionEn = TMath::Sqrt(chargedPionP * chargedPionP + chargedPionMass * chargedPionMass);
263 if (vertexAssociator_.associatedVertex(
jet).isNonnull())
264 vtx = vertexAssociator_.associatedVertex(
jet)->position();
283 p.setCharge(
track.charge());
286 if (trackPropagator.getSuccess() != 0) {
287 chargedHadron->positionAtECALEntrance_ = trackPropagator.particle().vertex();
289 if (chargedPionP4.pt() > 2. and
std::abs(chargedPionP4.eta()) < 3.) {
290 edm::LogWarning(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
291 <<
"Failed to propagate track: Pt = " <<
track.pt() <<
", eta = " <<
track.eta()
292 <<
", phi = " <<
track.phi() <<
" to ECAL entrance !!" << std::endl;
297 std::vector<Candidate_withDistance> neutralJetConstituents_withDistance;
298 for (
const auto& jetConstituent :
jet.daughterPtrVector()) {
299 int pdgId = jetConstituent->pdgId();
304 double dRmerge = -1.;
306 dRmerge = dRmergeNeutralHadron_;
307 else if (
pdgId == 22)
308 dRmerge = dRmergePhoton_;
310 Candidate_withDistance jetConstituent_withDistance;
311 jetConstituent_withDistance.pfCandidate_ = jetConstituent;
312 jetConstituent_withDistance.distance_ =
dR;
313 neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
318 neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
320 const double caloResolutionCoeff =
322 double resolutionTrackP =
track.p() * (getTrackPtError(
track) /
track.pt());
323 double neutralEnSum = 0.;
324 for (std::vector<Candidate_withDistance>::const_iterator nextNeutral =
325 neutralJetConstituents_withDistance.begin();
326 nextNeutral != neutralJetConstituents_withDistance.end();
328 double nextNeutralEn = nextNeutral->pfCandidate_->energy();
329 double resolutionCaloEn = caloResolutionCoeff *
sqrt(neutralEnSum + nextNeutralEn);
330 double resolution =
sqrt(resolutionTrackP * resolutionTrackP + resolutionCaloEn * resolutionCaloEn);
332 chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
333 neutralEnSum += nextNeutralEn;
361 "PFRecoTauChargedHadronFromTrackPlugin");
364 "PFRecoTauChargedHadronFromLostTrackPlugin");