Skip to content

Commit

Permalink
Merge pull request #31602 from denerslemos/hiHFFilter_Struct_MiniAOD_…
Browse files Browse the repository at this point in the history
…112X

Include the HF filters used in heavy ions using struct in the MiniAOD content
  • Loading branch information
cmsbuild authored Oct 9, 2020
2 parents 13818bf + e67d14c commit d7632eb
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 1 deletion.
13 changes: 13 additions & 0 deletions DataFormats/HeavyIonEvent/interface/HFFilterInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef DataFormats_HeavyIonEvent_HFFilterInfo_H
#define DataFormats_HeavyIonEvent_HFFilterInfo_H

namespace reco {
struct HFFilterInfo {
unsigned short int numMinHFTowers2;
unsigned short int numMinHFTowers3;
unsigned short int numMinHFTowers4;
unsigned short int numMinHFTowers5;
};
} // namespace reco

#endif
1 change: 1 addition & 0 deletions DataFormats/HeavyIonEvent/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "DataFormats/HeavyIonEvent/interface/ClusterCompatibility.h"
#include "DataFormats/HeavyIonEvent/interface/EvtPlane.h"
#include "DataFormats/HeavyIonEvent/interface/HeavyIon.h"
#include "DataFormats/HeavyIonEvent/interface/HFFilterInfo.h"
#include "DataFormats/HeavyIonEvent/interface/VoronoiBackground.h"

#include "DataFormats/Common/interface/Wrapper.h"
4 changes: 4 additions & 0 deletions DataFormats/HeavyIonEvent/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<version ClassVersion="10" checksum="934677092"/>
</class>
<class name="edm::Wrapper<pat::HeavyIon >" />
<class name="reco::HFFilterInfo" ClassVersion="3">
<version ClassVersion="3" checksum="3699024521"/>
</class>
<class name="edm::Wrapper<reco::HFFilterInfo>"/>
<class name="reco::VoronoiBackground" />
<class name="edm::Wrapper<reco::VoronoiBackground>"/>
<class name="edm::ValueMap<reco::VoronoiBackground>" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
'keep floatedmValueMap_lostTrackChi2_*_*',
'keep recoCentrality_hiCentrality_*_*',
'keep int_centralityBin_*_*',
'keep recoHFFilterInfo_hiHFfilters_*_*',
]
from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
from Configuration.Eras.Modifier_pp_on_PbPb_run3_cff import pp_on_PbPb_run3
Expand Down
3 changes: 2 additions & 1 deletion PhysicsTools/PatAlgos/python/slimming/slimming_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@
from PhysicsTools.PatAlgos.packedCandidateMuonID_cfi import packedCandidateMuonID
from PhysicsTools.PatAlgos.packedPFCandidateTrackChi2_cfi import packedPFCandidateTrackChi2
from RecoHI.HiCentralityAlgos.CentralityBin_cfi import centralityBin
from RecoHI.HiCentralityAlgos.hiHFfilters_cfi import hiHFfilters
lostTrackChi2 = packedPFCandidateTrackChi2.clone(candidates = "lostTracks", doLostTracks = True)
(pp_on_AA_2018 | pp_on_PbPb_run3).toReplaceWith(
slimmingTask,
cms.Task(slimmingTask.copy(), packedCandidateMuonID, packedPFCandidateTrackChi2, lostTrackChi2, centralityBin))
cms.Task(slimmingTask.copy(), packedCandidateMuonID, packedPFCandidateTrackChi2, lostTrackChi2, centralityBin, hiHFfilters))

from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing
_phase2_timing_slimmingTask = cms.Task(slimmingTask.copy(),
Expand Down
92 changes: 92 additions & 0 deletions RecoHI/HiCentralityAlgos/plugins/HiHFFilterProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

#include <memory>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"

#include "DataFormats/CaloTowers/interface/CaloTower.h"
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
#include "DataFormats/HeavyIonEvent/interface/HFFilterInfo.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescriptionFiller.h"

#include "DataFormats/Common/interface/Wrapper.h"

#include <cmath>

class HiHFFilterProducer : public edm::stream::EDProducer<> {
public:
explicit HiHFFilterProducer(const edm::ParameterSet&);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void produce(edm::Event&, const edm::EventSetup&) override;
edm::EDGetTokenT<CaloTowerCollection> srcTowers_;
};

HiHFFilterProducer::HiHFFilterProducer(const edm::ParameterSet& iConfig)
: srcTowers_(consumes<CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("srcTowers"))) {
produces<reco::HFFilterInfo>("hiHFfilters");
}

void HiHFFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace std;
using namespace edm;

auto const& towers = iEvent.get(srcTowers_);

unsigned short int nTowersTh2HFplus = 0;
unsigned short int nTowersTh2HFminus = 0;
unsigned short int nTowersTh3HFplus = 0;
unsigned short int nTowersTh3HFminus = 0;
unsigned short int nTowersTh4HFplus = 0;
unsigned short int nTowersTh4HFminus = 0;
unsigned short int nTowersTh5HFplus = 0;
unsigned short int nTowersTh5HFminus = 0;

auto hiHFFilterResults = std::make_unique<reco::HFFilterInfo>();
for (const auto& tower : towers) {
const auto et = tower.et();
const auto energy = tower.energy();
const auto eta = tower.eta();
const bool eta_plus = (eta > 3.0) && (eta < 6.0);
const bool eta_minus = (eta < -3.0) && (eta > -6.0);
if (et < 0.0)
continue;
if (eta_plus) {
nTowersTh2HFplus += energy >= 2.0 ? 1 : 0;
nTowersTh3HFplus += energy >= 3.0 ? 1 : 0;
nTowersTh4HFplus += energy >= 4.0 ? 1 : 0;
nTowersTh5HFplus += energy >= 5.0 ? 1 : 0;
} else if (eta_minus) {
nTowersTh2HFminus += energy >= 2.0 ? 1 : 0;
nTowersTh3HFminus += energy >= 3.0 ? 1 : 0;
nTowersTh4HFminus += energy >= 4.0 ? 1 : 0;
nTowersTh5HFminus += energy >= 5.0 ? 1 : 0;
}
}

hiHFFilterResults->numMinHFTowers2 = std::min(nTowersTh2HFplus, nTowersTh2HFminus);
hiHFFilterResults->numMinHFTowers3 = std::min(nTowersTh3HFplus, nTowersTh3HFminus);
hiHFFilterResults->numMinHFTowers4 = std::min(nTowersTh4HFplus, nTowersTh4HFminus);
hiHFFilterResults->numMinHFTowers5 = std::min(nTowersTh5HFplus, nTowersTh5HFminus);

iEvent.put(std::move(hiHFFilterResults), "hiHFfilters");
}

void HiHFFilterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("srcTowers", {"towerMaker"});
descriptions.addWithDefaultLabel(desc);
}

DEFINE_FWK_MODULE(HiHFFilterProducer);
5 changes: 5 additions & 0 deletions RecoHI/HiCentralityAlgos/python/hiHFfilters_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import FWCore.ParameterSet.Config as cms

from RecoHI.HiCentralityAlgos.hiHFFilterProducer_cfi import hiHFFilterProducer

hiHFfilters = hiHFFilterProducer.clone()

0 comments on commit d7632eb

Please sign in to comment.