From 12ddb1110ee546cb3454be2f99261b66ffd67870 Mon Sep 17 00:00:00 2001 From: "Kostyleva D.A" Date: Mon, 6 Feb 2017 19:08:04 +0300 Subject: [PATCH] Function SmoothGraphs is added, script for viewing smoothed graphs is testShowSmooth.C Also the fTimeMid variable is added (time in the middle of front edge) --- dataClasses/AEvent.cpp | 40 +++++++++++++++++++++++++ dataClasses/AEvent.h | 8 +++++ macros/testShowSmooth.C | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 macros/testShowSmooth.C diff --git a/dataClasses/AEvent.cpp b/dataClasses/AEvent.cpp index 5056d25..247df98 100644 --- a/dataClasses/AEvent.cpp +++ b/dataClasses/AEvent.cpp @@ -59,6 +59,8 @@ void AEvent::ProcessEvent() { SetChargeLED(); SetChargeTF(); + SmoothGraphs(); + return; } @@ -76,6 +78,7 @@ void AEvent::Reset() { fEdgeSlope=-100.; fTime10=0.; fTime90=0.; + fTimeMid=0.; fAmpMax = 0.; fTimeAmpMax = 0.; fTimeCFD = -100.; @@ -102,6 +105,7 @@ void AEvent::Init() { fGraphSignal = new TGraph(); fGraphCFD = new TGraph(); + fGraphSmooth = new TGraph(); fInputEvent = 0; fCFratio = 0.; @@ -123,6 +127,40 @@ void AEvent::SetGraphs() { return; } +void AEvent::SmoothGraphs() { + + //smoothing graph + + fGraphSmooth->Set(fNPoints - 4); + + Int_t winSize = 5; //number of smoothing points + Int_t winMidSize = winSize / 2; + Double_t tmin, tmax, meanTime, meanAmp; + + for(Int_t i = winMidSize; i < fNPoints - winMidSize; ++i) { + Float_t mean = 0; + tmin = 0; + tmax = 0; + meanTime = 0; + meanAmp = 0; + for(Int_t j = i - winMidSize; j <= (i + winMidSize); ++j) { + if (j == i - winMidSize) { tmin = fTime[j]; } + if (j == i + winMidSize) { tmax = fTime[j]; } + mean += fAmpPos[j]; + } + meanTime = (tmax - tmin)*0.5 + tmin; + //cout<<"mean time "<SetPoint(i, meanTime, meanAmp); + + } + + return; +} + void AEvent::SetCFD() { Double_t time = 0; @@ -203,6 +241,8 @@ void AEvent::FindFrontProperties() { fEdgeSlope = fit1->GetParameter(1); fEdgeXi = fit1->GetChisquare(); + fTimeMid = (fTime90 -fTime10)*0.5 + fTime10; //time point between fTime90 and fTime10 + //adding point where fit function crosses zero Double_t a = 0, b = 0; TF1 *line = new TF1("line","[1]*x + [0]"); diff --git a/dataClasses/AEvent.h b/dataClasses/AEvent.h index 1ca0c1d..ac1fa92 100644 --- a/dataClasses/AEvent.h +++ b/dataClasses/AEvent.h @@ -43,6 +43,7 @@ private: Double_t fEdgeSlope; //slope coefficient for the rising edge of the signal Double_t fTime10; //time of 10% of rising edge amplitude in ns Double_t fTime90; //time of 10% of rising edge amplitude in ns + Double_t fTimeMid; //time point between fTime90 and fTime10 TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed) Double_t fTimeCFD; //zero-crossing time @@ -55,6 +56,7 @@ private: TGraph *fGraphSignal; TGraph *fGraphCFD; + TGraph *fGraphSmooth; RawEvent *fInputEvent; //! @@ -114,6 +116,11 @@ public: return fGraphSignal; } + + TGraph* GetGraphSmooth() { + + return fGraphSmooth; + } //draws signal shape graphs void FindFrontProperties(); @@ -144,6 +151,7 @@ private: void Init(); void SetMaxAmplitudes(); void SetGraphs(); + void SmoothGraphs(); void SetCFD(); //constant fraction discriminator method }; diff --git a/macros/testShowSmooth.C b/macros/testShowSmooth.C new file mode 100644 index 0000000..76dbca0 --- /dev/null +++ b/macros/testShowSmooth.C @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include "TStyle.h" + +void testShowSmooth() +{ + gSystem->Load("../libData.so"); + const Long64_t kFirstEvent = 128; + + TFile fr("../data/dataDSR4/analysis_07_1.root"); + TTree *tr = (TTree*)fr.Get("atree"); + + AEvent *revent = new AEvent(); + tr->SetBranchAddress("Ach0.",&revent); + TGraph *grs[12]; //smoothed graphs + TGraph *gr[12]; //normal graphs + + for (Long64_t i = 0; i < 12; i++) { + grs[i] = 0; + gr[i] = 0; + + tr->GetEntry(i+kFirstEvent); + + grs[i] = new TGraph(*revent->GetGraphSmooth()); + gr[i] = new TGraph(*revent->GetGraphSignal()); + } + + TCanvas *c1 = new TCanvas("c1","smoothed graphs",10,10,1000,600); + c1->Divide(2,2); + + for (Int_t k = 0; k < 4; k++) { + c1->cd(k+1); + grs[k]->GetXaxis()->SetTitle("Time [ns]"); + grs[k]->GetXaxis()->CenterTitle(); + grs[k]->GetYaxis()->SetTitle("Amplitude [V]"); + grs[k]->GetYaxis()->CenterTitle(); + grs[k]->GetXaxis()->SetRangeUser(120, 160); + grs[k]->SetMarkerStyle(7); + grs[k]->Draw(""); + + //gr[k]->SetMarkerColor(2); + //gr[k]->Draw(""); + } + + TCanvas *c2 = new TCanvas("c2","non-smoothed graphs",10,10,1000,600); + c2->Divide(2,2); + + for (Int_t k = 0; k < 4; k++) { + c2->cd(k+1); + gr[k]->GetXaxis()->SetTitle("Time [ns]"); + gr[k]->GetXaxis()->CenterTitle(); + gr[k]->GetYaxis()->SetTitle("Amplitude [V]"); + gr[k]->GetYaxis()->CenterTitle(); + gr[k]->GetXaxis()->SetRangeUser(120, 160); + gr[k]->SetMarkerStyle(7); + gr[k]->Draw(""); + + //gr[k]->SetMarkerColor(2); + //gr[k]->Draw(""); + } + + +} -- 2.18.1