164 edm::LogWarning(
"DataSource") <<
"WARNING! No Tau collection found. This missing input will not block the job. " 165 "Instead, an empty tau collection is being be produced.";
166 auto patTaus = std::make_unique<std::vector<Tau>>();
180 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
185 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(
genMatchTokens_.size());
197 std::vector<edm::ValueMap<TauJetCorrFactors>> tauJetCorrs;
202 tauJetCorrs.push_back(*tauJetCorr);
206 auto patTaus = std::make_unique<std::vector<Tau>>();
215 aTau.embedLeadTrack();
217 aTau.embedSignalTracks();
219 aTau.embedIsolationTracks();
222 aTau.embedLeadPFCand();
224 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 225 "from a reco::PFTau is impossible.\n";
229 aTau.embedLeadPFChargedHadrCand();
231 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 232 "from a reco::PFTau is impossible.\n";
236 aTau.embedLeadPFNeutralCand();
238 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 239 "from a reco::PFTau is impossible.\n";
243 aTau.embedSignalPFCands();
245 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 246 "from a reco::PFTau is impossible.\n";
250 aTau.embedSignalPFChargedHadrCands();
252 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 253 "from a reco::PFTau is impossible.\n";
257 aTau.embedSignalPFNeutralHadrCands();
259 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 260 "from a reco::PFTau is impossible.\n";
264 aTau.embedSignalPFGammaCands();
266 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 267 "from a reco::PFTau is impossible.\n";
271 aTau.embedIsolationPFCands();
273 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 274 "from a reco::PFTau is impossible.\n";
278 aTau.embedIsolationPFChargedHadrCands();
280 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 281 "from a reco::PFTau is impossible.\n";
285 aTau.embedIsolationPFNeutralHadrCands();
287 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 288 "from a reco::PFTau is impossible.\n";
292 aTau.embedIsolationPFGammaCands();
294 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 295 "from a reco::PFTau is impossible.\n";
300 for (
unsigned int i = 0;
i < tauJetCorrs.size(); ++
i) {
304 aTau.addJECFactors(tauJetCorr);
306 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
307 if (
std::find(levels.begin(), levels.end(),
"L2L3Residual") != levels.end()) {
308 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
309 }
else if (
std::find(levels.begin(), levels.end(),
"L3Absolute") != levels.end()) {
310 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
312 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
315 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 316 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 325 for (
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
327 aTau.addGenParticleRef(genTau);
330 aTau.embedGenParticle();
337 aTau.setGenJet(genJetTau);
345 auto const& tausDeref = *tausRef;
356 if (!missingDiscriminators.empty()) {
357 missingDiscriminators +=
", ";
366 <<
"PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
370 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n" 371 << missingDiscriminators <<
"\n" 372 <<
"They will not be embedded into the pat::Tau object.\n" 373 <<
"Note: this message will be printed only at first occurence.";
381 if (aTau.isPFTau()) {
386 aTau.setDecayMode(pfTauRef->decayMode());
390 if (!aTau.pfEssential_.empty()) {
395 float ecalEnergy = 0;
396 float hcalEnergy = 0;
397 float sumPhiTimesEnergy = 0.;
398 float sumEtaTimesEnergy = 0.;
399 float sumEnergy = 0.;
400 float leadChargedCandPt = -99;
401 float leadChargedCandEtaAtEcalEntrance = -99;
402 const std::vector<reco::CandidatePtr>& signalCands = pfTauRef->signalCands();
403 for (
const auto& it : signalCands) {
405 if (icand !=
nullptr) {
410 sumEnergy += icand->
energy();
417 track = icand->
muonRef()->globalTrack().
get();
423 if (track->
pt() > leadChargedCandPt) {
425 leadChargedCandPt = track->
pt();
432 sumEnergy += it->energy();
434 if (track !=
nullptr) {
435 if (track->
pt() > leadChargedCandPt) {
436 leadChargedCandPt = track->
pt();
445 if (sumEnergy != 0.) {
452 float leadingTrackNormChi2 = 0;
453 float ecalEnergyLeadChargedHadrCand = -99.;
454 float hcalEnergyLeadChargedHadrCand = -99.;
455 float emFraction = -1.;
456 float myHCALenergy = 0.;
457 float myECALenergy = 0.;
461 if (pfCandPtr !=
nullptr) {
462 ecalEnergyLeadChargedHadrCand = pfCandPtr->
ecalEnergy();
463 hcalEnergyLeadChargedHadrCand = pfCandPtr->
hcalEnergy();
466 leadingTrackNormChi2 = trackRef->normalizedChi2();
467 for (
const auto& isoPFCand : pfTauRef->isolationPFCands()) {
468 myHCALenergy += isoPFCand->hcalEnergy();
469 myECALenergy += isoPFCand->ecalEnergy();
471 for (
const auto& signalPFCand : pfTauRef->signalPFCands()) {
472 myHCALenergy += signalPFCand->hcalEnergy();
473 myECALenergy += signalPFCand->ecalEnergy();
475 if (myHCALenergy + myECALenergy != 0.) {
476 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
481 if (packedCandPtr !=
nullptr) {
484 if (track !=
nullptr) {
502 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
507 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
521 aTau.setIsolation(it->first, it->second);
525 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
bool enabled() const
'true' if this there is at least one efficiency configured
double ecalEnergy() const
return corrected Ecal energy
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
float etaAtEcalEntranceLeadChargedCand_
bool hasSecondaryVertex() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool addTauJetCorrFactors_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T const * get() const
Returns C++ pointer to the item.
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
float getTauIdDiscriminator(const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
const Point & dxy_PCA() const
const math::XYZPointF & positionAtECALEntrance() const
bool enabled() const
'true' if this there is at least one efficiency configured
bool embedIsolationPFChargedHadrCands_
reco::TrackRef trackRef() const
bool enabled() const
True if it has a non null configuration.
double ip3d_error() const
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
double flightLengthSig() const
edm::EDGetTokenT< PFTauTIPAssociationByRef > tauTransverseImpactParameterToken_
pat::helper::MultiIsolator isolator_
const Vector & flightLength() const
edm::EDGetTokenT< edm::View< reco::BaseTau > > baseTauToken_
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
bool embedIsolationPFNeutralHadrCands_
double pt() const
track transverse momentum
double energy() const final
energy
pat::PATUserDataHelper< pat::Tau > userDataHelper_
virtual const reco::Track & pseudoTrack() const
genJetMatch
switch on/off embedding of matched genJet's
T const * get() const
Returns C++ pointer to the item.
bool embedSignalPFNeutralHadrCands_
bool embedIsolationPFCands_
reco::MuonRef muonRef() const
bool isNonnull() const
Checks for non-null.
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
std::vector< edm::EDGetTokenT< edm::ValueMap< TauJetCorrFactors > > > tauJetCorrFactorsTokens_
edm::InputTag tauTransverseImpactParameterSrc_
bool embedIsolationTracks_
bool embedLeadPFChargedHadrCand_
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
bool embedIsolationPFGammaCands_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetMatchToken_
bool embedSignalPFGammaCands_
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
Particle reconstructed by the particle flow algorithm.
bool embedLeadPFNeutralCand_
float leadingTrackNormChi2_
reco::GsfTrackRef gsfTrackRef() const
double hcalEnergy() const
return corrected Hcal energy
float ecalEnergyLeadChargedHadrCand_
bool embedSignalPFChargedHadrCands_
std::vector< edm::EDGetTokenT< reco::PFTauDiscriminator > > pfTauIDTokens_
std::vector< NameTag > tauIDSrcs_
edm::EDGetTokenT< reco::PFTauCollection > pfTauToken_
float hcalEnergyLeadChargedHadrCand_
GreaterByPt< Tau > pTTauComparator_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const