CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripFEDDump.cc
Go to the documentation of this file.
1 #include <sstream>
2 
11 
16 
17 //
18 // Class declaration
19 //
20 
22 {
23  public:
24  explicit SiStripFEDDumpPlugin(const edm::ParameterSet&);
26  private:
27  virtual void beginJob() override;
28  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
29  virtual void endJob() override;
30 
31  //tag of FEDRawData collection
34  //FED ID to dump
35  unsigned int fedIdToDump_;
36 };
37 
38 
39 //
40 // Constructors and destructor
41 //
42 
44  : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag",edm::InputTag("source",""))),
45  fedIdToDump_(iConfig.getUntrackedParameter<unsigned int>("FEDID",50))
46 {
47  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
49  edm::LogError("SiStripFEDDump") << "FED ID " << fedIdToDump_ << " is not valid. "
50  << "SiStrip FED IDs are " << uint16_t(FEDNumbering::MINSiStripFEDID) << "-" << uint16_t(FEDNumbering::MAXSiStripFEDID);
51 }
52 
54 {
55 }
56 
57 
58 //
59 // Member functions
60 //
61 
62 // ------------ method called to for each event ------------
63 void
65 {
66  //get raw data
67  edm::Handle<FEDRawDataCollection> rawDataCollectionHandle;
68  iEvent.getByToken(rawDataToken_,rawDataCollectionHandle);
69  const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle;
70 
71  const FEDRawData& rawData = rawDataCollection.FEDData(fedIdToDump_);
72  const sistrip::FEDBufferBase buffer(rawData.data(),rawData.size(),true);
73  std::ostringstream os;
74  os << buffer << std::endl;
75  buffer.dump(os);
76  edm::LogVerbatim("SiStripFEDDump") << os.str();
77 }
78 
79 // ------------ method called once each job just before starting event loop ------------
80 void
82 {
83 }
84 
85 // ------------ method called once each job just after ending the event loop ------------
86 void
88 {
89 }
90 
91 //
92 // Define as a plug-in
93 //
94 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int iEvent
Definition: GenABIO.cc:230
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
unsigned int fedIdToDump_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
edm::InputTag rawDataTag_
void dump(std::ostream &os) const
virtual void beginJob() override
SiStripFEDDumpPlugin(const edm::ParameterSet &)
virtual void endJob() override
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28