Skip to content

Commit

Permalink
- bug-fix in computing isolation of boosted taus (PFCandidates contai…
Browse files Browse the repository at this point in the history
…ned in other subjet were not excluded from isolation Pt-sum)

- added debug output (disabled per default)
  • Loading branch information
Christian committed Nov 6, 2013
1 parent 1eb43f5 commit 749413d
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 37 deletions.
9 changes: 5 additions & 4 deletions RecoTauTag/Configuration/python/boostedHPSPFTaus_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
bottomCollection = cms.InputTag('particleFlow')
)

import RecoJets.JetProducers.ak5PFJetsPruned_cfi as boostedTaus2
##import RecoJets.JetProducers.ak5PFJetsPruned_cfi as boostedTaus2
import RecoJets.JetProducers.ak5PFJets_cfi as boostedTaus2
import RecoJets.JetProducers.CMSBoostedTauSeedingParameters_cfi as boostedTaus3
ca8PFJetsCHSprunedForBoostedTaus = boostedTaus2.ak5PFJetsPruned.clone(
##ca8PFJetsCHSprunedForBoostedTaus = boostedTaus2.ak5PFJetsPruned.clone(
ca8PFJetsCHSprunedForBoostedTaus = boostedTaus2.ak5PFJets.clone(
boostedTaus3.CMSBoostedTauSeedingParameters,
src = cms.InputTag('pfNoPileUpForBoostedTaus'),
jetPtMin = cms.double(10.0),
Expand All @@ -39,14 +41,13 @@

from RecoTauTag.Configuration.RecoPFTauTag_cff import *
recoTauAK5PFJets08Region.src = cms.InputTag('boostedTauSeeds')
recoTauAK5PFJets08Region.src = cms.InputTag('boostedTauSeeds')
recoTauAK5PFJets08Region.pfCandSrc = cms.InputTag('pfNoPileUpForBoostedTaus')
recoTauAK5PFJets08Region.pfCandAssocMapSrc = cms.InputTag('boostedTauSeeds', 'pfCandAssocMapForIsolation')

ak5PFJetsLegacyHPSPiZeros.jetSrc = cms.InputTag('boostedTauSeeds')

ak5PFJetsRecoTauChargedHadrons.jetSrc = cms.InputTag('boostedTauSeeds')
ak5PFJetsRecoTauChargedHadrons.builders[1].dRcone = cms.double(1.2)
ak5PFJetsRecoTauChargedHadrons.builders[1].dRcone = cms.double(0.3)
ak5PFJetsRecoTauChargedHadrons.builders[1].dRconeLimitedToJetArea = cms.bool(True)

combinatoricRecoTaus.jetSrc = cms.InputTag('boostedTauSeeds')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ RecoTauBuilderCombinatoricPlugin::operator()(
{
if ( verbosity_ ) {
std::cout << "<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
std::cout << " processing jet: Pt = " << jet->pt() << ", eta = " << jet->eta() << ", phi = " << jet->eta() << ","
<< " mass = " << jet->mass() << ", area = " << jet->jetArea() << std::endl;
}

// Define output.
Expand Down
7 changes: 7 additions & 0 deletions RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ namespace
assert(tauRef_.key() == idx_);
std::cout << " Pt = " << tauRef_->pt() << ", eta = " << tauRef_->eta() << ", phi = " << tauRef_->phi() << ", mass = " << tauRef_->mass() << " (decayMode = " << tauRef_->decayMode() << ")";
std::cout << std::endl;
std::cout << "associated jet:";
if ( tauRef_->jetRef().isNonnull() ) {
std::cout << " Pt = " << tauRef_->jetRef()->pt() << ", eta = " << tauRef_->jetRef()->eta() << ", phi = " << tauRef_->jetRef()->phi()
<< ", mass = " << tauRef_->jetRef()->mass() << ", area = " << tauRef_->jetRef()->jetArea();
}
else std::cout << " N/A";
std::cout << std::endl;
const std::vector<reco::PFRecoTauChargedHadron>& signalTauChargedHadronCandidates = tauRef_->signalTauChargedHadronCandidates();
size_t numChargedHadrons = signalTauChargedHadronCandidates.size();
for ( size_t iChargedHadron = 0; iChargedHadron < numChargedHadrons; ++iChargedHadron ) {
Expand Down
89 changes: 61 additions & 28 deletions RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,56 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

class RecoTauJetRegionProducer : public edm::EDProducer {
public:
typedef edm::Association<reco::PFJetCollection> PFJetMatchMap;
explicit RecoTauJetRegionProducer(const edm::ParameterSet& pset);
~RecoTauJetRegionProducer() {}
void produce(edm::Event& evt, const edm::EventSetup& es);
private:
float deltaR2_;
edm::InputTag inputJets_;
edm::InputTag pfCandSrc_;
edm::InputTag pfCandAssocMapSrc_;
#include <string>
#include <iostream>

class RecoTauJetRegionProducer : public edm::EDProducer
{
public:
typedef edm::Association<reco::PFJetCollection> PFJetMatchMap;

explicit RecoTauJetRegionProducer(const edm::ParameterSet& pset);
~RecoTauJetRegionProducer() {}

void produce(edm::Event& evt, const edm::EventSetup& es);

private:
std::string moduleLabel_;

edm::InputTag inputJets_;
edm::InputTag pfCandSrc_;
edm::InputTag pfCandAssocMapSrc_;

double deltaR2_;

int verbosity_;
};

RecoTauJetRegionProducer::RecoTauJetRegionProducer(
const edm::ParameterSet& pset) {
deltaR2_ = pset.getParameter<double>("deltaR"); deltaR2_*=deltaR2_;
inputJets_ = pset.getParameter<edm::InputTag>("src");
pfCandSrc_ = pset.getParameter<edm::InputTag>("pfCandSrc");
pfCandAssocMapSrc_ = pset.getParameter<edm::InputTag>("pfCandAssocMapSrc");
RecoTauJetRegionProducer::RecoTauJetRegionProducer(const edm::ParameterSet& cfg)
: moduleLabel_(cfg.getParameter<std::string>("@module_label"))
{
inputJets_ = cfg.getParameter<edm::InputTag>("src");
pfCandSrc_ = cfg.getParameter<edm::InputTag>("pfCandSrc");
pfCandAssocMapSrc_ = cfg.getParameter<edm::InputTag>("pfCandAssocMapSrc");

double deltaR = cfg.getParameter<double>("deltaR");
deltaR2_ = deltaR*deltaR;

verbosity_ = ( cfg.exists("verbosity") ) ?
cfg.getParameter<int>("verbosity") : 0;

produces<reco::PFJetCollection>("jets");
produces<PFJetMatchMap>();
}

void RecoTauJetRegionProducer::produce(edm::Event& evt,
const edm::EventSetup& es) {
void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& es)
{
if ( verbosity_ ) {
std::cout << "<RecoTauJetRegionProducer::produce (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
std::cout << " inputJets = " << inputJets_ << std::endl;
std::cout << " pfCandSrc = " << pfCandSrc_ << std::endl;
std::cout << " pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl;
}

edm::Handle<reco::PFCandidateCollection> pfCandsHandle;
evt.getByLabel(pfCandSrc_, pfCandsHandle);
Expand All @@ -59,16 +84,15 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt,
typedef edm::Ptr<reco::PFCandidate> PFCandPtr;
std::vector<PFCandPtr> pfCands;
pfCands.reserve(pfCandsHandle->size());
for (size_t icand = 0; icand < pfCandsHandle->size(); ++icand) {
for ( size_t icand = 0; icand < pfCandsHandle->size(); ++icand ) {
pfCands.push_back(PFCandPtr(pfCandsHandle, icand));
}

// Get the jets
edm::Handle<reco::CandidateView> jetView;
evt.getByLabel(inputJets_, jetView);
// Convert to a vector of PFJetRefs
reco::PFJetRefVector jets =
reco::tau::castView<reco::PFJetRefVector>(jetView);
reco::PFJetRefVector jets = reco::tau::castView<reco::PFJetRefVector>(jetView);
size_t nJets = jets.size();

// Get the association map matching jets to PFCandidates
Expand All @@ -86,7 +110,7 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt,
size_t nOriginalJets = 0;
// We have to make sure that we have some selected jets, otherwise we don't
// actually have a valid product ID to the original jets.
if (nJets) {
if ( nJets ) {
try {
evt.get(originalId, originalJets);
} catch(const cms::Exception &e) {
Expand All @@ -105,7 +129,7 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt,
// -1 indicates no match.
std::vector<int> matchInfo(nOriginalJets, -1);
newJets->reserve(nJets);
for (size_t ijet = 0; ijet < nJets; ++ijet) {
for ( size_t ijet = 0; ijet < nJets; ++ijet ) {
// Get a ref to jet
reco::PFJetRef jetRef = jets[ijet];
// Make an initial copy.
Expand All @@ -129,20 +153,29 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt,
} else {
isMappedToJet = true;
}
if ( reco::deltaR2(*jetRef, **pfCand) < deltaR2_ ) newJet.addDaughter(*pfCand);
if ( reco::deltaR2(*jetRef, **pfCand) < deltaR2_ && isMappedToJet ) newJet.addDaughter(*pfCand);
}
if ( verbosity_ ) {
std::cout << "jet #" << ijet << ": Pt = " << jetRef->pt() << ", eta = " << jetRef->eta() << ", phi = " << jetRef->eta() << ","
<< " mass = " << jetRef->mass() << ", area = " << jetRef->jetArea() << std::endl;
std::vector<reco::PFCandidatePtr> jetConstituents = newJet.getPFConstituents();
int idx = 0;
for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
jetConstituent != jetConstituents.end(); ++jetConstituent ) {
std::cout << " constituent #" << idx << ": Pt = " << (*jetConstituent)->pt() << ", eta = " << (*jetConstituent)->eta() << ", phi = " << (*jetConstituent)->phi() << std::endl;
}
}
// Match the index of the jet we just made to the index into the original
// collection.
matchInfo[jetRef.key()] = ijet;
}

// Put our new jets into the event
edm::OrphanHandle<reco::PFJetCollection> newJetsInEvent =
evt.put(newJets, "jets");
edm::OrphanHandle<reco::PFJetCollection> newJetsInEvent = evt.put(newJets, "jets");

// Create a matching between original jets -> extra collection
std::auto_ptr<PFJetMatchMap> matching(new PFJetMatchMap(newJetsInEvent));
if (nJets) {
if ( nJets ) {
PFJetMatchMap::Filler filler(*matching);
filler.insert(originalJets, matchInfo.begin(), matchInfo.end());
filler.fill();
Expand Down
2 changes: 1 addition & 1 deletion RecoTauTag/RecoTau/plugins/RecoTauProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset)
}
}
buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");

produces<reco::PFTauCollection>();
}

Expand Down Expand Up @@ -146,7 +147,6 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es)

// Loop over the jets and build the taus for each jet
BOOST_FOREACH( reco::PFJetRef jetRef, jets ) {
if ( !(jetRef->nConstituents() >= 1 && jetRef->pt() > 1.) ) continue; // CV: skip pathological cases
// Get the jet with extra constituents from an area around the jet
reco::PFJetRef jetRegionRef = (*jetRegionHandle)[jetRef];
if ( jetRegionRef.isNull() ) {
Expand Down
2 changes: 0 additions & 2 deletions RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ std::vector<reco::PFCandidatePtr> pfChargedCands(const reco::PFJet& jet,
return output;
}



} }
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ TTree* preselectTree(TTree* inputTree, const std::string& outputTreeName,
branchEntry->branchName_ = branch->GetName();
branchEntry->branchName_and_Type_ = branch->GetTitle();
int idx = branchEntry->branchName_and_Type_.find_last_of("/");
if ( idx == (int(branchEntry->branchName_and_Type_.length()) - 2) ) {
if ( idx == (branchEntry->branchName_and_Type_.length() - 2) ) {
branchEntry->branchType_ = branchEntry->branchName_and_Type_[idx + 1];
if ( branchEntry->branchType_ == 'F' ) {
inputTree->SetBranchAddress(branchEntry->branchName_.data(), &branchEntry->valueF_);
Expand Down
2 changes: 1 addition & 1 deletion RecoTauTag/TauAnalysisTools/bin/trainTauIdMVA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int main(int argc, char* argv[])
for ( vstring::const_iterator inputVariable = inputVariables.begin();
inputVariable != inputVariables.end(); ++inputVariable ) {
int idx = inputVariable->find_last_of("/");
if ( idx == (int(inputVariable->length()) - 2) ) {
if ( idx == (inputVariable->length() - 2) ) {
std::string inputVariableName = std::string(*inputVariable, 0, idx);
char inputVariableType = (*inputVariable)[idx + 1];
factory->AddVariable(inputVariableName.data(), inputVariableType);
Expand Down

0 comments on commit 749413d

Please sign in to comment.