Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTFEDSizeFilter
0004 // Class:      HLTFEDSizeFilter
0005 //
0006 /**\class HLTFEDSizeFilter HLTFEDSizeFilter.cc Work/HLTFEDSizeFilter/src/HLTFEDSizeFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Bryan DAHMES
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 "HLTrigger/HLTcore/interface/HLTFilter.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 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0032 
0033 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0034 
0035 //
0036 // class declaration
0037 //
0038 
0039 class HLTFEDSizeFilter : public HLTFilter {
0040 public:
0041   explicit HLTFEDSizeFilter(const edm::ParameterSet&);
0042   ~HLTFEDSizeFilter() override;
0043   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044 
0045 private:
0046   bool hltFilter(edm::Event&,
0047                  const edm::EventSetup&,
0048                  trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0049 
0050   // ----------member data ---------------------------
0051   edm::EDGetTokenT<FEDRawDataCollection> RawCollectionToken_;
0052   edm::InputTag RawCollection_;
0053   unsigned int threshold_;
0054   unsigned int fedStart_, fedStop_;
0055   bool requireAllFEDs_;
0056 };
0057 
0058 //
0059 // constructors and destructor
0060 //
0061 HLTFEDSizeFilter::HLTFEDSizeFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0062   threshold_ = iConfig.getParameter<unsigned int>("threshold");
0063   RawCollection_ = iConfig.getParameter<edm::InputTag>("rawData");
0064   // For a list of FEDs by subdetector, see DataFormats/FEDRawData/src/FEDNumbering.cc
0065   fedStart_ = iConfig.getParameter<unsigned int>("firstFED");
0066   fedStop_ = iConfig.getParameter<unsigned int>("lastFED");
0067   requireAllFEDs_ = iConfig.getParameter<bool>("requireAllFEDs");
0068 
0069   RawCollectionToken_ = consumes<FEDRawDataCollection>(RawCollection_);
0070 }
0071 
0072 HLTFEDSizeFilter::~HLTFEDSizeFilter() {
0073   // do anything here that needs to be done at desctruction time
0074   // (e.g. close files, deallocate resources etc.)
0075 }
0076 
0077 void HLTFEDSizeFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078   edm::ParameterSetDescription desc;
0079   makeHLTFilterDescription(desc);
0080   desc.add<edm::InputTag>("rawData", edm::InputTag("source", "", ""));
0081   desc.add<unsigned int>("threshold", 0)
0082       ->setComment(" # 0 is pass-through, 1 means *FED ispresent*, higher values are just FED size");
0083   desc.add<unsigned int>("firstFED", 0)->setComment(" # first FED, inclusive");
0084   desc.add<unsigned int>("lastFED", 39)->setComment(" # last FED, inclusive");
0085   desc.add<bool>("requireAllFEDs", false)
0086       ->setComment(" # if True, *all* FEDs must be above threshold; if False, only *one* is required");
0087   descriptions.add("hltFEDSizeFilter", desc);
0088 }
0089 
0090 //
0091 // member functions
0092 //
0093 
0094 // ------------ method called on each new Event  ------------
0095 bool HLTFEDSizeFilter::hltFilter(edm::Event& iEvent,
0096                                  const edm::EventSetup& iSetup,
0097                                  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0098   // get the RAW data collction
0099   edm::Handle<FEDRawDataCollection> h_raw;
0100   iEvent.getByToken(RawCollectionToken_, h_raw);
0101   // do NOT handle the case where the collection is not available - let the framework handle the exception
0102   const FEDRawDataCollection theRaw = *h_raw;
0103 
0104   bool result = false;
0105 
0106   if (not requireAllFEDs_) {
0107     // require that *at least one* FED in the given range has size above or equal to the threshold
0108     result = false;
0109     for (unsigned int i = fedStart_; i <= fedStop_; i++)
0110       if (theRaw.FEDData(i).size() >= threshold_) {
0111         result = true;
0112         break;
0113       }
0114   } else {
0115     // require that *all* FEDs in the given range have size above or equal to the threshold
0116     result = true;
0117     for (unsigned int i = fedStart_; i <= fedStop_; i++)
0118       if (theRaw.FEDData(i).size() < threshold_) {
0119         result = false;
0120         break;
0121       }
0122   }
0123 
0124   return result;
0125 }
0126 
0127 // declare this class as a framework plugin
0128 DEFINE_FWK_MODULE(HLTFEDSizeFilter);