CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
EgammaHLTPhase2ExtraProducer Class Reference
Inheritance diagram for EgammaHLTPhase2ExtraProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  Tokens
 

Public Member Functions

 EgammaHLTPhase2ExtraProducer (const edm::ParameterSet &pset)
 
void produce (edm::StreamID streamID, edm::Event &event, const edm::EventSetup &eventSetup) const override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

template<typename CollType , typename RefType >
std::unique_ptr< CollType > filterObjs (const trigger::EgammaObjectCollection &egTrigObjs, const edm::Handle< CollType > &objs, std::vector< RefType > &orgRefs, float maxDR2=0.4 *0.4) const
 
template<typename RecHitCollection >
std::unique_ptr< RecHitCollection > filterRecHits (const trigger::EgammaObjectCollection &egTrigObjs, const edm::Handle< RecHitCollection > &recHits, const CaloGeometry &geom, float maxDR2=0.4 *0.4) const
 

Static Private Member Functions

template<typename T , typename H >
static std::unique_ptr< edm::ValueMap< T > > makeValueMap (const H &handle, const std::vector< T > &values)
 

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecord > const caloGeomToken_
 
float minPtToSaveHits_
 
std::vector< double > recHitCountThresholds_
 
bool saveHitsPlusHalfPi_
 
bool saveHitsPlusPi_
 
const Tokens tokens_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 80 of file EgammaHLTPhase2ExtraProducer.cc.

Constructor & Destructor Documentation

◆ EgammaHLTPhase2ExtraProducer()

EgammaHLTPhase2ExtraProducer::EgammaHLTPhase2ExtraProducer ( const edm::ParameterSet pset)
explicit

Definition at line 173 of file EgammaHLTPhase2ExtraProducer.cc.

References edm::EDConsumerBase::esConsumes().

