CMS 3D CMS Logo

RecHitFilter.cc
Go to the documentation of this file.
1 
7 // C/C++ headers
8 #include <iostream>
9 #include <vector>
10 #include <memory>
11 
12 // Framework
18 
19 // Reconstruction Classes
23 
24 // Class header file
26 
27 
29  noiseEnergyThreshold_(ps.getParameter<double>("noiseEnergyThreshold")),
30  noiseChi2Threshold_(ps.getParameter<double>("noiseChi2Threshold")),
31  reducedHitCollection_(ps.getParameter<std::string>("reducedHitCollection")),
32  hitCollection_(consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("hitCollection")))
33 {
34  produces< EcalRecHitCollection >(reducedHitCollection_);
35 }
36 
37 
39 {
40 }
41 
42 
44 {
45  // get the hit collection from the event:
47  evt.getByToken(hitCollection_, rhcHandle);
48  const EcalRecHitCollection* hit_collection = rhcHandle.product();
49 
50  int nTot = hit_collection->size();
51  int nRed = 0;
52 
53  // create a unique_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
54  auto redCollection = std::make_unique<EcalRecHitCollection>();
55 
56  for(EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) {
57  //std::cout << *it << std::endl;
58  if(it->energy() > noiseEnergyThreshold_ && it->chi2() < noiseChi2Threshold_) {
59  nRed++;
60  redCollection->push_back( EcalRecHit(*it) );
61  }
62 
63  }
64 
65  edm::LogInfo("")<< "total # hits: " << nTot << " #hits with E > " << noiseEnergyThreshold_ << " GeV and chi2 < " << noiseChi2Threshold_ << " : " << nRed << std::endl;
66 
67  evt.put(std::move(redCollection), reducedHitCollection_);
68 
69 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const edm::EDGetTokenT< EcalRecHitCollection > hitCollection_
Definition: RecHitFilter.h:37
std::vector< EcalRecHit >::const_iterator const_iterator
~RecHitFilter() override
Definition: RecHitFilter.cc:38
const double noiseEnergyThreshold_
Definition: RecHitFilter.h:34
const_iterator end() const
T const * product() const
Definition: Handle.h:74
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: RecHitFilter.cc:43
HLT enums.
const double noiseChi2Threshold_
Definition: RecHitFilter.h:35
size_type size() const
const std::string reducedHitCollection_
Definition: RecHitFilter.h:36
RecHitFilter(const edm::ParameterSet &ps)
Definition: RecHitFilter.cc:28
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const