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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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, const edm::ESHandle< CaloGeometry > &caloGeomHandle, const std::vector< EtaPhiRegion > &regions)
 
static bool validIDForGeom (const DetId &id)
 

Private Attributes

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

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

Definition at line 96 of file HLTCaloObjInRegionsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 119 of file HLTCaloObjInRegionsProducer.cc.

References Exception, edm::ParameterSet::getParameter(), muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

119  {
120  const std::vector<edm::ParameterSet> etaPhiRegions =
121  para.getParameter<std::vector<edm::ParameterSet>>("etaPhiRegions");
122  for (auto& pset : etaPhiRegions) {
123  const std::string type = pset.getParameter<std::string>("type");
125  type,
126  pset,
127  consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs
128  }
129 
130  outputProductNames_ = para.getParameter<std::vector<std::string>>("outputProductNames");
131  inputCollTags_ = para.getParameter<std::vector<edm::InputTag>>("inputCollTags");
132  if (outputProductNames_.size() != inputCollTags_.size()) {
133  throw cms::Exception("InvalidConfiguration")
134  << " error outputProductNames and inputCollTags must be the same size, they are " << outputProductNames_.size()
135  << " vs " << inputCollTags_.size();
136  }
137  for (unsigned int collNr = 0; collNr < inputCollTags_.size(); collNr++) {
138  inputTokens_.push_back(consumes<CaloObjCollType>(inputCollTags_[collNr]));
139  produces<CaloObjCollType>(outputProductNames_[collNr]);
140  }
141 }
type
Definition: HCALResponse.h:21
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
EtaPhiRegionDataBase * createEtaPhiRegionData(const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
std::vector< std::string > outputProductNames_
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::~HLTCaloObjInRegionsProducer ( )
inlineoverride

Member Function Documentation

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 263 of file HLTCaloObjInRegionsProducer.cc.

References Exception.

264  {
265  if (type == "L1EGamma") {
266  return new EtaPhiRegionData<l1t::EGammaBxCollection>(para, consumesColl);
267  } else if (type == "L1Jet") {
268  return new EtaPhiRegionData<l1t::JetBxCollection>(para, consumesColl);
269  } else if (type == "L1Muon") {
270  return new EtaPhiRegionData<l1t::MuonBxCollection>(para, consumesColl);
271  } else if (type == "L1Tau") {
272  return new EtaPhiRegionData<l1t::TauBxCollection>(para, consumesColl);
273  } else if (type == "RecoEcalCandidate") {
274  return new EtaPhiRegionData<reco::RecoEcalCandidateCollection>(para, consumesColl);
275  } else if (type == "RecoChargedCandidate") {
276  return new EtaPhiRegionData<reco::RecoChargedCandidateCollection>(para, consumesColl);
277  } else if (type == "Electron") {
278  return new EtaPhiRegionData<reco::Electron>(para, consumesColl);
279  } else {
280  //this is a major issue and could lead to rather subtle efficiency losses, so if its incorrectly configured, we're aborting the job!
281  throw cms::Exception("InvalidConfig")
282  << " type " << type
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"
285  << std::endl;
286  }
287 }
type
Definition: HCALResponse.h:21
template<typename CaloObjType , typename CaloObjCollType >
void HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 144 of file HLTCaloObjInRegionsProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSet::addParameter(), edm::ParameterSetDescription::addVPSet(), defaultModuleLabel(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

145  {
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;
151  inputColls.push_back(edm::InputTag("hltHcalDigis"));
152  desc.add<std::vector<edm::InputTag>>("inputCollTags", inputColls);
153  std::vector<edm::ParameterSet> etaPhiRegions;
154 
155  edm::ParameterSet ecalCandPSet;
156  ecalCandPSet.addParameter<std::string>("type", "RecoEcalCandidate");
157  ecalCandPSet.addParameter<double>("minEt", -1);
158  ecalCandPSet.addParameter<double>("maxEt", -1);
159  ecalCandPSet.addParameter<double>("maxDeltaR", 0.5);
160  ecalCandPSet.addParameter<double>("maxDEta", 0.);
161  ecalCandPSet.addParameter<double>("maxDPhi", 0.);
162  ecalCandPSet.addParameter<edm::InputTag>("inputColl", edm::InputTag("hltEgammaCandidates"));
163  etaPhiRegions.push_back(ecalCandPSet);
164 
165  edm::ParameterSetDescription etaPhiRegionDesc;
166  etaPhiRegionDesc.add<std::string>("type");
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");
172  etaPhiRegionDesc.add<edm::InputTag>("inputColl");
173  desc.addVPSet("etaPhiRegions", etaPhiRegionDesc, etaPhiRegions);
174 
176 }
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::string defaultModuleLabel()
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:124
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename CaloObjType , typename CaloObjCollType >
std::unique_ptr< CaloObjCollType > HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::makeFilteredColl ( const edm::Handle< CaloObjCollType > &  inputColl,
const edm::ESHandle< CaloGeometry > &  caloGeomHandle,
const std::vector< EtaPhiRegion > &  regions 
)
staticprivate

Definition at line 207 of file HLTCaloObjInRegionsProducer.cc.

References PVValHelper::eta, CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), edm::HandleBase::id(), Skims_PA_cff::name, getGTfromDQMFile::obj, HLT_2018_cff::outputColl, phi, HLT_2018_cff::region, and GeomDetEnumerators::subDetGeom.

210  {
211  auto outputColl = std::make_unique<CaloObjCollType>();
212  if (!inputColl->empty()) {
213  const CaloSubdetectorGeometry* subDetGeom = caloGeomHandle->getSubdetectorGeometry(inputColl->begin()->id());
214  if (!regions.empty()) {
215  for (const CaloObjType& obj : *inputColl) {
216  auto objGeom = subDetGeom->getGeometry(obj.id());
217  if (objGeom == nullptr) {
218  //wondering what to do here
219  //something is very very wrong
220  //given HLT should never crash or throw, decided to log an error
221  //update: so turns out HCAL can pass through calibration channels in QIE11 so for that module, its an expected behaviour
222  //so we check if the ID is valid
223  if (validIDForGeom(obj.id())) {
224  edm::LogError("HLTCaloObjInRegionsProducer")
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 "
228  "hit";
229  }
230  outputColl->push_back(obj);
231  continue;
232  }
233  float eta = objGeom->getPosition().eta();
234  float phi = objGeom->getPosition().phi();
235 
236  for (const auto& region : regions) {
237  if (region(eta, phi)) {
238  outputColl->push_back(obj);
239  break;
240  }
241  }
242  }
243  } //end check of empty regions
244  } //end check of empty rec-hits
245  return outputColl;
246 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
ProductID id() const
Definition: HandleBase.cc:13
static bool validIDForGeom(const DetId &id)
SubDetector subDetGeom[21]
Definition: DetId.h:17
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.
template<typename CaloObjType , typename CaloObjCollType >
void HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 179 of file HLTCaloObjInRegionsProducer.cc.

References event(), edm::EventSetup::get(), input, HLT_2018_cff::inputColl, edm::HandleBase::isValid(), eostools::move(), Skims_PA_cff::name, and HLT_2018_cff::outputColl.

180  {
181  // get the collection geometry:
182  edm::ESHandle<CaloGeometry> caloGeomHandle;
183  setup.get<CaloGeometryRecord>().get(caloGeomHandle);
184 
185  std::vector<EtaPhiRegion> regions;
186  std::for_each(etaPhiRegionData_.begin(),
187  etaPhiRegionData_.end(),
188  [&event, &regions](const std::unique_ptr<EtaPhiRegionDataBase>& input) {
189  input->getEtaPhiRegions(event, regions);
190  });
191 
192  for (size_t inputCollNr = 0; inputCollNr < inputTokens_.size(); inputCollNr++) {
194  event.getByToken(inputTokens_[inputCollNr], inputColl);
195 
196  if (!(inputColl.isValid())) {
197  edm::LogError("ProductNotFound") << "could not get a handle on the " << typeid(CaloObjCollType).name()
198  << " named " << inputCollTags_[inputCollNr].encode() << std::endl;
199  continue;
200  }
201  auto outputColl = makeFilteredColl(inputColl, caloGeomHandle, regions);
202  event.put(std::move(outputColl), outputProductNames_[inputCollNr]);
203  }
204 }
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
static std::string const input
Definition: EdmProvDump.cc:48
std::vector< std::string > outputProductNames_
static std::unique_ptr< CaloObjCollType > makeFilteredColl(const edm::Handle< CaloObjCollType > &inputColl, const edm::ESHandle< CaloGeometry > &caloGeomHandle, const std::vector< EtaPhiRegion > &regions)
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
bool isValid() const
Definition: HandleBase.h:70
T get() const
Definition: EventSetup.h:73
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
def move(src, dest)
Definition: eostools.py:511
template<typename CaloObjType , typename CaloObjCollType >
bool HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::validIDForGeom ( const DetId id)
staticprivate

Definition at line 253 of file HLTCaloObjInRegionsProducer.cc.

References DetId::Hcal, HcalEmpty, and HcalOther.

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

Member Data Documentation

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

Definition at line 115 of file HLTCaloObjInRegionsProducer.cc.

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

Definition at line 113 of file HLTCaloObjInRegionsProducer.cc.

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

Definition at line 114 of file HLTCaloObjInRegionsProducer.cc.

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

Definition at line 112 of file HLTCaloObjInRegionsProducer.cc.