Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the HF Filters in Heavy Ions miniAOD #30810

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@

_pp_on_AA_extraCommands = [
'keep patPackedCandidates_hiPixelTracks_*_*',
'keep ints_hiHFfilters_*_*',
'keep *_packedCandidateMuonID_*_*'
]
from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
Expand Down
3 changes: 3 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimming_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
from PhysicsTools.PatAlgos.packedCandidateMuonID_cfi import packedCandidateMuonID
(pp_on_AA_2018 | pp_on_PbPb_run3).toReplaceWith(slimmingTask, cms.Task(slimmingTask.copy(), packedCandidateMuonID))

from RecoHI.HiCentralityAlgos.HiHFFilterProducer_cfi import hiHFfilters
(pp_on_AA_2018 | pp_on_PbPb_run3).toReplaceWith(slimmingTask, cms.Task(slimmingTask.copy(), hiHFfilters))

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

#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 "RecoLocalCalo/CaloTowersCreator/src/CaloTowerCandidateCreator.h"
#include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
#include "DataFormats/CaloTowers/interface/CaloTower.h"
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.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 <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<std::vector<int>>("hiHFfilters");
}

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

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

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

std::size_t size = 4;
auto hiHFfiltersOut = std::make_unique<std::vector<int>>(size);

for (unsigned int towerIndx = 0; towerIndx < towers->size(); ++towerIndx) {
const CaloTower& tower = (*towers)[towerIndx];
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) {
if (energy >= 2.0)
nTowersTh2HFplus += 1;
if (energy >= 3.0)
nTowersTh3HFplus += 1;
if (energy >= 4.0)
nTowersTh4HFplus += 1;
if (energy >= 5.0)
nTowersTh5HFplus += 1;
} else if (eta_minus) {
if (energy >= 2.0)
nTowersTh2HFminus += 1;
if (energy >= 3.0)
nTowersTh3HFminus += 1;
if (energy >= 4.0)
nTowersTh4HFminus += 1;
if (energy >= 5.0)
nTowersTh5HFminus += 1;
}
}

(*hiHFfiltersOut)[0] = std::min(nTowersTh2HFplus, nTowersTh2HFminus);
(*hiHFfiltersOut)[1] = std::min(nTowersTh3HFplus, nTowersTh3HFminus);
(*hiHFfiltersOut)[2] = std::min(nTowersTh4HFplus, nTowersTh4HFminus);
(*hiHFfiltersOut)[3] = std::min(nTowersTh5HFplus, nTowersTh5HFminus);

iEvent.put(std::move(hiHFfiltersOut), "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/HiHFFilterProducer_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import FWCore.ParameterSet.Config as cms

hiHFfilters = cms.EDProducer("HiHFFilterProducer",
srcTowers = cms.InputTag("towerMaker")
)