Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:39

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTCSCActivityFilter
0004 // Class:      HLTCSCActivityFilter
0005 //
0006 /**\class HLTCSCActivityFilter HLTCSCActivityFilter.cc filter/HLTCSCActivityFilter/src/HLTCSCActivityFilter.cc
0007 
0008 Description:
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Carlo Battilana
0015 //         Created:  Tue Jan 22 13:55:00 CET 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <vector>
0021 #include <map>
0022 #include <iostream>
0023 #include <memory>
0024 
0025 // user include files
0026 #include "HLTCSCActivityFilter.h"
0027 
0028 //
0029 // constructors and destructor
0030 //
0031 HLTCSCActivityFilter::HLTCSCActivityFilter(const edm::ParameterSet& iConfig)
0032     : HLTFilter(iConfig),
0033       m_cscStripDigiTag(iConfig.getParameter<edm::InputTag>("cscStripDigiTag")),
0034       m_MESR(iConfig.getParameter<bool>("skipStationRing")),
0035       m_RingNumb(iConfig.getParameter<int>("skipRingNumber")),
0036       m_StationNumb(iConfig.getParameter<int>("skipStationNumber")) {
0037   m_cscStripDigiToken = consumes<CSCStripDigiCollection>(m_cscStripDigiTag);
0038 }
0039 
0040 HLTCSCActivityFilter::~HLTCSCActivityFilter() = default;
0041 
0042 void HLTCSCActivityFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0043   edm::ParameterSetDescription desc;
0044   makeHLTFilterDescription(desc);
0045   desc.add<edm::InputTag>("cscStripDigiTag", edm::InputTag("hltMuonCSCDigis", "MuonCSCStripDigi"));
0046   desc.add<bool>("skipStationRing", true);
0047   desc.add<int>("skipRingNumber", 1);
0048   desc.add<int>("skipStationNumber", 4);
0049   descriptions.add("hltCSCActivityFilter", desc);
0050 }
0051 
0052 //
0053 // member functions
0054 //
0055 
0056 // ------------ method called on each new Event  ------------
0057 bool HLTCSCActivityFilter::hltFilter(edm::Event& iEvent,
0058                                      const edm::EventSetup& iSetup,
0059                                      trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0060   using namespace edm;
0061   using namespace std;
0062   using namespace trigger;
0063 
0064   int nStripsFired = 0;
0065 
0066   edm::Handle<CSCStripDigiCollection> cscStrips;
0067   iEvent.getByToken(m_cscStripDigiToken, cscStrips);
0068 
0069   for (auto&& dSDiter : *cscStrips) {
0070     CSCDetId id = (CSCDetId)dSDiter.first;
0071     bool thisME = ((id.station() == m_StationNumb) && (id.ring() == m_RingNumb));
0072     if (m_MESR && thisME)
0073       continue;
0074 
0075     auto stripIter = dSDiter.second.first;
0076     auto lStrip = dSDiter.second.second;
0077     for (; stripIter != lStrip; ++stripIter) {
0078       const std::vector<int>& myADCVals = stripIter->getADCCounts();
0079       const float pedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
0080       const float threshold = 20;
0081       const float cut = pedestal + threshold;
0082       for (unsigned int i = 2; i < myADCVals.size(); ++i)
0083         if (myADCVals[i] > cut) {
0084           ++nStripsFired;
0085           break;
0086         }
0087     }
0088   }
0089 
0090   return (nStripsFired >= 1);
0091 }
0092 
0093 // define as a framework module
0094 #include "FWCore/Framework/interface/MakerMacros.h"
0095 DEFINE_FWK_MODULE(HLTCSCActivityFilter);