![]() |
![]() |
00001 00010 // C/C++ headers 00011 #include <iostream> 00012 #include <vector> 00013 #include <memory> 00014 00015 // Framework 00016 #include "FWCore/Framework/interface/Event.h" 00017 #include "FWCore/Framework/interface/EventSetup.h" 00018 #include "DataFormats/Common/interface/Handle.h" 00019 #include "FWCore/Framework/interface/ESHandle.h" 00020 00021 // Reconstruction Classes 00022 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h" 00023 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" 00024 #include "DataFormats/EcalDetId/interface/EBDetId.h" 00025 00026 00027 // Class header file 00028 #include "RecoEcal/EgammaClusterProducers/interface/RecHitFilter.h" 00029 00030 00031 RecHitFilter::RecHitFilter(const edm::ParameterSet& ps) 00032 { 00033 00034 noiseThreshold_ = ps.getParameter<double>("noiseThreshold"); 00035 hitProducer_ = ps.getParameter<std::string>("hitProducer"); 00036 hitCollection_ = ps.getParameter<std::string>("hitCollection"); 00037 reducedHitCollection_ = ps.getParameter<std::string>("reducedHitCollection"); 00038 00039 produces< EcalRecHitCollection >(reducedHitCollection_); 00040 } 00041 00042 00043 RecHitFilter::~RecHitFilter() 00044 { 00045 } 00046 00047 00048 void RecHitFilter::produce(edm::Event& evt, const edm::EventSetup& es) 00049 { 00050 // get the hit collection from the event: 00051 edm::Handle<EcalRecHitCollection> rhcHandle; 00052 evt.getByLabel(hitProducer_, hitCollection_, rhcHandle); 00053 if (!(rhcHandle.isValid())) 00054 { 00055 std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; 00056 return; 00057 } 00058 const EcalRecHitCollection* hit_collection = rhcHandle.product(); 00059 00060 int nTot = hit_collection->size(); 00061 int nRed = 0; 00062 00063 // create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event: 00064 std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection); 00065 //clusters_p->assign(clusters.begin(), clusters.end()); 00066 00067 for(EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) { 00068 //std::cout << *it << std::endl; 00069 if(it->energy() > noiseThreshold_) { 00070 nRed++; 00071 redCollection->push_back( EcalRecHit(*it) ); 00072 } 00073 } 00074 std::cout << "total # hits: " << nTot << " #hits with E > " << noiseThreshold_ << " GeV : " << nRed << std::endl; 00075 00076 evt.put(redCollection, reducedHitCollection_); 00077 00078 //std::cout << "BasicClusterCollection added to the Event! :-)" << std::endl; 00079 00080 }