Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:42

0001 // -*- C++ -*-
0002 //
0003 // Package:    HcalEmptyEventFilter
0004 // Class:      HcalEmptyEventFilter
0005 //
0006 /**\class HcalEmptyEventFilter HcalEmptyEventFilter.cc filter/HcalEmptyEventFilter/src/HcalEmptyEventFilter.cc
0007 
0008 Description: <one line class summary>
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Jeremiah Mans
0015 //         Created:  Tue Jun 4 CET 2012
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 
0025 #include "FWCore/Framework/interface/global/EDFilter.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 
0031 #include <string>
0032 #include <iostream>
0033 
0034 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0035 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0036 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0037 #include "EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h"
0038 #include "EventFilter/HcalRawToDigi/interface/HcalHTRData.h"
0039 
0040 //
0041 // class declaration
0042 //
0043 
0044 class HcalEmptyEventFilter : public edm::global::EDFilter<> {
0045 public:
0046   explicit HcalEmptyEventFilter(const edm::ParameterSet&);
0047 
0048 private:
0049   bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0050 
0051   // ----------member data ---------------------------
0052 
0053   edm::EDGetTokenT<FEDRawDataCollection> tok_data_;
0054 };
0055 
0056 //
0057 // constructors and destructor
0058 //
0059 HcalEmptyEventFilter::HcalEmptyEventFilter(const edm::ParameterSet& iConfig) {
0060   //now do what ever initialization is needed
0061 
0062   tok_data_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("InputLabel"));
0063 }
0064 
0065 //
0066 // member functions
0067 //
0068 
0069 // ------------ method called on each new Event  ------------
0070 bool HcalEmptyEventFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0071   using namespace edm;
0072 
0073   edm::Handle<FEDRawDataCollection> rawdata;
0074   iEvent.getByToken(tok_data_, rawdata);
0075 
0076   bool haveEmpty = false;
0077 
0078   for (int i = FEDNumbering::MINHCALFEDID; !haveEmpty && i <= FEDNumbering::MAXHCALFEDID; i++) {
0079     const FEDRawData& fedData = rawdata->FEDData(i);
0080 
0081     if (fedData.size() < 16)
0082       continue;
0083 
0084     // get the DCC header
0085     const HcalDCCHeader* dccHeader = (const HcalDCCHeader*)(fedData.data());
0086 
0087     // walk through the HTR data...
0088     HcalHTRData htr;
0089 
0090     for (int spigot = 0; spigot < HcalDCCHeader::SPIGOT_COUNT && !haveEmpty; spigot++) {
0091       if (!dccHeader->getSpigotPresent(spigot))
0092         continue;
0093 
0094       int retval = dccHeader->getSpigotData(spigot, htr, fedData.size());
0095 
0096       if (retval != 0)
0097         continue;  // format error is not empty event
0098 
0099       if (htr.isEmptyEvent())
0100         haveEmpty = true;
0101     }
0102   }
0103   return haveEmpty;
0104 }
0105 
0106 //define this as a plug-in
0107 DEFINE_FWK_MODULE(HcalEmptyEventFilter);