80#include "TRestDetectorSignalEvent.h"
88TRestDetectorSignalEvent::TRestDetectorSignalEvent() {
93TRestDetectorSignalEvent::~TRestDetectorSignalEvent() {
101 fMinValue = std::numeric_limits<Double_t>::max();
102 fMaxValue = std::numeric_limits<Double_t>::min();
103 fMinTime = std::numeric_limits<Double_t>::max();
104 fMaxTime = std::numeric_limits<Double_t>::min();
108 if (signalIDExists(signal.GetSignalID())) {
109 cout <<
"Warning. Signal ID : " << signal.GetSignalID()
110 <<
" already exists. Signal will not be added to signal event" << endl;
114 fSignal.emplace_back(signal);
117void TRestDetectorSignalEvent::RemoveSignalWithId(Int_t sId) {
118 Int_t index = GetSignalIndex(sId);
121 std::cout <<
"Warning. Signal ID : " << sId
122 <<
" does not exist. Signal will not be removed from signal event" << std::endl;
126 fSignal.erase(fSignal.begin() + index);
129Int_t TRestDetectorSignalEvent::GetSignalIndex(Int_t signalID) {
130 for (
int i = 0; i < GetNumberOfSignals(); i++)
131 if (fSignal[i].GetSignalID() == signalID)
return i;
135Double_t TRestDetectorSignalEvent::GetIntegral(Int_t startBin, Int_t endBin) {
138 for (
int i = 0; i < GetNumberOfSignals(); i++) sum += fSignal[i].GetIntegral(startBin, endBin);
143Double_t TRestDetectorSignalEvent::GetIntegralWithTime(Double_t startTime, Double_t endTime) {
145 for (
int n = 0; n < GetNumberOfSignals(); n++) sum += fSignal[n].GetIntegralWithTime(startTime, endTime);
150void TRestDetectorSignalEvent::AddChargeToSignal(Int_t signalID, Double_t time, Double_t charge) {
151 Int_t signalIndex = GetSignalIndex(signalID);
152 if (signalIndex == -1) {
153 signalIndex = GetNumberOfSignals();
155 signal.SetSignalID(signalID);
159 fSignal[signalIndex].IncreaseAmplitude(time, charge);
162void TRestDetectorSignalEvent::PrintEvent() {
165 for (
int i = 0; i < GetNumberOfSignals(); i++) {
166 const auto& signal = fSignal[i];
172void TRestDetectorSignalEvent::SetMaxAndMin() {
173 fMinValue = std::numeric_limits<Double_t>::max();
174 fMaxValue = std::numeric_limits<Double_t>::min();
175 fMinTime = std::numeric_limits<Double_t>::max();
176 fMaxTime = std::numeric_limits<Double_t>::min();
178 for (
int s = 0; s < GetNumberOfSignals(); s++) {
179 if (fMinTime > fSignal[s].GetMinTime()) fMinTime = fSignal[s].GetMinTime();
180 if (fMaxTime < fSignal[s].GetMaxTime()) fMaxTime = fSignal[s].GetMaxTime();
182 if (fMinValue > fSignal[s].GetMinValue()) fMinValue = fSignal[s].GetMinValue();
183 if (fMaxValue < fSignal[s].GetMaxValue()) fMaxValue = fSignal[s].GetMaxValue();
187Double_t TRestDetectorSignalEvent::GetMaxValue() {
192Double_t TRestDetectorSignalEvent::GetMinValue() {
197Double_t TRestDetectorSignalEvent::GetMinTime() {
198 Double_t minTime = numeric_limits<Double_t>::max();
199 for (
int s = 0; s < GetNumberOfSignals(); s++) {
200 if (minTime > fSignal[s].GetMinTime()) {
201 minTime = fSignal[s].GetMinTime();
207Double_t TRestDetectorSignalEvent::GetMaxTime() {
208 Double_t maxTime = numeric_limits<Double_t>::min();
209 for (
int s = 0; s < GetNumberOfSignals(); s++) {
210 if (maxTime < fSignal[s].GetMaxTime()) {
211 maxTime = fSignal[s].GetMaxTime();
221 int nSignals = this->GetNumberOfSignals();
224 cout <<
"Empty event " << endl;
228 fMinValue = std::numeric_limits<Double_t>::max();
229 fMaxValue = std::numeric_limits<Double_t>::min();
230 fMinTime = std::numeric_limits<Double_t>::max();
231 fMaxTime = std::numeric_limits<Double_t>::min();
233 fPad =
new TPad(this->GetName(),
" ", 0, 0, 1, 1);
236 fPad->DrawFrame(GetMinTime(), GetMinValue(), GetMaxTime(), GetMaxValue());
239 sprintf(title,
"Event ID %d", this->GetID());
241 TMultiGraph* mg =
new TMultiGraph();
243 mg->GetXaxis()->SetTitle(
"Time [us]");
244 mg->GetXaxis()->SetTitleOffset(1.1);
245 mg->GetYaxis()->SetTitle(
"Amplitude [a.u.]");
246 mg->GetYaxis()->SetTitleOffset(0.8);
248 mg->GetYaxis()->SetTitleSize(1.4 * mg->GetYaxis()->GetTitleSize());
249 mg->GetXaxis()->SetTitleSize(1.4 * mg->GetXaxis()->GetTitleSize());
250 mg->GetYaxis()->SetLabelSize(1.25 * mg->GetYaxis()->GetLabelSize());
251 mg->GetXaxis()->SetLabelSize(1.25 * mg->GetXaxis()->GetLabelSize());
253 for (
int n = 0; n < nSignals; n++) {
254 TGraph* gr = fSignal[n].GetGraph(n + 1);
TPad * DrawEvent(const TString &option="")
Draw the event.
virtual void PrintEvent() const
virtual void Initialize()=0