All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MWRData.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 #include <sstream>
5 #include <vector>
6 #include <boost/algorithm/string.hpp>
7 #include "MWRData.h"
8 
9 using namespace std;
10 
11 namespace sbn{
12 
13  std::vector< std::vector < int > > MWRData::unpackMWR(std::string packed_data, std::vector<double> &time_stamp, double timeoffset) const
14 {
15 
16  std::vector<std::vector<int> > unpacked_data;
17  unpacked_data.resize(4);
18  short data[444];
19 
20  std::vector<std::string> row(0);
21  boost::split(row, packed_data, boost::is_any_of(","));
22  if (row.size()==447) {
23  for (int i=3;i<447;i++) {
24  data[i-3]=atoi(row[i].c_str());
25  }
26  string devname=row[1].substr(0,8);
27  for (int idev=0;idev<4;idev++) {
28  mwrpulse_t mwr=getMWRdata(data,idev);
29  time_stamp.push_back(mwr.sheader.timesec+mwr.sheader.timensec/1000000000.+timeoffset);
30  for (int ich=0;ich<48;ich++) {
31  unpacked_data[idev].push_back(mwr.hor[ich]);
32  }
33  for (int ich=0;ich<48;ich++) {
34  unpacked_data[idev].push_back(mwr.ver[ich]);
35  }
36  }
37  } else {
38  cout <<"BeamSpillInfoRetriever: MRWData: Bad data!"<<endl;
39  return unpacked_data;
40  }
41 
42  return unpacked_data;
43 }
44 
45 MWRData::mwrpulse_t MWRData::getMWRdata(short* data, int nblock) const
46 {
47  mwrpulse_t mwrdata;
48 
49  memcpy(&mwrdata.hor, data+nblock*111, 96);
50  memcpy(&mwrdata.ver, data+nblock*111+48, 96);
51  memcpy(&mwrdata.sheader.timesec, data+nblock*111+96, 4);
52  memcpy(&mwrdata.sheader.timensec, data+nblock*111+98, 4);
53  memcpy(&mwrdata.sheader.gpstime1, data+nblock*111+100, 4);
54  memcpy(&mwrdata.sheader.gpstime2, data+nblock*111+102, 4);
55  memcpy(&mwrdata.sheader.boosterevent, data+nblock*111+104, 2);
56  memcpy(&mwrdata.sheader.mievent, data+nblock*111+105, 2);
57  memcpy(&mwrdata.sheader.hz15micnt, data+nblock*111+106, 2);
58  memcpy(&mwrdata.sheader.delta1f, data+nblock*111+107, 4);
59  memcpy(&mwrdata.sheader.pulsemi, data+nblock*111+109, 2);
60  memcpy(&mwrdata.sheader.pulsesc, data+nblock*111+110, 2);
61 
62  mwrdata.sheader.timesec=flipByte(mwrdata.sheader.timesec);
63  mwrdata.sheader.timensec=flipByte(mwrdata.sheader.timensec);
64  mwrdata.sheader.gpstime1=flipByte(mwrdata.sheader.gpstime1);
65  mwrdata.sheader.gpstime2=flipByte(mwrdata.sheader.gpstime2);
66  mwrdata.sheader.delta1f=flipByte(mwrdata.sheader.delta1f);
67 
68  return mwrdata;
69 
70 }
71 }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
swicheader_t sheader
Definition: MWRData.h:24
BEGIN_PROLOG could also be cout