150 edm::LogWarning(
"DataSource") <<
"WARNING! No Tau collection found. This missing input will not block the job. Instead, an empty tau collection is being be produced.";
151 auto patTaus = std::make_unique<std::vector<Tau>>();
162 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
167 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
178 std::vector<edm::ValueMap<TauJetCorrFactors> > tauJetCorrs;
183 tauJetCorrs.push_back( *tauJetCorr );
187 auto patTaus = std::make_unique<std::vector<Tau>>();
190 for (
size_t idx = 0, ntaus = anyTaus->size();
idx < ntaus; ++
idx) {
200 aTau.embedLeadPFCand();
202 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
206 aTau.embedLeadPFChargedHadrCand();
208 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
212 aTau.embedLeadPFNeutralCand();
214 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
218 aTau.embedSignalPFCands();
220 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
224 aTau.embedSignalPFChargedHadrCands();
226 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
230 aTau.embedSignalPFNeutralHadrCands();
232 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
236 aTau.embedSignalPFGammaCands();
238 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
242 aTau.embedIsolationPFCands();
244 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
248 aTau.embedIsolationPFChargedHadrCands();
250 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
254 aTau.embedIsolationPFNeutralHadrCands();
256 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
260 aTau.embedIsolationPFGammaCands();
262 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
267 for (
unsigned int i=0;
i<tauJetCorrs.size(); ++
i ) {
271 aTau.addJECFactors(tauJetCorr);
273 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
274 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
275 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
277 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
278 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
281 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
284 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 285 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 294 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
296 aTau.addGenParticleRef(genTau);
305 aTau.setGenJet( genJetTau );
313 auto const& tausDeref = *tausRef;
324 if(!missingDiscriminators.empty()){
325 missingDiscriminators+=
", ";
341 if(!missingDiscriminators.empty()){
342 missingDiscriminators+=
", ";
351 "PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
355 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n" 356 << missingDiscriminators <<
"\n" 357 <<
"They will not be embedded into the pat::Tau object.\n" 358 <<
"Note: this message will be printed only at first occurence.";
366 if ( aTau.isPFTau() ) {
371 aTau.setDecayMode(pfTauRef->decayMode());
375 if( !aTau.pfEssential_.empty() ) {
380 float ecalEnergy = 0;
381 float hcalEnergy = 0;
382 float sumPhiTimesEnergy = 0.;
383 float sumEtaTimesEnergy = 0.;
384 float sumEnergy = 0.;
385 float leadChargedCandPt = -99;
386 float leadChargedCandEtaAtEcalEntrance = -99;
387 const std::vector<reco::CandidatePtr>& signalCands = pfTauRef->signalCands();
388 for(
const auto& it : signalCands) {
390 if (icand !=
nullptr) {
395 sumEnergy += icand->
energy();
403 if( track->
pt() > leadChargedCandPt ) {
405 leadChargedCandPt = track->
pt();
413 sumEnergy += it->energy();
415 if( track !=
nullptr ) {
416 if( track->
pt() > leadChargedCandPt ) {
417 leadChargedCandPt = track->
pt();
426 if (sumEnergy != 0.) {
434 float leadingTrackNormChi2 = 0;
435 float ecalEnergyLeadChargedHadrCand = -99.;
436 float hcalEnergyLeadChargedHadrCand = -99.;
437 float emFraction = -1.;
438 float myHCALenergy = 0.;
439 float myECALenergy = 0.;
443 if(pfCandPtr !=
nullptr) {
444 ecalEnergyLeadChargedHadrCand = pfCandPtr->
ecalEnergy();
445 hcalEnergyLeadChargedHadrCand = pfCandPtr->
hcalEnergy();
448 leadingTrackNormChi2 = trackRef->normalizedChi2();
449 for(
const auto& isoPFCand : pfTauRef->isolationPFCands()){
450 myHCALenergy += isoPFCand->hcalEnergy();
451 myECALenergy += isoPFCand->ecalEnergy();
453 for(
const auto& signalPFCand : pfTauRef->signalPFCands()){
454 myHCALenergy += signalPFCand->hcalEnergy();
455 myECALenergy += signalPFCand->ecalEnergy();
457 if( myHCALenergy + myECALenergy != 0. ) {
458 emFraction = myECALenergy/( myHCALenergy + myECALenergy);
464 if (packedCandPtr !=
nullptr) {
467 if (track !=
nullptr) {
485 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
490 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
502 aTau.setIsolation(it->first, it->second);
506 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
edm::EDGetTokenT< reco::CaloTauCollection > caloTauToken_
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< edm::EDGetTokenT< reco::CaloTauDiscriminator > > caloTauIDTokens_
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, float > > IsolationValuePairs
Particle reconstructed by the particle flow algorithm.
bool embedLeadPFNeutralCand_
float leadingTrackNormChi2_
reco::GsfTrackRef gsfTrackRef() const
double hcalEnergy() const
return corrected Hcal energy
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
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