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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 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
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
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
ReducedRecHitCollectionProducer::~ReducedRecHitCollectionProducer ( )
override

Definition at line 47 of file ReducedRecHitCollectionProducer.cc.

48 {}

Member Function Documentation

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

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, eostools::move(), edm::Event::put(), recHitsToken_, reducedHitsCollection_, lumiQTWidget::t, and tier0::unique().

55 {
56  using namespace edm;
57  using namespace std;
58 
59  if (interestingDetIdCollections_.empty())
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;
79  labelsForToken(interestingDetIdCollections_[t], 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:125
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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:25
bool isValid() const
Definition: HandleBase.h:74
ii
Definition: cuy.py:590
const_iterator end() const
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
iterator find(key_type k)
HLT enums.
def move(src, dest)
Definition: eostools.py:511

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().