CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType > Class Template Reference
Inheritance diagram for HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >:
edm::stream::EDProducer<>

Public Member Functions

 HLTCaloObjInRegionsProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HLTCaloObjInRegionsProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

EtaPhiRegionDataBasecreateEtaPhiRegionData (const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
 

Static Private Member Functions

static std::unique_ptr< CaloObjCollType > makeFilteredColl (const edm::Handle< CaloObjCollType > &inputColl, CaloGeometry const &caloGeomHandle, const std::vector< EtaPhiRegion > &regions)
 
static bool validIDForGeom (const DetId &id)
 

Private Attributes

const edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeometryToken_
 
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
 
std::vector< edm::InputTaginputCollTags_
 
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
 
std::vector< std::string > outputProductNames_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename CaloObjType, typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
class HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >

Definition at line 97 of file HLTCaloObjInRegionsProducer.cc.

Constructor & Destructor Documentation

◆ HLTCaloObjInRegionsProducer()

template<typename CaloObjType , typename CaloObjCollType >
HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::HLTCaloObjInRegionsProducer ( const edm::ParameterSet ps)

Definition at line 121 of file HLTCaloObjInRegionsProducer.cc.

References deDxTools::esConsumes().

123  const std::vector<edm::ParameterSet> etaPhiRegions =
124  para.getParameter<std::vector<edm::ParameterSet>>("etaPhiRegions");
125  for (auto& pset : etaPhiRegions) {
126  const std::string type = pset.getParameter<std::string>("type");
128  type,
129  pset,
130  consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs
131  }
132 
133  outputProductNames_ = para.getParameter<std::vector<std::string>>("outputProductNames");
134  inputCollTags_ = para.getParameter<std::vector<edm::InputTag>>("inputCollTags");
135  if (outputProductNames_.size() != inputCollTags_.size()) {
136  throw cms::Exception("InvalidConfiguration")
137  << " error outputProductNames and inputCollTags must be the same size, they are " << outputProductNames_.size()
138  << " vs " << inputCollTags_.size();
139  }
140  for (unsigned int collNr = 0; collNr < inputCollTags_.size(); collNr++) {
141  inputTokens_.push_back(consumes<CaloObjCollType>(inputCollTags_[collNr]));
142  produces<CaloObjCollType>(outputProductNames_[collNr]);
143  }
144 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
EtaPhiRegionDataBase * createEtaPhiRegionData(const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
std::vector< std::string > outputProductNames_
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_

◆ ~HLTCaloObjInRegionsProducer()

template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::~HLTCaloObjInRegionsProducer ( )
inlineoverride

Definition at line 100 of file HLTCaloObjInRegionsProducer.cc.

100 {}

Member Function Documentation

◆ createEtaPhiRegionData()

template<typename CaloObjType , typename CaloObjCollType >
EtaPhiRegionDataBase * HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::createEtaPhiRegionData ( const std::string &  type,
const edm::ParameterSet para,
edm::ConsumesCollector &&  consumesColl 
)
private

Definition at line 265 of file HLTCaloObjInRegionsProducer.cc.

References Exception.

266  {
267  if (type == "L1P2GTCandidate") {
268  return new EtaPhiRegionData<l1t::P2GTCandidateCollection>(para, consumesColl);
269  } else if (type == "L1EGamma") {
270  return new EtaPhiRegionData<l1t::EGammaBxCollection>(para, consumesColl);
271  } else if (type == "L1Jet") {
272  return new EtaPhiRegionData<l1t::JetBxCollection>(para, consumesColl);
273  } else if (type == "L1Muon") {
274  return new EtaPhiRegionData<l1t::MuonBxCollection>(para, consumesColl);
275  } else if (type == "L1Tau") {
276  return new EtaPhiRegionData<l1t::TauBxCollection>(para, consumesColl);
277  } else if (type == "RecoEcalCandidate") {
278  return new EtaPhiRegionData<reco::RecoEcalCandidateCollection>(para, consumesColl);
279  } else if (type == "RecoChargedCandidate") {
280  return new EtaPhiRegionData<reco::RecoChargedCandidateCollection>(para, consumesColl);
281  } else if (type == "Electron") {
282  return new EtaPhiRegionData<reco::Electron>(para, consumesColl);
283  } else {
284  //this is a major issue and could lead to rather subtle efficiency losses, so if its incorrectly configured, we're aborting the job!
285  throw cms::Exception("InvalidConfig")
286  << " type " << type
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"
289  << std::endl;
290  }
291 }

◆ fillDescriptions()

template<typename CaloObjType , typename CaloObjCollType >
void HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 147 of file HLTCaloObjInRegionsProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSet::addParameter(), defaultModuleLabel(), submitPVResolutionJobs::desc, hgcalDigisL1Seeded_cfi::etaPhiRegions, ProducerED_cfi::InputTag, hgcalDigisL1Seeded_cfi::outputProductNames, and AlCaHLTBitMon_QueryRunRegistry::string.

148  {
150  std::vector<std::string> outputProductNames;
151  outputProductNames.push_back("EcalRegionalRecHitsEB");
152  desc.add<std::vector<std::string>>("outputProductNames", outputProductNames);
153  std::vector<edm::InputTag> inputColls;
154  inputColls.push_back(edm::InputTag("hltHcalDigis"));
155  desc.add<std::vector<edm::InputTag>>("inputCollTags", inputColls);
156  std::vector<edm::ParameterSet> etaPhiRegions;
157 
158  edm::ParameterSet ecalCandPSet;
159  ecalCandPSet.addParameter<std::string>("type", "RecoEcalCandidate");
160  ecalCandPSet.addParameter<double>("minEt", -1);
161  ecalCandPSet.addParameter<double>("maxEt", -1);
162  ecalCandPSet.addParameter<double>("maxDeltaR", 0.5);
163  ecalCandPSet.addParameter<double>("maxDEta", 0.);
164  ecalCandPSet.addParameter<double>("maxDPhi", 0.);
165  ecalCandPSet.addParameter<edm::InputTag>("inputColl", edm::InputTag("hltEgammaCandidates"));
166  etaPhiRegions.push_back(ecalCandPSet);
167 
168  edm::ParameterSetDescription etaPhiRegionDesc;
169  etaPhiRegionDesc.add<std::string>("type");
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");
175  etaPhiRegionDesc.add<edm::InputTag>("inputColl");
176  desc.addVPSet("etaPhiRegions", etaPhiRegionDesc, etaPhiRegions);
177 
179 }
std::string defaultModuleLabel()
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ makeFilteredColl()

template<typename CaloObjType , typename CaloObjCollType >
std::unique_ptr< CaloObjCollType > HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::makeFilteredColl ( const edm::Handle< CaloObjCollType > &  inputColl,
CaloGeometry const &  caloGeomHandle,
const std::vector< EtaPhiRegion > &  regions 
)
staticprivate

Definition at line 209 of file HLTCaloObjInRegionsProducer.cc.

References PVValHelper::eta, CaloGeometry::getSubdetectorGeometry(), HLT_2024v10_cff::inputColl, Skims_PA_cff::name, getGTfromDQMFile::obj, hiSpikeCleaner_cfi::outputColl, PVValHelper::phi, nano_mu_digi_cff::rawId, nano_mu_digi_cff::region, and GeomDetEnumerators::subDetGeom.

212  {
213  auto outputColl = std::make_unique<CaloObjCollType>();
214  if (!inputColl->empty()) {
215  const CaloSubdetectorGeometry* subDetGeom = caloGeomHandle.getSubdetectorGeometry(inputColl->begin()->id());
216  if (!regions.empty()) {
217  for (auto const& obj : *inputColl) {
218  auto objGeom = subDetGeom->getGeometry(obj.id());
219  if (objGeom == nullptr) {
220  //wondering what to do here
221  //something is very very wrong
222  //given HLT should never crash or throw, decided to log an error
223  //update: so turns out HCAL can pass through calibration channels in QIE11 so for that module, its an expected behaviour
224  //so we check if the ID is valid
225  if (validIDForGeom(obj.id())) {
226  edm::LogError("HLTCaloObjInRegionsProducer")
227  << "for an object of type " << typeid(CaloObjType).name() << " the geometry returned null for id "
228  << DetId(obj.id()).rawId() << " with initial ID " << DetId(inputColl->begin()->id()).rawId()
229  << " in HLTCaloObjsInRegion, this shouldnt be possible and something has gone wrong, auto accepting "
230  "hit";
231  }
232  outputColl->push_back(obj);
233  continue;
234  }
235  float eta = objGeom->getPosition().eta();
236  float phi = objGeom->getPosition().phi();
237 
238  for (const auto& region : regions) {
239  if (region(eta, phi)) {
240  outputColl->push_back(obj);
241  break;
242  }
243  }
244  }
245  } //end check of empty regions
246  } //end check of empty rec-hits
247  return outputColl;
248 }
constexpr SubDetector subDetGeom[21]
static bool validIDForGeom(const DetId &id)
Log< level::Error, false > LogError
Definition: DetId.h:17

◆ produce()

template<typename CaloObjType , typename CaloObjCollType >
void HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 182 of file HLTCaloObjInRegionsProducer.cc.

References edmPickEvents::event, input, HLT_2024v10_cff::inputColl, eostools::move(), Skims_PA_cff::name, hiSpikeCleaner_cfi::outputColl, and singleTopDQM_cfi::setup.

183  {
184  // get the collection geometry:
185  auto const& caloGeom = setup.getData(caloGeometryToken_);
186 
187  std::vector<EtaPhiRegion> regions;
188  std::for_each(etaPhiRegionData_.begin(),
189  etaPhiRegionData_.end(),
190  [&event, &regions](const std::unique_ptr<EtaPhiRegionDataBase>& input) {
191  input->getEtaPhiRegions(event, regions);
192  });
193 
194  for (size_t inputCollNr = 0; inputCollNr < inputTokens_.size(); inputCollNr++) {
196  event.getByToken(inputTokens_[inputCollNr], inputColl);
197 
198  if (!(inputColl.isValid())) {
199  edm::LogError("ProductNotFound") << "could not get a handle on the " << typeid(CaloObjCollType).name()
200  << " named " << inputCollTags_[inputCollNr].encode() << std::endl;
201  continue;
202  }
203  auto outputColl = makeFilteredColl(inputColl, caloGeom, regions);
204  event.put(std::move(outputColl), outputProductNames_[inputCollNr]);
205  }
206 }
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Log< level::Error, false > LogError
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< std::string > outputProductNames_
static std::unique_ptr< CaloObjCollType > makeFilteredColl(const edm::Handle< CaloObjCollType > &inputColl, CaloGeometry const &caloGeomHandle, const std::vector< EtaPhiRegion > &regions)
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

◆ validIDForGeom()

template<typename CaloObjType , typename CaloObjCollType >
bool HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::validIDForGeom ( const DetId id)
staticprivate

Definition at line 255 of file HLTCaloObjInRegionsProducer.cc.

References DetId::Hcal, HcalEmpty, and HcalOther.

255  {
256  if (id.det() == DetId::Hcal) {
257  if (id.subdetId() == HcalSubdetector::HcalEmpty || id.subdetId() == HcalSubdetector::HcalOther) {
258  return false;
259  }
260  }
261  return true;
262 }

Member Data Documentation

◆ caloGeometryToken_

template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::caloGeometryToken_
private

Definition at line 117 of file HLTCaloObjInRegionsProducer.cc.

◆ etaPhiRegionData_

template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
std::vector<std::unique_ptr<EtaPhiRegionDataBase> > HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::etaPhiRegionData_
private

Definition at line 116 of file HLTCaloObjInRegionsProducer.cc.

◆ inputCollTags_

template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
std::vector<edm::InputTag> HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::inputCollTags_
private

Definition at line 114 of file HLTCaloObjInRegionsProducer.cc.

◆ inputTokens_

template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
std::vector<edm::EDGetTokenT<CaloObjCollType> > HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::inputTokens_
private

Definition at line 115 of file HLTCaloObjInRegionsProducer.cc.

◆ outputProductNames_

template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
std::vector<std::string> HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::outputProductNames_
private

Definition at line 113 of file HLTCaloObjInRegionsProducer.cc.