Skip to content

Commit

Permalink
Include the HF filters for heavy ions in the MiniAOD content
Browse files Browse the repository at this point in the history
  • Loading branch information
ddesouza committed Sep 27, 2020
1 parent 051d43f commit 058dbef
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 1 deletion.
13 changes: 13 additions & 0 deletions DataFormats/HeavyIonEvent/interface/HFFilterStruct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef HEAVYIONEVENT_HFFILTERSTRUCT_H
#define HEAVYIONEVENT_HFFILTERSTRUCT_H

namespace pat {
struct HFFilterStruct {
int numMinHFTowers2;
int numMinHFTowers3;
int numMinHFTowers4;
int numMinHFTowers5;
};
} // namespace pat

#endif
1 change: 1 addition & 0 deletions DataFormats/HeavyIonEvent/src/HFFilterStruct.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "DataFormats/HeavyIonEvent/interface/HFFilterStruct.h"
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/HFFilterStruct.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="pat::HFFilterStruct" ClassVersion="3">
<version ClassVersion="3" checksum="2657003700"/>
</class>
<class name="edm::Wrapper<pat::HFFilterStruct>"/>
<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 @@ -145,6 +145,7 @@
'keep floatedmValueMap_lostTrackChi2_*_*',
'keep recoCentrality_hiCentrality_*_*',
'keep int_centralityBin_*_*',
'keep patHFFilterStruct_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.HiHFFilterProducer_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
103 changes: 103 additions & 0 deletions RecoHI/HiCentralityAlgos/plugins/HiHFFilterProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

#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 "DataFormats/HeavyIonEvent/interface/HFFilterStruct.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<pat::HFFilterStruct>("hiHFfilters");
}

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

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;

auto HFFilterResults = std::make_unique<pat::HFFilterStruct>();
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;
}
}

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

iEvent.put(std::move(HFFilterResults), "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")
)

0 comments on commit 058dbef

Please sign in to comment.