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::EDProducer 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::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- 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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::vector< edm::InputTaginterestingDetIdCollections_
 
edm::InputTag recHitsLabel_
 
std::string reducedHitsCollection_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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 34 of file ReducedRecHitCollectionProducer.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 23 of file ReducedRecHitCollectionProducer.cc.

References edm::ParameterSet::getParameter(), interestingDetIdCollections_, recHitsLabel_, reducedHitsCollection_, and AlCaHLTBitMon_QueryRunRegistry::string.

24 {
25 
26  recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel");
27  interestingDetIdCollections_ = iConfig.getParameter< std::vector<edm::InputTag> > ("interestingDetIdCollections");
28 
29  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
30 
31  //register your products
32  produces< EcalRecHitCollection > (reducedHitsCollection_) ;
33 
34 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > interestingDetIdCollections_
ReducedRecHitCollectionProducer::~ReducedRecHitCollectionProducer ( )

Definition at line 37 of file ReducedRecHitCollectionProducer.cc.

38 {}

Member Function Documentation

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

producer

Implements edm::EDProducer.

Definition at line 43 of file ReducedRecHitCollectionProducer.cc.

References filterCSVwithJSON::copy, spr::find(), edm::Event::getByLabel(), cuy::ii, interestingDetIdCollections_, edm::HandleBase::isValid(), edm::Event::put(), recHitsLabel_, reducedHitsCollection_, python.multivaluedict::sort(), and lumiQTWidget::t.

45 {
46  using namespace edm;
47  using namespace std;
48 
49  if (interestingDetIdCollections_.size() < 1)
50  {
51  edm::LogError("ReducedRecHitCollectionProducer") << "VInputTag collections empty" ;
52  return;
53  }
54 
55 
57  iEvent.getByLabel(interestingDetIdCollections_[0],detIds);
58  std::vector<DetId> xtalsToStore((*detIds).size());
59  std::copy( (*detIds).begin() , (*detIds).end() , xtalsToStore.begin() );
60 
61  //Merging DetIds from different collections
62  for( unsigned int t = 1; t < interestingDetIdCollections_.size(); ++t )
63  {
66  if( !detId.isValid() ){
67  edm::LogError("MissingInput")<<"no reason to skip detid from :"<<interestingDetIdCollections_[t];
68  continue;
69  }
70 
71  for (unsigned int ii=0;ii<(*detId).size();ii++)
72  {
73  if (std::find(xtalsToStore.begin(),xtalsToStore.end(),(*detId)[ii]) == xtalsToStore.end())
74  xtalsToStore.push_back((*detId)[ii]);
75  }
76  }
77 
78  Handle<EcalRecHitCollection> recHitsHandle;
79  iEvent.getByLabel(recHitsLabel_,recHitsHandle);
80  if( !recHitsHandle.isValid() )
81  {
82  edm::LogError("ReducedRecHitCollectionProducer") << "RecHit collection not found";
83  return;
84  }
85 
86  //Create empty output collections
87  std::auto_ptr< EcalRecHitCollection > miniRecHitCollection (new EcalRecHitCollection) ;
88 
89  for (unsigned int iCry=0;iCry<xtalsToStore.size();iCry++)
90  {
91  EcalRecHitCollection::const_iterator iRecHit = recHitsHandle->find(xtalsToStore[iCry]);
92  if ( (iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(xtalsToStore[iCry]) == miniRecHitCollection->end()) )
93  miniRecHitCollection->push_back(*iRecHit);
94  }
95 
96  std::sort(xtalsToStore.begin(), xtalsToStore.end());
97  std::unique(xtalsToStore.begin(), xtalsToStore.end());
98 
99  // std::cout << "New Collection " << reducedHitsCollection_ << " size is " << miniRecHitCollection->size() << " original is " << recHitsHandle->size() << std::endl;
100  iEvent.put( miniRecHitCollection,reducedHitsCollection_ );
101 }
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
std::vector< edm::InputTag > interestingDetIdCollections_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361

Member Data Documentation

std::vector<edm::InputTag> ReducedRecHitCollectionProducer::interestingDetIdCollections_
private

Definition at line 45 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

edm::InputTag ReducedRecHitCollectionProducer::recHitsLabel_
private

Definition at line 44 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().

std::string ReducedRecHitCollectionProducer::reducedHitsCollection_
private

Definition at line 46 of file ReducedRecHitCollectionProducer.h.

Referenced by produce(), and ReducedRecHitCollectionProducer().