Skip to content

Commit

Permalink
Merge pull request #74 from steggema/TauRecoMiniAODSinglePFTauClass_10X
Browse files Browse the repository at this point in the history
Tau reco mini aod single pf tau class 10 x
  • Loading branch information
roger-wolf authored Mar 13, 2018
2 parents 1379757 + 95d5cef commit 4bdc092
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 44 deletions.
33 changes: 4 additions & 29 deletions PhysicsTools/PatAlgos/plugins/PATTauProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,13 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
else{
const pat::PackedCandidate* packedCandPtr = dynamic_cast<const pat::PackedCandidate*>(it.get());
if(packedCandPtr != nullptr) {
//position at ECAL entrance can be recomputed, but individual ECAL and HCAL energies not
//ecalEnergy += packedCandPtr->ecalEnergy();
//hcalEnergy += packedCandPtr->hcalEnergy();
//sumPhiTimesEnergy += packedCandPtr->positionAtECALEntrance().phi()*packedCandPtr->energy();
//sumEtaTimesEnergy += packedCandPtr->positionAtECALEntrance().eta()*packedCandPtr->energy();
// TauReco@MiniAOD: individual ECAL and HCAL energies currently not available for PackedCandidates
// (see above implementation for PFCandidates).
// Should be added if available, as well as on-the-fly computation of position at ECAL entrance
sumEnergy += packedCandPtr->energy();
const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr;
if( track != nullptr ) {
if( track->pt() > leadChargedCandPt ) {
//leadChargedCandEtaAtEcalEntrance = packedCandPtr->positionAtECALEntrance().eta();
leadChargedCandPt = track->pt();
}
}
Expand Down Expand Up @@ -473,32 +470,10 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
else {
const pat::PackedCandidate* packedCandPtr = dynamic_cast<const pat::PackedCandidate*>(leadingPFCharged.get());
if (packedCandPtr != nullptr) {
//individual ECAL and HCAL energies not available with packedCandPtridates
//ecalEnergyLeadChargedHadrCand = packedCandPtr->ecalEnergy();
//hcalEnergyLeadChargedHadrCand = packedCandPtr->hcalEnergy();
// TauReco@MiniAOD: Update code below if ecal/hcal energies are available.
const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr;
if (track != nullptr) {
leadingTrackNormChi2 = track->normalizedChi2();
//individual ECAL and HCAL energies not available with packedCandidates
/*
for(const auto& tauIt : pfTauRef->isolationPFCands()){
const pat::PackedCandidate* packedPtr = dynamic_cast<const pat::PackedCandidate*>(tauIt.get());
if(packedPtr != nullptr) {
myHCALenergy += packedPtr->hcalEnergy();
myECALenergy += packedPtr->ecalEnergy();
}
}
for(const auto& tauIt : pfTauRef->signalPFCands()){
const pat::PackedCandidate* packedPtr = dynamic_cast<const pat::PackedCandidate*>(tauIt.get());
if(packedPtr != nullptr) {
myHCALenergy += packedPtr->hcalEnergy();
myECALenergy += packedPtr->ecalEnergy();
}
}
if( myHCALenergy + myECALenergy > 0. ) {
emFraction = myECALenergy/( myHCALenergy + myECALenergy);
}
*/
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TauIdMVAAuxiliaries {
EcalEnInSignalPFCands += pfcand->ecalEnergy();
HcalEnInSignalPFCands += pfcand->hcalEnergy();
}
// JAN - FIXME: not calculated for PackedCandidate
// TauReco@MiniAOD: recalculate for PackedCandidate if added to MiniAOD event content
}
float total = EcalEnInSignalPFCands + HcalEnInSignalPFCands;
if(total == 0.){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,15 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF
else algo = PFRecoTauChargedHadron::kPFNeutralHadron;
std::auto_ptr<PFRecoTauChargedHadron> chargedHadron(new PFRecoTauChargedHadron(**cand, algo));

// JAN - work on this. This must be adapted carefully to MiniAOD packed candidates
const reco::PFCandidate* pfCand = dynamic_cast<const reco::PFCandidate*>(&**cand);
if (pfCand) {
if ( pfCand->trackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->trackRef());
else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->innerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->innerTrack());
else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->globalTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->globalTrack());
else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->outerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->outerTrack());
else if ( pfCand->gsfTrackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->gsfTrackRef());


}
} // TauReco@MiniAOD: Tracks only available dynamically, so no possiblity to save ref here; checked by code downstream

chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand, bField_);
chargedHadron->chargedPFCandidate_ = (*cand);
chargedHadron->addDaughter(*cand);
Expand Down Expand Up @@ -238,7 +236,7 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF
maxUnmatchedBlockElements = maxUnmatchedBlockElementsPhoton_;
minMergeEt = minMergeGammaEt_;
}
// JAN - FIXME - block matching possible in miniAOD? probably not?? but is it important after all?
// TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact
const reco::PFCandidate* pfCHCand = dynamic_cast<const reco::PFCandidate*>(&*chargedHadron->chargedPFCandidate_);
const reco::PFCandidate* pfJetConstituent = dynamic_cast<const reco::PFCandidate*>(&**jetConstituent);
if (pfCHCand && pfJetConstituent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p
const reco::PFCandidate* pflch = dynamic_cast<const reco::PFCandidate*>(pfLeadChargedHadron.get());
if (pflch != nullptr) {
reco::MuonRef muonRef = pflch->muonRef();
if (muonRef.isNonnull() && muon == pflch->muonRef() )
if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; }
continue;
if (muonRef.isNonnull() && muon == pflch->muonRef() ) {
if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; }
continue;
}
} else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n";
}
double dR = deltaR(muon->p4(), pfTau->p4());
Expand Down
3 changes: 1 addition & 2 deletions RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const
<< " HCAL = " << (pfCand)->hcalEnergy() << ","
<< " HO = " << (pfCand)->hoEnergy() << std::endl;
}
// JAN - FIXME - this info is not readily available in miniAOD
// This means this sub-algo is currently broken
// TauReco@MiniAOD: This info is not yet available in miniAOD.
if ( edm::isFinite(pfCand->ecalEnergy()) ) allNeutralsSumEn += pfCand->ecalEnergy();
if ( edm::isFinite(pfCand->hcalEnergy()) ) allNeutralsSumEn += pfCand->hcalEnergy();
if ( edm::isFinite(pfCand->hoEnergy()) ) allNeutralsSumEn += pfCand->hoEnergy();
Expand Down
1 change: 0 additions & 1 deletion RecoTauTag/RecoTau/plugins/RecoTauProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es)
builder != builders_.end(); ++builder) {
// Get a ptr_vector of taus from the builder
reco::tau::RecoTauBuilderPlugin::output_type taus((*builder)(jetRef, chargedHadrons, piZeros, uniqueRegionalCands));
// JAN - convert reco::Jet ref to PFJet ref (only in direct interaction with PFTau)

// Make sure all taus have their jetref set correctly
std::for_each(taus.begin(), taus.end(), boost::bind(&reco::PFTau::setjetRef, _1, reco::JetBaseRef(jetRef)));
Expand Down
5 changes: 2 additions & 3 deletions RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ namespace {

inline const reco::TrackBaseRef getTrackRef(const Candidate& cand)
{
// TauReco@MiniAOD: This version does not work on top of MiniAOD, however,
// it is only used for non-default track-vertex associations
const PFCandidate* pfCandPtr = dynamic_cast<const PFCandidate*>(&cand);
if (pfCandPtr != nullptr) {
if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef());
else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef());
else return reco::TrackBaseRef();
}

// FIXME - JAN - should put an error message somewhere that we use an algo that
// is not supported for PackedCandidates

return reco::TrackBaseRef();
}
}
Expand Down

0 comments on commit 4bdc092

Please sign in to comment.