-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resurrect the tau tag info producer and add trimmed-down dependent co…
…de that lived in the TauTagTools package
- Loading branch information
Showing
5 changed files
with
393 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef RecoTauTag_RecoTau_PFRecoTauTagInfoAlgorithm_H | ||
#define RecoTauTag_RecoTau_PFRecoTauTagInfoAlgorithm_H | ||
|
||
#include "DataFormats/TauReco/interface/PFTauTagInfo.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "Math/GenVector/VectorUtil.h" | ||
|
||
class PFRecoTauTagInfoAlgorithm { | ||
public: | ||
PFRecoTauTagInfoAlgorithm(){} | ||
PFRecoTauTagInfoAlgorithm(const edm::ParameterSet&); | ||
~PFRecoTauTagInfoAlgorithm(){} | ||
reco::PFTauTagInfo buildPFTauTagInfo(const reco::JetBaseRef&,const std::vector<reco::CandidatePtr>&,const reco::TrackRefVector&,const reco::Vertex&) const; | ||
private: | ||
double ChargedHadrCand_tkminPt_; | ||
int ChargedHadrCand_tkminPixelHitsn_; | ||
int ChargedHadrCand_tkminTrackerHitsn_; | ||
double ChargedHadrCand_tkmaxipt_; | ||
double ChargedHadrCand_tkmaxChi2_; | ||
double ChargedHadrCand_tkPVmaxDZ_; | ||
// | ||
double NeutrHadrCand_HcalclusMinEt_; | ||
// | ||
double GammaCand_EcalclusMinEt_; | ||
double ChargedHadronsAssociationCone_; | ||
// | ||
double tkminPt_; | ||
int tkminPixelHitsn_; | ||
int tkminTrackerHitsn_; | ||
double tkmaxipt_; | ||
double tkmaxChi2_; | ||
double tkPVmaxDZ_; | ||
// | ||
bool UsePVconstraint_; | ||
}; | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef RecoTauTag_RecoTau_TauTagTools_h | ||
#define RecoTauTag_RecoTau_TauTagTools_h | ||
|
||
#include "DataFormats/Candidate/interface/Candidate.h" | ||
#include "DataFormats/Candidate/interface/CandidateFwd.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
|
||
namespace TauTagTools{ | ||
reco::TrackRefVector filteredTracks(const reco::TrackRefVector& theInitialTracks, double tkminPt, int tkminPixelHitsn, int tkminTrackerHitsn, double tkmaxipt, double tkmaxChi2, const reco::Vertex& pV); | ||
reco::TrackRefVector filteredTracks(const reco::TrackRefVector& theInitialTracks, double tkminPt, int tkminPixelHitsn, int tkminTrackerHitsn, double tkmaxipt, double tkmaxChi2, double tktorefpointmaxDZ, const reco::Vertex& pV, double refpoint_Z); | ||
|
||
std::vector<reco::CandidatePtr> filteredPFChargedHadrCands(const std::vector<reco::CandidatePtr>& theInitialPFCands, double ChargedHadrCand_tkminPt, int ChargedHadrCand_tkminPixelHitsn, int ChargedHadrCand_tkminTrackerHitsn, double ChargedHadrCand_tkmaxipt, double ChargedHadrCand_tkmaxChi2, const reco::Vertex& pV); | ||
std::vector<reco::CandidatePtr> filteredPFChargedHadrCands(const std::vector<reco::CandidatePtr>& theInitialPFCands, double ChargedHadrCand_tkminPt, int ChargedHadrCand_tkminPixelHitsn, int ChargedHadrCand_tkminTrackerHitsn, double ChargedHadrCand_tkmaxipt, double ChargedHadrCand_tkmaxChi2, double ChargedHadrCand_tktorefpointmaxDZ, const reco::Vertex& pV, double refpoint_Z); | ||
std::vector<reco::CandidatePtr> filteredPFNeutrHadrCands(const std::vector<reco::CandidatePtr>& theInitialPFCands, double NeutrHadrCand_HcalclusMinEt); | ||
std::vector<reco::CandidatePtr> filteredPFGammaCands(const std::vector<reco::CandidatePtr>& theInitialPFCands, double GammaCand_EcalclusMinEt); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
/* class PFRecoTauTagInfoProducer | ||
* returns a PFTauTagInfo collection starting from a JetTrackAssociations <a PFJet,a list of Tracks> collection, | ||
* created: Aug 28 2007, | ||
* revised: , | ||
* authors: Ludovic Houchu | ||
*/ | ||
|
||
#include "DataFormats/JetReco/interface/JetTracksAssociation.h" | ||
#include "DataFormats/TauReco/interface/PFTauTagInfo.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
|
||
#include "RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h" | ||
|
||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/global/EDProducer.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
#include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h> | ||
#include <FWCore/ParameterSet/interface/ParameterSetDescription.h> | ||
|
||
#include "CLHEP/Random/RandGauss.h" | ||
|
||
#include "Math/GenVector/VectorUtil.h" | ||
|
||
#include <memory> | ||
|
||
using namespace reco; | ||
using namespace edm; | ||
using namespace std; | ||
|
||
class PFRecoTauTagInfoProducer : public edm::global::EDProducer<> { | ||
public: | ||
explicit PFRecoTauTagInfoProducer(const edm::ParameterSet& iConfig); | ||
~PFRecoTauTagInfoProducer() override; | ||
void produce(edm::StreamID, edm::Event&,const edm::EventSetup&) const override; | ||
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); | ||
private: | ||
std::unique_ptr<const PFRecoTauTagInfoAlgorithm> PFRecoTauTagInfoAlgo_; | ||
edm::InputTag PFCandidateProducer_; | ||
edm::InputTag PFJetTracksAssociatorProducer_; | ||
edm::InputTag PVProducer_; | ||
double smearedPVsigmaX_; | ||
double smearedPVsigmaY_; | ||
double smearedPVsigmaZ_; | ||
|
||
edm::EDGetTokenT<PFCandidateCollection> PFCandidate_token; | ||
edm::EDGetTokenT<JetTracksAssociationCollection> PFJetTracksAssociator_token; | ||
edm::EDGetTokenT<VertexCollection> PV_token; | ||
}; | ||
|
||
PFRecoTauTagInfoProducer::PFRecoTauTagInfoProducer(const edm::ParameterSet& iConfig){ | ||
|
||
PFCandidateProducer_ = iConfig.getParameter<edm::InputTag>("PFCandidateProducer"); | ||
PFJetTracksAssociatorProducer_ = iConfig.getParameter<edm::InputTag>("PFJetTracksAssociatorProducer"); | ||
PVProducer_ = iConfig.getParameter<edm::InputTag>("PVProducer"); | ||
smearedPVsigmaX_ = iConfig.getParameter<double>("smearedPVsigmaX"); | ||
smearedPVsigmaY_ = iConfig.getParameter<double>("smearedPVsigmaY"); | ||
smearedPVsigmaZ_ = iConfig.getParameter<double>("smearedPVsigmaZ"); | ||
PFRecoTauTagInfoAlgo_.reset( new PFRecoTauTagInfoAlgorithm(iConfig) ); | ||
PFCandidate_token = consumes<PFCandidateCollection>(PFCandidateProducer_); | ||
PFJetTracksAssociator_token = consumes<JetTracksAssociationCollection>(PFJetTracksAssociatorProducer_); | ||
PV_token = consumes<VertexCollection>(PVProducer_); | ||
produces<PFTauTagInfoCollection>(); | ||
} | ||
PFRecoTauTagInfoProducer::~PFRecoTauTagInfoProducer(){ | ||
} | ||
|
||
void PFRecoTauTagInfoProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { | ||
edm::Handle<JetTracksAssociationCollection> thePFJetTracksAssociatorCollection; | ||
iEvent.getByToken(PFJetTracksAssociator_token,thePFJetTracksAssociatorCollection); | ||
// *** access the PFCandidateCollection in the event in order to retrieve the PFCandidateRefVector which constitutes each PFJet | ||
edm::Handle<PFCandidateCollection> thePFCandidateCollection; | ||
iEvent.getByToken(PFCandidate_token,thePFCandidateCollection); | ||
vector<CandidatePtr> thePFCandsInTheEvent; | ||
for(unsigned int i_PFCand=0;i_PFCand!=thePFCandidateCollection->size();i_PFCand++) { | ||
thePFCandsInTheEvent.push_back(CandidatePtr(thePFCandidateCollection,i_PFCand)); | ||
} | ||
// *** | ||
// query a rec/sim PV | ||
edm::Handle<VertexCollection> thePVs; | ||
iEvent.getByToken(PV_token,thePVs); | ||
const VertexCollection vertCollection=*(thePVs.product()); | ||
math::XYZPoint V(0,0,-1000.); | ||
|
||
Vertex thePV; | ||
if(!vertCollection.empty()) thePV =*(vertCollection.begin()); | ||
else{ | ||
Vertex::Error SimPVError; | ||
SimPVError(0,0)=15.*15.; | ||
SimPVError(1,1)=15.*15.; | ||
SimPVError(2,2)=15.*15.; | ||
Vertex::Point SimPVPoint(0.,0.,-1000.); | ||
thePV=Vertex(SimPVPoint,SimPVError,1,1,1); | ||
} | ||
|
||
auto resultExt = std::make_unique<PFTauTagInfoCollection>(); | ||
for(JetTracksAssociationCollection::const_iterator iAssoc=thePFJetTracksAssociatorCollection->begin();iAssoc!=thePFJetTracksAssociatorCollection->end();iAssoc++){ | ||
PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo(JetBaseRef((*iAssoc).first),thePFCandsInTheEvent,(*iAssoc).second,thePV); | ||
resultExt->push_back(myPFTauTagInfo); | ||
} | ||
|
||
|
||
// OrphanHandle<PFTauTagInfoCollection> myPFTauTagInfoCollection=iEvent.put(std::move(resultExt)); | ||
iEvent.put(std::move(resultExt)); | ||
} | ||
|
||
void | ||
PFRecoTauTagInfoProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
{ | ||
// pfRecoTauTagInfoProducerInsideOut | ||
edm::ParameterSetDescription desc; | ||
desc.add<int>("tkminTrackerHitsn", 3); | ||
desc.add<double>("tkminPt", 0.5); | ||
desc.add<double>("tkmaxChi2", 100.0); | ||
desc.add<double>("ChargedHadrCand_AssociationCone", 1.0); | ||
desc.add<int>("ChargedHadrCand_tkminTrackerHitsn", 3); | ||
desc.add<double>("ChargedHadrCand_tkmaxChi2", 100.0); | ||
desc.add<double>("tkPVmaxDZ", 0.2); | ||
desc.add<double>("GammaCand_EcalclusMinEt", 1.0); | ||
desc.add<int>("tkminPixelHitsn", 0); | ||
desc.add<edm::InputTag>("PVProducer", edm::InputTag("offlinePrimaryVertices")); | ||
desc.add<edm::InputTag>("PFCandidateProducer", edm::InputTag("particleFlow")); | ||
desc.add<double>("ChargedHadrCand_tkminPt", 0.5); | ||
desc.add<double>("ChargedHadrCand_tkmaxipt", 0.03); | ||
desc.add<int>("ChargedHadrCand_tkminPixelHitsn", 0); | ||
desc.add<bool>("UsePVconstraint", true); | ||
desc.add<double>("NeutrHadrCand_HcalclusMinEt", 1.0); | ||
desc.add<edm::InputTag>("PFJetTracksAssociatorProducer", edm::InputTag("insideOutJetTracksAssociatorAtVertex")); | ||
desc.add<double>("smearedPVsigmaY", 0.0015); | ||
desc.add<double>("smearedPVsigmaX", 0.0015); | ||
desc.add<double>("smearedPVsigmaZ", 0.005); | ||
desc.add<double>("ChargedHadrCand_tkPVmaxDZ", 0.2); | ||
desc.add<double>("tkmaxipt", 0.03); | ||
descriptions.add("pfRecoTauTagInfoProducerInsideOut", desc); | ||
} | ||
{ | ||
// pfRecoTauTagInfoProducer | ||
edm::ParameterSetDescription desc; | ||
desc.add<int>("tkminTrackerHitsn", 3); | ||
desc.add<double>("tkminPt", 0.5); | ||
desc.add<double>("tkmaxChi2", 100.0); | ||
desc.add<double>("ChargedHadrCand_AssociationCone", 0.8); | ||
desc.add<int>("ChargedHadrCand_tkminTrackerHitsn", 3); | ||
desc.add<double>("ChargedHadrCand_tkmaxChi2", 100.0); | ||
desc.add<double>("tkPVmaxDZ", 0.2); | ||
desc.add<double>("GammaCand_EcalclusMinEt", 1.0); | ||
desc.add<int>("tkminPixelHitsn", 0); | ||
desc.add<edm::InputTag>("PVProducer", edm::InputTag("offlinePrimaryVertices")); | ||
desc.add<edm::InputTag>("PFCandidateProducer", edm::InputTag("particleFlow")); | ||
desc.add<double>("ChargedHadrCand_tkminPt", 0.5); | ||
desc.add<double>("ChargedHadrCand_tkmaxipt", 0.03); | ||
desc.add<int>("ChargedHadrCand_tkminPixelHitsn", 0); | ||
desc.add<bool>("UsePVconstraint", true); | ||
desc.add<double>("NeutrHadrCand_HcalclusMinEt", 1.0); | ||
desc.add<edm::InputTag>("PFJetTracksAssociatorProducer", edm::InputTag("ak4PFJetTracksAssociatorAtVertex")); | ||
desc.add<double>("smearedPVsigmaY", 0.0015); | ||
desc.add<double>("smearedPVsigmaX", 0.0015); | ||
desc.add<double>("smearedPVsigmaZ", 0.005); | ||
desc.add<double>("ChargedHadrCand_tkPVmaxDZ", 0.2); | ||
desc.add<double>("tkmaxipt", 0.03); | ||
descriptions.add("pfRecoTauTagInfoProducer", desc); | ||
} | ||
} | ||
|
||
DEFINE_FWK_MODULE(PFRecoTauTagInfoProducer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h" | ||
|
||
#include "DataFormats/Math/interface/deltaR.h" | ||
#include "RecoTauTag/RecoTau/interface/TauTagTools.h" | ||
|
||
using namespace reco; | ||
|
||
PFRecoTauTagInfoAlgorithm::PFRecoTauTagInfoAlgorithm(const edm::ParameterSet& parameters){ | ||
// parameters of the considered charged hadr. PFCandidates, based on their rec. tk properties : | ||
ChargedHadronsAssociationCone_ = parameters.getParameter<double>("ChargedHadrCand_AssociationCone"); | ||
ChargedHadrCand_tkminPt_ = parameters.getParameter<double>("ChargedHadrCand_tkminPt"); | ||
ChargedHadrCand_tkminPixelHitsn_ = parameters.getParameter<int>("ChargedHadrCand_tkminPixelHitsn"); | ||
ChargedHadrCand_tkminTrackerHitsn_ = parameters.getParameter<int>("ChargedHadrCand_tkminTrackerHitsn"); | ||
ChargedHadrCand_tkmaxipt_ = parameters.getParameter<double>("ChargedHadrCand_tkmaxipt"); | ||
ChargedHadrCand_tkmaxChi2_ = parameters.getParameter<double>("ChargedHadrCand_tkmaxChi2"); | ||
// parameters of the considered neutral hadr. PFCandidates, based on their rec. HCAL clus. properties : | ||
NeutrHadrCand_HcalclusMinEt_ = parameters.getParameter<double>("NeutrHadrCand_HcalclusMinEt"); | ||
// parameters of the considered gamma PFCandidates, based on their rec. ECAL clus. properties : | ||
GammaCand_EcalclusMinEt_ = parameters.getParameter<double>("GammaCand_EcalclusMinEt"); | ||
// parameters of the considered rec. Tracks (these ones catched through a JetTracksAssociation object, not through the charged hadr. PFCandidates inside the PFJet ; the motivation for considering them is the need for checking that a selection by the charged hadr. PFCandidates is equivalent to a selection by the rec. Tracks.) : | ||
tkminPt_ = parameters.getParameter<double>("tkminPt"); | ||
tkminPixelHitsn_ = parameters.getParameter<int>("tkminPixelHitsn"); | ||
tkminTrackerHitsn_ = parameters.getParameter<int>("tkminTrackerHitsn"); | ||
tkmaxipt_ = parameters.getParameter<double>("tkmaxipt"); | ||
tkmaxChi2_ = parameters.getParameter<double>("tkmaxChi2"); | ||
// | ||
UsePVconstraint_ = parameters.getParameter<bool>("UsePVconstraint"); | ||
ChargedHadrCand_tkPVmaxDZ_ = parameters.getParameter<double>("ChargedHadrCand_tkPVmaxDZ"); | ||
tkPVmaxDZ_ = parameters.getParameter<double>("tkPVmaxDZ"); | ||
} | ||
|
||
PFTauTagInfo PFRecoTauTagInfoAlgorithm::buildPFTauTagInfo(const JetBaseRef& thePFJet,const std::vector<reco::CandidatePtr>& thePFCandsInEvent, const TrackRefVector& theTracks,const Vertex& thePV) const { | ||
PFTauTagInfo resultExtended; | ||
resultExtended.setpfjetRef(thePFJet); | ||
|
||
std::vector<reco::CandidatePtr> thePFCands; | ||
const float jetPhi = (*thePFJet).phi(); | ||
const float jetEta = (*thePFJet).eta(); | ||
auto dr2 = [jetPhi,jetEta](float phi, float eta) { return reco::deltaR2(jetEta,jetPhi,eta,phi);}; | ||
for (auto iPFCand : thePFCandsInEvent){ | ||
float delta = dr2((*iPFCand).phi(),(*iPFCand).eta()); | ||
if (delta < ChargedHadronsAssociationCone_*ChargedHadronsAssociationCone_) thePFCands.push_back(iPFCand); | ||
} | ||
bool pvIsFake = (thePV.z() < -500.); | ||
|
||
std::vector<reco::CandidatePtr> theFilteredPFChargedHadrCands; | ||
if (UsePVconstraint_ && !pvIsFake) theFilteredPFChargedHadrCands=TauTagTools::filteredPFChargedHadrCands(thePFCands,ChargedHadrCand_tkminPt_,ChargedHadrCand_tkminPixelHitsn_,ChargedHadrCand_tkminTrackerHitsn_,ChargedHadrCand_tkmaxipt_,ChargedHadrCand_tkmaxChi2_,ChargedHadrCand_tkPVmaxDZ_, thePV, thePV.z()); | ||
else theFilteredPFChargedHadrCands=TauTagTools::filteredPFChargedHadrCands(thePFCands,ChargedHadrCand_tkminPt_,ChargedHadrCand_tkminPixelHitsn_,ChargedHadrCand_tkminTrackerHitsn_,ChargedHadrCand_tkmaxipt_,ChargedHadrCand_tkmaxChi2_, thePV); | ||
resultExtended.setPFChargedHadrCands(theFilteredPFChargedHadrCands); | ||
resultExtended.setPFNeutrHadrCands(TauTagTools::filteredPFNeutrHadrCands(thePFCands,NeutrHadrCand_HcalclusMinEt_)); | ||
resultExtended.setPFGammaCands(TauTagTools::filteredPFGammaCands(thePFCands,GammaCand_EcalclusMinEt_)); | ||
|
||
TrackRefVector theFilteredTracks; | ||
if (UsePVconstraint_ && !pvIsFake) theFilteredTracks=TauTagTools::filteredTracks(theTracks,tkminPt_,tkminPixelHitsn_,tkminTrackerHitsn_,tkmaxipt_,tkmaxChi2_,tkPVmaxDZ_,thePV, thePV.z()); | ||
else theFilteredTracks=TauTagTools::filteredTracks(theTracks,tkminPt_,tkminPixelHitsn_,tkminTrackerHitsn_,tkmaxipt_,tkmaxChi2_,thePV); | ||
resultExtended.setTracks(theFilteredTracks); | ||
|
||
return resultExtended; | ||
} | ||
|
Oops, something went wrong.