CMS 3D CMS Logo

HLTHcalNZSFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTHcalNZSFilter
4 // Class: HLTHcalNZSFilter
5 //
13 //
14 // Original Author: Bryan DAHMES
15 // Created: Tue Jan 22 13:55:00 CET 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <string>
22 #include <iostream>
23 #include <memory>
24 
25 // user include files
27 
33 
38 
39 #include "HLTHcalNZSFilter.h"
40 
41 //
42 // constructors and destructor
43 //
45 {
46  //now do what ever initialization is needed
47 
48  dataInputTag_ = iConfig.getParameter<edm::InputTag>("InputTag") ;
49  dataInputToken_ = consumes<FEDRawDataCollection>(dataInputTag_);
50 }
51 
52 
54 {
55 
56  // do anything here that needs to be done at desctruction time
57  // (e.g. close files, deallocate resources etc.)
58 
59 }
60 
61 void
65  desc.add<edm::InputTag>("InputTag",edm::InputTag("source"));
66  descriptions.add("hltHcalNZSFilter",desc);
67 }
68 
69 //
70 // member functions
71 //
72 
73 // ------------ method called on each new Event ------------
74 bool
76 {
77  using namespace edm;
78 
79  // MC treatment for this filter(NZS not fully emulated in HTR for MC)
80  if (!iEvent.isRealData()) return false;
81 
83  iEvent.getByToken(dataInputToken_,rawdata);
84 
85  int nFEDs = 0 ; int nNZSfed = 0 ; int nZSfed = 0 ;
87  const FEDRawData& fedData = rawdata->FEDData(i) ;
88  if ( fedData.size() < 24 ) continue ;
89  nFEDs++ ;
90 
91  // Check for Zero-suppression
92  HcalHTRData htr;
93  const HcalDCCHeader* dccHeader = (const HcalDCCHeader*)(fedData.data()) ;
94  int nZS = 0 ; int nUS = 0 ; int nSpigot = 0 ;
95  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
96  if (!dccHeader->getSpigotPresent(spigot)) continue;
97 
98  // Load the given decoder with the pointer and length from this spigot.
99  dccHeader->getSpigotData(spigot,htr, fedData.size());
100  if ((htr.getFirmwareFlavor()&0xE0)==0x80) continue ; // This is TTP data
101 
102  nSpigot++ ;
103  // check min length, correct wordcount, empty event, or total length if histo event.
104  if ( htr.isUnsuppressed() ) nUS++ ;
105  else nZS++ ;
106  }
107 
108  if ( nUS == nSpigot ) nNZSfed++ ;
109  else {
110  nZSfed++ ;
111  if ( nUS > 0 ) LogWarning("HLTHcalNZSFilter") << "Mixture of ZS(" << nZS
112  << ") and NZS(" << nUS
113  << ") spigots in FED " << i ;
114  }
115  }
116 
117  if ( (nNZSfed == nFEDs) && (nFEDs > 0) ) { return true ; }
118  else {
119  if ( nNZSfed > 0 ) LogWarning("HLTHcalNZSFilter") << "Mixture of ZS(" << nZSfed
120  << ") and NZS(" << nNZSfed
121  << ") FEDs in this event" ;
122  return false ;
123  }
124 
125 }
126 
127 
128 // declare this class as a framework plugin
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< FEDRawDataCollection > dataInputToken_
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
bool isRealData() const
Definition: EventBase.h:62
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:354
int iEvent
Definition: GenABIO.cc:224
HLTHcalNZSFilter(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:410
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
~HLTHcalNZSFilter() override
edm::InputTag dataInputTag_