20 for (
auto data : frame)
21 std::cout << std::hex << data << std::endl;
22 std::cout << std::endl;
33 unsigned int nHits = (header >> 32) & 0xff;
34 if (
verbose > 1) std::cout <<
"Hits in Frame: " << nHits << std::endl;
35 if (nHits == frame.size() - 2){
38 else if (nHits == 0xff && frame.size() == 2)
41 std::cout <<
"***** Error Hit Count ***** Header: " << header <<
" nHits: " << nHits <<
" size frame: " << frame.size() - 2 << std::endl;
55 unsigned int frameCount = header & 0xffffffff;
60 if (
verbose > 0) std::cout <<
"****** Info Setting allCountedFrames to start frames ***** " << summary.
fAllCountedFrames.back() << std::endl;
62 else if (calcFrameCount > frameCount) {
63 if (
verbose > 0) std::cout <<
"***** Info PartialReset? calcFrameCount " << calcFrameCount <<
" > frameCount " << frameCount << std::endl;
68 if (
verbose > 0) std::cout <<
"Error allCountedFrames does not match!" << std::endl;
76 if (
verbose > 1) std::cout <<
"oldFrameCount " <<
oldFrameCount <<
" framesSince: " << framesSinceLastData <<
" newFrame " << frameCount <<
77 " difference: " << std::dec << frameCount - calcFrameCount <<
82 if (calcFrameCount > 0x100000000){
83 if (
verbose > 0) std::cout <<
"New Super Frame: calcFrame " << calcFrameCount << std::endl;
85 calcFrameCount = calcFrameCount & 0xffffffff;
88 if (calcFrameCount == frameCount){
93 std::cout <<
"***** Error Frame Count ***** : calcFrameCount " << calcFrameCount <<
" frameCount " << frameCount <<
" allCountedFrames " << summary.
fAllCountedFrames.back() << std::endl;
102 std::vector<char> frameInChar = pastaConv.
ConvertData(frame);
105 if (
verbose > 1) std::cout <<
"CalculatedCRC: " << hex << calculatedCRC << std::endl;
106 if (calculatedCRC == frame.back()){
110 std::cout <<
"***** Error CRC ***** CalculatedCRC: " << calculatedCRC << std::endl;
118 std::vector<PndMvdPastaDigi>
ProcessFrame(std::vector<ULong64_t> frame)
120 std::vector<PndMvdPastaDigi> digis;
123 frame.erase(frame.begin());
129 if (
verbose > 1) std::cout <<
"CRC match!" << std::endl;
132 if (
verbose > 0) std::cout <<
"*********** CRC error *************" << std::endl;
141 if (HitCount_Ok ==
true){
142 if (
verbose > 1) std::cout <<
"Correct Hit Count!" << std::endl;
144 if (
verbose > 0) std::cout <<
"************* Wrong Hit Counts ***************" << std::endl;
147 if (FrameCount_Ok ==
true){
148 if (
verbose > 1) std::cout <<
"Correct Frame Count!" << std::endl;
150 if (
verbose > 0) std::cout <<
"************** Wrong Frame Count *************" << std::endl;
153 if (
verbose > 1) std::cout << std::endl;
155 if (CRC_Ok && HitCount_Ok && FrameCount_Ok && (frame.size() % 2 == 0)){
156 for (
int i = 1;
i < frame.size() -1;
i+=2){
158 if (
verbose > 1) std::cout << newDigi;
159 digis.push_back(newDigi);
169 TFile
f(outputFileName,
"RECREATE");
170 TTree
t(
"PastaTB",
"Pasta Digis from TestBeam");
172 TClonesArray* pastadata =
new TClonesArray(
"PndMvdPastaDigi");
173 t.Branch(
"data", &pastadata);
177 std::ifstream inputFile(fileName.Data());
179 std::vector<ULong64_t> frame;
181 while (!(inputFile.eof())){
182 inputFile >> std::hex >> data;
183 if (
verbose > 1) std::cout << std::hex << data << std::endl;
184 if (data == 0xffffffffff){
185 if (frame.size() > 1){
186 std::vector<PndMvdPastaDigi> pastavec =
ProcessFrame(frame);
187 for (
int i = 0;
i < pastavec.size();
i++)
189 if (pastavec.size() > 0){
195 else if (frame.size() == 1) {
198 frame.erase(frame.begin(), frame.end());
203 frame.push_back(data);
206 std::cout <<
"*************** Summary **************" << std::endl;
207 std::cout << std::dec <<
"CRCMatch: " << summary.
fCrcMatchCount <<
bool CheckCRC(std::vector< ULong64_t > frame)
void PrintFrame(std::vector< ULong64_t > &frame)
ThresholdDataFullMode AnalyzeThresholdWordFull(ULong64_t word)
int PastaTBRawToRoot(TString fileName)
int fWrongFrameCount
count of all frames where the expected frame ID did not match the frameID in the header ...
PndCRCCalculator decoder(16, 0x1021, 0, 0, 0, 0x0F4A)
unsigned int oldFrameCount
int fWrongHitCount
count of all frames where the hits in the header do not match the data
int fSingleWordFrames
count of all frames with just one word. This is an error a frame has at least two words ...
std::vector< PndMvdPastaDigi > ProcessFrame(std::vector< ULong64_t > frame)
A simple class which adds the corresponding file extensions to a given base class.
int fAllPartialResets
count of all partial resets detected
int fMissingFrames
count of all missing frames (not very reliable)
int fCrcErrorCount
count of all frames with wrong CRC
std::vector< ULong64_t > fAllCountedFrames
counts all frames within a partial reset
std::vector< char > ConvertData(std::vector< ULong64_t > frame)
PndMvdCreateDefaultApvMap * creator
ULong64_t CalculateCRCTableFast(std::vector< char > p, ULong64_t len)
bool CheckFrameCount(std::vector< ULong64_t > frame)
FrameHeader AnalyzeHeader(ULong64_t word)
ULong64_t diffAllFrameCount
int fSuperFrameCount
count of frame counter overflow (should not happen because the frame counter is HUGE ...
ULong64_t framesSinceLastData
bool CheckHitCount(std::vector< ULong64_t > frame)
PndCRCCalculator calculates the CRC checksum from a given vector<char>
int fCrcMatchCount
count of all frames with correct CRC