22#include "TRestDetectorSignalEvent.h"
30TRestDetectorSignalEvent::TRestDetectorSignalEvent() {
35TRestDetectorSignalEvent::~TRestDetectorSignalEvent() {
43 fMinValue = std::numeric_limits<Double_t>::max();
44 fMaxValue = std::numeric_limits<Double_t>::min();
45 fMinTime = std::numeric_limits<Double_t>::max();
46 fMaxTime = std::numeric_limits<Double_t>::min();
50 if (signalIDExists(signal.GetSignalID())) {
51 cout <<
"Warning. Signal ID : " << signal.GetSignalID()
52 <<
" already exists. Signal will not be added to signal event" << endl;
56 fSignal.emplace_back(signal);
59void TRestDetectorSignalEvent::RemoveSignalWithId(Int_t sId) {
60 Int_t index = GetSignalIndex(sId);
63 std::cout <<
"Warning. Signal ID : " << sId
64 <<
" does not exist. Signal will not be removed from signal event" << std::endl;
68 fSignal.erase(fSignal.begin() + index);
71Int_t TRestDetectorSignalEvent::GetSignalIndex(Int_t signalID) {
72 for (
int i = 0; i < GetNumberOfSignals(); i++)
73 if (fSignal[i].GetSignalID() == signalID)
return i;
77Double_t TRestDetectorSignalEvent::GetIntegral(Int_t startBin, Int_t endBin) {
80 for (
int i = 0; i < GetNumberOfSignals(); i++) sum += fSignal[i].GetIntegral(startBin, endBin);
85Double_t TRestDetectorSignalEvent::GetIntegralWithTime(Double_t startTime, Double_t endTime) {
87 for (
int n = 0; n < GetNumberOfSignals(); n++) sum += fSignal[n].GetIntegralWithTime(startTime, endTime);
92void TRestDetectorSignalEvent::AddChargeToSignal(Int_t signalID, Double_t time, Double_t charge) {
93 Int_t signalIndex = GetSignalIndex(signalID);
94 if (signalIndex == -1) {
95 signalIndex = GetNumberOfSignals();
97 signal.SetSignalID(signalID);
101 fSignal[signalIndex].IncreaseAmplitude(time, charge);
104void TRestDetectorSignalEvent::PrintEvent() {
107 for (
int i = 0; i < GetNumberOfSignals(); i++) {
108 const auto& signal = fSignal[i];
114void TRestDetectorSignalEvent::SetMaxAndMin() {
115 fMinValue = std::numeric_limits<Double_t>::max();
116 fMaxValue = std::numeric_limits<Double_t>::min();
117 fMinTime = std::numeric_limits<Double_t>::max();
118 fMaxTime = std::numeric_limits<Double_t>::min();
120 for (
int s = 0; s < GetNumberOfSignals(); s++) {
121 if (fMinTime > fSignal[s].GetMinTime()) fMinTime = fSignal[s].GetMinTime();
122 if (fMaxTime < fSignal[s].GetMaxTime()) fMaxTime = fSignal[s].GetMaxTime();
124 if (fMinValue > fSignal[s].GetMinValue()) fMinValue = fSignal[s].GetMinValue();
125 if (fMaxValue < fSignal[s].GetMaxValue()) fMaxValue = fSignal[s].GetMaxValue();
129Double_t TRestDetectorSignalEvent::GetMaxValue() {
134Double_t TRestDetectorSignalEvent::GetMinValue() {
139Double_t TRestDetectorSignalEvent::GetMinTime() {
140 Double_t minTime = numeric_limits<Double_t>::max();
141 for (
int s = 0; s < GetNumberOfSignals(); s++) {
142 if (minTime > fSignal[s].GetMinTime()) {
143 minTime = fSignal[s].GetMinTime();
149Double_t TRestDetectorSignalEvent::GetMaxTime() {
150 Double_t maxTime = numeric_limits<Double_t>::min();
151 for (
int s = 0; s < GetNumberOfSignals(); s++) {
152 if (maxTime < fSignal[s].GetMaxTime()) {
153 maxTime = fSignal[s].GetMaxTime();
163 int nSignals = this->GetNumberOfSignals();
166 cout <<
"Empty event " << endl;
170 fMinValue = std::numeric_limits<Double_t>::max();
171 fMaxValue = std::numeric_limits<Double_t>::min();
172 fMinTime = std::numeric_limits<Double_t>::max();
173 fMaxTime = std::numeric_limits<Double_t>::min();
175 fPad =
new TPad(this->GetName(),
" ", 0, 0, 1, 1);
178 fPad->DrawFrame(GetMinTime(), GetMinValue(), GetMaxTime(), GetMaxValue());
181 sprintf(title,
"Event ID %d", this->GetID());
183 TMultiGraph* mg =
new TMultiGraph();
185 mg->GetXaxis()->SetTitle(
"Time [us]");
186 mg->GetXaxis()->SetTitleOffset(1.1);
187 mg->GetYaxis()->SetTitle(
"Amplitude [a.u.]");
188 mg->GetYaxis()->SetTitleOffset(0.8);
190 mg->GetYaxis()->SetTitleSize(1.4 * mg->GetYaxis()->GetTitleSize());
191 mg->GetXaxis()->SetTitleSize(1.4 * mg->GetXaxis()->GetTitleSize());
192 mg->GetYaxis()->SetLabelSize(1.25 * mg->GetYaxis()->GetLabelSize());
193 mg->GetXaxis()->SetLabelSize(1.25 * mg->GetXaxis()->GetLabelSize());
195 for (
int n = 0; n < nSignals; n++) {
196 TGraph* gr = fSignal[n].GetGraph(n + 1);
TPad * DrawEvent(const TString &option="")
Draw the event.
virtual void PrintEvent() const
virtual void Initialize()=0