CMS 3D CMS Logo

TMTFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TMTFilter
4 // Class: TMTFilter
5 //
12 //
13 // Original Author: Jim Brooke
14 // Created:
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
24 
31 
32 #include <string>
33 #include <vector>
34 #include <iostream>
35 
36 
41 
42 
43 //
44 // class declaration
45 //
46 
47 class TMTFilter : public edm::EDFilter {
48 public:
49  explicit TMTFilter(const edm::ParameterSet&);
50  ~TMTFilter() override;
51 
52 private:
53  void beginJob() override ;
54  bool filter(edm::Event&, const edm::EventSetup&) override;
55  void endJob() override ;
56 
57  // ----------member data ---------------------------
59 
60  std::vector<int> mpList_; // list of MPs to select
61 
62 };
63 
64 
65 //
66 // constructors and destructor
67 //
69  mpList_( iConfig.getUntrackedParameter<std::vector<int> >("mpList") )
70 {
71  //now do what ever initialization is needed
72 
73  fedData_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("inputTag"));
74 
75 }
76 
77 
79 {
80 
81  // do anything here that needs to be done at desctruction time
82  // (e.g. close files, deallocate resources etc.)
83 
84 }
85 
86 
87 //
88 // member functions
89 //
90 
91 // ------------ method called on each new Event ------------
92 bool
94 {
95  using namespace edm;
96 
98  iEvent.getByToken(fedData_, feds);
99 
100  if (!feds.isValid()) {
101  LogError("L1T") << "Cannot unpack: no FEDRawDataCollection found";
102  return false;
103  }
104 
105  const FEDRawData& l1tRcd = feds->FEDData(1024);
106 
107  const unsigned char *data = l1tRcd.data();
108  FEDHeader header(data);
109 
110  bool mp = false;
111  for (auto itr : mpList_) {
112  mp |= ( ((header.bxID()-1)%9) == itr );
113  }
114 
115  return mp;
116 
117 }
118 
119 // ------------ method called once each job just before starting event loop ------------
120 void
122 {
123 
124 }
125 
126 // ------------ method called once each job just after ending the event loop ------------
127 void
129 
130 }
131 
132 //define this as a plug-in
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void endJob() override
Definition: TMTFilter.cc:128
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
std::vector< int > mpList_
Definition: TMTFilter.cc:60
void beginJob() override
Definition: TMTFilter.cc:121
bool isValid() const
Definition: HandleBase.h:74
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: TMTFilter.cc:93
~TMTFilter() override
Definition: TMTFilter.cc:78
edm::EDGetTokenT< FEDRawDataCollection > fedData_
Definition: TMTFilter.cc:58
uint16_t bxID() const
The bunch crossing number.
Definition: FEDHeader.cc:27
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
TMTFilter(const edm::ParameterSet &)
Definition: TMTFilter.cc:68