54 template <
class TrackClass>
55 class PFRecoTauChargedHadronFromGenericTrackPlugin :
public PFRecoTauChargedHadronBuilderPlugin {
91 template <
class TrackClass>
94 template <
class TrackClass>
101 edm::ParameterSet qcuts_pset =
pset.getParameterSet(
"qualityCuts").getParameterSet(
"signalQualityCuts");
115 template <
class TrackClass>
121 template <
class TrackClass>
123 vertexAssociator_.setEvent(*this->evt());
125 magneticFieldStrength_ = evtSetup()->getData(magneticFieldToken_).inTesla(
GlobalPoint(0., 0., 0.));
133 return qcuts_->filterTrack(trackRef);
138 const edm::Handle<std::vector<pat::PackedCandidate> >&
tracks,
size_t iTrack)
const {
141 if (
cand.charge() == 0)
144 return qcuts_->filterChargedCand(
cand);
161 return track.ptError();
167 double trackPtError =
170 if (
track !=
nullptr) {
171 trackPtError =
track->ptError();
174 trackPtError = 0.025;
194 struct Candidate_withDistance {
199 bool isSmallerDistance(
const Candidate_withDistance& cand1,
const Candidate_withDistance& cand2) {
200 return (cand1.distance_ < cand2.distance_);
204 template <
class TrackClass>
208 edm::LogPrint(
"TauChHFromTrack") <<
"<PFRecoTauChargedHadronFromGenericTrackPlugin::operator()>:";
219 qcuts_->setPV(vertexAssociator_.associatedVertex(
jet));
220 float jEta =
jet.eta();
221 float jPhi =
jet.phi();
222 size_t numTracks =
tracks->size();
223 for (
size_t iTrack = 0; iTrack < numTracks; ++iTrack) {
228 double dRmatch = dRcone_;
229 if (dRconeLimitedToJetArea_) {
230 double jetArea =
jet.jetArea();
234 if (numWarnings_ < maxWarnings_) {
235 edm::LogInfo(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
236 <<
"Jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi()
237 <<
" has area = " << jetArea <<
" !!" << std::endl;
246 if (!this->filterTrack(
tracks, iTrack))
250 if (
track.charge() > 0.)
251 trackCharge_int = +1;
252 else if (
track.charge() < 0.)
253 trackCharge_int = -1;
255 const double chargedPionMass = 0.13957;
256 double chargedPionP =
track.p();
257 double chargedPionEn = TMath::Sqrt(chargedPionP * chargedPionP + chargedPionMass * chargedPionMass);
261 if (vertexAssociator_.associatedVertex(
jet).isNonnull())
262 vtx = vertexAssociator_.associatedVertex(
jet)->position();
281 p.setCharge(
track.charge());
284 if (trackPropagator.getSuccess() != 0) {
285 chargedHadron->positionAtECALEntrance_ = trackPropagator.particle().vertex();
287 if (chargedPionP4.pt() > 2. and
std::abs(chargedPionP4.eta()) < 3.) {
288 edm::LogWarning(
"PFRecoTauChargedHadronFromGenericTrackPlugin::operator()")
289 <<
"Failed to propagate track: Pt = " <<
track.pt() <<
", eta = " <<
track.eta()
290 <<
", phi = " <<
track.phi() <<
" to ECAL entrance !!" << std::endl;
295 std::vector<Candidate_withDistance> neutralJetConstituents_withDistance;
296 for (
const auto& jetConstituent :
jet.daughterPtrVector()) {
297 int pdgId = jetConstituent->pdgId();
302 double dRmerge = -1.;
304 dRmerge = dRmergeNeutralHadron_;
305 else if (
pdgId == 22)
306 dRmerge = dRmergePhoton_;
308 Candidate_withDistance jetConstituent_withDistance;
309 jetConstituent_withDistance.pfCandidate_ = jetConstituent;
310 jetConstituent_withDistance.distance_ =
dR;
311 neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
316 neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
318 const double caloResolutionCoeff =
320 double resolutionTrackP =
track.p() * (getTrackPtError(
track) /
track.pt());
321 double neutralEnSum = 0.;
322 for (std::vector<Candidate_withDistance>::const_iterator nextNeutral =
323 neutralJetConstituents_withDistance.begin();
324 nextNeutral != neutralJetConstituents_withDistance.end();
326 double nextNeutralEn = nextNeutral->pfCandidate_->energy();
327 double resolutionCaloEn = caloResolutionCoeff *
sqrt(neutralEnSum + nextNeutralEn);
328 double resolution =
sqrt(resolutionTrackP * resolutionTrackP + resolutionCaloEn * resolutionCaloEn);
330 chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
331 neutralEnSum += nextNeutralEn;
359 "PFRecoTauChargedHadronFromTrackPlugin");
362 "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)
RecoTauQualityCuts * qcuts_
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.
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