Skip to content

Commit

Permalink
Add option for jet tags with ID information
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin committed Apr 26, 2016
1 parent 25ea639 commit 0a298d4
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions HLTrigger/JetMET/plugins/HLTScoutingCaloProducer.cc
Expand Up @@ -47,7 +47,8 @@ class HLTScoutingCaloProducer : public edm::global::EDProducer<> {
virtual void produce(edm::StreamID sid, edm::Event & iEvent, edm::EventSetup const & setup) const override final;

const edm::EDGetTokenT<reco::CaloJetCollection> caloJetCollection_;
const edm::EDGetTokenT<reco::JetTagCollection> caloJetTagCollection_;
const edm::EDGetTokenT<reco::JetTagCollection> caloJetBTagCollection_;
const edm::EDGetTokenT<reco::JetTagCollection> caloJetIDTagCollection_;
const edm::EDGetTokenT<reco::VertexCollection> vertexCollection_;
const edm::EDGetTokenT<reco::CaloMETCollection> metCollection_;
const edm::EDGetTokenT<double> rho_;
Expand All @@ -56,22 +57,25 @@ class HLTScoutingCaloProducer : public edm::global::EDProducer<> {
const double caloJetEtaCut;

const bool doMet;
const bool doJetTags;
const bool doJetBTags;
const bool doJetIDTags;
};

//
// constructors and destructor
//
HLTScoutingCaloProducer::HLTScoutingCaloProducer(const edm::ParameterSet& iConfig):
caloJetCollection_(consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("caloJetCollection"))),
caloJetTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetTagCollection"))),
caloJetBTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetBTagCollection"))),
caloJetIDTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetIDTagCollection"))),
vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
metCollection_(consumes<reco::CaloMETCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
caloJetPtCut(iConfig.getParameter<double>("caloJetPtCut")),
caloJetEtaCut(iConfig.getParameter<double>("caloJetEtaCut")),
doMet(iConfig.getParameter<bool>("doMet")),
doJetTags(iConfig.getParameter<bool>("doJetTags"))
doJetBTags(iConfig.getParameter<bool>("doJetBTags")),
doJetIDTags(iConfig.getParameter<bool>("doJetIDTags"))
{
//register products
produces<ScoutingCaloJetCollection>();
Expand All @@ -95,23 +99,39 @@ HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm::Ev
std::auto_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
if(iEvent.getByToken(caloJetCollection_, caloJetCollection)){
//get jet tags
Handle<reco::JetTagCollection> caloJetTagCollection;
bool haveJetTags = false;
if(doJetTags && iEvent.getByToken(caloJetTagCollection_, caloJetTagCollection)){
haveJetTags = true;
Handle<reco::JetTagCollection> caloJetBTagCollection;
bool haveJetBTags = false;
if(doJetBTags && iEvent.getByToken(caloJetBTagCollection_, caloJetBTagCollection)){
haveJetBTags = true;
}
Handle<reco::JetTagCollection> caloJetIDTagCollection;
bool haveJetIDTags = false;
if(doJetIDTags && iEvent.getByToken(caloJetIDTagCollection_, caloJetIDTagCollection)){
haveJetIDTags = true;
}

for(auto &jet : *caloJetCollection){
if(jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut){
//find the jet tag corresponding to the jet
float tagValue = -20;
float minDR2 = 0.01;
if(haveJetTags){
for(auto &tag : *caloJetTagCollection){
//find the jet tag(s) corresponding to the jet
float bTagValue = -20;
float bTagMinDR2 = 0.01;
if(haveJetBTags){
for(auto &tag : *caloJetBTagCollection){
float dR2 = reco::deltaR2(jet, *(tag.first));
if(dR2 < bTagMinDR2){
bTagMinDR2 = dR2;
bTagValue = tag.second;
}
}
}
float idTagValue = -20;
float idTagMinDR2 = 0.01;
if(haveJetIDTags){
for(auto &tag : *caloJetIDTagCollection){
float dR2 = reco::deltaR2(jet, *(tag.first));
if(dR2 < minDR2){
minDR2 = dR2;
tagValue = tag.second;
if(dR2 < idTagMinDR2){
idTagMinDR2 = dR2;
idTagValue = tag.second;
}
}
}
Expand All @@ -120,7 +140,7 @@ HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm::Ev
jet.jetArea(), jet.maxEInEmTowers(), jet.maxEInHadTowers(),
jet.hadEnergyInHB(), jet.hadEnergyInHE(), jet.hadEnergyInHF(),
jet.emEnergyInEB(), jet.emEnergyInEE(), jet.emEnergyInHF(),
jet.towersArea(), 0.0, tagValue
jet.towersArea(), idTagValue, bTagValue
);
}
}
Expand Down Expand Up @@ -167,14 +187,16 @@ void
HLTScoutingCaloProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("caloJetCollection",edm::InputTag("hltAK4CaloJets"));
desc.add<edm::InputTag>("caloJetTagCollection",edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo"));
desc.add<edm::InputTag>("caloJetBTagCollection",edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo"));
desc.add<edm::InputTag>("caloJetIDTagCollection",edm::InputTag("hltCaloJetFromPV"));
desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
desc.add<edm::InputTag>("metCollection", edm::InputTag("hltMet"));
desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAllCalo"));
desc.add<double>("caloJetPtCut", 20.0);
desc.add<double>("caloJetEtaCut", 3.0);
desc.add<bool>("doMet", true);
desc.add<bool>("doJetTags", false);
desc.add<bool>("doJetBTags", false);
desc.add<bool>("doJetIDTags", false);
descriptions.add("hltScoutingCaloProducer", desc);
}

Expand Down

0 comments on commit 0a298d4

Please sign in to comment.