176  minPtToSaveHits_(pset.getParameter<double>("minPtToSaveHits")),
177  saveHitsPlusPi_(pset.getParameter<bool>("saveHitsPlusPi")),
178  saveHitsPlusHalfPi_(pset.getParameter<bool>("saveHitsPlusHalfPi")),
179  recHitCountThresholds_(pset.getParameter<std::vector<double>>("recHitCountThresholds")) {
180  produces<L1TrackCollection>();
181  produces<L1TrackTruthPairCollection>();
182  produces<TrackingParticleCollection>();
183  produces<reco::CaloClusterCollection>("hgcalLayerClusters");
184  produces<edm::ValueMap<std::pair<float, float>>>("hgcalLayerClustersTime");
185  for (auto& tokenLabel : tokens_.hgcal) {
186  produces<HGCRecHitCollection>(tokenLabel.second);
187  for (const auto& thres : recHitCountThresholds_) {
188  produces<int>("countHgcalRecHits" + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
189  }
190  }
191 }
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > const caloGeomToken_
std::vector< std::pair< edm::EDGetTokenT< HGCRecHitCollection >, std::string > > hgcal

Member Function Documentation

◆ fillDescriptions()

void EgammaHLTPhase2ExtraProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 193 of file EgammaHLTPhase2ExtraProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, AlCaHLTBitMon_QueryRunRegistry::string, and trackerHitRTTI::vector.

193  {
195  desc.add<edm::InputTag>("egTrigObjs", edm::InputTag("hltEgammaHLTExtra"));
196  desc.add<edm::InputTag>("l1Trks", edm::InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks"));
197  desc.add<edm::InputTag>("trkParts", edm::InputTag("mix", "MergedTrackTruth"));
198  desc.add<edm::InputTag>("l1TrkToTrkPartMap", edm::InputTag("TTTrackAssociatorFromPixelDigis", "Level1TTTracks"));
199  desc.add<edm::InputTag>("hgcalLayerClusters", edm::InputTag("hgcalLayerClusters"));
200  desc.add<edm::InputTag>("hgcalLayerClustersTime", edm::InputTag("hgcalLayerClusters", "timeLayerCluster"));
201  desc.add<double>("minPtToSaveHits", 0.);
202  desc.add<bool>("saveHitsPlusPi", true);
203  desc.add<bool>("saveHitsPlusHalfPi", true);
204  desc.add<std::vector<double>>("recHitCountThresholds", std::vector{0., 0.5, 1.0, 1.5, 2.0});
205  std::vector<edm::ParameterSet> ecalDefaults(2);
206  edm::ParameterSetDescription tokenLabelDesc;
207  tokenLabelDesc.add<edm::InputTag>("src", edm::InputTag(""));
208  tokenLabelDesc.add<std::string>("label", "");
209  std::vector<edm::ParameterSet> hgcalDefaults(3);
210  hgcalDefaults[0].addParameter("src", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
211  hgcalDefaults[0].addParameter("label", std::string("HGCEERecHits"));
212  hgcalDefaults[1].addParameter("src", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
213  hgcalDefaults[1].addParameter("label", std::string("HGCHEFRecHits"));
214  hgcalDefaults[2].addParameter("src", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
215  hgcalDefaults[2].addParameter("label", std::string("HGCHEBRecHits"));
216  desc.addVPSet("hgcal", tokenLabelDesc, hgcalDefaults);
217  descriptions.add(("hltEgammaHLTPhase2ExtraProducer"), desc);
218 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ filterObjs()

template<typename CollType , typename RefType >
std::unique_ptr< CollType > EgammaHLTPhase2ExtraProducer::filterObjs ( const trigger::EgammaObjectCollection egTrigObjs,
const edm::Handle< CollType > &  objs,
std::vector< RefType > &  orgRefs,
float  maxDR2 = 0.4 * 0.4 
) const
private

Definition at line 309 of file EgammaHLTPhase2ExtraProducer.cc.

References reco::deltaR2(), PVValHelper::eta, minPtToSaveHits_, HLTEGTnPMonitor_cfi::objs, phi, saveHitsPlusHalfPi_, and saveHitsPlusPi_.

Referenced by produce().

312  {
313  auto filteredObjs = std::make_unique<CollType>();
314  orgRefs.clear();
315  if (!objs.isValid())
316  return filteredObjs;
317 
318  //so because each egamma object can have multiple eta/phi pairs
319  //easier to just make a temp vector and then copy that in with the +pi and +pi/2
320  std::vector<std::pair<float, float>> etaPhisTmp;
321  for (const auto& egTrigObj : egTrigObjs) {
322  if (egTrigObj.pt() >= minPtToSaveHits_) {
323  etaPhisTmp.push_back({egTrigObj.eta(), egTrigObj.phi()});
324  //also save the eta /phi of all gsf tracks with the object
325  for (const auto& gsfTrk : egTrigObj.gsfTracks()) {
326  etaPhisTmp.push_back({gsfTrk->eta(), gsfTrk->phi()});
327  }
328  }
329  }
330  std::vector<std::pair<float, float>> etaPhis;
331  for (const auto& etaPhi : etaPhisTmp) {
332  etaPhis.push_back(etaPhi);
333  if (saveHitsPlusPi_)
334  etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159});
336  etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159 / 2.});
337  }
338 
339  auto deltaR2Match = [&etaPhis, &maxDR2](float eta, float phi) {
340  for (auto& etaPhi : etaPhis) {
341  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
342  return true;
343  }
344  return false;
345  };
346 
347  for (size_t objNr = 0; objNr < objs->size(); objNr++) {
348  RefType ref(objs, objNr);
349  if (deltaR2Match(ref->eta(), ref->phi())) {
350  filteredObjs->push_back(*ref);
351  orgRefs.push_back(ref);
352  }
353  }
354  return filteredObjs;
355 }
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

◆ filterRecHits()

template<typename RecHitCollection >
std::unique_ptr< RecHitCollection > EgammaHLTPhase2ExtraProducer::filterRecHits ( const trigger::EgammaObjectCollection egTrigObjs,
const edm::Handle< RecHitCollection > &  recHits,
const CaloGeometry geom,
float  maxDR2 = 0.4 * 0.4 
) const
private

Definition at line 358 of file EgammaHLTPhase2ExtraProducer.cc.

References reco::deltaR2(), PVValHelper::eta, Exception, relativeConstraints::geom, hit::id, minPtToSaveHits_, phi, FastTrackerRecHitMaskProducer_cfi::recHits, saveHitsPlusHalfPi_, saveHitsPlusPi_, and GeomDetEnumerators::subDetGeom.

Referenced by produce().

362  {
363  auto filteredHits = std::make_unique<RecHitCollection>();
364  if (!recHits.isValid())
365  return filteredHits;
366 
367  std::vector<std::pair<float, float>> etaPhis;
368  for (const auto& egTrigObj : egTrigObjs) {
369  if (egTrigObj.pt() >= minPtToSaveHits_) {
370  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
371  if (saveHitsPlusPi_)
372  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
374  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
375  }
376  }
377  auto deltaR2Match = [&etaPhis, &maxDR2](const GlobalPoint& pos) {
378  float eta = pos.eta();
379  float phi = pos.phi();
380  for (auto& etaPhi : etaPhis) {
381  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
382  return true;
383  }
384  return false;
385  };
386 
387  for (auto& hit : *recHits) {
388  const CaloSubdetectorGeometry* subDetGeom = geom.getSubdetectorGeometry(hit.id());
389  if (subDetGeom) {
390  auto cellGeom = subDetGeom->getGeometry(hit.id());
391  if (deltaR2Match(cellGeom->getPosition()))
392  filteredHits->push_back(hit);
393  } else {
394  throw cms::Exception("GeomError") << "could not get geometry for det id " << hit.id().rawId();
395  }
396  }
397  return filteredHits;
398 }
constexpr SubDetector subDetGeom[21]
unsigned int id
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

◆ makeValueMap()

template<typename T , typename H >
static std::unique_ptr<edm::ValueMap<T> > EgammaHLTPhase2ExtraProducer::makeValueMap ( const H &  handle,
const std::vector< T > &  values 
)
inlinestaticprivate

Definition at line 145 of file EgammaHLTPhase2ExtraProducer.cc.

References trigObjTnPSource_cfi::filler, patZpeak::handle, and contentValuesCheck::values.

Referenced by produce().

145  {
146  auto valueMap = std::make_unique<edm::ValueMap<T>>();
147  typename edm::ValueMap<T>::Filler filler(*valueMap);
148  filler.insert(handle, values.begin(), values.end());
149  filler.fill();
150  return valueMap;
151  }

◆ produce()

void EgammaHLTPhase2ExtraProducer::produce ( edm::StreamID  streamID,
edm::Event event,
const edm::EventSetup eventSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 220 of file EgammaHLTPhase2ExtraProducer.cc.

References caloGeomToken_, submitPVResolutionJobs::count, EgammaHLTPhase2ExtraProducer::Tokens::egTrigObjs, edmPickEvents::event, options_cfi::eventSetup, filterObjs(), filterRecHits(), HLT_2023v12_cff::flags, patZpeak::handle, EgammaHLTPhase2ExtraProducer::Tokens::hgcal, EgammaHLTPhase2ExtraProducer::Tokens::hgcalLayerClusters, EgammaHLTPhase2ExtraProducer::Tokens::hgcalLayerClustersTime, edm::OrphanHandleBase::id(), TTTrackTruthPair< T >::StatusFlags::IsCombinatoric, TTTrackTruthPair< T >::StatusFlags::IsGenuine, TTTrackTruthPair< T >::StatusFlags::IsLooselyGenuine, TTTrackTruthPair< T >::StatusFlags::IsUnknown, crabWrapper::key, EgammaHLTPhase2ExtraProducer::Tokens::l1Trks, EgammaHLTPhase2ExtraProducer::Tokens::l1TrkToTrkPartMap, makeValueMap(), eostools::move(), recHitCountThresholds_, FastTrackerRecHitMaskProducer_cfi::recHits, edm::refToPtr(), AlCaHLTBitMon_QueryRunRegistry::string, particleFlowZeroSuppressionECAL_cff::thresholds, tokens_, and EgammaHLTPhase2ExtraProducer::Tokens::trkParts.

222  {
223  auto egTrigObjs = event.getHandle(tokens_.egTrigObjs);
224 
225  auto trkParts = event.getHandle(tokens_.trkParts);
226  auto l1trks = event.getHandle(tokens_.l1Trks);
227  auto l1TrkToTrkPartMap = event.getHandle(tokens_.l1TrkToTrkPartMap);
228 
229  auto const caloGeomHandle = eventSetup.getHandle(caloGeomToken_);
230 
231  for (const auto& tokenLabel : tokens_.hgcal) {
232  auto handle = event.getHandle(tokenLabel.first);
233  auto recHits = filterRecHits(*egTrigObjs, handle, *caloGeomHandle);
234  event.put(std::move(recHits), tokenLabel.second);
235  }
236 
237  auto storeCountRecHits = [&event](const auto& tokenLabels, const auto& thresholds, const std::string& prefixLabel) {
238  for (const auto& tokenLabel : tokenLabels) {
239  auto handle = event.getHandle(tokenLabel.first);
240  auto count = countRecHits(handle, thresholds);
241  for (size_t thresNr = 0; thresNr < thresholds.size(); thresNr++) {
242  const auto& thres = thresholds[thresNr];
243  event.put(std::move(count[thresNr]),
244  prefixLabel + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
245  }
246  }
247  };
248  storeCountRecHits(tokens_.hgcal, recHitCountThresholds_, "countHgcalRecHits");
249 
250  auto hgcalLayerClusters = event.getHandle(tokens_.hgcalLayerClusters);
251  auto hgcalLayerClustersTime = event.getHandle(tokens_.hgcalLayerClustersTime);
252  std::vector<edm::Ref<reco::CaloClusterCollection>> orgHGCalLayerClusterRefs;
253  auto hgcalLayerClustersFiltered = filterObjs(*egTrigObjs, hgcalLayerClusters, orgHGCalLayerClusterRefs);
254  std::vector<std::pair<float, float>> timesFiltered;
255  timesFiltered.reserve(orgHGCalLayerClusterRefs.size());
256  for (auto& clusRef : orgHGCalLayerClusterRefs) {
257  timesFiltered.push_back((*hgcalLayerClustersTime)[clusRef]);
258  }
259  auto hgcalLayerClustersFilteredHandle = event.put(std::move(hgcalLayerClustersFiltered), "hgcalLayerClusters");
260  event.put(makeValueMap(hgcalLayerClustersFilteredHandle, timesFiltered), "hgcalLayerClustersTime");
261 
262  std::vector<edm::Ref<L1TrackCollection>> orgL1TrkRefs;
263  auto l1TrksFiltered = filterObjs(*egTrigObjs, l1trks, orgL1TrkRefs);
264  std::vector<edm::Ref<TrackingParticleCollection>> orgTPRefs;
265  auto trkPartsFiltered = filterObjs(*egTrigObjs, trkParts, orgTPRefs);
266 
267  //meh should make this edm::Ref<T>::key_type
268  std::unordered_map<size_t, size_t> orgTPIndxToNewIndx;
269  for (size_t refNr = 0; refNr < orgTPRefs.size(); refNr++) {
270  orgTPIndxToNewIndx.insert(std::make_pair(orgTPRefs[refNr].key(), refNr));
271  }
272 
273  edm::OrphanHandle<L1TrackCollection> l1TrksFiltHandle = event.put(std::move(l1TrksFiltered));
274  edm::OrphanHandle<TrackingParticleCollection> trkPartsFiltHandle = event.put(std::move(trkPartsFiltered));
275 
276  auto l1TrkExtraColl = std::make_unique<L1TrackTruthPairCollection>();
277 
278  for (size_t l1TrkNr = 0; l1TrkNr < orgL1TrkRefs.size(); l1TrkNr++) {
279  auto orgTrkRef = orgL1TrkRefs[l1TrkNr];
280  auto orgTrkPtr = edm::refToPtr(orgTrkRef);
281  int flags = 0;
282  if (l1TrkToTrkPartMap->isGenuine(orgTrkPtr))
284  if (l1TrkToTrkPartMap->isLooselyGenuine(orgTrkPtr))
286  if (l1TrkToTrkPartMap->isCombinatoric(orgTrkPtr))
288  if (l1TrkToTrkPartMap->isUnknown(orgTrkPtr))
290 
291  auto orgTPRef = l1TrkToTrkPartMap->findTrackingParticlePtr(orgTrkPtr);
292  auto getNewTPRef = [&orgTPIndxToNewIndx, &orgTPRef, &trkPartsFiltHandle]() {
293  auto newIndexPair = orgTPIndxToNewIndx.find(orgTPRef.key());
294  if (newIndexPair != orgTPIndxToNewIndx.end()) {
295  return edm::Ref<TrackingParticleCollection>(trkPartsFiltHandle, newIndexPair->second);
296  } else
297  return edm::Ref<TrackingParticleCollection>(trkPartsFiltHandle.id());
298  };
299  auto newTPRef = getNewTPRef();
300  edm::Ref<L1TrackCollection> newL1TrkRef(l1TrksFiltHandle, l1TrkNr);
301 
302  L1TrackTruthPair l1TrkExtra(newL1TrkRef, newTPRef, flags);
303  l1TrkExtraColl->push_back(l1TrkExtra);
304  }
305  event.put(std::move(l1TrkExtraColl));
306 }
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > hgcalLayerClustersTime
std::unique_ptr< RecHitCollection > filterRecHits(const trigger::EgammaObjectCollection &egTrigObjs, const edm::Handle< RecHitCollection > &recHits, const CaloGeometry &geom, float maxDR2=0.4 *0.4) const
edm::EDGetTokenT< L1TrackCollection > l1Trks
static std::unique_ptr< edm::ValueMap< T > > makeValueMap(const H &handle, const std::vector< T > &values)
ProductID id() const
edm::EDGetTokenT< reco::CaloClusterCollection > hgcalLayerClusters
std::unique_ptr< CollType > filterObjs(const trigger::EgammaObjectCollection &egTrigObjs, const edm::Handle< CollType > &objs, std::vector< RefType > &orgRefs, float maxDR2=0.4 *0.4) const
edm::EDGetTokenT< trigger::EgammaObjectCollection > egTrigObjs
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > l1TrkToTrkPartMap
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > const caloGeomToken_
edm::EDGetTokenT< TrackingParticleCollection > trkParts
std::vector< std::pair< edm::EDGetTokenT< HGCRecHitCollection >, std::string > > hgcal
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ caloGeomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> const EgammaHLTPhase2ExtraProducer::caloGeomToken_
private

Definition at line 155 of file EgammaHLTPhase2ExtraProducer.cc.

Referenced by produce().

◆ minPtToSaveHits_

float EgammaHLTPhase2ExtraProducer::minPtToSaveHits_
private

Definition at line 157 of file EgammaHLTPhase2ExtraProducer.cc.

Referenced by filterObjs(), and filterRecHits().

◆ recHitCountThresholds_

std::vector<double> EgammaHLTPhase2ExtraProducer::recHitCountThresholds_
private

Definition at line 160 of file EgammaHLTPhase2ExtraProducer.cc.

Referenced by produce().

◆ saveHitsPlusHalfPi_

bool EgammaHLTPhase2ExtraProducer::saveHitsPlusHalfPi_
private

Definition at line 159 of file EgammaHLTPhase2ExtraProducer.cc.

Referenced by filterObjs(), and filterRecHits().

◆ saveHitsPlusPi_

bool EgammaHLTPhase2ExtraProducer::saveHitsPlusPi_
private

Definition at line 158 of file EgammaHLTPhase2ExtraProducer.cc.

Referenced by filterObjs(), and filterRecHits().

◆ tokens_

const Tokens EgammaHLTPhase2ExtraProducer::tokens_
private

Definition at line 153 of file EgammaHLTPhase2ExtraProducer.cc.

Referenced by produce().