CMS 3D CMS Logo

CSCDMBHeader.cc
Go to the documentation of this file.
5 #include <iostream>
6 
7 
8 CSCDMBHeader::CSCDMBHeader(uint16_t firmware_version)
9 : theHeaderFormat(), theFirmwareVersion(firmware_version)
10 {
11 
12  if (theFirmwareVersion == 2013) {
13  theHeaderFormat = std::make_shared<CSCDMBHeader2013>();
14  } else {
15  theHeaderFormat = std::make_shared<CSCDMBHeader2005>();
16  }
17 
18 }
19 
20 CSCDMBHeader::CSCDMBHeader(const uint16_t * buf, uint16_t firmware_version)
21 : theHeaderFormat(), theFirmwareVersion(firmware_version)
22 {
23  if (theFirmwareVersion == 2013) {
24  theHeaderFormat = std::make_shared<CSCDMBHeader2013>(buf);
25  } else {
26  theHeaderFormat = std::make_shared<CSCDMBHeader2005>(buf);
27  }
28 }
29 
31  const CSCDMBHeader2005 * result = dynamic_cast<const CSCDMBHeader2005 *>(theHeaderFormat.get());
32  if(result == nullptr)
33  {
34  throw cms::Exception("Could not get 2005 DMB header format");
35  }
36  return *result;
37 }
38 
39 
41  const CSCDMBHeader2013 * result = dynamic_cast<const CSCDMBHeader2013 *>(theHeaderFormat.get());
42  if(result == nullptr)
43  {
44  throw cms::Exception("Could not get 2013 DMB header format");
45  }
46  return *result;
47 }
48 
49 
50 
int theFirmwareVersion
Definition: CSCDMBHeader.h:72
CSCDMBHeader2005 dmbHeader2005() const
will throw if the cast fails
Definition: CSCDMBHeader.cc:30
std::shared_ptr< CSCVDMBHeaderFormat > theHeaderFormat
Definition: CSCDMBHeader.h:71
CSCDMBHeader2013 dmbHeader2013() const
Definition: CSCDMBHeader.cc:40
CSCDMBHeader(uint16_t firmware_version=2005)
Definition: CSCDMBHeader.cc:8