147 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.";
148 auto patTaus = std::make_unique<std::vector<Tau>>();
159 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
164 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
175 std::vector<edm::ValueMap<TauJetCorrFactors> > tauJetCorrs;
180 tauJetCorrs.push_back( *tauJetCorr );
184 auto patTaus = std::make_unique<std::vector<Tau>>();
187 for (
size_t idx = 0, ntaus = anyTaus->size();
idx < ntaus; ++
idx) {
197 aTau.embedLeadPFCand();
199 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
203 aTau.embedLeadPFChargedHadrCand();
205 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
209 aTau.embedLeadPFNeutralCand();
211 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
215 aTau.embedSignalPFCands();
217 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
221 aTau.embedSignalPFChargedHadrCands();
223 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
227 aTau.embedSignalPFNeutralHadrCands();
229 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
233 aTau.embedSignalPFGammaCands();
235 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
239 aTau.embedIsolationPFCands();
241 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
245 aTau.embedIsolationPFChargedHadrCands();
247 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
251 aTau.embedIsolationPFNeutralHadrCands();
253 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
257 aTau.embedIsolationPFGammaCands();
259 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
264 for (
unsigned int i=0;
i<tauJetCorrs.size(); ++
i ) {
268 aTau.addJECFactors(tauJetCorr);
270 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
271 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
272 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
274 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
275 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
278 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
281 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 282 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 291 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
293 aTau.addGenParticleRef(genTau);
302 aTau.setGenJet( genJetTau );
308 std::vector<pat::Tau::IdPair> ids(
tauIDSrcs_.size());
332 "PATTauProducer: unsupported datatype '" <<
typeid(*tausRef).name() <<
"' for tauSource\n";
341 if ( aTau.isPFTau() ) {
346 aTau.setDecayMode(pfTauRef->decayMode());
350 if( aTau.isPFTau() ) {
355 float ecalEnergy = 0;
356 float hcalEnergy = 0;
357 float sumPhiTimesEnergy = 0.;
358 float sumEtaTimesEnergy = 0.;
359 float sumEnergy = 0.;
360 float leadChargedCandPt = -99;
361 float leadChargedCandEtaAtEcalEntrance = -99;
362 const std::vector<reco::PFCandidatePtr>& signalCands = pfTauRef->signalPFCands();
363 for(std::vector<reco::PFCandidatePtr>::const_iterator it = signalCands.begin(); it != signalCands.end(); ++it) {
365 ecalEnergy += icand->ecalEnergy();
366 hcalEnergy += icand->hcalEnergy();
367 sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy();
368 sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy();
369 sumEnergy += icand->energy();
371 if ( icand->trackRef().
isNonnull() ) track = icand->trackRef().
get();
372 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->innerTrack().
isNonnull() ) track = icand->muonRef()->innerTrack().
get();
373 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->globalTrack().
isNonnull() ) track = icand->muonRef()->globalTrack().
get();
374 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->outerTrack().
isNonnull() ) track = icand->muonRef()->outerTrack().
get();
375 else if ( icand->gsfTrackRef().
isNonnull() ) track = icand->gsfTrackRef().
get();
377 if( track->
pt() > leadChargedCandPt ) {
378 leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta();
379 leadChargedCandPt = track->
pt();
387 if (sumEnergy != 0.) {
395 float leadingTrackNormChi2 = 0;
396 float ecalEnergyLeadChargedHadrCand = -99.;
397 float hcalEnergyLeadChargedHadrCand = -99.;
398 float emFraction = -1.;
399 float myHCALenergy = 0.;
400 float myECALenergy = 0.;
403 ecalEnergyLeadChargedHadrCand = leadingPFCharged->ecalEnergy();
404 hcalEnergyLeadChargedHadrCand = leadingPFCharged->hcalEnergy();
407 leadingTrackNormChi2 = trackRef->normalizedChi2();
408 for( std::vector<reco::PFCandidatePtr>::const_iterator tauIt = pfTauRef->isolationPFCands().begin(); tauIt!=pfTauRef->isolationPFCands().end(); ++tauIt ){
409 myHCALenergy += (*tauIt)->hcalEnergy();
410 myECALenergy += (*tauIt)->ecalEnergy();
412 for( std::vector<reco::PFCandidatePtr>::const_iterator tauIt = pfTauRef->signalPFCands().begin(); tauIt!=pfTauRef->signalPFCands().end(); ++tauIt ){
413 myHCALenergy += (*tauIt)->hcalEnergy();
414 myECALenergy += (*tauIt)->ecalEnergy();
416 if( myHCALenergy + myECALenergy != 0. ) {
417 emFraction = myECALenergy/( myHCALenergy + myECALenergy);
432 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
437 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
449 aTau.setIsolation(it->first, it->second);
453 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