diff --git a/dataClasses/AEvent.cpp b/dataClasses/AEvent.cpp index 5056d2504a77d803f4191de542c27d58bce43dc0..247df9810c29b716ca9a47c85e8186c8f0c140d0 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 1ca0c1dfa90f0d8518badbfebb69c3066501d497..ac1fa9257014efa76d2812045616213c28e2f9a4 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 0000000000000000000000000000000000000000..76dbca0cad64d09fb398631d7d4f04e69c591e0f --- /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(""); + } + + +}