CMS 3D CMS Logo

HLTL1NumberFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTL1NumberFilter
4 // Class: HLTL1NumberFilter
5 //
13 //
14 // Original Author: Martin Grunewald
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
26 #include "HLTL1NumberFilter.h"
32 
33 //
34 // constructors and destructor
35 //
37  //now do what ever initialization is needed
38  inputToken_( consumes<FEDRawDataCollection>(config.getParameter<edm::InputTag>("rawInput")) ),
39  period_( config.getParameter<unsigned int>("period") ),
40  fedId_( config.getParameter<int>("fedId") ),
41  invert_( config.getParameter<bool>("invert") ),
42  // only try and use TCDS event number if the FED ID 1024 is selected
43  useTCDS_( config.getParameter<bool>("useTCDSEventNumber") and fedId_ == 1024)
44 {
45 }
46 
47 
49 {
50  // do anything here that needs to be done at desctruction time
51  // (e.g. close files, deallocate resources etc.)
52 }
53 
54 
55 void
58  desc.add<edm::InputTag>("rawInput",edm::InputTag("source"));
59  desc.add<unsigned int>("period",4096);
60  desc.add<bool>("invert",true);
61  desc.add<int>("fedId",812);
62  desc.add<bool>("useTCDSEventNumber",false);
63  descriptions.add("hltL1NumberFilter",desc);
64 }
65 //
66 // member functions
67 //
68 
69 // ------------ method called on each new Event ------------
70 bool
72 {
73  using namespace edm;
74 
75  if (iEvent.isRealData()) {
76  bool accept(false);
78  iEvent.getByToken(inputToken_,theRaw) ;
79  const FEDRawData& data = theRaw->FEDData(fedId_) ;
80  if (data.data() and data.size() > 0) {
81  unsigned long counter;
82  if (useTCDS_) {
83  TCDSRecord record(data.data());
84  counter = record.getTriggerCount();
85  } else {
86  FEDHeader header(data.data());
87  counter = header.lvl1ID();
88  }
89  if (period_!=0) accept = (counter % period_ == 0);
90  if (invert_) accept = not accept;
91  return accept;
92  } else{
93  LogWarning("HLTL1NumberFilter")<<"No valid data for FED "<<fedId_<<" used by HLTL1NumberFilter";
94  return false;
95  }
96  } else {
97  return true;
98  }
99 
100 }
101 
102 // declare this class as a framework plugin
const int fedId_
FED from which to get lv1ID number.
JetCorrectorParameters::Record record
Definition: classes.h:7
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const bool useTCDS_
if useTCDS=true, use 64-bit Event Number from TCDS record (FED 1024) word 11
Definition: config.py:1
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
bool isRealData() const
Definition: EventBase.h:62
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
Class to contain information from TCDS FED.
Definition: TCDSRecord.h:21
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const unsigned int period_
accept the event if its event number is a multiple of period_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< FEDRawDataCollection > inputToken_
raw data
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static std::atomic< unsigned int > counter
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
HLTL1NumberFilter(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~HLTL1NumberFilter() override
const bool invert_
if invert_=true, invert that event accept decision