Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new method to draw signals in TRestRawSignalEvent #46

Merged
merged 11 commits into from
Apr 26, 2022
Merged
1 change: 1 addition & 0 deletions inc/TRestRawSignalEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class TRestRawSignalEvent : public TRestEvent {
void PrintEvent();

TPad* DrawEvent(TString option = "");
TPad* DrawSignals(const std::vector<Int_t> &signals);
TPad* DrawSignal(Int_t signal, TString option = "");

// Construtor
Expand Down
43 changes: 43 additions & 0 deletions src/TRestRawSignalEvent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,49 @@ TPad* TRestRawSignalEvent::DrawEvent(TString option) {
return fPad;
}

///////////////////////////////////////////////
/// \brief This method draws selected signal IDs, given by the vector
/// passed as reference
///

TPad* TRestRawSignalEvent::DrawSignals(const std::vector<Int_t> &signals) {

int maxSID=-1;
int max=0;
int color=1;

for(const auto &s : signals){
TRestRawSignal* sgnl = GetSignalById(s);
if(sgnl->fGraph)delete sgnl->fGraph;
sgnl->fGraph = new TGraph();
for(int p=0;p<sgnl->GetNumberOfPoints();p++){
double val = sgnl->GetData(p);
sgnl->fGraph->SetPoint(p,p,val);
sgnl->fGraph->SetLineColor(color);
if(val>max){max=val;maxSID=s;};
}
color++;
}

TPad *pad =new TPad("RawSignal", " ", 0, 0, 1, 1);
pad->Draw();

debug<<"Max SID "<<maxSID<<endl;

if(maxSID ==-1)return pad;

TRestRawSignal* sgn = GetSignalById(maxSID);
pad->cd();
sgn->fGraph->Draw();

for(const auto &s : signals){
TRestRawSignal* sgnl = GetSignalById(s);
if(sgnl->GetID() !=sgn->GetID())sgnl->fGraph->Draw("SAME");
}

return pad;
}

///////////////////////////////////////////////
/// \brief This method draws selected signal by ID, with baseline range and
/// points over threshold highlighted.
Expand Down