Change the output filename format, including tick2ns, fix evenbuilder bug
This commit is contained in:
parent
0d9690b5ed
commit
bdc02a5639
|
@ -13,8 +13,8 @@
|
||||||
#define BUFFERFILL 0.1 // only 0.5 * MAXNData will be filled in memeory each time
|
#define BUFFERFILL 0.1 // only 0.5 * MAXNData will be filled in memeory each time
|
||||||
|
|
||||||
template<typename T> void swap(T * a, T *b );
|
template<typename T> void swap(T * a, T *b );
|
||||||
int partition(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int start, int end);
|
int partition(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int t2ns[], int start, int end);
|
||||||
void quickSort(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int start, int end);
|
void quickSort(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int t2ns[], int start, int end);
|
||||||
|
|
||||||
//^#############################################################
|
//^#############################################################
|
||||||
//^#############################################################
|
//^#############################################################
|
||||||
|
@ -71,62 +71,47 @@ int main(int argc, char **argv) {
|
||||||
int type[nFile];
|
int type[nFile];
|
||||||
unsigned int fileSize[nFile];
|
unsigned int fileSize[nFile];
|
||||||
unsigned int numBlock[nFile];
|
unsigned int numBlock[nFile];
|
||||||
|
int tick2ns[nFile];
|
||||||
|
// file name format is expName_runID_SN_DPP_tick2ns_order.fsu
|
||||||
for( int i = 0; i < nFile; i++){
|
for( int i = 0; i < nFile; i++){
|
||||||
int snPos = inFileName[i].Index("_"); // first "_"
|
|
||||||
//snPos = inFileName[i].Index("_", snPos + 1);
|
FSUReader * reader = new FSUReader(inFileName[i].Data(), false);
|
||||||
int sn = atoi(&inFileName[i][snPos+5]);
|
|
||||||
|
|
||||||
int typePos = inFileName[i].Index("_", snPos+5);
|
|
||||||
TString typeStr = &inFileName[i][typePos+1];
|
|
||||||
typeStr.Resize(3);
|
|
||||||
|
|
||||||
//printf("sn %d %s \n", sn, typeStr.Data());
|
|
||||||
|
|
||||||
if( typeStr == "PHA" ) type[i] = DPPType::DPP_PHA_CODE;
|
|
||||||
if( typeStr == "PSD" ) type[i] = DPPType::DPP_PSD_CODE;
|
|
||||||
if( typeStr == "QDC" ) type[i] = DPPType::DPP_QDC_CODE;
|
|
||||||
|
|
||||||
int orderPos = inFileName[i].Index("_", typePos + 1);
|
|
||||||
int order = atoi(&inFileName[i][orderPos+1]);
|
|
||||||
ID[i] = sn + order * 100000;
|
|
||||||
|
|
||||||
FILE * temp = fopen(inFileName[i].Data(), "rb");
|
|
||||||
if( temp == NULL ) {
|
|
||||||
fileSize[i] = 0;
|
|
||||||
}else{
|
|
||||||
fseek(temp, 0, SEEK_END);
|
|
||||||
fileSize[i] = ftell(temp);
|
|
||||||
}
|
|
||||||
fclose(temp);
|
|
||||||
|
|
||||||
FSUReader * reader = new FSUReader(inFileName[i].Data(), typeStr == "QDC" ? 64 : 16, false);
|
|
||||||
reader->ScanNumBlock(false);
|
reader->ScanNumBlock(false);
|
||||||
numBlock[i] = reader->GetTotNumBlock();
|
numBlock[i] = reader->GetTotNumBlock();
|
||||||
fileSize[i] = reader->GetFileByteSize();
|
fileSize[i] = reader->GetFileByteSize();
|
||||||
delete reader;
|
tick2ns[i] = reader->GetTick2ns();
|
||||||
|
type[i] = reader->GetDPPType();
|
||||||
//printf("sn:%d, type:%d (%s), order:%d \n", sn, type[i], typeStr.Data(), order);
|
|
||||||
|
|
||||||
|
int sn = reader->GetSN();
|
||||||
|
int order = reader->GetFileOrder();
|
||||||
|
|
||||||
|
ID[i] = sn + order * 100000;
|
||||||
|
|
||||||
|
delete reader;
|
||||||
|
|
||||||
}
|
}
|
||||||
quickSort(&(ID[0]), &(type[0]), &(inFileName[0]), &(fileSize[0]), &(numBlock[0]), 0, nFile-1);
|
quickSort(&(ID[0]), &(type[0]), &(inFileName[0]), &(fileSize[0]), &(numBlock[0]), &(tick2ns[0]), 0, nFile-1);
|
||||||
unsigned int totBlock = 0;
|
unsigned int totBlock = 0;
|
||||||
for( int i = 0 ; i < nFile; i++){
|
for( int i = 0 ; i < nFile; i++){
|
||||||
printf("%d | %6d | %3d | %30s | %6u | %u Bytes = %.2f MB\n", i, ID[i], type[i], inFileName[i].Data(), numBlock[i], fileSize[i], fileSize[i]/1024./1024.);
|
printf("%d | %6d | %3d | %30s | %2d | %6u | %u Bytes = %.2f MB\n", i,
|
||||||
|
ID[i], type[i], inFileName[i].Data(), tick2ns[i], numBlock[i], fileSize[i], fileSize[i]/1024./1024.);
|
||||||
totBlock += numBlock[i];
|
totBlock += numBlock[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("----- total number of block : %u.\n", totBlock);
|
printf("----- total number of block : %u.\n", totBlock);
|
||||||
|
|
||||||
//*======================================= Sort files in to group
|
//*======================================= Sort files into groups
|
||||||
std::vector<int> snList; // store the serial number of the group
|
std::vector<int> snList; // store the serial number of the group
|
||||||
std::vector<int> typeList; // store the DPP type of the group
|
std::vector<int> typeList; // store the DPP type of the group
|
||||||
std::vector<std::vector<TString>> fileList; // store the file list of the group
|
std::vector<std::vector<TString>> fileList; // store the file list of the group
|
||||||
|
std::vector<int> t2nsList;
|
||||||
for( int i = 0; i < nFile; i++){
|
for( int i = 0; i < nFile; i++){
|
||||||
if( ID[i] / 100000 == 0 ) {
|
if( ID[i] / 100000 == 0 ) {
|
||||||
std::vector<TString> temp = {inFileName[i]};
|
std::vector<TString> temp = {inFileName[i]};
|
||||||
fileList.push_back(temp);
|
fileList.push_back(temp);
|
||||||
typeList.push_back(type[i]);
|
typeList.push_back(type[i]);
|
||||||
snList.push_back(ID[i]%100000);
|
snList.push_back(ID[i]%100000);
|
||||||
|
t2nsList.push_back(tick2ns[i]);
|
||||||
}else{
|
}else{
|
||||||
for( int p = 0; p < (int) snList.size(); p++){
|
for( int p = 0; p < (int) snList.size(); p++){
|
||||||
if( (ID[i] % 1000) == snList[p] ) {
|
if( (ID[i] % 1000) == snList[p] ) {
|
||||||
|
@ -160,6 +145,7 @@ int main(int argc, char **argv) {
|
||||||
if( typeList[i] == DPPType::DPP_QDC_CODE ) data[i] = new Data(64);
|
if( typeList[i] == DPPType::DPP_QDC_CODE ) data[i] = new Data(64);
|
||||||
data[i]->DPPType = typeList[i];
|
data[i]->DPPType = typeList[i];
|
||||||
data[i]->boardSN = snList[i];
|
data[i]->boardSN = snList[i];
|
||||||
|
data[i]->tick2ns = t2nsList[i];
|
||||||
}else{
|
}else{
|
||||||
inFileIndex[i] = -1;
|
inFileIndex[i] = -1;
|
||||||
data[i] = nullptr;
|
data[i] = nullptr;
|
||||||
|
@ -239,16 +225,24 @@ int main(int argc, char **argv) {
|
||||||
// go to next file in same digitizer
|
// go to next file in same digitizer
|
||||||
if( feof(inFile[i])){
|
if( feof(inFile[i])){
|
||||||
fclose(inFile[i]);
|
fclose(inFile[i]);
|
||||||
inFile[i] = fopen(fileList[i][inFileIndex[i]+1], "r");
|
if( inFileIndex[i] + 1 < (int) fileList[i].size() ){
|
||||||
if( inFile[i] ){
|
inFile[i] = fopen(fileList[i][inFileIndex[i]+1], "r");
|
||||||
inFileIndex[i]++;
|
inFileIndex[i]++;
|
||||||
printf("---- go to next file for digi-%d\n", snList[i]);
|
printf("---- go to next file for digi-%d\n", snList[i]);
|
||||||
}else{
|
}else{
|
||||||
|
inFile[i] = nullptr;
|
||||||
inFileIndex[i] = -1;
|
inFileIndex[i] = -1;
|
||||||
printf("---- no more file for digi-%d.\n", snList[i]);
|
printf("---- no more file for digi-%d.\n", snList[i]);
|
||||||
fillFlag = false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// if( inFile[i] ){
|
||||||
|
// inFileIndex[i]++;
|
||||||
|
// printf("---- go to next file for digi-%d\n", snList[i]);
|
||||||
|
// }else{
|
||||||
|
// inFileIndex[i] = -1;
|
||||||
|
// printf("---- no more file for digi-%d.\n", snList[i]);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -290,6 +284,7 @@ int main(int argc, char **argv) {
|
||||||
if( iData < 0 ) continue;
|
if( iData < 0 ) continue;
|
||||||
|
|
||||||
if( (iLoop*MaxNData + iData) - (lastLoopIndex[i][ch]*MaxNData + lastDataIndex[i][ch]) > MaxNData * BUFFERFILL ) {
|
if( (iLoop*MaxNData + iData) - (lastLoopIndex[i][ch]*MaxNData + lastDataIndex[i][ch]) > MaxNData * BUFFERFILL ) {
|
||||||
|
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 * BUFFERFILL);
|
||||||
fillFlag = false;
|
fillFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +295,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if( debug ){
|
if( debug ){
|
||||||
printf(" %3d | agg : %d | %u | %s\n", snList[i], aggCount[i], data[i]->aggTime, fillFlag ? "cont. fill" : "break." );
|
printf("-------------------------> %3d | agg : %d | %u \n", snList[i], aggCount[i], data[i]->aggTime);
|
||||||
//data[i]->PrintStat();
|
//data[i]->PrintStat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,6 +307,7 @@ int main(int argc, char **argv) {
|
||||||
lastDataIndex[i][ch] = data[i]->DataIndex[ch];
|
lastDataIndex[i][ch] = data[i]->DataIndex[ch];
|
||||||
lastLoopIndex[i][ch] = data[i]->LoopIndex[ch];
|
lastLoopIndex[i][ch] = data[i]->LoopIndex[ch];
|
||||||
}
|
}
|
||||||
|
//data[i]->PrintAllData();
|
||||||
}
|
}
|
||||||
|
|
||||||
mb->BuildEvents(0, !traceOn, debug);
|
mb->BuildEvents(0, !traceOn, debug);
|
||||||
|
@ -420,7 +416,7 @@ template<typename T> void swap(T * a, T *b ){
|
||||||
*a = temp;
|
*a = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int partition(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int start, int end){
|
int partition(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int tick2ns[], int start, int end){
|
||||||
int pivot = arr[start];
|
int pivot = arr[start];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = start + 1; i <= end; i++) {
|
for (int i = start + 1; i <= end; i++) {
|
||||||
|
@ -433,6 +429,7 @@ int partition(int arr[], int kaka[], TString file[], unsigned int fileSize[], un
|
||||||
swap(&kaka[pivotIndex], &kaka[start]);
|
swap(&kaka[pivotIndex], &kaka[start]);
|
||||||
swap(&fileSize[pivotIndex], &fileSize[start]);
|
swap(&fileSize[pivotIndex], &fileSize[start]);
|
||||||
swap(&numBlock[pivotIndex], &numBlock[start]);
|
swap(&numBlock[pivotIndex], &numBlock[start]);
|
||||||
|
swap(&tick2ns[pivotIndex], &tick2ns[start]);
|
||||||
|
|
||||||
/// Sorting left and right parts of the pivot element
|
/// Sorting left and right parts of the pivot element
|
||||||
int i = start, j = end;
|
int i = start, j = end;
|
||||||
|
@ -447,18 +444,19 @@ int partition(int arr[], int kaka[], TString file[], unsigned int fileSize[], un
|
||||||
swap(&kaka[ip], &kaka[jm]);
|
swap(&kaka[ip], &kaka[jm]);
|
||||||
swap(&fileSize[ip], &fileSize[jm]);
|
swap(&fileSize[ip], &fileSize[jm]);
|
||||||
swap(&numBlock[ip], &numBlock[jm]);
|
swap(&numBlock[ip], &numBlock[jm]);
|
||||||
|
swap(&tick2ns[ip], &tick2ns[jm]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pivotIndex;
|
return pivotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void quickSort(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int start, int end){
|
void quickSort(int arr[], int kaka[], TString file[], unsigned int fileSize[], unsigned int numBlock[], int tick2ns[], int start, int end){
|
||||||
/// base case
|
/// base case
|
||||||
if (start >= end) return;
|
if (start >= end) return;
|
||||||
/// partitioning the array
|
/// partitioning the array
|
||||||
int p = partition(arr, kaka, file, fileSize, numBlock, start, end);
|
int p = partition(arr, kaka, file, fileSize, numBlock, tick2ns, start, end);
|
||||||
/// Sorting the left part
|
/// Sorting the left part
|
||||||
quickSort(arr, kaka, file, fileSize, numBlock, start, p - 1);
|
quickSort(arr, kaka, file, fileSize, numBlock, tick2ns, start, p - 1);
|
||||||
/// Sorting the right part
|
/// Sorting the right part
|
||||||
quickSort(arr, kaka, file, fileSize, numBlock, p + 1, end);
|
quickSort(arr, kaka, file, fileSize, numBlock, tick2ns, p + 1, end);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class FSUReader{
|
class FSUReader{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FSUReader(std::string fileName, unsigned short numCh, bool verbose = true);
|
FSUReader(std::string fileName, bool verbose = true);
|
||||||
~FSUReader();
|
~FSUReader();
|
||||||
|
|
||||||
void ScanNumBlock(bool verbose = true);
|
void ScanNumBlock(bool verbose = true);
|
||||||
|
@ -14,8 +14,11 @@ class FSUReader{
|
||||||
|
|
||||||
Data * GetData() const{return data;}
|
Data * GetData() const{return data;}
|
||||||
|
|
||||||
int GetDPPType() const{return DPPType;}
|
int GetDPPType() const{return DPPType;}
|
||||||
|
int GetSN() const{return sn;}
|
||||||
|
int GetTick2ns() const{return tick2ns;}
|
||||||
|
int GetNumCh() const{return numCh;}
|
||||||
|
int GetFileOrder() const{return order;}
|
||||||
unsigned long GetFileByteSize() const {return inFileSize;}
|
unsigned long GetFileByteSize() const {return inFileSize;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -29,8 +32,12 @@ class FSUReader{
|
||||||
unsigned int blockID;
|
unsigned int blockID;
|
||||||
|
|
||||||
// for dual block
|
// for dual block
|
||||||
|
int sn;
|
||||||
int DPPType;
|
int DPPType;
|
||||||
|
int tick2ns;
|
||||||
|
int order;
|
||||||
int chMask;
|
int chMask;
|
||||||
|
int numCh;
|
||||||
|
|
||||||
std::vector<unsigned int> blockPos;
|
std::vector<unsigned int> blockPos;
|
||||||
|
|
||||||
|
@ -40,7 +47,7 @@ class FSUReader{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FSUReader::FSUReader(std::string fileName, unsigned short numCh, bool verbose){
|
inline FSUReader::FSUReader(std::string fileName, bool verbose){
|
||||||
|
|
||||||
inFile = fopen(fileName.c_str(), "r");
|
inFile = fopen(fileName.c_str(), "r");
|
||||||
|
|
||||||
|
@ -55,17 +62,10 @@ inline FSUReader::FSUReader(std::string fileName, unsigned short numCh, bool ver
|
||||||
fseek(inFile, 0L, SEEK_SET);
|
fseek(inFile, 0L, SEEK_SET);
|
||||||
filePos = 0;
|
filePos = 0;
|
||||||
|
|
||||||
data = new Data(numCh);
|
|
||||||
|
|
||||||
totNumBlock = 0;
|
totNumBlock = 0;
|
||||||
blockID = 0;
|
blockID = 0;
|
||||||
blockPos.clear();
|
blockPos.clear();
|
||||||
|
|
||||||
//Get DPPType from file name;
|
|
||||||
DPPType = -1;
|
|
||||||
if( fileName.find("PHA") != std::string::npos ) DPPType = DPPType::DPP_PHA_CODE;
|
|
||||||
if( fileName.find("PSD") != std::string::npos ) DPPType = DPPType::DPP_PSD_CODE;
|
|
||||||
if( fileName.find("QDC") != std::string::npos ) DPPType = DPPType::DPP_QDC_CODE;
|
|
||||||
|
|
||||||
//check is the file is *.fsu or *.fsu.X
|
//check is the file is *.fsu or *.fsu.X
|
||||||
size_t found = fileName.find_last_of('.');
|
size_t found = fileName.find_last_of('.');
|
||||||
|
@ -78,6 +78,29 @@ inline FSUReader::FSUReader(std::string fileName, unsigned short numCh, bool ver
|
||||||
if(verbose) printf("It is a splitted dual block data *.fsu.X format, dual channel mask : %d \n", chMask);
|
if(verbose) printf("It is a splitted dual block data *.fsu.X format, dual channel mask : %d \n", chMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string fileNameNoExt = fileName.substr(0, found);
|
||||||
|
|
||||||
|
// Split the string by underscores
|
||||||
|
std::istringstream iss(fileNameNoExt);
|
||||||
|
std::vector<std::string> tokens;
|
||||||
|
std::string token;
|
||||||
|
|
||||||
|
while (std::getline(iss, token, '_')) { tokens.push_back(token); }
|
||||||
|
sn = atoi(tokens[2].c_str());
|
||||||
|
tick2ns = atoi(tokens[4].c_str());
|
||||||
|
order = atoi(tokens[5].c_str());
|
||||||
|
|
||||||
|
DPPType = -1;
|
||||||
|
if( fileName.find("PHA") != std::string::npos ) DPPType = DPPType::DPP_PHA_CODE;
|
||||||
|
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;
|
||||||
|
|
||||||
|
data = new Data(numCh);
|
||||||
|
data->tick2ns = tick2ns;
|
||||||
|
data->boardSN = sn;
|
||||||
|
data->DPPType = DPPType;
|
||||||
//ScanNumBlock();
|
//ScanNumBlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
14
ClassData.h
14
ClassData.h
|
@ -29,9 +29,9 @@ class Data{
|
||||||
public:
|
public:
|
||||||
char *buffer; /// readout buffer
|
char *buffer; /// readout buffer
|
||||||
int DPPType;
|
int DPPType;
|
||||||
std::string DPPTypeStr;
|
std::string DPPTypeStr; /// only for saving fiel name
|
||||||
unsigned short boardSN;
|
unsigned short boardSN;
|
||||||
float tick2ns; /// only use in TriggerRate calculation
|
float tick2ns; /// use in convert the timestamp to ns, and use in TriggerRate calculation
|
||||||
|
|
||||||
unsigned int nByte; /// number of byte from read buffer
|
unsigned int nByte; /// number of byte from read buffer
|
||||||
uint32_t AllocatedSize;
|
uint32_t AllocatedSize;
|
||||||
|
@ -230,6 +230,7 @@ inline bool Data::OpenSaveFile(std::string fileNamePrefix){
|
||||||
oss << outFilePrefix << "_"
|
oss << outFilePrefix << "_"
|
||||||
<< std::setfill('0') << std::setw(3) << boardSN << "_"
|
<< std::setfill('0') << std::setw(3) << boardSN << "_"
|
||||||
<< DPPTypeStr << "_"
|
<< DPPTypeStr << "_"
|
||||||
|
<< std::fixed << std::setprecision(0) << tick2ns << "_"
|
||||||
<< std::setfill('0') << std::setw(3) << outFileIndex << ".fsu";
|
<< std::setfill('0') << std::setw(3) << outFileIndex << ".fsu";
|
||||||
std::string saveFileName = oss.str();
|
std::string saveFileName = oss.str();
|
||||||
|
|
||||||
|
@ -271,6 +272,7 @@ inline void Data::SaveData(){
|
||||||
oss << outFilePrefix << "_"
|
oss << outFilePrefix << "_"
|
||||||
<< std::setfill('0') << std::setw(3) << boardSN << "_"
|
<< std::setfill('0') << std::setw(3) << boardSN << "_"
|
||||||
<< DPPTypeStr << "_"
|
<< DPPTypeStr << "_"
|
||||||
|
<< std::fixed << std::setprecision(0) << tick2ns << "_"
|
||||||
<< std::setfill('0') << std::setw(3) << outFileIndex << ".fsu";
|
<< std::setfill('0') << std::setw(3) << outFileIndex << ".fsu";
|
||||||
std::string saveFileName = oss.str();
|
std::string saveFileName = oss.str();
|
||||||
|
|
||||||
|
@ -350,7 +352,7 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const
|
||||||
if( DataIndex[ch] < 0 ) continue;
|
if( DataIndex[ch] < 0 ) continue;
|
||||||
printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]);
|
printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]);
|
||||||
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){
|
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){
|
||||||
if( DPPType == DPPType::DPP_PHA_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[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( 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;
|
if( maxRowDisplay > 0 && (unsigned int) ev > maxRowDisplay ) break;
|
||||||
}
|
}
|
||||||
|
@ -761,7 +763,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
|
||||||
}
|
}
|
||||||
|
|
||||||
Energy[channel][DataIndex[channel]] = energy;
|
Energy[channel][DataIndex[channel]] = energy;
|
||||||
Timestamp[channel][DataIndex[channel]] = timeStamp;
|
Timestamp[channel][DataIndex[channel]] = timeStamp * tick2ns;
|
||||||
if(extra2Option == 2 ) fineTime[channel][DataIndex[channel]] = (extra2 & 0x03FF );
|
if(extra2Option == 2 ) fineTime[channel][DataIndex[channel]] = (extra2 & 0x03FF );
|
||||||
PileUp[channel][DataIndex[channel]] = pileUp;
|
PileUp[channel][DataIndex[channel]] = pileUp;
|
||||||
NumEventsDecoded[channel] ++;
|
NumEventsDecoded[channel] ++;
|
||||||
|
@ -964,7 +966,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
|
||||||
|
|
||||||
Energy2[channel][DataIndex[channel]] = Qshort;
|
Energy2[channel][DataIndex[channel]] = Qshort;
|
||||||
Energy[channel][DataIndex[channel]] = Qlong;
|
Energy[channel][DataIndex[channel]] = Qlong;
|
||||||
Timestamp[channel][DataIndex[channel]] = timeStamp;
|
Timestamp[channel][DataIndex[channel]] = timeStamp * tick2ns;
|
||||||
if( extraOption == 2 ) fineTime[channel][DataIndex[channel]] = extra & 0x3FF;
|
if( extraOption == 2 ) fineTime[channel][DataIndex[channel]] = extra & 0x3FF;
|
||||||
|
|
||||||
NumEventsDecoded[channel] ++;
|
NumEventsDecoded[channel] ++;
|
||||||
|
@ -1119,7 +1121,7 @@ inline int Data::DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fas
|
||||||
}
|
}
|
||||||
|
|
||||||
Energy[channel][DataIndex[channel]] = energy;
|
Energy[channel][DataIndex[channel]] = energy;
|
||||||
Timestamp[channel][DataIndex[channel]] = timeStamp;
|
Timestamp[channel][DataIndex[channel]] = timeStamp * tick2ns;
|
||||||
|
|
||||||
NumEventsDecoded[channel] ++;
|
NumEventsDecoded[channel] ++;
|
||||||
if( !pileup && !OverRange){
|
if( !pileup && !OverRange){
|
||||||
|
|
|
@ -11,6 +11,11 @@ MultiBuilder::MultiBuilder(Data ** multiData, std::vector<int> type, std::vector
|
||||||
leftOverTime = 100;
|
leftOverTime = 100;
|
||||||
breakTime = -1;
|
breakTime = -1;
|
||||||
ClearEvents();
|
ClearEvents();
|
||||||
|
|
||||||
|
// for( int i = 0; i < nData; i++){
|
||||||
|
// printf("sn: %d, numCh : %d \n", snList[i], data[i]->GetNChannel());
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiBuilder::MultiBuilder(Data * singleData, int type, int sn): nData(1){
|
MultiBuilder::MultiBuilder(Data * singleData, int type, int sn): nData(1){
|
||||||
|
@ -220,10 +225,11 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
// printf("##### %d/%d | ", k, nData);
|
// printf("##### %d/%d | ", k, nData);
|
||||||
// data[k]->PrintAllData(true, 10);
|
// data[k]->PrintAllData(true, 10);
|
||||||
|
|
||||||
const int numCh = data[k]->GetNChannel();
|
const int numCh = data[bd]->GetNChannel();
|
||||||
|
|
||||||
for( int i = 0; i < numCh; i++){
|
for( int i = 0; i < numCh; i++){
|
||||||
int ch = (i + earlistCh ) % numCh;
|
int ch = (i + earlistCh ) % numCh;
|
||||||
|
// printf("ch : %d | exhaused ? %s \n", ch, chExhaused[bd][ch] ? "Yes" : "No");
|
||||||
if( chExhaused[bd][ch] ) continue;
|
if( chExhaused[bd][ch] ) continue;
|
||||||
if( loopIndex[bd][ch] * MaxNData + nextIndex[bd][ch] > data[bd]->LoopIndex[ch] * MaxNData + data[bd]->DataIndex[ch]) {
|
if( loopIndex[bd][ch] * MaxNData + nextIndex[bd][ch] > data[bd]->LoopIndex[ch] * MaxNData + data[bd]->DataIndex[ch]) {
|
||||||
nExhaushedCh ++;
|
nExhaushedCh ++;
|
||||||
|
@ -234,7 +240,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
do {
|
do {
|
||||||
|
|
||||||
unsigned long long time = data[bd]->Timestamp[ch][nextIndex[bd][ch]];
|
unsigned long long time = data[bd]->Timestamp[ch][nextIndex[bd][ch]];
|
||||||
|
// printf("Check timestamp : %llu | earlistTime : %llu | timeWindow : %u \n", time, earlistTime, timeWindow);
|
||||||
if( time >= earlistTime && (time - earlistTime <= timeWindow) ){
|
if( time >= earlistTime && (time - earlistTime <= timeWindow) ){
|
||||||
em.sn = snList[bd];
|
em.sn = snList[bd];
|
||||||
em.bd = bd;
|
em.bd = bd;
|
||||||
|
@ -269,7 +275,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
}
|
}
|
||||||
|
|
||||||
///Find the next earlist
|
///Find the next earlist
|
||||||
FindEarlistTimeAndCh(verbose);
|
FindEarlistTimeAndCh(false);
|
||||||
|
|
||||||
if( verbose ){
|
if( verbose ){
|
||||||
printf(">>>>>>>>>>>>>>>>> Event ID : %ld, total built: %ld, multiplicity : %ld\n", eventIndex, totalEventBuilt, events[eventIndex].size());
|
printf(">>>>>>>>>>>>>>>>> Event ID : %ld, total built: %ld, multiplicity : %ld\n", eventIndex, totalEventBuilt, events[eventIndex].size());
|
||||||
|
|
|
@ -73,6 +73,7 @@ private:
|
||||||
std::vector<int> typeList;
|
std::vector<int> typeList;
|
||||||
std::vector<int> snList;
|
std::vector<int> snList;
|
||||||
std::vector<int> idList;
|
std::vector<int> idList;
|
||||||
|
std::vector<int> tick2ns;
|
||||||
const unsigned short nData;
|
const unsigned short nData;
|
||||||
Data ** data; // assume all data has MaxNChannel (16)
|
Data ** data; // assume all data has MaxNChannel (16)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user