this is the noheader data, and all channels and board are combined.
This commit is contained in:
parent
5ae7c256f2
commit
d5f5ee232d
47
Bin2Root.cpp
47
Bin2Root.cpp
|
@ -16,7 +16,7 @@ inline unsigned int getTime_us(){
|
||||||
#include "TMacro.h"
|
#include "TMacro.h"
|
||||||
|
|
||||||
#define MAX_TRACE_LENGTH 2000
|
#define MAX_TRACE_LENGTH 2000
|
||||||
#define MAX_MULTI 100
|
#define MAX_MULTI 1000
|
||||||
#define NMINARG 5
|
#define NMINARG 5
|
||||||
#define debug 0 // for > 1 number of hit to debug
|
#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) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -107,9 +116,6 @@ int main(int argc, char **argv) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" Time offset file format :\n");
|
printf(" Time offset file format :\n");
|
||||||
printf("[board SN] [time offset(int64_t)]\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");
|
printf("\n\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -170,13 +176,13 @@ int main(int argc, char **argv) {
|
||||||
BinReader reader[nFile];
|
BinReader reader[nFile];
|
||||||
for(int i = 0; i < nFile; i++ ){
|
for(int i = 0; i < nFile; i++ ){
|
||||||
printf(">>>>>>>> %2d | %s \n", i, inFileName[i].Data());
|
printf(">>>>>>>> %2d | %s \n", i, inFileName[i].Data());
|
||||||
reader[i].OpenFile(inFileName[i]);
|
reader[i].OpenFile(inFileName[i], 0, true);
|
||||||
if( timeOffsetList.size() > 1 ){
|
// if( timeOffsetList.size() > 1 ){
|
||||||
for (size_t i = 1 ; timeOffsetList.size(); i++) {
|
// for (size_t i = 1 ; timeOffsetList.size(); i++) {
|
||||||
int sn = extractDigiSN(inFileName[i].Data(), timeOffsetList[0].first);
|
// int sn = extractDigiSN(inFileName[i].Data(), timeOffsetList[0].first);
|
||||||
if( sn == timeOffsetList[i].first ) reader[i].SetTimeOffset(timeOffsetList[i].second);
|
// if( sn == timeOffsetList[i].first ) reader[i].SetTimeOffset(timeOffsetList[i].second);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
reader[i].ScanNumHit();
|
reader[i].ScanNumHit();
|
||||||
totalHitCount += reader[i].GetNumHit();
|
totalHitCount += reader[i].GetNumHit();
|
||||||
}
|
}
|
||||||
|
@ -190,9 +196,9 @@ int main(int argc, char **argv) {
|
||||||
unsigned short sn[MAX_MULTI] = {0};
|
unsigned short sn[MAX_MULTI] = {0};
|
||||||
unsigned short ch[MAX_MULTI] = {0};
|
unsigned short ch[MAX_MULTI] = {0};
|
||||||
unsigned short e[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 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];
|
unsigned short traceLength[MAX_MULTI];
|
||||||
short trace[MAX_MULTI][MAX_TRACE_LENGTH];
|
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("sn", sn, "sn[multi]/s");
|
||||||
tree->Branch("ch", ch, "ch[multi]/s");
|
tree->Branch("ch", ch, "ch[multi]/s");
|
||||||
tree->Branch("e", e, "e[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_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");
|
tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
|
||||||
|
|
||||||
if( traceOn ) {
|
if( traceOn ) {
|
||||||
|
@ -232,6 +238,7 @@ int main(int argc, char **argv) {
|
||||||
long long ID[nFile]; // filled hit ID
|
long long ID[nFile]; // filled hit ID
|
||||||
for( int i = 0 ; i < nFile ; i++ ) {
|
for( int i = 0 ; i < nFile ; i++ ) {
|
||||||
reader[i].ReadBlock();
|
reader[i].ReadBlock();
|
||||||
|
SetTimeOffset(&reader[i], timeOffsetList);
|
||||||
ID[i] = -1;
|
ID[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +270,7 @@ int main(int argc, char **argv) {
|
||||||
if( ID[i] + 1 >= reader[i].GetNumHit() ) continue;
|
if( ID[i] + 1 >= reader[i].GetNumHit() ) continue;
|
||||||
|
|
||||||
if( timeWindow >= 0 ){
|
if( timeWindow >= 0 ){
|
||||||
|
int ret = 0;
|
||||||
do{
|
do{
|
||||||
if( (long int)( reader[i].data.TimeStamp - t0) <= timeWindow ){
|
if( (long int)( reader[i].data.TimeStamp - t0) <= timeWindow ){
|
||||||
events.push_back(reader[i].data);
|
events.push_back(reader[i].data);
|
||||||
|
@ -270,11 +278,14 @@ int main(int argc, char **argv) {
|
||||||
}else{
|
}else{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while( reader[i].ReadBlock() == 1 );
|
ret = reader[i].ReadBlock();
|
||||||
|
SetTimeOffset(&reader[i], timeOffsetList);
|
||||||
|
}while( ret == 1 );
|
||||||
}else{
|
}else{
|
||||||
events.push_back(reader[g0].data);
|
events.push_back(reader[g0].data);
|
||||||
ID[g0] ++;
|
ID[g0] ++;
|
||||||
reader[g0].ReadBlock();
|
reader[g0].ReadBlock();
|
||||||
|
SetTimeOffset(&reader[g0], timeOffsetList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,9 +316,9 @@ int main(int argc, char **argv) {
|
||||||
sn[p] = events[p].BoardID;
|
sn[p] = events[p].BoardID;
|
||||||
ch[p] = events[p].Channel;
|
ch[p] = events[p].Channel;
|
||||||
e[p] = events[p].Energy;
|
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_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;
|
traceLength[p] = events[p].NSample;
|
||||||
if( traceOn ){
|
if( traceOn ){
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
123 456
|
0 0
|
||||||
86 49
|
1 0
|
||||||
19267 0
|
2 0
|
||||||
|
3 0
|
Loading…
Reference in New Issue
Block a user