CMS 3D CMS Logo

TcdsRawToDigi.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ProdTutorial/TcdsRawToDigi
4 // Class: TcdsRawToDigi
5 //
11 //
12 // Original Author: Chris Palmer
13 // Improved by : Salvatore Di Guida and Remi Mommsen
14 // Created: Thu, 28 May 2015 19:54:56 GMT
15 //
16 //
17 
18 // system include files
19 #include <memory>
20 #include <iostream>
21 
22 // user include files
25 
28 
30 
33 
35 
36 //
37 // class declaration
38 //
39 
41 public:
42  explicit TcdsRawToDigi(const edm::ParameterSet&);
43  ~TcdsRawToDigi() override;
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 private:
48  void produce(edm::Event&, const edm::EventSetup&) override;
49 
51 };
52 
54  edm::InputTag dataLabel = iConfig.getParameter<edm::InputTag>("InputLabel");
55  dataToken_ = consumes<FEDRawDataCollection>(dataLabel);
56  produces<TCDSRecord>("tcdsRecord").setBranchAlias("tcdsRecord");
57 }
58 
60 
61 //
62 // member functions
63 //
64 
65 // ------------ method called to produce the data ------------
67  using namespace edm;
68 
70  iEvent.getByToken(dataToken_, rawdata);
71 
73  if (rawdata.isValid()) {
74  uint16_t selectedId = 0;
76  const FEDRawData& tcdsData = rawdata->FEDData(fedId);
77  if (tcdsData.size() > 0) {
78  if (selectedId)
79  throw cms::Exception("TcdsRawToDigi::produce")
80  << "Second TCDS FED ID " << fedId << " found. First ID: " << selectedId;
81  tcdsRecord = TCDSRecord(tcdsData.data());
82  selectedId = fedId;
83  }
84  }
85  }
86  iEvent.put(std::make_unique<TCDSRecord>(tcdsRecord), "tcdsRecord");
87 }
88 
89 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
91  //The following says we do not know what parameters are allowed so do no validation
92  // Please change this to state exactly what you do use, even if it is no parameters
94  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
95  descriptions.add("tcdsRawToDigi", desc);
96 }
97 
98 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~TcdsRawToDigi() override
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
Class to contain information from TCDS FED.
Definition: TCDSRecord.h:19
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
TcdsRawToDigi(const edm::ParameterSet &)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
edm::EDGetTokenT< FEDRawDataCollection > dataToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24