5 #include <boost/lexical_cast.hpp>
17 std::vector<std::vector<MyEvent> >
allHits;
22 throw "Hit un-initialized";
23 uint8_t header =
data[0];
24 uint16_t chan = ((header >> 0) & 0x3);
25 chan |= ((header >> 3) & (0x7 << 2));
32 throw "Hit un-initialized";
33 uint8_t header =
reinterpret_cast<uint16_t*
>(
data)[0];
34 uint16_t type = ((header >> 2) & 0x7);
41 throw "Hit un-initialized";
42 uint32_t ts =
reinterpret_cast<uint32_t*
>(
data)[0];
44 return ts & 0x00FFFFFF;
50 throw "Hit un-initialized";
51 uint16_t patt =
reinterpret_cast<uint16_t*
>(
data + 4)[0];
52 utl::BinIO::swap(patt);
59 throw "Hit un-initialized";
61 std::cout << std::hex << std::setfill(
'0') << std::setw(2) << (uint32_t)
data[i];
63 std::cout << std::dec << std::endl;
69 throw "Hit un-initialized";
71 << std::setfill(
' ') << std::setw(3) <<
Channel()
72 << std::setw(2) <<
Type()
74 << std::hex << std::setfill(
'0') <<
" 0x" << std::setw(4) <<
Pattern()
75 << std::dec << std::endl;
98 uint8_t st = GetNumber<uint8_t>(20u);
104 uint32_t Nb =
reinterpret_cast<uint32_t*
>(rawPreamble + 20u)[0];
105 utl::BinIO::swap(Nb);
106 return Nb & 0x00FFFFFF;
112 throw "frame not initialized";
114 throw "Hit is out of bounds";
120 if (rawPreamble == 0)
121 throw "Raw Preamble un-initialized";
122 std::cout << std::string(95,
'=') << std::endl;
124 std::cout << std::hex << std::setfill(
'0') << std::setw(2) << (uint32_t) rawPreamble[i] <<
' ';
126 std::cout << std::dec << std::endl;
131 if (rawPreamble == 0)
132 throw "Raw Preamble un-initialized";
133 std::cout << std::string(95,
'=') << std::endl;
134 std::cout << std::dec
135 << std::setfill(
' ') << std::setw(8) <<
FrameSize()
138 << std::setfill(
'0') << std::setw(17) <<
FrameTime()
139 << std::setfill(
' ') << std::setw(7) <<
FrameIndex()
140 << std::setfill(
'0') <<
" 0x" << std::hex << std::setw(2) <<
Status() << std::dec
141 << std::setfill(
' ') << std::setw(9) <<
NbItems()
142 << std::setw(6) <<
DomId()
150 for (
size_t i = 0; i <
NbItems(); ++i) {
151 std::cout << std::dec << std::setfill(
' ') << std::setw(6) << i <<
": ";
154 std::cout << std::dec << std::endl;
159 for (
size_t i = 0; i <
NbItems(); ++i) {
160 std::cout << std::dec << std::setfill(
' ') << std::setw(6) << i <<
": ";
163 std::cout << std::dec << std::endl;
169 throw "Raw Data buffer un-initialized";
171 std::cout << std::hex << std::setfill(
'0') << std::setw(2) << (uint32_t) rawData[i] <<
' ';
173 std::cout << std::dec << std::endl;
197 std::vector<pmt> pmtData;
200 for (
int nPm = 0; nPm <
pmtNb; ++nPm) {
202 std::vector<MyEvent>
event;
204 int eventSize =
event.size();
206 const int timeOffset = 0;
208 std::vector<signal> pmtSignals;
209 if (!eventSize)
continue;
210 for (
int i = 0; i < eventSize; ++i) {
211 const long long int value = 8*
event[i].timeStamp +
event[i].firstBit + timeOffset;
217 pmtSignals.push_back(
signal(value, event[i].widthPat));
221 pmtData.push_back(curPmt);
239 uint32_t lastTS[
pmtNb];
241 std::vector<MyEvent>
event;
244 int nbItems = thisFrame.
NbItems();
248 for(
int i = 0; i <
pmtNb; ++i) {
252 for (
int it = 0; it < nbItems; ++it) {
259 if((curFirstBit =
GetFirstBit(curPattern, 0)) == -10)
261 if((curLastBit =
GetLastBit(curPattern, curFirstBit)) == -10)
263 curWidthPat = curLastBit - curFirstBit;
266 if ((ichan > 30) || (ichan < 0))
continue;
267 if (abs((
int)(lastTS[ichan] - curTS)) == 2) {
268 if (
allHits.at(ichan).size() > 0) {
269 int previous =
allHits.at(ichan).size() - 1;
270 allHits.at(ichan).at(previous).widthPat += curWidthPat;
279 allHits.at(ichan).push_back(hitChan);
282 lastTS[ichan] = curTS;
304 for (
size_t i = firstBit; i < (int(
sizeof(pattern))*CHAR_BIT); ++i) {
305 if ((pattern & (1 << i)) != 0) {
314 for (
int i = firstBit; i < (int(
sizeof(pattern))*CHAR_BIT); ++i) {
315 if ((pattern & (1 << i)) == 0) {
323 FillRaw(std::ifstream& str, std::vector<dom>& vSlice,
long long int bitPosition,
bool toWrite) {
325 size_t nFrames = ~0u;
328 str.seekg(bitPosition);
329 long long int newPosition = bitPosition;
330 while (nFrames-- > 0) {
332 if (not curFrame.
Read(str))
334 if (curFrame.
StreamId() == 6)
continue;
341 if (toWrite ==
true) {
346 << curFrame.
DomId() <<
' ' << curFrame.
StreamId() <<
" 0" << std::endl;
351 switch(
Analyse(curFrame, toWrite)) {
359 std::cout <<
"error: empty frame" << std::endl;
363 std::cout <<
"error: pb with firstBit" << std::endl;
367 std::cout <<
"error: pb with lastBit" << std::endl;
388 newPosition = str.tellg();
389 if ((newPosition - bitPosition) > 2.0e9)
396 vSlice.push_back(curDom);
400 std::cerr <<
"number of frames analysed: "<< nanalysed
401 <<
" - total number of hits " <<
cpt << std::endl;
407 str.seekg(0, std::ifstream::end);
408 long long int theSize = str.tellg();
409 str.seekg(0, std::ifstream::beg);
416 return (signalNb > limitNb) ?
true :
false;
void SetSignal(std::vector< signal > list)
set the signal of the pmt (to use only when reading the binary)
organisation of the data - dom level
int ReplacePmtId(const int dom, const int first)
long long int FillRaw(std::ifstream &str, std::vector< dom > &vSlice, long long int bitPosition, bool toWrite)
bool Read(std::istream &input)
Identify and fill the pmts with data.
void SetPmtsData(const std::vector< pmt > pmts)
set the filled pmts in the dom
std::vector< std::vector< MyEvent > > allHits
const int old2NewPmtMapCorrected2[pmtNb]
void SetDomHeader(const domHeader &eHeader)
set the information in the header (see domHeader class)
int GetLastBit(size_t pattern, int firstBit)
const double fineTimeOffsetDom[domNb]
bool IsNoisySlice(const int signalNb, const double limitNb)
long long int GetFileLength(std::ifstream &str)
static const size_t PREAMBLE_SIZE_BYTES
void WriteSlice(dom &curDom)
int Analyse(frame &thisFrame, bool toWrite)
static const size_t SIZE_BYTES
int GetFirstBit(size_t pattern, int firstBit)
const int old2NewPmtMapCorrected01[pmtNb]
void ClearSignalData()
clear the pmt signal before to fill it again
const int timeOffsetDom[domNb]