#include <Calibration/EcalAlCaRecoProducers/src/ReducedRecHitCollectionProducer.cc>
Public Member Functions | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
producer | |
ReducedRecHitCollectionProducer (const edm::ParameterSet &) | |
ctor | |
~ReducedRecHitCollectionProducer () | |
Private Attributes | |
std::vector< edm::InputTag > | interestingDetIdCollections_ |
edm::InputTag | recHitsLabel_ |
std::string | reducedHitsCollection_ |
Original author: Paolo Meridiani PH/CMG
Implementation: <Notes on="" implementation>="">
Definition at line 34 of file ReducedRecHitCollectionProducer.h.
ReducedRecHitCollectionProducer::ReducedRecHitCollectionProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
ctor
Definition at line 23 of file ReducedRecHitCollectionProducer.cc.
References edm::ParameterSet::getParameter(), interestingDetIdCollections_, recHitsLabel_, and reducedHitsCollection_.
{ recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel"); interestingDetIdCollections_ = iConfig.getParameter< std::vector<edm::InputTag> > ("interestingDetIdCollections"); reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection"); //register your products produces< EcalRecHitCollection > (reducedHitsCollection_) ; }
ReducedRecHitCollectionProducer::~ReducedRecHitCollectionProducer | ( | ) |
Definition at line 37 of file ReducedRecHitCollectionProducer.cc.
{}
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(), interestingDetIdCollections_, edm::HandleBase::isValid(), edm::Event::put(), recHitsLabel_, reducedHitsCollection_, and matplotRender::t.
{ using namespace edm; using namespace std; if (interestingDetIdCollections_.size() < 1) { edm::LogError("ReducedRecHitCollectionProducer") << "VInputTag collections empty" ; return; } Handle< DetIdCollection > detIds; iEvent.getByLabel(interestingDetIdCollections_[0],detIds); std::vector<DetId> xtalsToStore((*detIds).size()); std::copy( (*detIds).begin() , (*detIds).end() , xtalsToStore.begin() ); //Merging DetIds from different collections for( unsigned int t = 1; t < interestingDetIdCollections_.size(); ++t ) { Handle< DetIdCollection > detId; iEvent.getByLabel(interestingDetIdCollections_[t],detId); if( !detId.isValid() ){ edm::LogError("MissingInput")<<"no reason to skip detid from :"<<interestingDetIdCollections_[t]; continue; } for (unsigned int ii=0;ii<(*detId).size();ii++) { if (std::find(xtalsToStore.begin(),xtalsToStore.end(),(*detId)[ii]) == xtalsToStore.end()) xtalsToStore.push_back((*detId)[ii]); } } Handle<EcalRecHitCollection> recHitsHandle; iEvent.getByLabel(recHitsLabel_,recHitsHandle); if( !recHitsHandle.isValid() ) { edm::LogError("ReducedRecHitCollectionProducer") << "RecHit collection not found"; return; } //Create empty output collections std::auto_ptr< EcalRecHitCollection > miniRecHitCollection (new EcalRecHitCollection) ; for (unsigned int iCry=0;iCry<xtalsToStore.size();iCry++) { EcalRecHitCollection::const_iterator iRecHit = recHitsHandle->find(xtalsToStore[iCry]); if ( (iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(xtalsToStore[iCry]) == miniRecHitCollection->end()) ) miniRecHitCollection->push_back(*iRecHit); } // std::cout << "New Collection " << reducedHitsCollection_ << " size is " << miniRecHitCollection->size() << " original is " << recHitsHandle->size() << std::endl; iEvent.put( miniRecHitCollection,reducedHitsCollection_ ); }
std::vector<edm::InputTag> ReducedRecHitCollectionProducer::interestingDetIdCollections_ [private] |
Definition at line 45 of file ReducedRecHitCollectionProducer.h.
Referenced by produce(), and ReducedRecHitCollectionProducer().
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().