Compare commits
5 Commits
c0e6d7ae9a
...
2e65bbf233
Author | SHA1 | Date | |
---|---|---|---|
|
2e65bbf233 | ||
|
55ee3931cc | ||
|
5c6b5e7001 | ||
|
792d1c5545 | ||
|
2ee71637cc |
|
@ -33,7 +33,7 @@ int main(){
|
|||
count ++;
|
||||
|
||||
data->DataIndex[ch] ++;
|
||||
if( data->DataIndex[ch] > MaxNData ) {
|
||||
if( data->DataIndex[ch] > data->GetDataSize() ) {
|
||||
data->LoopIndex[ch] ++;
|
||||
data->DataIndex[ch] = 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ int main(int argc, char **argv) {
|
|||
printf("Incorrect number of arguments:\n");
|
||||
printf("%s [timeWindow] [Buffer] [traceOn/Off] [verbose] [inFile1] [inFile2] .... \n", argv[0]);
|
||||
printf(" timeWindow : in ns \n");
|
||||
printf(" Buffer : Fraction of %d, recommand 0.4 \n", MaxNData);
|
||||
printf(" Buffer : Fraction of %d, recommand 0.4 \n", DefaultDataSize);
|
||||
printf(" traceOn/Off : is traces stored \n");
|
||||
printf(" verbose : > 0 for debug \n");
|
||||
printf(" Output file name is contructed from inFile1 \n");
|
||||
|
@ -70,7 +70,7 @@ int main(int argc, char **argv) {
|
|||
for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].Data());
|
||||
printf("=====================================\n");
|
||||
printf(" Time Window = %u ns = %.1f us\n", timeWindow, timeWindow/1000.);
|
||||
printf(" Buffer size = %.0f event/channel\n", MaxNData * bufferSize);
|
||||
printf(" Buffer size = %.0f event/channel\n", DefaultDataSize * bufferSize);
|
||||
printf("===================================== input files:\n");
|
||||
printf("Scanning files.....\n");
|
||||
|
||||
|
@ -289,6 +289,8 @@ int main(int argc, char **argv) {
|
|||
//data[i]->PrintStat();
|
||||
}
|
||||
|
||||
uShort dataSize = data[i]->GetDataSize();
|
||||
|
||||
for( int ch = 0; ch < data[i]->GetNChannel(); ch ++){
|
||||
|
||||
int iData = data[i]->DataIndex[ch];
|
||||
|
@ -296,8 +298,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
if( iData < 0 ) continue;
|
||||
|
||||
if( (iLoop*MaxNData + iData) - (lastLoopIndex[i][ch]*MaxNData + lastDataIndex[i][ch]) > MaxNData * bufferSize ) {
|
||||
if( debug ) printf("############# BREAK!!!! Group: %d, ch : %d | last : %d(%d), Present : %d(%d) | BufferSize : %.0f \n", i, ch, lastDataIndex[i][ch], lastLoopIndex[i][ch], iData, iLoop, MaxNData * bufferSize);
|
||||
if( (iLoop*dataSize + iData) - (lastLoopIndex[i][ch]*dataSize + lastDataIndex[i][ch]) > dataSize * bufferSize ) {
|
||||
if( debug ) printf("############# BREAK!!!! Group: %d, ch : %d | last : %d(%d), Present : %d(%d) | BufferSize : %.0f \n", i, ch, lastDataIndex[i][ch], lastLoopIndex[i][ch], iData, iLoop, dataSize * bufferSize);
|
||||
fillFlag = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "fsuReader.h"
|
||||
#include <chrono>
|
||||
|
||||
#include "TROOT.h"
|
||||
#include "TSystem.h"
|
||||
|
@ -44,15 +43,6 @@ struct GroupInfo{
|
|||
};
|
||||
|
||||
|
||||
unsigned long long getTime_ns(){
|
||||
|
||||
std::chrono::high_resolution_clock::time_point currentTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::nanoseconds nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(currentTime.time_since_epoch());
|
||||
return nanoseconds.count();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//^#############################################################
|
||||
//^#############################################################
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -114,7 +104,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
printf("Processing %s (%d/%d) ..... \n\033[A\r", inFileName[i].Data(), i+1, nFile);
|
||||
|
||||
reader[i] = new FSUReader(inFileName[i].Data(), false);
|
||||
reader[i] = new FSUReader(inFileName[i].Data(), 0, false);
|
||||
reader[i]->ScanNumBlock(0, 1);
|
||||
// reader[i]->FillHitList();
|
||||
|
||||
|
|
119
Aux/fsuReader.h
119
Aux/fsuReader.h
|
@ -1,19 +1,20 @@
|
|||
#include "../ClassData.h"
|
||||
#include "../Hit.h"
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
||||
class FSUReader{
|
||||
|
||||
public:
|
||||
FSUReader();
|
||||
FSUReader(std::string fileName, uShort dataSize = 100, bool verbose = true);
|
||||
FSUReader(std::string fileName, uShort dataSize = 100, int verbose = 1);
|
||||
~FSUReader();
|
||||
|
||||
void OpenFile(std::string fileName, uShort dataSize, bool verbose = true);
|
||||
void OpenFile(std::string fileName, uShort dataSize, int verbose = 1);
|
||||
bool isOpen() const{return inFile == nullptr ? false : true;}
|
||||
|
||||
void ScanNumBlock(bool verbose = true, uShort saveData = 0);
|
||||
int ReadNextBlock(bool fast = false, int verbose = 0, uShort saveData = 0); // saveData = 0 (no save), 1 (no trace), 2 (with trace);
|
||||
void ScanNumBlock(int verbose = 1, uShort saveData = 0);
|
||||
int ReadNextBlock(bool skipTrace= false, int verbose = 0, uShort saveData = 0); // saveData = 0 (no save), 1 (no trace), 2 (with trace);
|
||||
int ReadBlock(unsigned int ID, int verbose = 0);
|
||||
|
||||
unsigned long GetTotNumBlock() const{ return totNumBlock;}
|
||||
|
@ -37,7 +38,9 @@ class FSUReader{
|
|||
void ClearHitCount() {numHit = 0;}
|
||||
ulong GetHitCount() const{ return numHit;}
|
||||
std::vector<Hit> GetHitVector() const {return hit;}
|
||||
void SortHit();
|
||||
void SortHit(int verbose = false);
|
||||
|
||||
std::string SaveHit2NewFile(std::string saveFolder = "./");
|
||||
|
||||
private:
|
||||
|
||||
|
@ -57,7 +60,7 @@ class FSUReader{
|
|||
int tick2ns;
|
||||
int order;
|
||||
int chMask;
|
||||
int numCh;
|
||||
uShort numCh;
|
||||
|
||||
std::vector<unsigned int> blockPos;
|
||||
std::vector<unsigned int > blockTimeStamp;
|
||||
|
@ -89,11 +92,11 @@ inline FSUReader::FSUReader(){
|
|||
|
||||
}
|
||||
|
||||
inline FSUReader::FSUReader(std::string fileName, uShort dataSize, bool verbose){
|
||||
inline FSUReader::FSUReader(std::string fileName, uShort dataSize, int verbose){
|
||||
OpenFile(fileName, dataSize, verbose);
|
||||
}
|
||||
|
||||
inline void FSUReader::OpenFile(std::string fileName, uShort dataSize, bool verbose){
|
||||
inline void FSUReader::OpenFile(std::string fileName, uShort dataSize, int verbose){
|
||||
|
||||
inFile = fopen(fileName.c_str(), "r");
|
||||
|
||||
|
@ -157,7 +160,7 @@ inline void FSUReader::OpenFile(std::string fileName, uShort dataSize, bool verb
|
|||
if( fileName.find("PSD") != std::string::npos ) DPPType = DPPType::DPP_PSD_CODE;
|
||||
if( fileName.find("QDC") != std::string::npos ) DPPType = DPPType::DPP_QDC_CODE;
|
||||
|
||||
numCh = DPPType == DPPType::DPP_QDC_CODE ? 64 : 16;
|
||||
numCh = (DPPType == DPPType::DPP_QDC_CODE ? 64 : 16);
|
||||
|
||||
data = new Data(numCh, dataSize);
|
||||
data->tick2ns = tick2ns;
|
||||
|
@ -166,7 +169,7 @@ inline void FSUReader::OpenFile(std::string fileName, uShort dataSize, bool verb
|
|||
|
||||
}
|
||||
|
||||
inline int FSUReader::ReadNextBlock(bool fast, int verbose, uShort saveData){
|
||||
inline int FSUReader::ReadNextBlock(bool skipTrace, int verbose, uShort saveData){
|
||||
if( inFile == NULL ) return -1;
|
||||
if( feof(inFile) ) return -1;
|
||||
if( filePos >= inFileSize) return -1;
|
||||
|
@ -193,8 +196,7 @@ inline int FSUReader::ReadNextBlock(bool fast, int verbose, uShort saveData){
|
|||
return -30;
|
||||
}
|
||||
|
||||
|
||||
data->DecodeBuffer(buffer, aggSize, fast, verbose); // data will own the buffer
|
||||
data->DecodeBuffer(buffer, aggSize, skipTrace, verbose); // data will own the buffer
|
||||
|
||||
}else if( (header & 0xF ) == 0x8 ) { /// dual channel header
|
||||
|
||||
|
@ -204,7 +206,7 @@ inline int FSUReader::ReadNextBlock(bool fast, int verbose, uShort saveData){
|
|||
filePos = ftell(inFile);
|
||||
|
||||
data->buffer = buffer;
|
||||
data->DecodeDualBlock(buffer, dualSize, DPPType, chMask, false, verbose);
|
||||
data->DecodeDualBlock(buffer, dualSize, DPPType, chMask, skipTrace, verbose);
|
||||
|
||||
}else{
|
||||
printf("incorrect header.\n trminate.");
|
||||
|
@ -229,7 +231,13 @@ inline int FSUReader::ReadNextBlock(bool fast, int verbose, uShort saveData){
|
|||
temp.energy2 = data->Energy2[ch][i];
|
||||
temp.timestamp = data->Timestamp[ch][i];
|
||||
temp.fineTime = data->fineTime[ch][i];
|
||||
if( saveData > 1 ) temp.trace = data->Waveform1[ch][i];
|
||||
if( saveData > 1 ) {
|
||||
temp.traceLength = data->Waveform1[ch][i].size();
|
||||
temp.trace = data->Waveform1[ch][i];
|
||||
}else{
|
||||
temp.traceLength = 0;
|
||||
if( temp.trace.size() > 0 ) temp.trace.clear();
|
||||
}
|
||||
|
||||
hit.push_back(temp);
|
||||
|
||||
|
@ -261,13 +269,15 @@ inline int FSUReader::ReadBlock(unsigned int ID, int verbose){
|
|||
|
||||
}
|
||||
|
||||
inline void FSUReader::SortHit(){
|
||||
inline void FSUReader::SortHit(int verbose){
|
||||
if( verbose) printf("\nQuick Sort hit array according to time...");
|
||||
std::sort(hit.begin(), hit.end(), [](const Hit& a, const Hit& b) {
|
||||
return a.timestamp < b.timestamp;
|
||||
});
|
||||
if( verbose) printf(".......done.\n");
|
||||
}
|
||||
|
||||
inline void FSUReader::ScanNumBlock(bool verbose, uShort saveData){
|
||||
inline void FSUReader::ScanNumBlock(int verbose, uShort saveData){
|
||||
if( feof(inFile) ) return;
|
||||
|
||||
blockID = 0;
|
||||
|
@ -277,7 +287,7 @@ inline void FSUReader::ScanNumBlock(bool verbose, uShort saveData){
|
|||
fseek(inFile, 0L, SEEK_SET);
|
||||
filePos = 0;
|
||||
|
||||
while( ReadNextBlock(true, false, saveData) == 0 ){
|
||||
while( ReadNextBlock(saveData < 2 ? true : false, verbose - 1, saveData) == 0 ){
|
||||
blockPos.push_back(filePos);
|
||||
blockTimeStamp.push_back(data->aggTime);
|
||||
blockID ++;
|
||||
|
@ -298,10 +308,77 @@ inline void FSUReader::ScanNumBlock(bool verbose, uShort saveData){
|
|||
blockID = 0;
|
||||
filePos = 0;
|
||||
|
||||
if(saveData) {
|
||||
if( verbose) printf("\nQuick Sort hit array according to time...");
|
||||
SortHit();
|
||||
if( verbose) printf(".......done.\n");
|
||||
SortHit(verbose);
|
||||
|
||||
}
|
||||
|
||||
inline std::string FSUReader::SaveHit2NewFile(std::string saveFolder){
|
||||
|
||||
printf("FSUReader::%s\n", __func__);
|
||||
|
||||
std::string folder = "";
|
||||
size_t found = fileName.find_last_of('/');
|
||||
std::string outFileName = fileName;
|
||||
if( found != std::string::npos ){
|
||||
folder = fileName.substr(0, found + 1);
|
||||
outFileName = fileName.substr(found +1 );
|
||||
}
|
||||
|
||||
if( saveFolder.empty() ) saveFolder = "./";
|
||||
if( saveFolder.back() != '/') saveFolder += '/';
|
||||
|
||||
//checkif the saveFolder exist;
|
||||
if( saveFolder != "./"){
|
||||
if (!std::filesystem::exists(saveFolder)) {
|
||||
if (std::filesystem::create_directory(saveFolder)) {
|
||||
std::cout << "Directory created successfully." << std::endl;
|
||||
} else {
|
||||
std::cerr << "Failed to create directory." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outFileName = saveFolder + outFileName + ".ts";
|
||||
|
||||
FILE * outFile = fopen(outFileName.c_str(), "wb"); //overwrite binary
|
||||
|
||||
uint32_t header = 0xAA000000;
|
||||
header += sn;
|
||||
fwrite( &header, 4, 1, outFile );
|
||||
|
||||
for( ulong i = 0; i < numHit; i++){
|
||||
|
||||
printf("Saving %lu/%lu (%.2f%%)\n\033[A\r", i, numHit, i*100./numHit);
|
||||
|
||||
fwrite( &(hit[i].sn), 2, 1, outFile);
|
||||
fwrite( &(hit[i].ch), 1, 1, outFile);
|
||||
fwrite( &(hit[i].energy), 2, 1, outFile);
|
||||
fwrite( &(hit[i].energy2), 2, 1, outFile);
|
||||
fwrite( &(hit[i].timestamp), 8, 1, outFile);
|
||||
fwrite( &(hit[i].fineTime), 2, 1, outFile);
|
||||
fwrite( &(hit[i].traceLength), 2, 1, outFile);
|
||||
|
||||
for( uShort j = 0; j < hit[i].traceLength; j++){
|
||||
fwrite( &(hit[i].trace[j]), 2, 1, outFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
off_t outFileSize = ftello(outFile); // unsigned int = Max ~4GB
|
||||
fclose(outFile);
|
||||
|
||||
printf("Saved to %s, size: ", outFileName.c_str());
|
||||
if( outFileSize < 1024 ) {
|
||||
printf(" %ld Byte", outFileSize);
|
||||
}else if( outFileSize < 1024*1024 ) {
|
||||
printf(" %.2f kB", outFileSize/1024.);
|
||||
}else if( outFileSize < 1024*1024*1024){
|
||||
printf(" %.2f MB", outFileSize/1024./1024.);
|
||||
}else{
|
||||
printf(" %.2f GB", outFileSize/1024./1024./1024.);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return outFileName;
|
||||
|
||||
}
|
||||
|
|
179
Aux/fsutsReader.h
Normal file
179
Aux/fsutsReader.h
Normal file
|
@ -0,0 +1,179 @@
|
|||
#include "../Hit.h"
|
||||
#include "../macro.h"
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
#include <cstring> ///memset
|
||||
#include <iostream> ///cout
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
||||
class FSUTSReader{
|
||||
|
||||
public:
|
||||
FSUTSReader();
|
||||
FSUTSReader(std::string fileName, int verbose = true);
|
||||
~FSUTSReader();
|
||||
|
||||
void OpenFile(std::string fileName, int verbose = true);
|
||||
bool isOpen() const{return inFile == nullptr ? false : true;}
|
||||
|
||||
void ScanFile(int verbose = true);
|
||||
int ReadNext(int verbose = 0);
|
||||
int ReadBlock(unsigned int ID, int verbose = 0);
|
||||
|
||||
unsigned long GetNumHit() const{ return numHit;}
|
||||
|
||||
std::string GetFileName() const{return fileName;}
|
||||
unsigned long GetFileByteSize() const {return inFileSize;}
|
||||
int GetSN() const{return sn;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
FILE * inFile;
|
||||
|
||||
std::string fileName;
|
||||
unsigned long inFileSize;
|
||||
unsigned int filePos;
|
||||
unsigned long numHit;
|
||||
|
||||
bool isDualBlock;
|
||||
ushort sn;
|
||||
|
||||
unsigned int blockID;
|
||||
std::vector<unsigned int> blockPos;
|
||||
|
||||
Hit hit;
|
||||
|
||||
uint32_t header;
|
||||
size_t dummy;
|
||||
|
||||
};
|
||||
|
||||
inline FSUTSReader::~FSUTSReader(){
|
||||
|
||||
fclose(inFile);
|
||||
|
||||
}
|
||||
|
||||
inline FSUTSReader::FSUTSReader(){
|
||||
inFile = nullptr;
|
||||
|
||||
blockPos.clear();
|
||||
hit.Clear();
|
||||
}
|
||||
|
||||
inline FSUTSReader::FSUTSReader(std::string fileName, int verbose){
|
||||
OpenFile(fileName, verbose);
|
||||
}
|
||||
|
||||
inline void FSUTSReader::OpenFile(std::string fileName, int verbose){
|
||||
|
||||
inFile = fopen(fileName.c_str(), "r");
|
||||
|
||||
if( inFile == NULL ){
|
||||
printf("FSUTSReader::Cannot open file : %s \n", fileName.c_str());
|
||||
this->fileName = "";
|
||||
return;
|
||||
}
|
||||
|
||||
this->fileName = fileName;
|
||||
|
||||
fseek(inFile, 0L, SEEK_END);
|
||||
inFileSize = ftell(inFile);
|
||||
if(verbose) printf("%s | file size : %ld Byte = %.2f MB\n", fileName.c_str() , inFileSize, inFileSize/1024./1024.);
|
||||
fseek(inFile, 0L, SEEK_SET);
|
||||
filePos = 0;
|
||||
|
||||
numHit = 0;
|
||||
blockID = 0;
|
||||
blockPos.clear();
|
||||
hit.Clear();
|
||||
|
||||
//check is the file is .ts file by checking the 1st 4 byte
|
||||
|
||||
dummy = fread(&header, 4, 1, inFile);
|
||||
printf(" header : 0x%8X \n", header);
|
||||
if( (header >> 24) != 0xAA ){
|
||||
printf(" This is not a time-sorted fsu (*.fsu.ts) file. Abort.");
|
||||
return;
|
||||
}
|
||||
sn = (header & 0xFFFFFF);
|
||||
hit.sn = sn;
|
||||
printf(" S/N : %u \n", sn);
|
||||
|
||||
}
|
||||
|
||||
inline int FSUTSReader::ReadNext(int verbose){
|
||||
if( inFile == NULL ) return -1;
|
||||
if( feof(inFile) ) return -1;
|
||||
if( filePos >= inFileSize) return -1;
|
||||
|
||||
dummy = fread(&(hit.sn), 2, 1, inFile);
|
||||
dummy = fread(&(hit.ch), 1, 1, inFile);
|
||||
dummy = fread(&(hit.energy), 2, 1, inFile);
|
||||
dummy = fread(&(hit.energy2), 2, 1, inFile);
|
||||
dummy = fread(&(hit.timestamp), 8, 1, inFile);
|
||||
dummy = fread(&(hit.fineTime), 2, 1, inFile);
|
||||
dummy = fread(&(hit.traceLength), 2, 1, inFile);
|
||||
|
||||
hit.trace.clear();
|
||||
if( hit.traceLength > 0 ){
|
||||
for(uShort j = 0; j < hit.traceLength; j++){
|
||||
short temp;
|
||||
fread( &temp, 2, 1, inFile);
|
||||
hit.trace.push_back(temp);
|
||||
}
|
||||
}
|
||||
|
||||
filePos = ftell(inFile);
|
||||
|
||||
if(verbose >= 1) hit.Print();
|
||||
if(verbose >= 2) hit.PrintTrace();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int FSUTSReader::ReadBlock(unsigned int ID, int verbose){
|
||||
if( numHit == 0 ) return -1;
|
||||
if( ID >= numHit ) return -1;
|
||||
|
||||
fseek( inFile, 0L, SEEK_SET);
|
||||
|
||||
if( verbose ) printf("Block index: %u, File Pos: %u byte\n", ID, blockPos[ID]);
|
||||
|
||||
fseek(inFile, blockPos[ID], SEEK_CUR);
|
||||
filePos = blockPos[ID];
|
||||
blockID = ID;
|
||||
return ReadNext(verbose);
|
||||
|
||||
}
|
||||
|
||||
inline void FSUTSReader::ScanFile(int verbose){
|
||||
if( feof(inFile) ) return;
|
||||
|
||||
blockPos.clear();
|
||||
fseek(inFile, 0L, SEEK_SET);
|
||||
dummy = fread(&header, 4, 1, inFile);
|
||||
filePos = ftell(inFile);
|
||||
blockPos.push_back(filePos);
|
||||
blockID = 0;
|
||||
|
||||
while( ReadNext(verbose) == 0 ){
|
||||
blockPos.push_back(filePos);
|
||||
blockID ++;
|
||||
if(verbose) printf("%u, %.2f%% %u/%lu\n\033[A\r", blockID, filePos*100./inFileSize, filePos, inFileSize);
|
||||
}
|
||||
|
||||
numHit = blockID;
|
||||
if(verbose) printf("\nScan complete: number of hit : %lu\n", numHit);
|
||||
|
||||
rewind(inFile);
|
||||
blockID = 0;
|
||||
filePos = 0;
|
||||
|
||||
}
|
23
ClassData.h
23
ClassData.h
|
@ -179,6 +179,10 @@ inline Data::~Data(){
|
|||
|
||||
inline void Data::AllocateDataSize(uShort dataSize){
|
||||
|
||||
if( dataSize < 1) {
|
||||
printf("dataSize cannot < 1, set dataSize = 1.\n");
|
||||
dataSize = 1;
|
||||
}
|
||||
printf("Data::%s, size: %u\n", __func__, dataSize);
|
||||
|
||||
this->dataSize = dataSize;
|
||||
|
@ -276,6 +280,15 @@ inline void Data::ClearData(){
|
|||
for( int ch = 0 ; ch < MaxNChannels; ch++){
|
||||
LoopIndex[ch] = 0;
|
||||
DataIndex[ch] = -1;
|
||||
NumEventsDecoded[ch] = 0;
|
||||
NumNonPileUpDecoded[ch] = 0;
|
||||
|
||||
TotNumNonPileUpEvents[ch] = 0 ;
|
||||
|
||||
calIndexes[ch][0] = -1;
|
||||
calIndexes[ch][1] = -1;
|
||||
|
||||
if( ch >= numInputCh) break;
|
||||
for( int j = 0; j < dataSize; j++){
|
||||
Timestamp[ch][j] = 0;
|
||||
fineTime[ch][j] = 0;
|
||||
|
@ -289,13 +302,6 @@ inline void Data::ClearData(){
|
|||
DigiWaveform4[ch][j].clear();
|
||||
}
|
||||
|
||||
NumEventsDecoded[ch] = 0;
|
||||
NumNonPileUpDecoded[ch] = 0;
|
||||
|
||||
TotNumNonPileUpEvents[ch] = 0 ;
|
||||
|
||||
calIndexes[ch][0] = -1;
|
||||
calIndexes[ch][1] = -1;
|
||||
}
|
||||
|
||||
tempWaveform1.clear();
|
||||
|
@ -304,6 +310,7 @@ inline void Data::ClearData(){
|
|||
tempDigiWaveform2.clear();
|
||||
tempDigiWaveform3.clear();
|
||||
tempDigiWaveform4.clear();
|
||||
|
||||
}
|
||||
|
||||
inline void Data::ClearBuffer(){
|
||||
|
@ -462,7 +469,7 @@ inline void Data::PrintChData(unsigned short ch, unsigned int maxRowDisplay) con
|
|||
|
||||
if( DataIndex[ch] < 0 ) printf("no data in ch-%d\n", ch);
|
||||
printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]);
|
||||
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? dataSize : DataIndex[ch]) ; ev++){
|
||||
for( int ev = 0; ev < (LoopIndex[ch] > 0 ? dataSize : DataIndex[ch]) ; ev++){
|
||||
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_QDC_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
|
||||
if( DPPType == DPPType::DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
|
||||
if( maxRowDisplay > 0 && (unsigned int) ev > maxRowDisplay ) break;
|
||||
|
|
14
Hit.h
14
Hit.h
|
@ -3,14 +3,15 @@
|
|||
|
||||
class Hit{
|
||||
public:
|
||||
int sn;
|
||||
unsigned short bd;
|
||||
unsigned short ch;
|
||||
unsigned short sn;
|
||||
uint8_t bd;
|
||||
uint8_t ch;
|
||||
unsigned short energy;
|
||||
unsigned short energy2;
|
||||
unsigned long long timestamp;
|
||||
unsigned short fineTime;
|
||||
|
||||
unsigned short traceLength;
|
||||
std::vector<short> trace;
|
||||
|
||||
Hit(){
|
||||
|
@ -25,6 +26,7 @@ public:
|
|||
energy2 = 0;
|
||||
timestamp = 0;
|
||||
fineTime = 0;
|
||||
traceLength = 0;
|
||||
trace.clear();
|
||||
}
|
||||
|
||||
|
@ -32,6 +34,12 @@ public:
|
|||
printf("(%5d, %2d) %6d %16llu, %6d, %5ld\n", sn, ch, energy, timestamp, fineTime, trace.size());
|
||||
}
|
||||
|
||||
void PrintTrace(){
|
||||
for( unsigned short i = 0; i < traceLength; i++){
|
||||
printf("%3u | %6d \n", i, trace[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Define operator< for sorting
|
||||
bool operator<(const Hit& other) const {
|
||||
return timestamp < other.timestamp;
|
||||
|
|
9
macro.h
9
macro.h
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <sys/time.h> /** struct timeval, select() */
|
||||
|
||||
inline unsigned int get_time(){
|
||||
inline unsigned int get_time_us(){
|
||||
unsigned int time_us;
|
||||
struct timeval t1;
|
||||
struct timezone tz;
|
||||
|
@ -31,6 +31,13 @@ inline unsigned int get_time(){
|
|||
return time_us;
|
||||
}
|
||||
|
||||
#include <chrono>
|
||||
inline unsigned long long getTime_ns(){
|
||||
std::chrono::high_resolution_clock::time_point currentTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::nanoseconds nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(currentTime.time_since_epoch());
|
||||
return nanoseconds.count();
|
||||
}
|
||||
|
||||
typedef unsigned short uShort;
|
||||
typedef unsigned int uInt;
|
||||
typedef unsigned long uLong;
|
||||
|
|
Loading…
Reference in New Issue
Block a user