FairRoot/PandaRoot
PndMvdReadInTBData.h
Go to the documentation of this file.
1 /*
2  * PndMvdReadInTBData.h
3  *
4  * Created on: 23.10.2014
5  * Author: Stockmanns
6  */
7 
8 #ifndef PNDMVDREADINTBDATA_H_
9 #define PNDMVDREADINTBDATA_H_
10 
11 #include "Rtypes.h"
12 #include "TClonesArray.h"
13 #include "TString.h"
14 
15 #include "PndSdsDigiTopix4.h"
16 #include "PndSdsDigiTopix4Header.h"
17 
18 #include <fstream>
19 #include <iostream>
20 #include <utility>
21 #include <vector>
22 
23 struct frameHeader{
25 
26  UInt_t fChipAddress;
27  UInt_t fFrameCount;
28  UInt_t fECC;
29 
30 };
31 
32 struct frameTrailer{
34 
35  UInt_t fNEvents;
36  UInt_t fFrameCRC;
37  UInt_t fECC;
38 };
39 
40 struct pixel{
42 
43  UInt_t fPixelAddress;
44  UInt_t fLeadingEdge;
45  UInt_t fTrailingEdge;
46 };
47 
49 public:
51  virtual ~PndMvdReadInTBData();
52  void SetFileName(std::vector<TString> fileName){
53 
54  std::cout << "number of entires " << fileName.size() << std::endl;
55  for(int i=0; i < fileName.size();i++)
56  {
57  std::cout << i<< " " << fileName[i] << std::endl;
58  }
59  fFileNames= fileName;
60  }
61 
62  void Init();
63 
64  Bool_t ReadInData(TClonesArray* sdsDigiContainer, TClonesArray* headerContainer, TClonesArray* allheaderContainer);
65  Bool_t ReadInRawData(std::ifstream* fileHandle, std::vector<ULong64_t>& rawData);//<input is fileHandle, output vector of raw data, output is end of file
66  void AnalyzeData(std::vector<ULong64_t>& rawData, Double_t clockFrequency);
67 
68  pixel BitAnalyzePixelData(ULong64_t& data);
69  frameHeader BitAnalyzeHeader(ULong64_t& header);
70  frameTrailer BitAnalyzeTrailer(ULong64_t& trailer);
71 
72  std::pair<UInt_t, UInt_t> PixeladdressToMatrixAddress(UInt_t pixelglobaladdress);
73 
75  void SetFE(Int_t val){fFE = val;}
76  UInt_t GetNonSequenctialFC() const {return fNonSequentialFC;}
77  UInt_t GetDoubleHeader() const {return fDoubleHeader;}
78  UInt_t GetDoubleTrailer() const {return fDoubleTrailer;}
79  UInt_t GetSuperFrameCount() const {return fSuperFrameCount;}
80 
81 
82  UInt_t GetTotalHitCount() const {return fTotalHitCount;}
83  UInt_t GetCorrectHitCount() const {return fCorrectHitCount;}
86  UInt_t GetCRCLossHitCount() const {return fCRCLossHitCount;}
87 
88  UInt_t GetTotalFrameCount() const {return fTotalFrameCount;}
89  UInt_t GetCorrectFrameCount() const {return fCorrectFrameCount;}
91  UInt_t GetCRCLossFrameCount() const {return fCRCLossFrameCount;}
92 
93  UInt_t GetTotalHeaderCount() const {return fTotalHeaderCount;}
94  UInt_t GetTotalTrailerCount() const {return fTotalTrailerCount;}
95 
96  PndSdsDigiTopix4 ProcessData(ULong64_t& data, frameHeader& header, Double_t& clockFrequency);
97  ULong64_t ReflectBitsStream(ULong64_t crc, int bitnum);
98  ULong64_t CalculateCRCTableFast(std::vector<char> p, ULong64_t len);
99  void GenerateCRCTable();
100  UShort_t CheckHammingCode(ULong64_t dataword, int dataword_length);
101  ULong64_t ConvertToPix4HammingToStandardHamming(ULong64_t topixhamming);
102  void AnalyzeToPixFrame(Double_t clockFrequency);
103  void SetVerbose(Int_t val){fVerbose = val;}
104 
105 private:
106  std::vector<TString> fFileNames;
107  std::ifstream* fFileHandle;
109  TClonesArray* fOutputArray;
110  TClonesArray* fOutputArrayHeader;
111  TClonesArray* fOutputArrayAllHeader;
118 
124 
133 
136 
137  Int_t fVerbose; // fVerbose==5 gives all detected errors from ToPix build in error detection
138  Int_t fFE;
140  UInt_t fDataCount;
143  std::vector<ULong64_t> fToPixFrame;
144 
145  TClonesArray* fDigiArray;
146  // CRC parameters :
147 
148  const UInt_t fOrder;
149  const ULong64_t fPolynom;
150  const ULong64_t fCRCXor;
151  const UInt_t fRefIn;
152  const UInt_t fRefOut;
153 
154  ULong64_t fCRCMask;
155  ULong64_t fCRCHighBit;
156  ULong64_t fCRCInit_direct;
157  ULong64_t fCRCTab[256];
158 
159 };
160 
161 #endif /* PNDMVDREADINTBDATA_H_ */
Bool_t ReadInRawData(std::ifstream *fileHandle, std::vector< ULong64_t > &rawData)
const ULong64_t fPolynom
Double_t p
Definition: anasim.C:58
UInt_t GetSuperFrameCount() const
void SetFE(Int_t val)
UInt_t GetCorrectHitCount() const
Int_t i
Definition: run_full.C:25
TClonesArray * fOutputArrayHeader
Data class to store the digi output of a pixel module.
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
UInt_t GetTotalHeaderCount() const
ULong64_t CalculateCRCTableFast(std::vector< char > p, ULong64_t len)
TClonesArray * fOutputArray
UInt_t GetTotalFrameCount() const
Bool_t ReadInData(TClonesArray *sdsDigiContainer, TClonesArray *headerContainer, TClonesArray *allheaderContainer)
std::ifstream * fFileHandle
ULong64_t fCRCTab[256]
UInt_t fLeadingEdge
UInt_t GetNonSequenctialFC() const
void SetVerbose(Int_t val)
UInt_t GetTotalTrailerCount() const
ULong64_t ConvertToPix4HammingToStandardHamming(ULong64_t topixhamming)
UInt_t GetHammingLossHitCount() const
TClonesArray * fDigiArray
UInt_t fTrailingEdge
std::vector< ULong64_t > fToPixFrame
Double_t
PndSdsDigiTopix4 ProcessData(ULong64_t &data, frameHeader &header, Double_t &clockFrequency)
UInt_t GetTotalHitCount() const
const ULong64_t fCRCXor
frameHeader fRecentFrameHeader
UInt_t GetCRCLossFrameCount() const
std::pair< UInt_t, UInt_t > PixeladdressToMatrixAddress(UInt_t pixelglobaladdress)
UInt_t GetCRCLossHitCount() const
frameHeader fRecentAllFrameHeader
pixel BitAnalyzePixelData(ULong64_t &data)
std::vector< TString > fFileNames
UInt_t GetDoubleTrailer() const
void AnalyzeToPixFrame(Double_t clockFrequency)
UShort_t CheckHammingCode(ULong64_t dataword, int dataword_length)
frameTrailer BitAnalyzeTrailer(ULong64_t &trailer)
void SetFileName(std::vector< TString > fileName)
TClonesArray * fOutputArrayAllHeader
UInt_t GetPreFrameLossHitCount() const
UInt_t GetHammingLossFrameCount() const
ULong64_t ReflectBitsStream(ULong64_t crc, int bitnum)
UInt_t fPixelAddress
UInt_t GetDoubleHeader() const
void AnalyzeData(std::vector< ULong64_t > &rawData, Double_t clockFrequency)
frameTrailer fRecentFrameTrailer
UInt_t GetCorrectFrameCount() const
frameHeader BitAnalyzeHeader(ULong64_t &header)
void SetClockFrequency(Double_t val)