CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ReducedRecHitCollectionProducer Class Reference

#include <Calibration/EcalAlCaRecoProducers/src/ReducedRecHitCollectionProducer.cc>

Inheritance diagram for ReducedRecHitCollectionProducer:
edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 producer More...
 
 ReducedRecHitCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
 ~ReducedRecHitCollectionProducer () 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
 

Private Attributes

std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsToken_
 
std::string reducedHitsCollection_
 

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

Original author: Paolo Meridiani PH/CMG

Implementation: <Notes on="" implementation>="">

Definition at line 33 of file ReducedRecHitCollectionProducer.h.

Constructor & Destructor Documentation

◆ ReducedRecHitCollectionProducer()

ReducedRecHitCollectionProducer::ReducedRecHitCollectionProducer ( const edm::ParameterSet iConfig)
explicit

ctor

Definition at line 21 of file ReducedRecHitCollectionProducer.cc.

21  {
22  recHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
23 
25  edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>("interestingDetIdCollections"),
26  [this](edm::InputTag const& tag) { return consumes<DetIdCollection>(tag); });
27 
28  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
29 
30  //register your products
31  produces<EcalRecHitCollection>(reducedHitsCollection_);
32 }

References edm::ParameterSet::getParameter(), interestingDetIdCollections_, recHitsToken_, reducedHitsCollection_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

◆ ~ReducedRecHitCollectionProducer()

ReducedRecHitCollectionProducer::~ReducedRecHitCollectionProducer ( )
override

Definition at line 34 of file ReducedRecHitCollectionProducer.cc.

34 {}

Member Function Documentation

◆ produce()

void ReducedRecHitCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

producer

Definition at line 37 of file ReducedRecHitCollectionProducer.cc.

37  {
38  using namespace edm;
39  using namespace std;
40 
41  if (interestingDetIdCollections_.empty()) {
42  edm::LogError("ReducedRecHitCollectionProducer") << "VInputTag collections empty";
43  return;
44  }
45 
47  iEvent.getByToken(interestingDetIdCollections_[0], detIds);
48  std::vector<DetId> xtalsToStore((*detIds).size());
49  std::copy((*detIds).begin(), (*detIds).end(), xtalsToStore.begin());
50 
51  //Merging DetIds from different collections
52  for (unsigned int t = 1; t < interestingDetIdCollections_.size(); ++t) {
54  iEvent.getByToken(interestingDetIdCollections_[t], detId);
55  if (!detId.isValid()) {
56  Labels labels;
57  labelsForToken(interestingDetIdCollections_[t], labels);
58  edm::LogError("MissingInput") << "no reason to skip detid from : (" << labels.module << ", "
59  << labels.productInstance << ", " << labels.process << ")" << std::endl;
60  continue;
61  }
62 
63  for (unsigned int ii = 0; ii < (*detId).size(); ii++) {
64  if (std::find(xtalsToStore.begin(), xtalsToStore.end(), (*detId)[ii]) == xtalsToStore.end())
65  xtalsToStore.push_back((*detId)[ii]);
66  }
67  }
68 
69  Handle<EcalRecHitCollection> recHitsHandle;
70  iEvent.getByToken(recHitsToken_, recHitsHandle);
71  if (!recHitsHandle.isValid()) {
72  edm::LogError("ReducedRecHitCollectionProducer") << "RecHit collection not found";
73  return;
74  }
75 
76  //Create empty output collections
77  auto miniRecHitCollection = std::make_unique<EcalRecHitCollection>();
78 
79  for (unsigned int iCry = 0; iCry < xtalsToStore.size(); iCry++) {
80  EcalRecHitCollection::const_iterator iRecHit = recHitsHandle->find(xtalsToStore[iCry]);
81  if ((iRecHit != recHitsHandle->end()) &&
82  (miniRecHitCollection->find(xtalsToStore[iCry]) == miniRecHitCollection->end()))
83  miniRecHitCollection->push_back(*iRecHit);
84  }
85 
86  std::sort(xtalsToStore.begin(), xtalsToStore.end());
87  std::unique(xtalsToStore.begin(), xtalsToStore.end());
88 
89  // std::cout << "New Collection " << reducedHitsCollection_ << " size is " << miniRecHitCollection->size() << " original is " << recHitsHandle->size() << std::endl;
90  iEvent.put(std::move(miniRecHitCollection), reducedHitsCollection_);
91 }

References filterCSVwithJSON::copy, edm::SortedCollection< T, SORT >::end(), spr::find(), edm::SortedCollection< T, SORT >::find(), iEvent, cuy::ii, interestingDetIdCollections_, edm::HandleBase::isValid(), SummaryClient_cfi::labels, eostools::move(), recHitsToken_, reducedHitsCollection_, OrderedSet::t, and tier0::unique().

Member Data Documentation

◆ interestingDetIdCollections_

std::vector<edm::EDGetTokenT<DetIdCollection> > ReducedRecHitCollectionProducer::interestingDetIdCollections_
private

Definition at line 44 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

◆ recHitsToken_

edm::EDGetTokenT<EcalRecHitCollection> ReducedRecHitCollectionProducer::recHitsToken_
private

Definition at line 43 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

◆ reducedHitsCollection_

std::string ReducedRecHitCollectionProducer::reducedHitsCollection_
private

Definition at line 45 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm
HLT enums.
Definition: AlignableModifier.h:19
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
edm::LogError
Definition: MessageLogger.h:183
ReducedRecHitCollectionProducer::recHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
Definition: ReducedRecHitCollectionProducer.h:43
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
iEvent
int iEvent
Definition: GenABIO.cc:224
ReducedRecHitCollectionProducer::reducedHitsCollection_
std::string reducedHitsCollection_
Definition: ReducedRecHitCollectionProducer.h:45
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
cuy.ii
ii
Definition: cuy.py:590
edm::InputTag
Definition: InputTag.h:15
ReducedRecHitCollectionProducer::interestingDetIdCollections_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
Definition: ReducedRecHitCollectionProducer.h:44