22 #include "TRestDetectorSignalEvent.h"
30 TRestDetectorSignalEvent::TRestDetectorSignalEvent() {
35 TRestDetectorSignalEvent::~TRestDetectorSignalEvent() {
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);
59 void 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);
71 Int_t TRestDetectorSignalEvent::GetSignalIndex(Int_t signalID) {
72 for (
int i = 0; i < GetNumberOfSignals(); i++)
73 if (fSignal[i].GetSignalID() == signalID)
return i;
77 Double_t TRestDetectorSignalEvent::GetIntegral(Int_t startBin, Int_t endBin) {
80 for (
int i = 0; i < GetNumberOfSignals(); i++) sum += fSignal[i].GetIntegral(startBin, endBin);
85 Double_t TRestDetectorSignalEvent::GetIntegralWithTime(Double_t startTime, Double_t endTime) {
87 for (
int n = 0; n < GetNumberOfSignals(); n++) sum += fSignal[n].GetIntegralWithTime(startTime, endTime);
92 void 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);
104 void TRestDetectorSignalEvent::PrintEvent() {
107 for (
int i = 0; i < GetNumberOfSignals(); i++) {
108 const auto& signal = fSignal[i];
114 void TRestDetectorSignalEvent::SetMaxAndMin() {
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();
129 Double_t TRestDetectorSignalEvent::GetMaxValue() {
134 Double_t TRestDetectorSignalEvent::GetMinValue() {
139 Double_t TRestDetectorSignalEvent::GetMinTime() {
140 Double_t minTime = 1.e10;
141 for (
int s = 0; s < GetNumberOfSignals(); s++)
142 if (minTime > fSignal[s].GetMinTime()) {
143 minTime = fSignal[s].GetMinTime();
148 Double_t TRestDetectorSignalEvent::GetMaxTime() {
149 Double_t maxTime = -1.e10;
150 for (
int s = 0; s < GetNumberOfSignals(); s++) {
151 if (maxTime < fSignal[s].GetMaxTime()) {
152 maxTime = fSignal[s].GetMaxTime();
162 int nSignals = this->GetNumberOfSignals();
165 cout <<
"Empty event " << endl;
174 fPad =
new TPad(this->GetName(),
" ", 0, 0, 1, 1);
177 fPad->DrawFrame(GetMinTime(), GetMinValue(), GetMaxTime(), GetMaxValue());
180 sprintf(title,
"Event ID %d", this->GetID());
182 TMultiGraph* mg =
new TMultiGraph();
184 mg->GetXaxis()->SetTitle(
"Time [us]");
185 mg->GetXaxis()->SetTitleOffset(1.1);
186 mg->GetYaxis()->SetTitle(
"Amplitude [a.u.]");
187 mg->GetYaxis()->SetTitleOffset(0.8);
189 mg->GetYaxis()->SetTitleSize(1.4 * mg->GetYaxis()->GetTitleSize());
190 mg->GetXaxis()->SetTitleSize(1.4 * mg->GetXaxis()->GetTitleSize());
191 mg->GetYaxis()->SetLabelSize(1.25 * mg->GetYaxis()->GetLabelSize());
192 mg->GetXaxis()->SetLabelSize(1.25 * mg->GetXaxis()->GetLabelSize());
194 for (
int n = 0; n < nSignals; n++) {
195 TGraph* gr = fSignal[n].GetGraph(n + 1);
TPad * DrawEvent(const TString &option="")
Draw the event.
virtual void PrintEvent() const
virtual void Initialize()=0