74 template <
typename T1>
86 :
minEt_(para.getParameter<double>(
"minEt")),
87 maxEt_(para.getParameter<double>(
"maxEt")),
88 maxDeltaR_(para.getParameter<double>(
"maxDeltaR")),
89 maxDEta_(para.getParameter<double>(
"maxDEta")),
90 maxDPhi_(para.getParameter<double>(
"maxDPhi")),
91 token_(consumesColl.consumes<T1>(para.getParameter<
edm::
InputTag>(
"inputColl"))) {}
96 template <
typename CaloObjType,
typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
111 const std::vector<EtaPhiRegion>&
regions);
120 template <
typename CaloObjType,
typename CaloObjCollType>
124 para.getParameter<std::vector<edm::ParameterSet>>(
"etaPhiRegions");
127 etaPhiRegionData_.emplace_back(createEtaPhiRegionData(
130 consumesCollector()));
133 outputProductNames_ = para.getParameter<std::vector<std::string>>(
"outputProductNames");
134 inputCollTags_ = para.getParameter<std::vector<edm::InputTag>>(
"inputCollTags");
135 if (outputProductNames_.size() != inputCollTags_.size()) {
137 <<
" error outputProductNames and inputCollTags must be the same size, they are " << outputProductNames_.size()
138 <<
" vs " << inputCollTags_.size();
140 for (
unsigned int collNr = 0; collNr < inputCollTags_.size(); collNr++) {
141 inputTokens_.push_back(consumes<CaloObjCollType>(inputCollTags_[collNr]));
142 produces<CaloObjCollType>(outputProductNames_[collNr]);
146 template <
typename CaloObjType,
typename CaloObjCollType>
153 std::vector<edm::InputTag> inputColls;
155 desc.add<std::vector<edm::InputTag>>(
"inputCollTags", inputColls);
170 etaPhiRegionDesc.
add<
double>(
"minEt");
171 etaPhiRegionDesc.
add<
double>(
"maxEt");
172 etaPhiRegionDesc.
add<
double>(
"maxDeltaR");
173 etaPhiRegionDesc.
add<
double>(
"maxDEta");
174 etaPhiRegionDesc.
add<
double>(
"maxDPhi");
181 template <
typename CaloObjType,
typename CaloObjCollType>
185 auto const& caloGeom =
setup.getData(caloGeometryToken_);
187 std::vector<EtaPhiRegion>
regions;
188 std::for_each(etaPhiRegionData_.begin(),
189 etaPhiRegionData_.end(),
194 for (
size_t inputCollNr = 0; inputCollNr < inputTokens_.size(); inputCollNr++) {
196 event.getByToken(inputTokens_[inputCollNr],
inputColl);
199 edm::LogError(
"ProductNotFound") <<
"could not get a handle on the " <<
typeid(CaloObjCollType).
name()
200 <<
" named " << inputCollTags_[inputCollNr].encode() << std::endl;
208 template <
typename CaloObjType,
typename CaloObjCollType>
212 const std::vector<EtaPhiRegion>&
regions) {
213 auto outputColl = std::make_unique<CaloObjCollType>();
219 if (objGeom ==
nullptr) {
225 if (validIDForGeom(
obj.id())) {
227 <<
"for an object of type " <<
typeid(CaloObjType).
name() <<
" the geometry returned null for id " 229 <<
" in HLTCaloObjsInRegion, this shouldnt be possible and something has gone wrong, auto accepting " 235 float eta = objGeom->getPosition().eta();
236 float phi = objGeom->getPosition().phi();
254 template <
typename CaloObjType,
typename CaloObjCollType>
264 template <
typename CaloObjType,
typename CaloObjCollType>
267 if (
type ==
"L1P2GTCandidate") {
269 }
else if (
type ==
"L1EGamma") {
271 }
else if (
type ==
"L1Jet") {
273 }
else if (
type ==
"L1Muon") {
275 }
else if (
type ==
"L1Tau") {
277 }
else if (
type ==
"RecoEcalCandidate") {
279 }
else if (
type ==
"RecoChargedCandidate") {
281 }
else if (
type ==
"Electron") {
287 <<
" is not recognised, this means the rec-hit you think you are keeping may not be and you should fix this " 288 "error as it can lead to hard to find efficiency loses" 293 template <
typename CandCollType>
295 std::vector<EtaPhiRegion>&
regions)
const {
297 event.getByToken(token_,
cands);
300 if (
cand.et() >= minEt_ && (maxEt_ < 0 ||
cand.et() < maxEt_)) {
constexpr double deltaPhi(double phi1, double phi2)
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
void getEtaPhiRegions(const edm::Event &, std::vector< EtaPhiRegion > &) const override
EtaPhiRegionDataBase * createEtaPhiRegionData(const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
constexpr SubDetector subDetGeom[21]
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
~HLTCaloObjInRegionsProducer() override
std::string defaultModuleLabel()
static bool validIDForGeom(const DetId &id)
Log< level::Error, false > LogError
virtual ~EtaPhiRegionDataBase()=default
bool operator()(float eta, float phi) const
static std::string const input
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::string > outputProductNames_
void addParameter(std::string const &name, T const &value)
Abs< T >::type abs(const T &t)
EtaPhiRegionData(const edm::ParameterSet ¶, edm::ConsumesCollector &consumesColl)
#define DEFINE_FWK_MODULE(type)
virtual void getEtaPhiRegions(const edm::Event &, std::vector< EtaPhiRegion > &) const =0
ParameterDescriptionBase * add(U const &iLabel, T const &value)
HLTCaloObjInRegionsProducer(const edm::ParameterSet &ps)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::EDGetTokenT< T1 > token_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static std::unique_ptr< CaloObjCollType > makeFilteredColl(const edm::Handle< CaloObjCollType > &inputColl, CaloGeometry const &caloGeomHandle, const std::vector< EtaPhiRegion > ®ions)
EtaPhiRegion(float iEta, float iPhi, float iDR, float iDEta, float iDPhi)
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
void produce(edm::Event &, const edm::EventSetup &) override