this is the noheader data, and all channels and board are combined.

This commit is contained in:
Ryan@Home 2024-09-25 17:12:14 -04:00
parent 5ae7c256f2
commit d5f5ee232d
2 changed files with 33 additions and 21 deletions

View File

@ -16,7 +16,7 @@ inline unsigned int getTime_us(){
#include "TMacro.h"
#define MAX_TRACE_LENGTH 2000
#define MAX_MULTI 100
#define MAX_MULTI 1000
#define NMINARG 5
#define debug 0 // for > 1 number of hit to debug
@ -88,6 +88,15 @@ int extractDigiSN(const std::string& str, int n = 1) {
}
}
void SetTimeOffset(BinReader * reader, std::vector<std::pair<int, int64_t>>& timeOffsetList){
int bd = reader->data.BoardID;
for( size_t i = 0 ; i < timeOffsetList.size(); i++){
if( bd == timeOffsetList[i].first) reader->data.TimeStamp += timeOffsetList[i].second;
}
}
//^#############################################################
//^#############################################################
int main(int argc, char **argv) {
@ -107,9 +116,6 @@ int main(int argc, char **argv) {
printf("\n");
printf(" Time offset file format :\n");
printf("[board SN] [time offset(int64_t)]\n");
printf("\n");
printf(" file name should be this format CH0@V1725_324_Data_run_196.bin\n");
printf(" so that the serial number is between the 1st and 2nd underscore\n");
printf("\n\n");
return 1;
@ -170,13 +176,13 @@ int main(int argc, char **argv) {
BinReader reader[nFile];
for(int i = 0; i < nFile; i++ ){
printf(">>>>>>>> %2d | %s \n", i, inFileName[i].Data());
reader[i].OpenFile(inFileName[i]);
if( timeOffsetList.size() > 1 ){
for (size_t i = 1 ; timeOffsetList.size(); i++) {
int sn = extractDigiSN(inFileName[i].Data(), timeOffsetList[0].first);
if( sn == timeOffsetList[i].first ) reader[i].SetTimeOffset(timeOffsetList[i].second);
}
}
reader[i].OpenFile(inFileName[i], 0, true);
// if( timeOffsetList.size() > 1 ){
// for (size_t i = 1 ; timeOffsetList.size(); i++) {
// int sn = extractDigiSN(inFileName[i].Data(), timeOffsetList[0].first);
// if( sn == timeOffsetList[i].first ) reader[i].SetTimeOffset(timeOffsetList[i].second);
// }
// }
reader[i].ScanNumHit();
totalHitCount += reader[i].GetNumHit();
}
@ -190,9 +196,9 @@ int main(int argc, char **argv) {
unsigned short sn[MAX_MULTI] = {0};
unsigned short ch[MAX_MULTI] = {0};
unsigned short e[MAX_MULTI] = {0};
unsigned short e2[MAX_MULTI] = {0};
// unsigned short e2[MAX_MULTI] = {0};
unsigned long long e_t[MAX_MULTI] = {0};
unsigned short e_f[MAX_MULTI] = {0};
// unsigned short e_f[MAX_MULTI] = {0};
unsigned short traceLength[MAX_MULTI];
short trace[MAX_MULTI][MAX_TRACE_LENGTH];
@ -203,9 +209,9 @@ int main(int argc, char **argv) {
tree->Branch("sn", sn, "sn[multi]/s");
tree->Branch("ch", ch, "ch[multi]/s");
tree->Branch("e", e, "e[multi]/s");
tree->Branch("e2", e2, "e2[multi]/s");
// tree->Branch("e2", e2, "e2[multi]/s");
tree->Branch("e_t", e_t, "e_t[multi]/l");
tree->Branch("e_f", e_f, "e_f[multi]/s");
// tree->Branch("e_f", e_f, "e_f[multi]/s");
tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
if( traceOn ) {
@ -232,6 +238,7 @@ int main(int argc, char **argv) {
long long ID[nFile]; // filled hit ID
for( int i = 0 ; i < nFile ; i++ ) {
reader[i].ReadBlock();
SetTimeOffset(&reader[i], timeOffsetList);
ID[i] = -1;
}
@ -263,6 +270,7 @@ int main(int argc, char **argv) {
if( ID[i] + 1 >= reader[i].GetNumHit() ) continue;
if( timeWindow >= 0 ){
int ret = 0;
do{
if( (long int)( reader[i].data.TimeStamp - t0) <= timeWindow ){
events.push_back(reader[i].data);
@ -270,11 +278,14 @@ int main(int argc, char **argv) {
}else{
break;
}
}while( reader[i].ReadBlock() == 1 );
ret = reader[i].ReadBlock();
SetTimeOffset(&reader[i], timeOffsetList);
}while( ret == 1 );
}else{
events.push_back(reader[g0].data);
ID[g0] ++;
reader[g0].ReadBlock();
SetTimeOffset(&reader[g0], timeOffsetList);
break;
}
@ -305,9 +316,9 @@ int main(int argc, char **argv) {
sn[p] = events[p].BoardID;
ch[p] = events[p].Channel;
e[p] = events[p].Energy;
e2[p] = events[p].Energy_short;
// e2[p] = events[p].Energy_short;
e_t[p] = events[p].TimeStamp / 1000;
e_f[p] = events[p].TimeStamp % 1000;
// e_f[p] = events[p].TimeStamp % 1000;
traceLength[p] = events[p].NSample;
if( traceOn ){

View File

@ -1,3 +1,4 @@
123 456
86 49
19267 0
0 0
1 0
2 0
3 0