CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::vector< edm::EDGetTokenT
< DetIdCollection > > 
interestingDetIdCollections_
 
edm::EDGetTokenT
< EcalRecHitCollection
recHitsToken_
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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_, 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

Implements edm::stream::EDProducerBase.

Definition at line 53 of file ReducedRecHitCollectionProducer.cc.

References filterCSVwithJSON::copy, spr::find(), edm::Event::getByToken(), cuy::ii, interestingDetIdCollections_, edm::HandleBase::isValid(), tablePrinter::labels, edm::EDConsumerBase::labelsForToken(), edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, edm::EDConsumerBase::Labels::productInstance, edm::Event::put(), recHitsToken_, reducedHitsCollection_, python.multivaluedict::sort(), and edmStreamStallGrapher::t.

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  std::auto_ptr< EcalRecHitCollection > miniRecHitCollection (new 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( miniRecHitCollection,reducedHitsCollection_ );
117 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
std::vector< EcalRecHit >::const_iterator const_iterator
int ii
Definition: cuy.py:588
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
bool isValid() const
Definition: HandleBase.h:76
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const

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