Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:45

0001 // -*- C++ -*-
0002 //
0003 // Package:    EcalBasicUncalibRecHitFilter
0004 // Class:      EcalBasicUncalibRecHitFilter
0005 //
0006 /**\class EcalBasicUncalibRecHitFilter EcalBasicUncalibRecHitFilter.cc Work/EcalBasicUncalibRecHitFilter/src/EcalBasicUncalibRecHitFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Giovanni FRANZONI
0015 //         Created:  Wed Sep 19 16:21:29 CEST 2007
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
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 // class declaration
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   // ----------member data ---------------------------
0048 
0049   const double minAdc_;
0050   const edm::InputTag EcalUncalibRecHitCollection_;
0051   std::vector<int> maskedList_;
0052 };
0053 
0054 //
0055 // constructors and destructor
0056 //
0057 EcalBasicUncalibRecHitFilter::EcalBasicUncalibRecHitFilter(const edm::ParameterSet& iConfig)
0058     : minAdc_(iConfig.getUntrackedParameter<double>("adcCut", 12)),
0059       EcalUncalibRecHitCollection_(iConfig.getParameter<edm::InputTag>("EcalUncalibRecHitCollection")) {
0060   //now do what ever initialization is needed
0061   //masked list is using the ashed index
0062   maskedList_ = iConfig.getUntrackedParameter<std::vector<int> >("maskedChannels", maskedList_);
0063 }
0064 
0065 //
0066 // member functions
0067 //
0068 
0069 // ------------ method called on each new Event  ------------
0070 bool EcalBasicUncalibRecHitFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0071   using namespace edm;
0072 
0073   // getting very basic uncalRH
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   // loop on crude rechits
0083   for (EcalUncalibratedRecHitCollection::const_iterator hitItr = crudeHits->begin(); hitItr != crudeHits->end();
0084        ++hitItr) {
0085     EcalUncalibratedRecHit hit = (*hitItr);
0086 
0087     // masking noisy channels
0088     std::vector<int>::iterator result;
0089     result = find(maskedList_.begin(), maskedList_.end(), EBDetId(hit.id()).hashedIndex());
0090     if (result != maskedList_.end())
0091       // LogWarning("EcalFilter") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli_ ;
0092       continue;
0093 
0094     float ampli_ = hit.amplitude();
0095 
0096     // seeking channels with signal and displaced jitter
0097     if (ampli_ >= minAdc_) {
0098       thereIsSignal = true;
0099       // LogWarning("EcalFilter")  << "at evet: " << iEvent.id().event()
0100       //                       << " and run: " << iEvent.id().run()
0101       //                       << " there is OUT OF TIME signal at chanel: " << ic
0102       //                       << " with amplitude " << ampli_  << " and max at: " << jitter_;
0103       break;
0104     }
0105   }
0106 
0107   return thereIsSignal;
0108 }
0109 
0110 //define this as a plug-in
0111 DEFINE_FWK_MODULE(EcalBasicUncalibRecHitFilter);