55 EtaPhiRegion(
float iEta,
float iPhi,
float iDR,
float iDEta,
float iDPhi)
56 : centreEta_(iEta), centrePhi_(iPhi), maxDeltaR2_(iDR * iDR), maxDEta_(iDEta), maxDPhi_(iDPhi) {}
59 return reco::deltaR2(eta, phi, centreEta_, centrePhi_) < maxDeltaR2_ ||
68 virtual void getEtaPhiRegions(
const edm::Event&, std::vector<EtaPhiRegion>&)
const = 0;
73 template <
typename T1>
85 : minEt_(para.getParameter<double>(
"minEt")),
86 maxEt_(para.getParameter<double>(
"maxEt")),
87 maxDeltaR_(para.getParameter<double>(
"maxDeltaR")),
88 maxDEta_(para.getParameter<double>(
"maxDEta")),
89 maxDPhi_(para.getParameter<double>(
"maxDPhi")),
90 token_(consumesColl.consumes<T1>(para.getParameter<
edm::
InputTag>(
"inputColl"))) {}
92 void getEtaPhiRegions(
const edm::Event&, std::vector<EtaPhiRegion>&)
const override;
95 template <
typename CaloObjType,
typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
110 const std::vector<EtaPhiRegion>&
regions);
111 static bool validIDForGeom(
const DetId&
id);
118 template <
typename CaloObjType,
typename CaloObjCollType>
120 const std::vector<edm::ParameterSet> etaPhiRegions =
121 para.
getParameter<std::vector<edm::ParameterSet>>(
"etaPhiRegions");
122 for (
auto&
pset : etaPhiRegions) {
124 etaPhiRegionData_.emplace_back(createEtaPhiRegionData(
127 consumesCollector()));
130 outputProductNames_ = para.
getParameter<std::vector<std::string>>(
"outputProductNames");
131 inputCollTags_ = para.
getParameter<std::vector<edm::InputTag>>(
"inputCollTags");
132 if (outputProductNames_.size() != inputCollTags_.size()) {
134 <<
" error outputProductNames and inputCollTags must be the same size, they are " << outputProductNames_.size()
135 <<
" vs " << inputCollTags_.size();
137 for (
unsigned int collNr = 0; collNr < inputCollTags_.size(); collNr++) {
138 inputTokens_.push_back(consumes<CaloObjCollType>(inputCollTags_[collNr]));
139 produces<CaloObjCollType>(outputProductNames_[collNr]);
143 template <
typename CaloObjType,
typename CaloObjCollType>
147 std::vector<std::string> outputProductNames;
148 outputProductNames.push_back(
"EcalRegionalRecHitsEB");
149 desc.
add<std::vector<std::string>>(
"outputProductNames", outputProductNames);
150 std::vector<edm::InputTag> inputColls;
152 desc.
add<std::vector<edm::InputTag>>(
"inputCollTags", inputColls);
153 std::vector<edm::ParameterSet> etaPhiRegions;
163 etaPhiRegions.push_back(ecalCandPSet);
167 etaPhiRegionDesc.
add<
double>(
"minEt");
168 etaPhiRegionDesc.
add<
double>(
"maxEt");
169 etaPhiRegionDesc.
add<
double>(
"maxDeltaR");
170 etaPhiRegionDesc.
add<
double>(
"maxDEta");
171 etaPhiRegionDesc.
add<
double>(
"maxDPhi");
173 desc.
addVPSet(
"etaPhiRegions", etaPhiRegionDesc, etaPhiRegions);
178 template <
typename CaloObjType,
typename CaloObjCollType>
185 std::vector<EtaPhiRegion>
regions;
186 std::for_each(etaPhiRegionData_.begin(),
187 etaPhiRegionData_.end(),
189 input->getEtaPhiRegions(event, regions);
192 for (
size_t inputCollNr = 0; inputCollNr < inputTokens_.size(); inputCollNr++) {
194 event.getByToken(inputTokens_[inputCollNr], inputColl);
197 edm::LogError(
"ProductNotFound") <<
"could not get a handle on the " <<
typeid(CaloObjCollType).
name()
198 <<
" named " << inputCollTags_[inputCollNr].encode() << std::endl;
201 auto outputColl = makeFilteredColl(inputColl, caloGeomHandle, regions);
206 template <
typename CaloObjType,
typename CaloObjCollType>
210 const std::vector<EtaPhiRegion>&
regions) {
211 auto outputColl = std::make_unique<CaloObjCollType>();
212 if (!inputColl->empty()) {
214 if (!regions.empty()) {
215 for (
const CaloObjType&
obj : *inputColl) {
217 if (objGeom ==
nullptr) {
223 if (validIDForGeom(
obj.id())) {
225 <<
"for an object of type " <<
typeid(CaloObjType).
name() <<
" the geometry returned null for id " 226 <<
DetId(
obj.id()).rawId() <<
" with initial ID " <<
DetId(inputColl->begin()->id()).rawId()
227 <<
" in HLTCaloObjsInRegion, this shouldnt be possible and something has gone wrong, auto accepting " 233 float eta = objGeom->getPosition().eta();
234 float phi = objGeom->getPosition().phi();
236 for (
const auto&
region : regions) {
252 template <
typename CaloObjType,
typename CaloObjCollType>
262 template <
typename CaloObjType,
typename CaloObjCollType>
265 if (type ==
"L1EGamma") {
267 }
else if (type ==
"L1Jet") {
269 }
else if (type ==
"L1Muon") {
271 }
else if (type ==
"L1Tau") {
273 }
else if (type ==
"RecoEcalCandidate") {
275 }
else if (type ==
"RecoChargedCandidate") {
277 }
else if (type ==
"Electron") {
283 <<
" is not recognised, this means the rec-hit you think you are keeping may not be and you should fix this " 284 "error as it can lead to hard to find efficiency loses" 289 template <
typename CandCollType>
291 std::vector<EtaPhiRegion>&
regions)
const {
293 event.getByToken(token_, cands);
295 for (
auto const&
cand : *cands) {
296 if (
cand.et() >= minEt_ && (maxEt_ < 0 ||
cand.et() < maxEt_)) {
constexpr double deltaPhi(double phi1, double phi2)
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
EtaPhiRegionDataBase * createEtaPhiRegionData(const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
~HLTCaloObjInRegionsProducer() override
std::string defaultModuleLabel()
static bool validIDForGeom(const DetId &id)
static std::string const input
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::string > outputProductNames_
#define DEFINE_FWK_MODULE(type)
static std::unique_ptr< CaloObjCollType > makeFilteredColl(const edm::Handle< CaloObjCollType > &inputColl, const edm::ESHandle< CaloGeometry > &caloGeomHandle, const std::vector< EtaPhiRegion > ®ions)
void addParameter(std::string const &name, T const &value)
bool operator()(float eta, float phi) const
Abs< T >::type abs(const T &t)
EtaPhiRegionData(const edm::ParameterSet ¶, edm::ConsumesCollector &consumesColl)
SubDetector subDetGeom[21]
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
HLTCaloObjInRegionsProducer(const edm::ParameterSet &ps)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::EDGetTokenT< T1 > token_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void getEtaPhiRegions(const edm::Event &, std::vector< EtaPhiRegion > &) const override
EtaPhiRegion(float iEta, float iPhi, float iDR, float iDEta, float iDPhi)
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
void produce(edm::Event &, const edm::EventSetup &) override