diff --git a/Scripts_20210119/hit_analyse_v2 b/Scripts_20210119/hit_analyse_v2 index 3da64f0..aad5564 100755 Binary files a/Scripts_20210119/hit_analyse_v2 and b/Scripts_20210119/hit_analyse_v2 differ diff --git a/Scripts_20210119/hit_analyse_v2.c b/Scripts_20210119/hit_analyse_v2.c index 5af3e17..376dd84 100644 --- a/Scripts_20210119/hit_analyse_v2.c +++ b/Scripts_20210119/hit_analyse_v2.c @@ -132,13 +132,21 @@ int analyse(int argc, char **argv) else if (boardnumber==3) {BPMbeamrecon_3=BPMbeamrecon_Zeroed;} } - for (int j = 0;j<320;j++){ + // cout << "fill hist " << int(board_b[0].nrChannels) << endl; + + for (int j = 0;j< board_b[0].nrChannels;j++){ if (board_b[0].maxchannel_amp>100.) TH2D_b0_signal_vs_channel->Fill(j, board_b[0].channel_amp[j]); + } + for (int j = 0;j< board_b[1].nrChannels;j++){ if (board_b[1].maxchannel_amp>100.) TH2D_b1_signal_vs_channel->Fill(j, board_b[1].channel_amp[j]); + } + for (int j = 0;j< board_b[2].nrChannels;j++){ if (board_b[2].maxchannel_amp>100.) TH2D_b2_signal_vs_channel->Fill(j, board_b[2].channel_amp[j]); + } + for (int j = 0;j< board_b[3].nrChannels;j++){ if (board_b[3].maxchannel_amp>100.) TH2D_b3_signal_vs_channel->Fill(j, board_b[3].channel_amp[j]); - } + // cout << "fill tree" << endl; rootTree->Fill(); } @@ -215,6 +223,14 @@ int set_background_v2(int start_frame, int max_frames){ //Read first record to find board configuration Fullframe sampleframe; + file.seekg(start_frame * sampleframe.sizeInFile() , std::ios::beg); + if (sampleframe.read(&file) == 0) //read the next frame and catch if returns error + { + std::cerr << " ### Hitdata: First frame could not be read!" << std::endl; + file.close(); //read error, finish! + return 0; + } + //Read // file.seekg(sampleframe.sizeInFile(), std::ios::beg); @@ -228,6 +244,7 @@ int set_background_v2(int start_frame, int max_frames){ return 0; } for (int boardnumber = 0; boardnumber<4; boardnumber++){ + for (int j = 0; jsensor_data[j] << std::endl; @@ -245,26 +262,21 @@ bpm_frame_v2 readboard(Fullframe frame, int boardnumber){ board.integratedsignalamp = 0.; board.maxchannel_amp = 0.; + board.nrChannels = frame.boards[boardnumber].nrChannels; + board.board_number = boardnumber; + // file.seekg(boardnumber*sizeof(BufferData)+4*frame*sizeof(BufferData)); //file.read ((char*)dataptr ,sizeof(BufferData)); if (frame.boards[boardnumber].syncframe.device_nr==boardnumber){ + + // cout << "nrChannels" << frame.boards[boardnumber].nrChannels << endl; for (int j = 0; j channel_reducedlist; //for anomaly detection vector channel_reducedlistcopy; //for anomaly detection + //hardcoded pixels to mask for this data set. + const int arr_0[] = {139 }; + //const int arr_1[] = {}; + const int arr_2[] = { 11,12 }; + const int arr_3[] = { 1, 2, }; + + vector masked_channels[4]; + masked_channels[0].assign( arr_0, arr_0 + sizeof(arr_0) / sizeof(*arr_0) ); + // masked_channels[0].assign( arr_0, arr_0 + sizeof(arr_0) / sizeof(*arr_0) ); + masked_channels[2].assign( arr_2, arr_2 + sizeof(arr_2) / sizeof(*arr_2) ); + masked_channels[3].assign( arr_3, arr_3 + sizeof(arr_3) / sizeof(*arr_3) ); + + + + Channel tmp; int temp_lastneighbour= -128; for (int i = 0; i< array_length; i++){ + if (std::count( masked_channels[frametoanalyse.board_number].begin(), masked_channels[frametoanalyse.board_number].end(), i)) continue; //check masked pixel list, and do not add it to the list of channels for analysis. if (frametoanalyse.channel_amp[i]>=threshold) { // cout << "ch: " << i << endl; // signal_list.push_back(frametoanalyse.channel_amp[i]); diff --git a/Scripts_20210119/hit_analyse_v2.h b/Scripts_20210119/hit_analyse_v2.h index c30bd93..7c24423 100644 --- a/Scripts_20210119/hit_analyse_v2.h +++ b/Scripts_20210119/hit_analyse_v2.h @@ -4,6 +4,7 @@ #include #include #include +#include // std::count #include #include #include @@ -57,6 +58,8 @@ struct bpm_frame_v2 { double avg_width; double integratedsignalamp; int maxchannel; + int nrChannels; + int board_number; double maxchannel_amp; }; @@ -64,7 +67,6 @@ struct bpm_frame_v2 { bpm_frame_v2 board_b[4]; bpm_frame_v2 board_b_bkg[4]; - bpm_frame_v2 readboard(Fullframe frame, int boardnumber); int framestart = 0; diff --git a/Scripts_20210119/hitreader.h b/Scripts_20210119/hitreader.h index 4af0858..8bb465d 100644 --- a/Scripts_20210119/hitreader.h +++ b/Scripts_20210119/hitreader.h @@ -1,6 +1,7 @@ //This is an object interface for reading HIT data files //See HIT documentation for details and examples. /* + THIS DOESN'T WORK! .L hitreader.c Hitdata data; @@ -146,7 +147,7 @@ class Boardframe return 0; // std::cout<< "data[" << nrChannels << "]: "; // for (int i = 0;i