CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
CaloGeometryRecord
caloGeometryToken_
 
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 96 of file HLTCaloObjInRegionsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 120 of file HLTCaloObjInRegionsProducer.cc.

References DeDxTools::esConsumes().

122  const std::vector<edm::ParameterSet> etaPhiRegions =
123  para.getParameter<std::vector<edm::ParameterSet>>("etaPhiRegions");
124  for (auto& pset : etaPhiRegions) {
125  const std::string type = pset.getParameter<std::string>("type");
127  type,
128  pset,
129  consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs
130  }
131 
132  outputProductNames_ = para.getParameter<std::vector<std::string>>("outputProductNames");
133  inputCollTags_ = para.getParameter<std::vector<edm::InputTag>>("inputCollTags");
134  if (outputProductNames_.size() != inputCollTags_.size()) {
135  throw cms::Exception("InvalidConfiguration")
136  << " error outputProductNames and inputCollTags must be the same size, they are " << outputProductNames_.size()
137  << " vs " << inputCollTags_.size();
138  }
139  for (unsigned int collNr = 0; collNr < inputCollTags_.size(); collNr++) {
140  inputTokens_.push_back(consumes<CaloObjCollType>(inputCollTags_[collNr]));
141  produces<CaloObjCollType>(outputProductNames_[collNr]);
142  }
143 }
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_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
template<typename CaloObjType , typename CaloObjCollType = edm::SortedCollection<CaloObjType>>
HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::~HLTCaloObjInRegionsProducer ( )
inlineoverride

Definition at line 99 of file HLTCaloObjInRegionsProducer.cc.

99 {}

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

References consumesColl, and Exception.

265  {
266  if (type == "L1EGamma") {
268  } else if (type == "L1Jet") {
270  } else if (type == "L1Muon") {
272  } else if (type == "L1Tau") {
274  } else if (type == "RecoEcalCandidate") {
276  } else if (type == "RecoChargedCandidate") {
278  } else if (type == "Electron") {
280  } else {
281  //this is a major issue and could lead to rather subtle efficiency losses, so if its incorrectly configured, we're aborting the job!
282  throw cms::Exception("InvalidConfig")
283  << " type " << type
284  << " is not recognised, this means the rec-hit you think you are keeping may not be and you should fix this "
285  "error as it can lead to hard to find efficiency loses"
286  << std::endl;
287  }
288 }
edm::ConsumesCollector consumesColl(consumesCollector())
template<typename CaloObjType , typename CaloObjCollType >
void HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 146 of file HLTCaloObjInRegionsProducer.cc.

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

147  {
149  std::vector<std::string> outputProductNames;
150  outputProductNames.push_back("EcalRegionalRecHitsEB");
151  desc.add<std::vector<std::string>>("outputProductNames", outputProductNames);
152  std::vector<edm::InputTag> inputColls;
153  inputColls.push_back(edm::InputTag("hltHcalDigis"));
154  desc.add<std::vector<edm::InputTag>>("inputCollTags", inputColls);
155  std::vector<edm::ParameterSet> etaPhiRegions;
156 
157  edm::ParameterSet ecalCandPSet;
158  ecalCandPSet.addParameter<std::string>("type", "RecoEcalCandidate");
159  ecalCandPSet.addParameter<double>("minEt", -1);
160  ecalCandPSet.addParameter<double>("maxEt", -1);
161  ecalCandPSet.addParameter<double>("maxDeltaR", 0.5);
162  ecalCandPSet.addParameter<double>("maxDEta", 0.);
163  ecalCandPSet.addParameter<double>("maxDPhi", 0.);
164  ecalCandPSet.addParameter<edm::InputTag>("inputColl", edm::InputTag("hltEgammaCandidates"));
165  etaPhiRegions.push_back(ecalCandPSet);
166 
167  edm::ParameterSetDescription etaPhiRegionDesc;
168  etaPhiRegionDesc.add<std::string>("type");
169  etaPhiRegionDesc.add<double>("minEt");
170  etaPhiRegionDesc.add<double>("maxEt");
171  etaPhiRegionDesc.add<double>("maxDeltaR");
172  etaPhiRegionDesc.add<double>("maxDEta");
173  etaPhiRegionDesc.add<double>("maxDPhi");
174  etaPhiRegionDesc.add<edm::InputTag>("inputColl");
175  desc.addVPSet("etaPhiRegions", etaPhiRegionDesc, etaPhiRegions);
176 
178 }
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:135
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,
CaloGeometry const &  caloGeomHandle,
const std::vector< EtaPhiRegion > &  regions 
)
staticprivate

Definition at line 208 of file HLTCaloObjInRegionsProducer.cc.

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

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

References edmPickEvents::event, edm::EventSetup::getData(), input, edm::HandleBase::isValid(), eostools::move(), mergeVDriftHistosByStation::name, and HLT_FULL_cff::outputColl.

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

Definition at line 254 of file HLTCaloObjInRegionsProducer.cc.

References DetId::Hcal, HcalEmpty, and HcalOther.

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

Member Data Documentation

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

Definition at line 116 of file HLTCaloObjInRegionsProducer.cc.

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.