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
 
 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
 

Private Attributes

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

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

Original author: Paolo Meridiani PH/CMG

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

Definition at line 36 of file ReducedRecHitCollectionProducer.cc.

Constructor & Destructor Documentation

◆ ReducedRecHitCollectionProducer()

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

ctor

Definition at line 54 of file ReducedRecHitCollectionProducer.cc.

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

54  {
55  recHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
56 
58  edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>("interestingDetIdCollections"),
59  [this](edm::InputTag const& tag) { return consumes<DetIdCollection>(tag); });
60 
61  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
62 
63  //register your products
64  produces<EcalRecHitCollection>(reducedHitsCollection_);
65 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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::EDGetTokenT< EcalRecHitCollection > recHitsToken_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_

◆ ~ReducedRecHitCollectionProducer()

ReducedRecHitCollectionProducer::~ReducedRecHitCollectionProducer ( )
override

Definition at line 67 of file ReducedRecHitCollectionProducer.cc.

67 {}

Member Function Documentation

◆ produce()

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

producer

Definition at line 70 of file ReducedRecHitCollectionProducer.cc.

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_, jetsAK4_CHS_cff::sort, submitPVValidationJobs::t, and tier0::unique().

70  {
71  using namespace edm;
72  using namespace std;
73 
74  if (interestingDetIdCollections_.empty()) {
75  edm::LogError("ReducedRecHitCollectionProducer") << "VInputTag collections empty";
76  return;
77  }
78 
80  iEvent.getByToken(interestingDetIdCollections_[0], detIds);
81  std::vector<DetId> xtalsToStore((*detIds).size());
82  std::copy((*detIds).begin(), (*detIds).end(), xtalsToStore.begin());
83 
84  //Merging DetIds from different collections
85  for (unsigned int t = 1; t < interestingDetIdCollections_.size(); ++t) {
87  iEvent.getByToken(interestingDetIdCollections_[t], detId);
88  if (!detId.isValid()) {
89  Labels labels;
90  labelsForToken(interestingDetIdCollections_[t], labels);
91  edm::LogError("MissingInput") << "no reason to skip detid from : (" << labels.module << ", "
92  << labels.productInstance << ", " << labels.process << ")" << std::endl;
93  continue;
94  }
95 
96  for (unsigned int ii = 0; ii < (*detId).size(); ii++) {
97  if (std::find(xtalsToStore.begin(), xtalsToStore.end(), (*detId)[ii]) == xtalsToStore.end())
98  xtalsToStore.push_back((*detId)[ii]);
99  }
100  }
101 
102  Handle<EcalRecHitCollection> recHitsHandle;
103  iEvent.getByToken(recHitsToken_, recHitsHandle);
104  if (!recHitsHandle.isValid()) {
105  edm::LogError("ReducedRecHitCollectionProducer") << "RecHit collection not found";
106  return;
107  }
108 
109  //Create empty output collections
110  auto miniRecHitCollection = std::make_unique<EcalRecHitCollection>();
111 
112  for (unsigned int iCry = 0; iCry < xtalsToStore.size(); iCry++) {
113  EcalRecHitCollection::const_iterator iRecHit = recHitsHandle->find(xtalsToStore[iCry]);
114  if ((iRecHit != recHitsHandle->end()) &&
115  (miniRecHitCollection->find(xtalsToStore[iCry]) == miniRecHitCollection->end()))
116  miniRecHitCollection->push_back(*iRecHit);
117  }
118 
119  std::sort(xtalsToStore.begin(), xtalsToStore.end());
120  std::unique(xtalsToStore.begin(), xtalsToStore.end());
121 
122  // std::cout << "New Collection " << reducedHitsCollection_ << " size is " << miniRecHitCollection->size() << " original is " << recHitsHandle->size() << std::endl;
123  iEvent.put(std::move(miniRecHitCollection), reducedHitsCollection_);
124 }
std::vector< EcalRecHit >::const_iterator const_iterator
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
def unique(seq, keepstr=True)
Definition: tier0.py:24
ii
Definition: cuy.py:589
const_iterator end() const
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
bool isValid() const
Definition: HandleBase.h:70
iterator find(key_type k)
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ interestingDetIdCollections_

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

Definition at line 47 of file ReducedRecHitCollectionProducer.cc.

Referenced by produce(), and ReducedRecHitCollectionProducer().

◆ recHitsToken_

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

Definition at line 46 of file ReducedRecHitCollectionProducer.cc.

Referenced by produce(), and ReducedRecHitCollectionProducer().

◆ reducedHitsCollection_

std::string ReducedRecHitCollectionProducer::reducedHitsCollection_
private

Definition at line 48 of file ReducedRecHitCollectionProducer.cc.

Referenced by produce(), and ReducedRecHitCollectionProducer().