File indexing completed on 2024-04-06 12:25:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/stream/EDFilter.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030
0031 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0032 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
0033 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0034
0035
0036
0037
0038
0039 class EcalBasicUncalibRecHitFilter : public edm::stream::EDFilter<> {
0040 public:
0041 explicit EcalBasicUncalibRecHitFilter(const edm::ParameterSet&);
0042 ~EcalBasicUncalibRecHitFilter() override = default;
0043
0044 private:
0045 bool filter(edm::Event&, const edm::EventSetup&) override;
0046
0047
0048
0049 const double minAdc_;
0050 const edm::InputTag EcalUncalibRecHitCollection_;
0051 std::vector<int> maskedList_;
0052 };
0053
0054
0055
0056
0057 EcalBasicUncalibRecHitFilter::EcalBasicUncalibRecHitFilter(const edm::ParameterSet& iConfig)
0058 : minAdc_(iConfig.getUntrackedParameter<double>("adcCut", 12)),
0059 EcalUncalibRecHitCollection_(iConfig.getParameter<edm::InputTag>("EcalUncalibRecHitCollection")) {
0060
0061
0062 maskedList_ = iConfig.getUntrackedParameter<std::vector<int> >("maskedChannels", maskedList_);
0063 }
0064
0065
0066
0067
0068
0069
0070 bool EcalBasicUncalibRecHitFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0071 using namespace edm;
0072
0073
0074 Handle<EcalUncalibratedRecHitCollection> crudeHits;
0075 try {
0076 iEvent.getByLabel(EcalUncalibRecHitCollection_, crudeHits);
0077 } catch (std::exception& ex) {
0078 LogWarning("EcalBasicUncalibRecHitFilter") << EcalUncalibRecHitCollection_ << " not available";
0079 }
0080
0081 bool thereIsSignal = false;
0082
0083 for (EcalUncalibratedRecHitCollection::const_iterator hitItr = crudeHits->begin(); hitItr != crudeHits->end();
0084 ++hitItr) {
0085 EcalUncalibratedRecHit hit = (*hitItr);
0086
0087
0088 std::vector<int>::iterator result;
0089 result = find(maskedList_.begin(), maskedList_.end(), EBDetId(hit.id()).hashedIndex());
0090 if (result != maskedList_.end())
0091
0092 continue;
0093
0094 float ampli_ = hit.amplitude();
0095
0096
0097 if (ampli_ >= minAdc_) {
0098 thereIsSignal = true;
0099
0100
0101
0102
0103 break;
0104 }
0105 }
0106
0107 return thereIsSignal;
0108 }
0109
0110
0111 DEFINE_FWK_MODULE(EcalBasicUncalibRecHitFilter);