ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
GETDecoder2.cxx
Go to the documentation of this file.
1 // =================================================
2 // GETDecoder Class
3 //
4 // Author:
5 // Genie Jhang ( geniejhang@majimak.com )
6 //
7 // Log:
8 // - 2013. 09. 23
9 // Start writing class
10 // =================================================
11 
12 #include "GETDecoder2.h"
13 
14 #include <FairLogger.h>
15 
16 #include <Rtypes.h>
17 #include <TClonesArray.h>
18 #include <TString.h>
19 
20 #include "GETBasicFrame.h"
21 #include "GETBasicFrameHeader.h"
22 #include "GETCoboFrame.h"
23 #include "GETFileChecker.h"
24 #include "GETFrameInfo.h"
25 #include "GETHeaderBase.h"
26 #include "GETLayerHeader.h"
27 #include "GETLayeredFrame.h"
28 #include "GETTopologyFrame.h"
29 
30 #include <algorithm>
31 #include <bitset>
32 #include <fstream>
33 #include <iomanip>
34 #include <iostream>
35 #include <iterator>
36 #include <memory>
37 #include <string>
38 
39 //#define DEBUG
40 
42 
44  : fFrameInfoArray(nullptr), fCoboFrameInfoArray(nullptr), fFrameInfo(nullptr), fCoboFrameInfo(nullptr),
45  fHeaderBase(nullptr), fBasicFrameHeader(nullptr), fLayerHeader(nullptr), fTopologyFrame(nullptr),
46  fBasicFrame(nullptr), fCoboFrame(nullptr), fLayeredFrame(nullptr)
47 {
53  Initialize();
54 }
55 
56 GETDecoder2::GETDecoder2(TString filename)
57  : fFrameInfoArray(nullptr), fCoboFrameInfoArray(nullptr), fFrameInfo(nullptr), fCoboFrameInfo(nullptr),
58  fHeaderBase(nullptr), fBasicFrameHeader(nullptr), fLayerHeader(nullptr), fTopologyFrame(nullptr),
59  fBasicFrame(nullptr), fCoboFrame(nullptr), fLayeredFrame(nullptr)
60 {
66  Initialize();
67  AddData(filename);
68  SetData(0);
69 }
70 
71 void GETDecoder2::Initialize()
72 {
73  fNumTbs = 512;
74 
75  fFrameType = kBasic;
76 
77  fIsPositivePolarity = kFALSE;
78 
79  fIsDoneAnalyzing = kFALSE;
80  fIsDataInfo = kFALSE;
81  fIsContinuousData = kTRUE;
82  fIsMetaData = kFALSE;
83 
84  fDataSize = 0;
85  fCurrentDataID = -1;
86 
87  fFrameInfoIdx = 0;
88  fCoboFrameInfoIdx = 0;
89  fTargetFrameInfoIdx = -1;
90 
91  fBuffer = nullptr;
92  fWriteFile = "";
93 
94  if (fFrameInfoArray == nullptr)
95  fFrameInfoArray = new TClonesArray("GETFrameInfo", 10000);
96  fFrameInfoArray->Clear("C");
97 
98  if (fCoboFrameInfoArray == nullptr)
99  fCoboFrameInfoArray = new TClonesArray("GETFrameInfo", 10000);
100  fCoboFrameInfoArray->Clear("C");
101 
102  if (fHeaderBase == nullptr)
103  fHeaderBase = new GETHeaderBase();
104  else
105  fHeaderBase->Clear();
106 
107  if (fBasicFrameHeader == nullptr)
108  fBasicFrameHeader = new GETBasicFrameHeader();
109  else
110  fBasicFrameHeader->Clear();
111 
112  if (fLayerHeader == nullptr)
113  fLayerHeader = new GETLayerHeader();
114  else
115  fLayerHeader->Clear();
116 
117  if (fTopologyFrame == nullptr)
118  fTopologyFrame = new GETTopologyFrame();
119  else
120  fTopologyFrame->Clear();
121 
122  if (fBasicFrame == nullptr)
123  fBasicFrame = new GETBasicFrame();
124  else
125  fBasicFrame->Clear();
126 
127  if (fCoboFrame == nullptr)
128  fCoboFrame = new GETCoboFrame();
129  else
130  fCoboFrame->Clear();
131 
132  if (fLayeredFrame == nullptr)
133  fLayeredFrame = new GETLayeredFrame();
134  else
135  fLayeredFrame->Clear();
136 
137  fPrevDataID = 0;
138  fPrevPosition = 0;
139 }
140 
142 {
143  fFrameType = kBasic;
144 
145  fIsDoneAnalyzing = kFALSE;
146  fIsDataInfo = kFALSE;
147 
148  fDataSize = 0;
149  fCurrentDataID = -1;
150 
151  fFrameInfoIdx = 0;
152  fCoboFrameInfoIdx = 0;
153  fTargetFrameInfoIdx = -1;
154 
155  fBuffer = nullptr;
156  fWriteFile = "";
157 
158  fFrameInfoArray->Clear("C");
159  fCoboFrameInfoArray->Clear("C");
160 
161  fHeaderBase->Clear();
162  fBasicFrameHeader->Clear();
163  fLayerHeader->Clear();
164  fTopologyFrame->Clear();
165  fBasicFrame->Clear();
166  fCoboFrame->Clear();
167  fLayeredFrame->Clear();
168 
169  if (fIsContinuousData) {
170 
171 #ifdef DEBUG
172  std::cout << "== [GETDecoder] Discontinuous data set is set. Leave data list intact!" << std::endl;
173 #endif
174 
175  fDataList.clear();
176  }
177 }
178 
179 void GETDecoder2::SetNumTbs(Int_t value)
180 {
181  fNumTbs = value;
182 }
183 
184 Bool_t GETDecoder2::AddData(TString filename)
185 {
190  TString nextData = GETFileChecker::CheckFile(filename);
191  if (!nextData.EqualTo("")) {
192  Bool_t isExist = false;
193  for (Int_t iIdx = 0; iIdx < fDataList.size(); iIdx++) {
194  if (fDataList.at(0).EqualTo(nextData)) {
195  std::cout << "== [GETDecoder] The file already exists in the list!" << std::endl;
196  isExist = true;
197  }
198  }
199 
200  if (!isExist) {
201  fDataList.push_back(nextData);
202 
203  return kTRUE;
204  }
205  }
206 
207  return kFALSE;
208 }
209 
210 Bool_t GETDecoder2::SetData(Int_t index)
211 {
212  if (!fIsContinuousData) {
213 
214 #ifdef DEBUG
215  std::cout << "== [GETDecoder] Discontinuous data set is set. Clear info!" << std::endl;
216 #endif
217 
218  Clear();
219  }
220 
221  if (index >= fDataList.size()) {
222  std::cout << "== [GETDecoder] End of data list!" << std::endl;
223 
224  return kFALSE;
225  }
226 
227  if (fData.is_open())
228  fData.close();
229 
230  TString filename = fDataList.at(index);
231 
232  fData.open(filename.Data(), std::ios::ate | std::ios::binary);
233 
234  if (!(fData.is_open())) {
235  std::cout << "== [GETDecoder] Data file open error! Check it exists!" << std::endl;
236 
237  return kFALSE;
238  }
239 
240  fDataSize = fData.tellg();
241 
242  std::cout << "== [GETDecoder] " << filename << " is opened!" << std::endl;
243 
244  fData.seekg(0);
245 
246  if (!fIsDataInfo) {
247  fHeaderBase->Read(fData, kTRUE);
248 
249  if (fHeaderBase->IsBlob())
250  fTopologyFrame->Read(fData);
251 
252  std::cout << "== [GETDecoder] Frame Type: ";
253  if (fTopologyFrame->IsBlob()) {
254  fFrameType = kCobo;
255  std::cout << "Cobo frame (Max. 4 frames)" << std::endl;
256  } else {
257  fHeaderBase->Read(fData, kTRUE);
258  switch (fHeaderBase->GetFrameType()) {
259  case GETFRAMEMERGEDBYID:
260  fFrameType = kMergedID;
261  std::cout << "Event ID merged frame" << std::endl;
262  break;
263 
265  fFrameType = kMergedTime;
266  std::cout << "Event time merged frame" << std::endl;
267  break;
268 
269  default:
270  fFrameType = kBasic;
271  std::cout << "Basic frame" << std::endl;
272  break;
273  }
274  }
275 
276  fIsDataInfo = kTRUE;
277  } else {
278  fHeaderBase->Read(fData, kTRUE);
279 
280  if (fHeaderBase->IsBlob())
281  fTopologyFrame->Read(fData);
282  }
283 
284  fCurrentDataID = index;
285 
286  return kTRUE;
287 }
288 
290 {
291  fIsContinuousData = !value;
292 }
294 {
295  if (fIsContinuousData)
296  return SetData(fCurrentDataID + 1);
297  else
298  return kFALSE;
299 }
301 {
302  fIsPositivePolarity = value;
303 }
304 
306 {
307  std::cout << "== [GETDecoder] Index Data file" << std::endl;
308  for (Int_t iItem = 0; iItem < fDataList.size(); iItem++) {
309  if (iItem == fCurrentDataID)
310  std::cout << " *" << std::setw(6);
311  else
312  std::cout << std::setw(8);
313 
314  std::cout << iItem << " " << fDataList.at(iItem) << std::endl;
315  }
316 }
317 
319 {
320  return fDataList.size();
321 }
322 
323 TString GETDecoder2::GetDataName(Int_t index)
324 {
325  if (index >= fDataList.size()) {
326  std::cout << "== [GETDecoder] Size of the list is " << fDataList.size() << "!" << std::endl;
327 
328  return {"No data!"};
329  }
330 
331  return fDataList.at(index);
332 }
333 
335 {
336  return fNumTbs;
337 }
339 {
340  return fFrameType;
341 }
342 
344 {
345  if (fIsDoneAnalyzing)
346  switch (fFrameType) {
347  case kBasic:
348  case kMergedID:
349  case kMergedTime: return fFrameInfoArray->GetEntriesFast(); break;
350 
351  case kCobo: return fCoboFrameInfoArray->GetEntriesFast(); break;
352  }
353 
354  return -1;
355 }
356 
358 {
359  if (frameID == -1)
360  fTargetFrameInfoIdx++;
361  else
362  fTargetFrameInfoIdx = frameID;
363 
364  while (kTRUE) {
365  fData.clear();
366 
367  if (fIsDoneAnalyzing)
368  if (fTargetFrameInfoIdx > fFrameInfoArray->GetLast())
369  return nullptr;
370 
371  if (fFrameInfoIdx > fTargetFrameInfoIdx)
372  fFrameInfoIdx = fTargetFrameInfoIdx;
373 
374  fFrameInfo = (GETFrameInfo *)fFrameInfoArray->ConstructedAt(fFrameInfoIdx);
375  while (fFrameInfo->IsFill()) { // returns startByte != endByte
376 
377  LOG(debug) << "fFrameInfoIdx: " << fFrameInfoIdx << " fTargetFrameInfoIdx: " << fTargetFrameInfoIdx;
378 
379  if (fFrameInfoIdx == fTargetFrameInfoIdx) {
381 
382  if (fFrameInfo->GetDataID() != fCurrentDataID) {
383  LOG(info) << "Changing from " << fFrameInfo->GetDataID() << " to " << fCurrentDataID
384  << " at fFrameInfoIdx: " << fFrameInfoIdx
385  << " of fTargetFrameInfoIdx: " << fTargetFrameInfoIdx;
386  SetData(fFrameInfo->GetDataID());
387  }
388 
389  fData.seekg(fFrameInfo->GetStartByte());
390  fBasicFrame->Read(fData);
391 
393 
394  LOG(debug) << "Returned event ID: " << fBasicFrame->GetEventID();
395 
396  return fBasicFrame;
397  } else
398  fFrameInfo = (GETFrameInfo *)fFrameInfoArray->ConstructedAt(++fFrameInfoIdx);
399  }
400 
401  ULong64_t startByte = fData.tellg();
402 
403  fBasicFrameHeader->Read(fData);
404  fData.ignore(fBasicFrameHeader->GetFrameSkip());
405 
406  ULong64_t endByte = startByte + fBasicFrameHeader->GetFrameSize();
407 
408  fFrameInfo->SetDataID(fCurrentDataID);
409  fFrameInfo->SetStartByte(startByte);
410  fFrameInfo->SetEndByte(endByte);
411  fFrameInfo->SetEventID(fBasicFrameHeader->GetEventID());
412 
413  CheckEndOfData();
414  } // while(true)
415 
416  // return GetBasicFrame(fTargetFrameInfoIdx);
417 }
418 
420 {
421  if (frameID == -1)
422  fTargetFrameInfoIdx++;
423  else
424  fTargetFrameInfoIdx = frameID;
425 
426  while (kTRUE) {
427  fData.clear();
428 
429  if (fIsDoneAnalyzing)
430  if (fTargetFrameInfoIdx > fCoboFrameInfoArray->GetLast())
431  return nullptr;
432 
433  if (fCoboFrameInfoIdx > fTargetFrameInfoIdx)
434  fCoboFrameInfoIdx = fTargetFrameInfoIdx;
435 
436  fCoboFrameInfo = (GETFrameInfo *)fCoboFrameInfoArray->ConstructedAt(fCoboFrameInfoIdx);
437  while (fCoboFrameInfo->IsFill()) {
438 
439 #ifdef DEBUG
440  cout << "fFrameInfoIdx: " << fFrameInfoIdx << " fCoboFrameInfoIdx: " << fCoboFrameInfoIdx
441  << " fTargetFrameInfoIdx: " << fTargetFrameInfoIdx << endl;
442 #endif
443 
444 #ifdef DEBUG
445  cout << "fCoboFrameInfo -> GetNumFrames(): " << fCoboFrameInfo->GetNumFrames()
446  << " fTopologyFrame -> GetAsadMask().count(): " << fTopologyFrame->GetAsadMask().count() << endl;
447 #endif
448 
449  if (fCoboFrameInfo->GetNumFrames() == fTopologyFrame->GetAsadMask().count()) {
450  if (fCoboFrameInfoIdx == fTargetFrameInfoIdx) {
451  fCoboFrame->Clear();
452 
454 
455  fCoboFrameInfo = (GETFrameInfo *)fCoboFrameInfoArray->ConstructedAt(fCoboFrameInfoIdx);
456 
457  for (Int_t iFrame = 0; iFrame < fTopologyFrame->GetAsadMask().count(); iFrame++) {
458  if (fCoboFrameInfo->GetDataID() != fCurrentDataID) {
459  SetData(fCoboFrameInfo->GetDataID());
460  }
461  fData.seekg(fCoboFrameInfo->GetStartByte());
462  fCoboFrame->ReadFrame(fData);
463  fCoboFrameInfo = fCoboFrameInfo->GetNextInfo();
464  }
465 
467 
468 #ifdef DEBUG
469  cout << "Returned fCoboFrameInfoIdx: " << fCoboFrameInfoIdx
470  << " with event ID: " << fCoboFrame->GetFrame(0)->GetEventID() << endl;
471 #endif
472 
473  return fCoboFrame;
474  } else
475  fCoboFrameInfo = (GETFrameInfo *)fCoboFrameInfoArray->ConstructedAt(++fCoboFrameInfoIdx);
476  } else
477  break;
478  }
479 
480 #ifdef DEBUG
481  cout << "Not full in fCoboFrameInfoIdx: " << fCoboFrameInfoIdx << ", reading fFrameInfoIdx: " << fFrameInfoIdx
482  << endl;
483 #endif
484 
485  ULong64_t startByte = fData.tellg();
486 
487  fBasicFrameHeader->Read(fData);
488  fData.ignore(fBasicFrameHeader->GetFrameSkip());
489 
490  ULong64_t endByte = startByte + fBasicFrameHeader->GetFrameSize();
491 
492  fFrameInfo = (GETFrameInfo *)fFrameInfoArray->ConstructedAt(fFrameInfoIdx++);
493  fFrameInfo->SetDataID(fCurrentDataID);
494  fFrameInfo->SetStartByte(startByte);
495  fFrameInfo->SetEndByte(endByte);
496  fFrameInfo->SetEventID(fBasicFrameHeader->GetEventID());
497 
498  // std::cout << "fFrameInfo -> GetEndByte(): " << fFrameInfo -> GetEndByte() << " fData.tellg(): " <<
499  // fData.tellg() << " fDataSize: " << fDataSize << std::endl;
500  CheckEndOfData();
501 
502  if (fCoboFrameInfo->GetNumFrames() == 0)
503  fCoboFrameInfo->Copy(fFrameInfo);
504  else if (fCoboFrameInfo->GetEventID() == fFrameInfo->GetEventID())
505  fCoboFrameInfo->SetNextInfo(fFrameInfo);
506  else {
507  Int_t iChecker = (fCoboFrameInfoIdx - 10 < 0 ? 0 : fCoboFrameInfoIdx - 10);
508  while (auto *checkCoboFrameInfo = (GETFrameInfo *)fCoboFrameInfoArray->ConstructedAt(iChecker)) {
509  if (checkCoboFrameInfo->IsFill()) {
510  if (checkCoboFrameInfo->GetEventID() == fFrameInfo->GetEventID()) {
511  checkCoboFrameInfo->SetNextInfo(fFrameInfo);
512  break;
513  } else
514  iChecker++;
515  } else {
516  checkCoboFrameInfo->Copy(fFrameInfo);
517  break;
518  }
519  }
520  }
521  }
522 
523  // return GetCoboFrame(fTargetFrameInfoIdx);
524 }
525 
527 {
528  if (frameID == -1)
529  fTargetFrameInfoIdx++;
530  else
531  fTargetFrameInfoIdx = frameID;
532 
533  while (kTRUE) {
534  fData.clear();
535 
536  if (fIsDoneAnalyzing)
537  if (fTargetFrameInfoIdx > fFrameInfoArray->GetLast())
538  return nullptr;
539 
540  if (fFrameInfoIdx > fTargetFrameInfoIdx)
541  fFrameInfoIdx = fTargetFrameInfoIdx;
542 
543  fFrameInfo = (GETFrameInfo *)fFrameInfoArray->ConstructedAt(fFrameInfoIdx);
544  while (fFrameInfo->IsFill()) {
545 
546 #ifdef DEBUG
547  cout << "fFrameInfoIdx: " << fFrameInfoIdx << " fTargetFrameInfoIdx: " << fTargetFrameInfoIdx << endl;
548 #endif
549 
550  if (fFrameInfoIdx == fTargetFrameInfoIdx) {
552 
553  if (fFrameInfo->GetDataID() != fCurrentDataID) {
554  SetData(fFrameInfo->GetDataID());
555  }
556 
557  fData.seekg(fFrameInfo->GetStartByte());
558  fLayeredFrame->Read(fData);
559 
561 
562 #ifdef DEBUG
563  cout << "Returned event ID: " << fLayeredFrame->GetEventID() << endl;
564 #endif
565 
566  return fLayeredFrame;
567  } else
568  fFrameInfo = (GETFrameInfo *)fFrameInfoArray->ConstructedAt(++fFrameInfoIdx);
569  }
570 
571  ULong64_t startByte = fData.tellg();
572 
573  fLayerHeader->Read(fData);
574  fData.ignore(fLayerHeader->GetFrameSkip());
575 
576  ULong64_t endByte = startByte + fLayerHeader->GetFrameSize();
577 
578  fFrameInfo->SetDataID(fCurrentDataID);
579  fFrameInfo->SetStartByte(startByte);
580  fFrameInfo->SetEndByte(endByte);
581  switch (fFrameType) {
582  case kMergedID: fFrameInfo->SetEventID(fLayerHeader->GetEventID()); break;
583 
584  case kMergedTime:
585  fFrameInfo->SetEventTime(fLayerHeader->GetEventTime());
586  fFrameInfo->SetDeltaT(fLayerHeader->GetDeltaT());
587  break;
588 
589  case kBasic:
590  case kCobo: std::cerr << "== " << __func__ << " This is serious error!" << std::endl; break;
591  }
592 
593  CheckEndOfData();
594  }
595 
596  // return GetLayeredFrame(fTargetFrameInfoIdx);
597 }
598 
599 void GETDecoder2::PrintFrameInfo(Int_t frameID)
600 {
601  if (frameID == -1) {
602  for (Int_t iEntry = 0; iEntry < fFrameInfoArray->GetEntriesFast(); iEntry++)
603  ((GETFrameInfo *)fFrameInfoArray->At(iEntry))->Print();
604  } else
605  ((GETFrameInfo *)fFrameInfoArray->At(frameID))->Print();
606 }
607 
609 {
610  if (frameID == -1) {
611  for (Int_t iEntry = 0; iEntry < fCoboFrameInfoArray->GetEntriesFast(); iEntry++) {
612  auto *frameInfo = (GETFrameInfo *)fCoboFrameInfoArray->At(iEntry);
613  do {
614  frameInfo->Print();
615  frameInfo = frameInfo->GetNextInfo();
616  } while (frameInfo);
617  }
618  } else {
619  auto *frameInfo = (GETFrameInfo *)fCoboFrameInfoArray->At(frameID);
620  do {
621  frameInfo->Print();
622  frameInfo = frameInfo->GetNextInfo();
623  } while (frameInfo);
624  }
625 }
626 
627 Bool_t GETDecoder2::SetWriteFile(TString filename, Bool_t overwrite)
628 {
629  fWriteFile = GETFileChecker::CheckFile(filename);
630  if (!fWriteFile.IsNull() && !overwrite) {
631  std::cout << "== [GETDecoder] The file you specified already exists!" << std::endl;
632  std::cout << " If you want to overwrite it, give kTRUE as a second argument." << std::endl;
633 
634  fWriteFile = "";
635 
636  return kFALSE;
637  }
638 
639  fWriteFile = filename;
640  std::ofstream dummy(fWriteFile.Data(), std::ios::trunc);
641  dummy.close();
642 
643  if (fBuffer == nullptr)
644  fBuffer = new Char_t[14000000];
645 
646  if (fFrameType == kCobo) {
648  if (fCurrentDataID != 0)
649  SetData(0);
650 
651  std::ofstream outFile(fWriteFile.Data(), std::ios::ate | std::ios::binary | std::ios::app);
652  fData.seekg(0);
653  fData.read(fBuffer, fTopologyFrame->GetFrameSize());
654  outFile.write(fBuffer, fTopologyFrame->GetFrameSize());
655  outFile.close();
656 
658 
659  std::cout << "== [GETDecoder] Topology frame is written!" << std::endl;
660  }
661 
662  return kTRUE;
663 }
664 
666 {
667  if (fWriteFile.IsNull()) {
668  std::cout << "== [GETDecoder] Write file is not set. Use SetWriteFile() first!" << std::endl;
669 
670  return;
671  }
672 
674 
675  std::ofstream outFile(fWriteFile.Data(), std::ios::ate | std::ios::binary | std::ios::app);
676  switch (fFrameType) {
677  case kCobo:
678  fCoboFrameInfo = (GETFrameInfo *)fCoboFrameInfoArray->At(fTargetFrameInfoIdx);
679  do {
680  if (fCurrentDataID != fCoboFrameInfo->GetDataID())
681  SetData(fCoboFrameInfo->GetDataID());
682 
683  ULong64_t frameSize = fCoboFrameInfo->GetEndByte() - fCoboFrameInfo->GetStartByte();
684  fData.seekg(fCoboFrameInfo->GetStartByte());
685  fData.read(fBuffer, frameSize);
686  outFile.write(fBuffer, frameSize);
687  fCoboFrameInfo = fCoboFrameInfo->GetNextInfo();
688  } while (fCoboFrameInfo);
689  break;
690 
691  default:
692  fFrameInfo = (GETFrameInfo *)fFrameInfoArray->At(fTargetFrameInfoIdx);
693 
694  if (fCurrentDataID != fCoboFrameInfo->GetDataID())
695  SetData(fCoboFrameInfo->GetDataID());
696 
697  ULong64_t frameSize = fFrameInfo->GetEndByte() - fFrameInfo->GetStartByte();
698  fData.seekg(fFrameInfo->GetStartByte());
699  fData.read(fBuffer, frameSize);
700  outFile.write(fBuffer, frameSize);
701  break;
702  }
703  outFile.close();
704 
706 }
707 
709 {
710  if (!fIsMetaData && fFrameInfo->GetEndByte() == fDataSize)
711  if (!NextData() && !fIsDoneAnalyzing) {
712 
713 #ifdef DEBUG
714  std::cout << " == [GETDecoder] File ended!" << std::endl;
715 #endif
716 
717  fIsDoneAnalyzing = kTRUE;
718  fIsMetaData = kTRUE;
719 
720  // Writing meta data will be here.
721  }
722 }
723 
725 {
726  fPrevDataID = fCurrentDataID;
727  fPrevPosition = fData.tellg();
728 }
729 
731 {
732  if (fIsDoneAnalyzing)
733  return;
734 
735  if (fPrevDataID != fCurrentDataID)
736  SetData(fPrevDataID);
737 
738  fData.seekg(fPrevPosition);
739 }
740 
741 void GETDecoder2::SetPseudoTopologyFrame(Int_t asadMask, Bool_t check)
742 {
743  Char_t bytes[] = {0x40, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x07, 0x00, 0x00, (Char_t)(asadMask & 0xf), 0x00, 0x00};
744  std::stringstream topology(std::string(std::begin(bytes), std::end(bytes)));
745 
746  fTopologyFrame->Read(*((ifstream *)&topology));
747  if (check)
748  fTopologyFrame->Print();
749 }
GETHeaderBase::GetFrameSize
UInt_t GetFrameSize(Bool_t inBytes=kTRUE)
Definition: GETHeaderBase.cxx:21
GETHeaderBase::Clear
void Clear(Option_t *="")
Definition: GETHeaderBase.cxx:74
GETDecoder2::kCobo
@ kCobo
Definition: GETDecoder2.h:48
GETFrameInfo::GetNextInfo
GETFrameInfo * GetNextInfo()
Definition: GETFrameInfo.cxx:73
GETFrameInfo::SetEventTime
void SetEventTime(ULong64_t value)
Definition: GETFrameInfo.cxx:25
GETDecoder2::RestorePreviousState
void RestorePreviousState()
Definition: GETDecoder2.cxx:730
GETFrameInfo::GetDataID
UInt_t GetDataID()
Definition: GETFrameInfo.cxx:49
GETDecoder2::GetFrameType
EFrameType GetFrameType()
Definition: GETDecoder2.cxx:338
GETDecoder2::GetBasicFrame
GETBasicFrame * GetBasicFrame(Int_t frameID=-1)
Return specific frame of the given frame number. If frameID is -1, this method returns next frame.
Definition: GETDecoder2.cxx:357
ClassImp
ClassImp(GETDecoder2)
GETDecoder2::GETDecoder2
GETDecoder2()
Constructor.
Definition: GETDecoder2.cxx:43
GETFrameInfo::IsFill
Bool_t IsFill()
Definition: GETFrameInfo.cxx:95
GETFrameInfo::GetStartByte
ULong64_t GetStartByte()
Definition: GETFrameInfo.cxx:65
GETHeaderBase.h
GETCoboFrame::Clear
void Clear(Option_t *="")
Definition: GETCoboFrame.cxx:43
GETFileChecker.h
GETBasicFrame::Clear
void Clear(Option_t *="")
Definition: GETBasicFrame.cxx:24
GETLayeredFrame::Clear
void Clear(Option_t *="")
Definition: GETLayeredFrame.cxx:27
GETDecoder2::GetDataName
TString GetDataName(Int_t index)
Return the filename of data at index.
Definition: GETDecoder2.cxx:323
GETLayerHeader
Definition: GETLayerHeader.h:18
GETBasicFrameHeader::Read
void Read(ifstream &stream)
Definition: GETBasicFrameHeader.cxx:116
GETBasicFrame
Definition: GETBasicFrame.h:14
GETLayerHeader.h
GETBasicFrameHeader.h
GETDecoder2::GetLayeredFrame
GETLayeredFrame * GetLayeredFrame(Int_t frameID=-1)
Definition: GETDecoder2.cxx:526
GETLayerHeader::GetEventID
UInt_t GetEventID()
Definition: GETLayerHeader.cxx:27
GETDecoder2::SetNumTbs
void SetNumTbs(Int_t value=512)
Setting the number of time buckets.
Definition: GETDecoder2.cxx:179
GETFrameInfo::SetEventID
void SetEventID(UInt_t value)
Definition: GETFrameInfo.cxx:21
GETDecoder2::CheckEndOfData
void CheckEndOfData()
Definition: GETDecoder2.cxx:708
GETFRAMEMERGEDBYID
#define GETFRAMEMERGEDBYID
Definition: GETHeaderBase.h:7
GETDecoder2::WriteFrame
void WriteFrame()
Write current frame.
Definition: GETDecoder2.cxx:665
GETDecoder2
Definition: GETDecoder2.h:38
GETFrameInfo::SetDeltaT
void SetDeltaT(UInt_t value)
Definition: GETFrameInfo.cxx:29
GETBasicFrame.h
GETFrameInfo.h
GETBasicFrameHeader::Clear
void Clear(Option_t *="")
Definition: GETBasicFrameHeader.cxx:97
GETFrameInfo::SetDataID
void SetDataID(UInt_t value)
Definition: GETFrameInfo.cxx:17
GETCoboFrame::GetFrame
GETBasicFrame * GetFrame(Int_t index)
Definition: GETCoboFrame.cxx:38
GETFrameInfo::GetEndByte
ULong64_t GetEndByte()
Definition: GETFrameInfo.cxx:69
GETHeaderBase::GetFrameType
UInt_t GetFrameType()
Definition: GETHeaderBase.cxx:29
GETHeaderBase::IsBlob
Bool_t IsBlob()
Definition: GETHeaderBase.cxx:46
GETDecoder2::GetNumData
Int_t GetNumData()
Return the number of data added in the list.
Definition: GETDecoder2.cxx:318
GETDecoder2::GetNumTbs
Int_t GetNumTbs()
Return the number of time buckets.
Definition: GETDecoder2.cxx:334
GETDecoder2::kMergedTime
@ kMergedTime
Definition: GETDecoder2.h:48
GETCoboFrame.h
GETLayerHeader::GetDeltaT
UInt_t GetDeltaT()
Definition: GETLayerHeader.cxx:35
GETDecoder2::SetData
Bool_t SetData(Int_t index)
Set the data file to the class.
Definition: GETDecoder2.cxx:210
GETDecoder2::Clear
void Clear()
Clear data information.
Definition: GETDecoder2.cxx:141
GETDecoder2::PrintFrameInfo
void PrintFrameInfo(Int_t frameID=-1)
Definition: GETDecoder2.cxx:599
GETDecoder2::SetPseudoTopologyFrame
void SetPseudoTopologyFrame(Int_t asadMask, Bool_t check=kFALSE)
Definition: GETDecoder2.cxx:741
GETCoboFrame::ReadFrame
void ReadFrame(ifstream &stream)
Definition: GETCoboFrame.cxx:8
GETLayerHeader::GetFrameSkip
ULong64_t GetFrameSkip()
Definition: GETLayerHeader.cxx:39
GETDecoder2.h
GETTopologyFrame::GetAsadMask
bitset< 4 > GetAsadMask()
Definition: GETTopologyFrame.cxx:19
GETFileChecker::CheckFile
static TString CheckFile(TString filename)
Definition: GETFileChecker.cxx:22
GETHeaderBase::Read
void Read(ifstream &file, Bool_t rewind=kFALSE)
Definition: GETHeaderBase.cxx:83
GETFrameInfo
Definition: GETFrameInfo.h:11
GETDecoder2::GetNumFrames
Int_t GetNumFrames()
Definition: GETDecoder2.cxx:343
GETDecoder2::NextData
Bool_t NextData()
Search the next file and set it if exists. Returns 1 if successful.
Definition: GETDecoder2.cxx:293
GETFrameInfo::Copy
void Copy(GETFrameInfo *frameInfo)
Definition: GETFrameInfo.cxx:124
GETLayerHeader::GetEventTime
ULong64_t GetEventTime()
Definition: GETLayerHeader.cxx:31
GETFrameInfo::GetNumFrames
UInt_t GetNumFrames()
Definition: GETFrameInfo.cxx:77
GETLayeredFrame.h
GETDecoder2::SetWriteFile
Bool_t SetWriteFile(TString filename, Bool_t overwrite=kFALSE)
Set the file for writing frame.
Definition: GETDecoder2.cxx:627
GETTopologyFrame.h
GETHeaderBase
Definition: GETHeaderBase.h:23
GETDecoder2::GetCoboFrame
GETCoboFrame * GetCoboFrame(Int_t frameID=-1)
Definition: GETDecoder2.cxx:419
GETTopologyFrame::Read
void Read(ifstream &Stream)
Definition: GETTopologyFrame.cxx:50
GETFrameInfo::SetNextInfo
void SetNextInfo(GETFrameInfo *pointer)
Definition: GETFrameInfo.cxx:41
GETDecoder2::PrintCoboFrameInfo
void PrintCoboFrameInfo(Int_t frameID=-1)
Definition: GETDecoder2.cxx:608
GETDecoder2::SetPositivePolarity
void SetPositivePolarity(Bool_t value=kTRUE)
Set the positive signal polarity.
Definition: GETDecoder2.cxx:300
GETDecoder2::BackupCurrentState
void BackupCurrentState()
Definition: GETDecoder2.cxx:724
GETLayeredFrame::Read
void Read(ifstream &stream)
Definition: GETLayeredFrame.cxx:36
GETBasicFrameHeader
Definition: GETBasicFrameHeader.h:21
GETLayerHeader::Clear
void Clear(Option_t *="")
Definition: GETLayerHeader.cxx:55
GETFrameInfo::SetEndByte
void SetEndByte(ULong64_t value)
Definition: GETFrameInfo.cxx:37
GETFRAMEMERGEDBYTIME
#define GETFRAMEMERGEDBYTIME
Definition: GETHeaderBase.h:8
GETLayeredFrame
Definition: GETLayeredFrame.h:16
GETDecoder2::kMergedID
@ kMergedID
Definition: GETDecoder2.h:48
GETFrameInfo::GetEventID
UInt_t GetEventID()
Definition: GETFrameInfo.cxx:53
GETBasicFrame::Read
void Read(ifstream &stream)
Definition: GETBasicFrame.cxx:31
GETCoboFrame
Definition: GETCoboFrame.h:14
GETLayerHeader::Read
void Read(ifstream &stream)
Definition: GETLayerHeader.cxx:67
GETBasicFrameHeader::GetFrameSkip
ULong64_t GetFrameSkip()
Definition: GETBasicFrameHeader.cxx:88
GETFrameInfo::SetStartByte
void SetStartByte(ULong64_t value)
Definition: GETFrameInfo.cxx:33
GETTopologyFrame
Definition: GETTopologyFrame.h:20
GETDecoder2::kBasic
@ kBasic
Definition: GETDecoder2.h:48
GETDecoder2::AddData
Bool_t AddData(TString filename)
Add the data file to the list of rawdata.
Definition: GETDecoder2.cxx:184
GETBasicFrameHeader::GetEventID
UInt_t GetEventID()
Definition: GETBasicFrameHeader.cxx:31
GETDecoder2::EFrameType
EFrameType
Frame type enumerator.
Definition: GETDecoder2.h:48
GETDecoder2::SetDiscontinuousData
void SetDiscontinuousData(Bool_t value=kTRUE)
Definition: GETDecoder2.cxx:289
GETTopologyFrame::Print
void Print()
Definition: GETTopologyFrame.cxx:62
GETDecoder2::ShowList
void ShowList()
Print rawdata file list on the screen.
Definition: GETDecoder2.cxx:305
GETTopologyFrame::Clear
void Clear(Option_t *="")
Definition: GETTopologyFrame.cxx:40