DB_Track/source/TrackFinder.cpp

66 lines
1.3 KiB
C++

//
// TrackFinder.cpp
// DB_Track
//
// Created by Baranyai David on 2018. 06. 05..
//
#include "TrackFinder.hpp"
#include <iostream>
TrackFinder::TrackFinder()
{
}
TrackFinder::~TrackFinder()
{
}
bool TrackFinder::FindAndDrawNextTrack(TH2D* histo, TCanvas *canvas)
{
std::vector<Hit> track;
track.clear();
for(int i = 0; i < 4; i++)
{
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++)
{
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);
}
for(int i = 0; i < 4; i++)
{
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);
}
}
histo -> Draw("colz");
histo -> Fit("pol1");
canvas -> Update();
return true;
}
}