CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.

11 { }

Member Function Documentation

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

Definition at line 28 of file HcalTBSourcePositionDataUnpacker.cc.

References gather_cfg::cout, FEDRawData::data(), edm::hlt::Exception, 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().

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