CMS 3D CMS Logo

List of all members | Public Member Functions
hcaltb::HcalTBSourcePositionDataUnpacker Class Reference

#include <HcalTBSourcePositionDataUnpacker.h>

Public Member Functions

 HcalTBSourcePositionDataUnpacker (void)
 
void unpack (const FEDRawData &raw, HcalSourcePositionData &hspd) const
 

Detailed Description

Definition at line 9 of file HcalTBSourcePositionDataUnpacker.h.

Constructor & Destructor Documentation

◆ HcalTBSourcePositionDataUnpacker()

hcaltb::HcalTBSourcePositionDataUnpacker::HcalTBSourcePositionDataUnpacker ( void  )
inline

Definition at line 11 of file HcalTBSourcePositionDataUnpacker.h.

11 {}

Member Function Documentation

◆ unpack()

void hcaltb::HcalTBSourcePositionDataUnpacker::unpack ( const FEDRawData raw,
HcalSourcePositionData hspd 
) const

Definition at line 27 of file HcalTBSourcePositionDataUnpacker.cc.

27  {
28  if (raw.size() < 3 * 8) {
29  throw cms::Exception("Missing Data") << "No data in the source position data block";
30  }
31 
32  const struct xdaqSourcePositionDataFormat *sp = (const struct xdaqSourcePositionDataFormat *)(raw.data());
33 
34  if (raw.size() < sizeof(xdaqSourcePositionDataFormat)) {
35  throw cms::Exception("DataFormatError", "Fragment too small");
36  }
37 
38  map<string, double> sp_dblmap;
39  map<string, string> sp_strmap;
40 
41 #ifdef DEBUG
42  cout << "#doubles = " << sp->n_doubles << endl;
43  ;
44  cout << "#strings = " << sp->n_strings << endl;
45  cout << "key_length = " << sp->key_length << endl;
46  cout << "string_value_length = " << sp->string_value_length << endl;
47 #endif
48 
49  // List of doubles:
50  const char *keyptr = &sp->start_of_data;
51  const double *valptr = (const double *)(&sp->start_of_data + sp->n_doubles * sp->key_length);
52 
53  for (int i = 0; i < sp->n_doubles; i++) {
54 #ifdef DEBUG
55  cout << keyptr << " = " << *valptr << endl;
56 #endif
57  sp_dblmap[keyptr] = *valptr;
58  keyptr += sp->key_length;
59  valptr++;
60  }
61 
62  // List of strings:
63  keyptr = (const char *)valptr;
64  const char *strptr = (keyptr + sp->n_strings * sp->key_length);
65 
66  for (int i = 0; i < sp->n_strings; i++) {
67 #ifdef DEBUG
68  cout << keyptr << " = " << strptr << endl;
69 #endif
70  sp_strmap[keyptr] = strptr;
71  keyptr += sp->key_length;
72  strptr += sp->string_value_length;
73  }
74 
75  // Now fill the input objects:
76  hspd.set(sp_dblmap["MESSAGE"], //double message_counter
77  sp_dblmap["TIME_STAMP1"], //double timestamp1_sec
78  sp_dblmap["TIME_STAMP2"], //double timestamp1_usec
79  -1, //double timestamp2_sec
80  -1, //double timestamp2_usec
81  sp_dblmap["STATUS"], //double status
82  sp_dblmap["INDEX"], //double index_counter
83  sp_dblmap["REEL"], //double reel_counter
84  sp_dblmap["MOTOR_CURRENT"], //double motor_current
85  sp_dblmap["MOTOR_VOLTAGE"], //double motor_voltage
86  -1, //double driver_id
87  -1, //double source_id
88  sp_strmap["CURRENT_TUBENAME_FROM_COORD"],
89  sp_strmap["INDEX_DESCRIPTION"],
90  sp_strmap["LAST_COMMAND"],
91  sp_strmap["MESSAGE"]);
92  }

References gather_cfg::cout, FEDRawData::data(), Exception, mps_fire::i, xdaqSourcePositionDataFormat::key_length, xdaqSourcePositionDataFormat::n_doubles, xdaqSourcePositionDataFormat::n_strings, HcalSourcePositionData::set(), FEDRawData::size(), xdaqSourcePositionDataFormat::start_of_data, and xdaqSourcePositionDataFormat::string_value_length.

Referenced by HcalTBObjectUnpacker::produce().

xdaqSourcePositionDataFormat::n_strings
uint16_t n_strings
Definition: HcalTBSourcePositionDataUnpacker.cc:14
xdaqSourcePositionDataFormat::key_length
uint16_t key_length
Definition: HcalTBSourcePositionDataUnpacker.cc:15
mps_fire.i
i
Definition: mps_fire.py:355
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
xdaqSourcePositionDataFormat::start_of_data
char start_of_data
Definition: HcalTBSourcePositionDataUnpacker.cc:17
xdaqSourcePositionDataFormat
Structure for Source Position Data.
Definition: HcalTBSourcePositionDataUnpacker.cc:11
HcalSourcePositionData::set
void set(int message_counter, int timestamp1_sec, int timestamp1_usec, int timestamp2_sec, int timestamp2_usec, int status, int index_counter, int reel_counter, int motor_current, int motor_voltage, int driver_id, int source_id, std::string tubeNameFromCoord, std::string tubeDescFromSD, std::string lastCommand, std::string message)
Definition: HcalSourcePositionData.cc:26
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
xdaqSourcePositionDataFormat::n_doubles
uint16_t n_doubles
Definition: HcalTBSourcePositionDataUnpacker.cc:13
Exception
Definition: hltDiff.cc:246
xdaqSourcePositionDataFormat::string_value_length
uint16_t string_value_length
Definition: HcalTBSourcePositionDataUnpacker.cc:16