added ConvertTimeOffset() and event window only open when sn == 0 and ch == 15
This commit is contained in:
parent
554247e046
commit
4eab257a01
|
@ -47,9 +47,13 @@ inline unsigned int getTime_us(){
|
||||||
|
|
||||||
//^================================================
|
//^================================================
|
||||||
///============ time offset
|
///============ time offset
|
||||||
std::vector<int64_t> timeOffsetList = {0, 0, 0, 0}; // in ps
|
// std::vector<uint64_t> timeOffsetList = {100863280000, 100562004000, 320120000, 0}; //in ps // run34
|
||||||
|
|
||||||
int bufferSize = 5000000;
|
std::vector<double> timeOffsetListSec = {0.0008849, 0.000359944, 0.000268992, 0.0}; // run 29
|
||||||
|
|
||||||
|
std::vector<uint64_t> timeOffsetList = {0, 0, 0, 0}; // in ps
|
||||||
|
|
||||||
|
int bufferSize = 10000000;
|
||||||
|
|
||||||
//^================================================
|
//^================================================
|
||||||
|
|
||||||
|
@ -82,6 +86,20 @@ std::vector<std::pair<int, std::string>> findDataFiles(const std::string& patter
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConvertTimeOffset(){
|
||||||
|
|
||||||
|
double tMax = 0;
|
||||||
|
for( size_t i = 0; i < timeOffsetListSec.size(); i++ ) {
|
||||||
|
if( tMax < timeOffsetListSec[i] ) tMax = timeOffsetListSec[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("############ Time Offset \n");
|
||||||
|
for( size_t i = 0; i < timeOffsetList.size(); i++ ) {
|
||||||
|
timeOffsetList[i] = uint64_t( ( tMax - timeOffsetListSec[i] ) * 1e12);
|
||||||
|
printf("%zu | %lu ps = %.3f msec\n", i, timeOffsetList[i],timeOffsetList[i] / 1e9);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Data> hitList_A ;
|
std::vector<Data> hitList_A ;
|
||||||
std::vector<Data> hitList_B ;
|
std::vector<Data> hitList_B ;
|
||||||
|
@ -89,6 +107,8 @@ BinReader * reader = nullptr;
|
||||||
|
|
||||||
int ReadBatch(int bufferSize){
|
int ReadBatch(int bufferSize){
|
||||||
|
|
||||||
|
printf("Reading Batch %d \n", bufferSize);
|
||||||
|
|
||||||
if( hitList_A.size() == 0 ){
|
if( hitList_A.size() == 0 ){
|
||||||
for( int i = 0 ; i < bufferSize; i++ ){
|
for( int i = 0 ; i < bufferSize; i++ ){
|
||||||
if( reader->ReadBlock() != 1 ){
|
if( reader->ReadBlock() != 1 ){
|
||||||
|
@ -124,7 +144,10 @@ int ReadBatch(int bufferSize){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if( hitList_B.size() == 0 ) return 1;
|
if( hitList_B.size() == 0 ) {
|
||||||
|
printf("hitList_B is empty. end of ReadBatch\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t t0_A = hitList_A.front().TimeStamp;
|
uint64_t t0_A = hitList_A.front().TimeStamp;
|
||||||
uint64_t t1_A = hitList_A.back().TimeStamp;
|
uint64_t t1_A = hitList_A.back().TimeStamp;
|
||||||
|
@ -226,6 +249,9 @@ int main(int argc, char **argv) {
|
||||||
printf(" Max multiplity = %d hits/event (hard coded)\n", MAX_MULTI);
|
printf(" Max multiplity = %d hits/event (hard coded)\n", MAX_MULTI);
|
||||||
printf(" Out file name = %s \n", outFileName.Data());
|
printf(" Out file name = %s \n", outFileName.Data());
|
||||||
printf(" Buffer Size = %d\n", bufferSize);
|
printf(" Buffer Size = %d\n", bufferSize);
|
||||||
|
|
||||||
|
ConvertTimeOffset();
|
||||||
|
|
||||||
printf("=============================== Number of input Files : %d \n", nFile);
|
printf("=============================== Number of input Files : %d \n", nFile);
|
||||||
for( int i = 0 ; i < nFile; i++ ){
|
for( int i = 0 ; i < nFile; i++ ){
|
||||||
printf(" %3d | %s\n", i, inFileName[i].second.c_str());
|
printf(" %3d | %s\n", i, inFileName[i].second.c_str());
|
||||||
|
@ -286,7 +312,8 @@ int main(int argc, char **argv) {
|
||||||
const uint16_t header = reader->data.Header;
|
const uint16_t header = reader->data.Header;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint64_t t0 = -1;
|
bool windowOpen = false;
|
||||||
|
uint64_t t0 = 0;
|
||||||
|
|
||||||
std::vector<Data> event;
|
std::vector<Data> event;
|
||||||
|
|
||||||
|
@ -305,8 +332,12 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = ReadBatch(bufferSize);
|
ret = ReadBatch(bufferSize);
|
||||||
if( tStart == 0 ) tStart = hitList_A[0].TimeStamp;
|
if( hitList_A.size() > 0 ) {
|
||||||
tEnd = hitList_A.back().TimeStamp;
|
unsigned long dtA = (hitList_A.back().TimeStamp - hitList_A.front().TimeStamp)/ 1000;
|
||||||
|
printf("hitList A | size %zu | timeRange %ld ns = %.3f sec\n", hitList_A.size(), dtA/100, dtA/1e12 );
|
||||||
|
if( tStart == 0 ) tStart = hitList_A[0].TimeStamp;
|
||||||
|
tEnd = hitList_A.back().TimeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
//build event from hitList_A;
|
//build event from hitList_A;
|
||||||
for( size_t i = 0; i < hitList_A.size(); i++){
|
for( size_t i = 0; i < hitList_A.size(); i++){
|
||||||
|
@ -324,12 +355,16 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
if( t0 == -1 ) {
|
// if( t0 == -1 ) {
|
||||||
|
if( !windowOpen && (hitList_A[i].BoardID == 0 && hitList_A[i].Channel == 15 ) ){ // for MUSICS, use the grid to open time window
|
||||||
t0 = hitList_A[i].TimeStamp;
|
t0 = hitList_A[i].TimeStamp;
|
||||||
|
windowOpen = true;
|
||||||
event.push_back(hitList_A[i]);
|
event.push_back(hitList_A[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !windowOpen ) continue;
|
||||||
|
|
||||||
if( hitList_A[i].TimeStamp - t0 < timeWindow ){
|
if( hitList_A[i].TimeStamp - t0 < timeWindow ){
|
||||||
event.push_back(hitList_A[i]);
|
event.push_back(hitList_A[i]);
|
||||||
}else{
|
}else{
|
||||||
|
@ -356,8 +391,10 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// start a new event
|
// start a new event
|
||||||
event.clear();
|
event.clear();
|
||||||
t0 = hitList_A[i].TimeStamp;
|
// t0 = hitList_A[i].TimeStamp;
|
||||||
event.push_back(hitList_A[i]);
|
// event.push_back(hitList_A[i]);
|
||||||
|
t0 = 0; // for MUSICS
|
||||||
|
windowOpen = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct Data{
|
||||||
printf(" Flag : 0x%08X\n", Flags);
|
printf(" Flag : 0x%08X\n", Flags);
|
||||||
if( (Header & 0x8 ) >= 1 ){ /// is waevform exist
|
if( (Header & 0x8 ) >= 1 ){ /// is waevform exist
|
||||||
printf(" Wave form code : %d , nSample : %d\n", WaveformCode, NSample);
|
printf(" Wave form code : %d , nSample : %d\n", WaveformCode, NSample);
|
||||||
for( int i = 0 ; i < NSample ; i++){
|
for( unsigned int i = 0 ; i < NSample ; i++){
|
||||||
printf("%4d | %d \n", i, Trace[i]);
|
printf("%4d | %d \n", i, Trace[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ int BinReader::ReadBlock(int skipTrace){
|
||||||
if( skipTrace == 0 ){
|
if( skipTrace == 0 ){
|
||||||
// if ( fread(data.Trace, sizeof(data.Trace), 1, inFile) != 1 ) endOfFile = IsEndOfFile();
|
// if ( fread(data.Trace, sizeof(data.Trace), 1, inFile) != 1 ) endOfFile = IsEndOfFile();
|
||||||
|
|
||||||
for( int i = 0; i < data.NSample; i++ ){
|
for( unsigned int i = 0; i < data.NSample; i++ ){
|
||||||
uint16_t haha;
|
uint16_t haha;
|
||||||
size_t dummy = fread(&haha, 2, 1, inFile);
|
size_t dummy = fread(&haha, 2, 1, inFile);
|
||||||
data.Trace.push_back(haha);
|
data.Trace.push_back(haha);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user