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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 producer More...
 
 ReducedRecHitCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
 ~ReducedRecHitCollectionProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 

Detailed Description

Original author: Paolo Meridiani PH/CMG

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

Definition at line 35 of file ReducedRecHitCollectionProducer.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 25 of file ReducedRecHitCollectionProducer.cc.

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

26 {
27 
28  recHitsToken_ =
29  consumes<EcalRecHitCollection>(iConfig.getParameter< edm::InputTag > ("recHitsLabel"));
30 
33  iConfig.getParameter<std::vector<edm::InputTag>>("interestingDetIdCollections"),
34  [this](edm::InputTag const & tag) {
35  return consumes<DetIdCollection>(tag);
36  }
37  );
38 
39  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
40 
41  //register your products
42  produces< EcalRecHitCollection > (reducedHitsCollection_) ;
43 
44 }
T getParameter(std::string const &) const
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 ( )

Definition at line 47 of file ReducedRecHitCollectionProducer.cc.

48 {}

Member Function Documentation

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

producer

Definition at line 53 of file ReducedRecHitCollectionProducer.cc.

References popcon2dropbox::copy(), edm::SortedCollection< T, SORT >::end(), spr::find(), edm::SortedCollection< T, SORT >::find(), edm::Event::getByToken(), cuy::ii, interestingDetIdCollections_, edm::HandleBase::isValid(), tablePrinter::labels, edm::EDConsumerBase::labelsForToken(), edm::ProductLabels::module, eostools::move(), edm::ProductLabels::process, edm::ProductLabels::productInstance, edm::Event::put(), recHitsToken_, reducedHitsCollection_, lumiQTWidget::t, and tier0::unique().

55 {
56  using namespace edm;
57  using namespace std;
58 
59  if (interestingDetIdCollections_.size() < 1)
60  {
61  edm::LogError("ReducedRecHitCollectionProducer") << "VInputTag collections empty" ;
62  return;
63  }
64 
65 
67  iEvent.getByToken(interestingDetIdCollections_[0],detIds);
68  std::vector<DetId> xtalsToStore((*detIds).size());
69  std::copy( (*detIds).begin() , (*detIds).end() , xtalsToStore.begin() );
70 
71  //Merging DetIds from different collections
72  for( unsigned int t = 1; t < interestingDetIdCollections_.size(); ++t )
73  {
76  if(!detId.isValid())
77  {
78  Labels labels;
80  edm::LogError("MissingInput")<<"no reason to skip detid from : (" << labels.module << ", "
81  << labels.productInstance << ", "
82  << labels.process << ")" << std::endl;
83  continue;
84  }
85 
86 
87  for (unsigned int ii=0;ii<(*detId).size();ii++)
88  {
89  if (std::find(xtalsToStore.begin(),xtalsToStore.end(),(*detId)[ii]) == xtalsToStore.end())
90  xtalsToStore.push_back((*detId)[ii]);
91  }
92  }
93 
94  Handle<EcalRecHitCollection> recHitsHandle;
95  iEvent.getByToken(recHitsToken_,recHitsHandle);
96  if( !recHitsHandle.isValid() )
97  {
98  edm::LogError("ReducedRecHitCollectionProducer") << "RecHit collection not found";
99  return;
100  }
101 
102  //Create empty output collections
103  auto miniRecHitCollection = std::make_unique<EcalRecHitCollection>();
104 
105  for (unsigned int iCry=0;iCry<xtalsToStore.size();iCry++)
106  {
107  EcalRecHitCollection::const_iterator iRecHit = recHitsHandle->find(xtalsToStore[iCry]);
108  if ( (iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(xtalsToStore[iCry]) == miniRecHitCollection->end()) )
109  miniRecHitCollection->push_back(*iRecHit);
110  }
111 
112  std::sort(xtalsToStore.begin(), xtalsToStore.end());
113  std::unique(xtalsToStore.begin(), xtalsToStore.end());
114 
115  // std::cout << "New Collection " << reducedHitsCollection_ << " size is " << miniRecHitCollection->size() << " original is " << recHitsHandle->size() << std::endl;
116  iEvent.put(std::move(miniRecHitCollection),reducedHitsCollection_ );
117 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
std::vector< EcalRecHit >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
def unique(seq, keepstr=True)
Definition: tier0.py:24
bool isValid() const
Definition: HandleBase.h:74
ii
Definition: cuy.py:588
const_iterator end() const
ProductLabels Labels
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
iterator find(key_type k)
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 46 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

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

Definition at line 45 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

std::string ReducedRecHitCollectionProducer::reducedHitsCollection_
private

Definition at line 47 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().