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;}
|
else if (boardnumber==3) {BPMbeamrecon_3=BPMbeamrecon_Zeroed;}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (int j = 0;j<320;j++){
|
// cout << "fill hist " << int(board_b[0].nrChannels) << endl;
|
||||||
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]);
|
|
||||||
|
|
||||||
|
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();
|
rootTree->Fill();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -215,6 +223,14 @@ int set_background_v2(int start_frame, int max_frames){
|
|||||||
|
|
||||||
//Read first record to find board configuration
|
//Read first record to find board configuration
|
||||||
Fullframe sampleframe;
|
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
|
//Read
|
||||||
// file.seekg(sampleframe.sizeInFile(), std::ios::beg);
|
// file.seekg(sampleframe.sizeInFile(), std::ios::beg);
|
||||||
@ -228,6 +244,7 @@ int set_background_v2(int start_frame, int max_frames){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (int boardnumber = 0; boardnumber<4; boardnumber++){
|
for (int boardnumber = 0; boardnumber<4; boardnumber++){
|
||||||
|
|
||||||
for (int j = 0; j<sampleframe.boards[boardnumber].nrChannels;j++){
|
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);
|
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;
|
// std::cout << j << " " << board.channel_amp[j] << " " << dataptr->sensor_data[j] << std::endl;
|
||||||
@ -245,26 +262,21 @@ bpm_frame_v2 readboard(Fullframe frame, int boardnumber){
|
|||||||
|
|
||||||
board.integratedsignalamp = 0.;
|
board.integratedsignalamp = 0.;
|
||||||
board.maxchannel_amp = 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.seekg(boardnumber*sizeof(BufferData)+4*frame*sizeof(BufferData));
|
||||||
//file.read ((char*)dataptr ,sizeof(BufferData));
|
//file.read ((char*)dataptr ,sizeof(BufferData));
|
||||||
|
|
||||||
if (frame.boards[boardnumber].syncframe.device_nr==boardnumber){
|
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++){
|
for (int j = 0; j<frame.boards[boardnumber].nrChannels;j++){
|
||||||
//subtract the background from the data
|
//subtract the background from the data
|
||||||
if (boardnumber==0){
|
board.channel_amp[j] = frame.boards[boardnumber].data[j] - board_b_bkg[boardnumber].channel_amp[j];
|
||||||
// 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;
|
// std::cout << j << " " << board.channel_amp[j] << " " << frame.boards[boardnumber].data[j] << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//sum the signal across channels
|
//sum the signal across channels
|
||||||
@ -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 = 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_reducedlist; //for anomaly detection
|
||||||
vector<Channel> channel_reducedlistcopy; //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;
|
Channel tmp;
|
||||||
|
|
||||||
int temp_lastneighbour= -128;
|
int temp_lastneighbour= -128;
|
||||||
for (int i = 0; i< array_length; i++){
|
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) {
|
if (frametoanalyse.channel_amp[i]>=threshold) {
|
||||||
// cout << "ch: " << i << endl;
|
// cout << "ch: " << i << endl;
|
||||||
// signal_list.push_back(frametoanalyse.channel_amp[i]);
|
// signal_list.push_back(frametoanalyse.channel_amp[i]);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm> // std::count
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <TH2.h>
|
#include <TH2.h>
|
||||||
#include <TF1.h>
|
#include <TF1.h>
|
||||||
@ -57,6 +58,8 @@ struct bpm_frame_v2 {
|
|||||||
double avg_width;
|
double avg_width;
|
||||||
double integratedsignalamp;
|
double integratedsignalamp;
|
||||||
int maxchannel;
|
int maxchannel;
|
||||||
|
int nrChannels;
|
||||||
|
int board_number;
|
||||||
double maxchannel_amp;
|
double maxchannel_amp;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,7 +67,6 @@ struct bpm_frame_v2 {
|
|||||||
bpm_frame_v2 board_b[4];
|
bpm_frame_v2 board_b[4];
|
||||||
bpm_frame_v2 board_b_bkg[4];
|
bpm_frame_v2 board_b_bkg[4];
|
||||||
|
|
||||||
|
|
||||||
bpm_frame_v2 readboard(Fullframe frame, int boardnumber);
|
bpm_frame_v2 readboard(Fullframe frame, int boardnumber);
|
||||||
int framestart = 0;
|
int framestart = 0;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//This is an object interface for reading HIT data files
|
//This is an object interface for reading HIT data files
|
||||||
//See HIT documentation for details and examples.
|
//See HIT documentation for details and examples.
|
||||||
/*
|
/*
|
||||||
|
THIS DOESN'T WORK!
|
||||||
.L hitreader.c
|
.L hitreader.c
|
||||||
|
|
||||||
Hitdata data;
|
Hitdata data;
|
||||||
@ -146,7 +147,7 @@ class Boardframe
|
|||||||
return 0;
|
return 0;
|
||||||
// std::cout<< "data[" << nrChannels << "]: ";
|
// std::cout<< "data[" << nrChannels << "]: ";
|
||||||
// for (int i = 0;i<nrChannels;i++) std::cout << data[i] << " ";
|
// for (int i = 0;i<nrChannels;i++) std::cout << data[i] << " ";
|
||||||
// std::cout << std::endl;
|
// std::cout << std::endl;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user