DB_Track/source/TrackFinder.cpp

66 lines
1.3 KiB
C++
Raw Normal View History

2018-06-05 23:09:11 +02:00
//
// TrackFinder.cpp
// DB_Track
//
// Created by Baranyai David on 2018. 06. 05..
//
#include "TrackFinder.hpp"
#include <iostream>
TrackFinder::TrackFinder()
{
}
TrackFinder::~TrackFinder()
{
2018-10-16 13:05:13 +02:00
2018-06-05 23:09:11 +02:00
}
2018-10-16 13:05:13 +02:00
bool TrackFinder::FindAndDrawNextTrack(TH2D* histo, TCanvas *canvas)
2018-06-05 23:09:11 +02:00
{
2018-10-16 13:05:13 +02:00
std::vector<Hit> track;
track.clear();
for(int i = 0; i < 4; i++)
2018-06-05 23:09:11 +02:00
{
2018-10-16 13:05:13 +02:00
track_data[i].clear();
}
track = sqlHandler.QueryNext();
histo -> Reset();
canvas -> cd(0);
if (track.size() == 0)
{
std::cout << "End of database" << std::endl;
return false;
}
else
{
for(int i = 0; i < track.size(); i++)
2018-06-05 23:09:11 +02:00
{
2018-10-16 13:05:13 +02:00
Hit helper;
helper.amplitude_peak = track[i].amplitude_peak;
helper.elapsed_time = track[i].elapsed_time;
helper.channel_id = track[i].channel_id % 16;
track_data[track[i].channel_id / 16].push_back(helper);
2018-06-05 23:09:11 +02:00
}
2018-10-16 13:05:13 +02:00
for(int i = 0; i < 4; i++)
2018-06-05 23:09:11 +02:00
{
2018-10-16 13:05:13 +02:00
for(int j = 0; j < track_data[i].size(); j++)
{
histo -> Fill(track_data[i][j].channel_id, i, track_data[i][j].amplitude_peak);
}
2018-06-05 23:09:11 +02:00
}
2018-10-16 13:05:13 +02:00
histo -> Draw("colz");
2018-10-30 16:10:59 +01:00
histo -> Fit("pol1");
2018-10-16 13:05:13 +02:00
canvas -> Update();
return true;
2018-06-05 23:09:11 +02:00
}
}