CMS 3D CMS Logo

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