149 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.";
150 auto patTaus = std::make_unique<std::vector<Tau>>();
161 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
166 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
177 std::vector<edm::ValueMap<TauJetCorrFactors> > tauJetCorrs;
182 tauJetCorrs.push_back( *tauJetCorr );
186 auto patTaus = std::make_unique<std::vector<Tau>>();
189 for (
size_t idx = 0, ntaus = anyTaus->size();
idx < ntaus; ++
idx) {
199 aTau.embedLeadPFCand();
201 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
205 aTau.embedLeadPFChargedHadrCand();
207 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
211 aTau.embedLeadPFNeutralCand();
213 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
217 aTau.embedSignalPFCands();
219 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
223 aTau.embedSignalPFChargedHadrCands();
225 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
229 aTau.embedSignalPFNeutralHadrCands();
231 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
235 aTau.embedSignalPFGammaCands();
237 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
241 aTau.embedIsolationPFCands();
243 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
247 aTau.embedIsolationPFChargedHadrCands();
249 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
253 aTau.embedIsolationPFNeutralHadrCands();
255 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
259 aTau.embedIsolationPFGammaCands();
261 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
266 for (
unsigned int i=0;
i<tauJetCorrs.size(); ++
i ) {
270 aTau.addJECFactors(tauJetCorr);
272 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
273 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
274 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
276 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
277 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
280 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
283 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 284 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 293 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
295 aTau.addGenParticleRef(genTau);
304 aTau.setGenJet( genJetTau );
312 auto const& tausDeref = *tausRef;
323 if(!missingDiscriminators.empty()){
324 missingDiscriminators+=
", ";
340 if(!missingDiscriminators.empty()){
341 missingDiscriminators+=
", ";
350 "PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
354 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n" 355 << missingDiscriminators <<
"\n" 356 <<
"They will not be embedded into the pat::Tau object.\n" 357 <<
"Note: this message will be printed only at first occurence.";
365 if ( aTau.isPFTau() ) {
370 aTau.setDecayMode(pfTauRef->decayMode());
374 if( aTau.isPFTau() ) {
379 float ecalEnergy = 0;
380 float hcalEnergy = 0;
381 float sumPhiTimesEnergy = 0.;
382 float sumEtaTimesEnergy = 0.;
383 float sumEnergy = 0.;
384 float leadChargedCandPt = -99;
385 float leadChargedCandEtaAtEcalEntrance = -99;
386 const std::vector<reco::PFCandidatePtr>& signalCands = pfTauRef->signalPFCands();
387 for(std::vector<reco::PFCandidatePtr>::const_iterator it = signalCands.begin(); it != signalCands.end(); ++it) {
389 ecalEnergy += icand->ecalEnergy();
390 hcalEnergy += icand->hcalEnergy();
391 sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy();
392 sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy();
393 sumEnergy += icand->energy();
395 if ( icand->trackRef().
isNonnull() ) track = icand->trackRef().
get();
396 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->innerTrack().
isNonnull() ) track = icand->muonRef()->innerTrack().
get();
397 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->globalTrack().
isNonnull() ) track = icand->muonRef()->globalTrack().
get();
398 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->outerTrack().
isNonnull() ) track = icand->muonRef()->outerTrack().
get();
399 else if ( icand->gsfTrackRef().
isNonnull() ) track = icand->gsfTrackRef().
get();
401 if( track->
pt() > leadChargedCandPt ) {
402 leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta();
403 leadChargedCandPt = track->
pt();
411 if (sumEnergy != 0.) {
419 float leadingTrackNormChi2 = 0;
420 float ecalEnergyLeadChargedHadrCand = -99.;
421 float hcalEnergyLeadChargedHadrCand = -99.;
422 float emFraction = -1.;
423 float myHCALenergy = 0.;
424 float myECALenergy = 0.;
427 ecalEnergyLeadChargedHadrCand = leadingPFCharged->ecalEnergy();
428 hcalEnergyLeadChargedHadrCand = leadingPFCharged->hcalEnergy();
431 leadingTrackNormChi2 = trackRef->normalizedChi2();
432 for( std::vector<reco::PFCandidatePtr>::const_iterator tauIt = pfTauRef->isolationPFCands().begin(); tauIt!=pfTauRef->isolationPFCands().end(); ++tauIt ){
433 myHCALenergy += (*tauIt)->hcalEnergy();
434 myECALenergy += (*tauIt)->ecalEnergy();
436 for( std::vector<reco::PFCandidatePtr>::const_iterator tauIt = pfTauRef->signalPFCands().begin(); tauIt!=pfTauRef->signalPFCands().end(); ++tauIt ){
437 myHCALenergy += (*tauIt)->hcalEnergy();
438 myECALenergy += (*tauIt)->ecalEnergy();
440 if( myHCALenergy + myECALenergy != 0. ) {
441 emFraction = myECALenergy/( myHCALenergy + myECALenergy);
456 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
461 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
473 aTau.setIsolation(it->first, it->second);
477 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
bool enabled() const
'true' if this there is at least one efficiency configured
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_
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
bool enabled() const
'true' if this there is at least one efficiency configured
bool embedIsolationPFChargedHadrCands_
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_
pat::PATUserDataHelper< pat::Tau > userDataHelper_
genJetMatch
switch on/off embedding of matched genJet's
bool embedSignalPFNeutralHadrCands_
bool embedIsolationPFCands_
bool isNonnull() const
Checks for non-null.
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
bool embedLeadPFNeutralCand_
float leadingTrackNormChi2_
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