![]() |
![]() |
00001 // -*- C++ -*- 00002 // 00003 // Package: HLTFEDSizeFilter 00004 // Class: HLTFEDSizeFilter 00005 // 00013 // 00014 // Original Author: Bryan DAHMES 00015 // Created: Wed Sep 19 16:21:29 CEST 2007 00016 // $Id: HLTFEDSizeFilter.cc,v 1.8 2009/05/16 13:58:31 fwyzard Exp $ 00017 // 00018 // 00019 00020 00021 // system include files 00022 #include <memory> 00023 00024 // user include files 00025 #include "FWCore/Framework/interface/Frameworkfwd.h" 00026 #include "HLTrigger/HLTcore/interface/HLTFilter.h" 00027 00028 #include "FWCore/Framework/interface/Event.h" 00029 #include "FWCore/Framework/interface/MakerMacros.h" 00030 00031 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00032 00033 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" 00034 00035 // 00036 // class declaration 00037 // 00038 00039 class HLTFEDSizeFilter : public HLTFilter { 00040 public: 00041 explicit HLTFEDSizeFilter(const edm::ParameterSet&); 00042 ~HLTFEDSizeFilter(); 00043 00044 private: 00045 virtual bool filter(edm::Event&, const edm::EventSetup&); 00046 00047 // ----------member data --------------------------- 00048 edm::InputTag RawCollection_; 00049 unsigned int threshold_; 00050 unsigned int fedStart_, fedStop_ ; 00051 bool requireAllFEDs_; 00052 00053 }; 00054 00055 // 00056 // constructors and destructor 00057 // 00058 HLTFEDSizeFilter::HLTFEDSizeFilter(const edm::ParameterSet& iConfig) 00059 { 00060 threshold_ = iConfig.getParameter<unsigned int>("threshold"); 00061 RawCollection_ = iConfig.getParameter<edm::InputTag>("rawData"); 00062 // For a list of FEDs by subdetector, see DataFormats/FEDRawData/src/FEDNumbering.cc 00063 fedStart_ = iConfig.getParameter<unsigned int>("firstFED"); 00064 fedStop_ = iConfig.getParameter<unsigned int>("lastFED"); 00065 requireAllFEDs_ = iConfig.getParameter<bool>("requireAllFEDs"); 00066 } 00067 00068 00069 HLTFEDSizeFilter::~HLTFEDSizeFilter() 00070 { 00071 // do anything here that needs to be done at desctruction time 00072 // (e.g. close files, deallocate resources etc.) 00073 } 00074 00075 00076 // 00077 // member functions 00078 // 00079 00080 // ------------ method called on each new Event ------------ 00081 bool 00082 HLTFEDSizeFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { 00083 00084 // get the RAW data collction 00085 edm::Handle<FEDRawDataCollection> h_raw; 00086 iEvent.getByLabel(RawCollection_, h_raw); 00087 // do NOT handle the case where the collection is not available - let the framework handle the exception 00088 const FEDRawDataCollection theRaw = * h_raw; 00089 00090 bool result = false; 00091 00092 if (not requireAllFEDs_) { 00093 // require that *at least one* FED in the given range has size above or equal to the threshold 00094 result = false; 00095 for (unsigned int i = fedStart_; i <= fedStop_; i++) 00096 if (theRaw.FEDData(i).size() >= threshold_) { 00097 result = true; 00098 break; 00099 } 00100 } else { 00101 // require that *all* FEDs in the given range have size above or equal to the threshold 00102 result = true; 00103 for (unsigned int i = fedStart_; i <= fedStop_; i++) 00104 if (theRaw.FEDData(i).size() < threshold_) { 00105 result = false; 00106 break; 00107 } 00108 } 00109 00110 return result; 00111 } 00112 00113 //define this as a plug-in 00114 DEFINE_FWK_MODULE(HLTFEDSizeFilter);