Skip to content

Commit

Permalink
changing LogWarning printout such that it is not raised for each tau …
Browse files Browse the repository at this point in the history
…but only at first occurence per instance
  • Loading branch information
roger-wolf committed Nov 17, 2017
1 parent 4a2a37d commit 01b008a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 17 additions & 5 deletions PhysicsTools/PatAlgos/plugins/PATTauProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ PATTauProducer::PATTauProducer(const edm::ParameterSet & iConfig):
isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false) ,
useUserData_(iConfig.exists("userData"))
{
firstOccurence_=true;
// initialize the configurables
baseTauToken_ = consumes<edm::View<reco::BaseTau> >(iConfig.getParameter<edm::InputTag>( "tauSource" ));
tauTransverseImpactParameterSrc_ = iConfig.getParameter<edm::InputTag>( "tauTransverseImpactParameterSource" );
Expand Down Expand Up @@ -306,6 +307,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup

// prepare ID extraction
if ( addTauID_ ) {
std::string missingDiscriminators;
std::vector<pat::Tau::IdPair> ids(tauIDSrcs_.size());
for ( size_t i = 0; i < tauIDSrcs_.size(); ++i ) {
if ( typeid(*tausRef) == typeid(reco::PFTau) ) {
Expand All @@ -317,8 +319,10 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
iEvent.getByToken(pfTauIDTokens_[i], pfTauIdDiscr);

if(skipMissingTauID_ && !pfTauIdDiscr.isValid()){
edm::LogWarning("DataSource") << "Tau discriminator '" << tauIDSrcs_[i].first
<< "' has not been found in the event. It will not be embedded into the pat::Tau object.";
if(!missingDiscriminators.empty()){
missingDiscriminators+=", ";
}
missingDiscriminators+=tauIDSrcs_[i].first;
continue;
}
ids[i].first = tauIDSrcs_[i].first;
Expand All @@ -332,8 +336,10 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
iEvent.getByToken(caloTauIDTokens_[i], caloTauIdDiscr);

if(skipMissingTauID_ && !caloTauIdDiscr.isValid()){
edm::LogWarning("DataSource") << "Tau discriminator '" << tauIDSrcs_[i].first
<< "' has not been found in the event. It will not be embedded into the pat::Tau object.";
if(!missingDiscriminators.empty()){
missingDiscriminators+=", ";
}
missingDiscriminators+=tauIDSrcs_[i].first;
continue;
}
ids[i].first = tauIDSrcs_[i].first;
Expand All @@ -343,7 +349,13 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
"PATTauProducer: unsupported datatype '" << typeid(*tausRef).name() << "' for tauSource\n";
}
}

if(!missingDiscriminators.empty() && firstOccurence_){
edm::LogWarning("DataSource") << "The following tau discriminators have not been found in the event:\n"
<< missingDiscriminators <<"\n"
<< "They will not be embedded into the pat::Tau object.\n"
<< "Note: this message will be printed only at first occurence.";
firstOccurence_=false;
}
aTau.setTauIDs(ids);
}

Expand Down
3 changes: 2 additions & 1 deletion PhysicsTools/PatAlgos/plugins/PATTauProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace pat {
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);

private:

bool firstOccurence_; // used to print LogWarnings only at first occurnece in the event loop

// configurables
edm::EDGetTokenT<edm::View<reco::BaseTau> > baseTauToken_;
edm::EDGetTokenT<PFTauTIPAssociationByRef> tauTransverseImpactParameterToken_;
Expand Down

0 comments on commit 01b008a

Please sign in to comment.