CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalEmptyEventFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalEmptyEventFilter
4 // Class: HcalEmptyEventFilter
5 //
13 //
14 // Original Author: Jeremiah Mans
15 // Created: Tue Jun 4 CET 2012
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
25 
31 
32 #include <string>
33 #include <iostream>
34 
40 
41 //
42 // class declaration
43 //
44 
46 public:
47  explicit HcalEmptyEventFilter(const edm::ParameterSet&);
48  virtual ~HcalEmptyEventFilter();
49 
50 private:
51  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
52 
53  // ----------member data ---------------------------
54 
56 
57 };
58 
59 
60 //
61 // constructors and destructor
62 //
64 {
65  //now do what ever initialization is needed
66 
67  tok_data_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("InputLabel") );
68 }
69 
70 
72 {
73 
74  // do anything here that needs to be done at desctruction time
75  // (e.g. close files, deallocate resources etc.)
76 
77 }
78 
79 
80 //
81 // member functions
82 //
83 
84 // ------------ method called on each new Event ------------
85 bool
87 {
88  using namespace edm;
89 
92 
93  bool haveEmpty=false;
94 
95  for (int i=FEDNumbering::MINHCALFEDID; !haveEmpty &&
97  const FEDRawData& fedData = rawdata->FEDData(i) ;
98 
99  if (fedData.size()<16) continue;
100 
101  // get the DCC header
102  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fedData.data());
103 
104  // walk through the HTR data...
105  HcalHTRData htr;
106 
107  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT && !haveEmpty; spigot++) {
108  if (!dccHeader->getSpigotPresent(spigot)) continue;
109 
110  int retval=dccHeader->getSpigotData(spigot,htr,fedData.size());
111 
112  if (retval!=0) continue; // format error is not empty event
113 
114  if (htr.isEmptyEvent()) haveEmpty=true;
115  }
116  }
117  return haveEmpty;
118 }
119 
120 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HcalEmptyEventFilter(const edm::ParameterSet &)
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
edm::EDGetTokenT< FEDRawDataCollection > tok_data_
int iEvent
Definition: GenABIO.cc:230
bool isEmptyEvent() const
Definition: HcalHTRData.cc:100
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
virtual bool filter(edm::Event &, const edm::EventSetup &) override
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
dictionary rawdata
Definition: lumiPlot.py:393