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

hcaltb::HcalTBSourcePositionDataUnpacker::HcalTBSourcePositionDataUnpacker ( void  )
inline

Definition at line 11 of file HcalTBSourcePositionDataUnpacker.h.

References unpack().

11 {}

Member Function Documentation

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

Definition at line 27 of file HcalTBSourcePositionDataUnpacker.cc.

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 HcalTBSourcePositionDataUnpacker(), and HcalTBObjectUnpacker::produce().

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  }
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)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Structure for Source Position Data.