added pixel masking in beamreconstruction()
This commit is contained in:
parent
6f25f8675f
commit
2c6a35c074
Binary file not shown.
@ -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++){
|
||||
if (board_b[0].maxchannel_amp>100.) TH2D_b0_signal_vs_channel->Fill(j, board_b[0].channel_amp[j]);
|
||||
if (board_b[1].maxchannel_amp>100.) TH2D_b1_signal_vs_channel->Fill(j, board_b[1].channel_amp[j]);
|
||||
if (board_b[2].maxchannel_amp>100.) TH2D_b2_signal_vs_channel->Fill(j, board_b[2].channel_amp[j]);
|
||||
if (board_b[3].maxchannel_amp>100.) TH2D_b3_signal_vs_channel->Fill(j, board_b[3].channel_amp[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; j<sampleframe.boards[boardnumber].nrChannels;j++){
|
||||
board_b_bkg[boardnumber].channel_amp[j] += sampleframe.boards[boardnumber].data[j] / double(max_frames);
|
||||
// std::cout << j << " " << board.channel_amp[j] << " " << dataptr->sensor_data[j] << std::endl;
|
||||
@ -245,25 +262,20 @@ 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<frame.boards[boardnumber].nrChannels;j++){
|
||||
//subtract the background from the data
|
||||
if (boardnumber==0){
|
||||
// board_0 has the even and odd channels swapped in the hardware.
|
||||
if(j%2==0){
|
||||
board.channel_amp[j] = frame.boards[boardnumber].data[j+1] - board_b_bkg[boardnumber].channel_amp[j+1];
|
||||
}
|
||||
else{
|
||||
board.channel_amp[j] = frame.boards[boardnumber].data[j-1] - board_b_bkg[boardnumber].channel_amp[j-1];
|
||||
}
|
||||
}
|
||||
else{
|
||||
board.channel_amp[j] = frame.boards[boardnumber].data[j] - board_b_bkg[boardnumber].channel_amp[j];
|
||||
// std::cout << j << " " << board.channel_amp[j] << " " << frame.boards[boardnumber].data[j] << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -323,14 +335,30 @@ beamRecon beamreconstruction(bpm_frame_v2 frametoanalyse, double threshold = 30.
|
||||
|
||||
|
||||
// const int array_length = sizeof(frametoanalyse.channel_amp)/sizeof(double);
|
||||
const int array_length = 320;
|
||||
const int array_length = frametoanalyse.nrChannels ;
|
||||
vector<Channel> channel_reducedlist; //for anomaly detection
|
||||
vector<Channel> 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<int> 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]);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <algorithm> // std::count
|
||||
#include <utility>
|
||||
#include <TH2.h>
|
||||
#include <TF1.h>
|
||||
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user