Commit 12ddb111 authored by Kostyleva D.A's avatar Kostyleva D.A

Function SmoothGraphs is added, script for viewing smoothed graphs is...

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)
parent 5ebbb653
...@@ -59,6 +59,8 @@ void AEvent::ProcessEvent() { ...@@ -59,6 +59,8 @@ void AEvent::ProcessEvent() {
SetChargeLED(); SetChargeLED();
SetChargeTF(); SetChargeTF();
SmoothGraphs();
return; return;
} }
...@@ -76,6 +78,7 @@ void AEvent::Reset() { ...@@ -76,6 +78,7 @@ void AEvent::Reset() {
fEdgeSlope=-100.; fEdgeSlope=-100.;
fTime10=0.; fTime10=0.;
fTime90=0.; fTime90=0.;
fTimeMid=0.;
fAmpMax = 0.; fAmpMax = 0.;
fTimeAmpMax = 0.; fTimeAmpMax = 0.;
fTimeCFD = -100.; fTimeCFD = -100.;
...@@ -102,6 +105,7 @@ void AEvent::Init() { ...@@ -102,6 +105,7 @@ void AEvent::Init() {
fGraphSignal = new TGraph(); fGraphSignal = new TGraph();
fGraphCFD = new TGraph(); fGraphCFD = new TGraph();
fGraphSmooth = new TGraph();
fInputEvent = 0; fInputEvent = 0;
fCFratio = 0.; fCFratio = 0.;
...@@ -123,6 +127,40 @@ void AEvent::SetGraphs() { ...@@ -123,6 +127,40 @@ void AEvent::SetGraphs() {
return; 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 "<<meant<<endl;
meanAmp = mean / winSize;
//cout<<"mean amp "<<fAmpPos[i]<<endl;
fGraphSmooth->SetPoint(i, meanTime, meanAmp);
}
return;
}
void AEvent::SetCFD() { void AEvent::SetCFD() {
Double_t time = 0; Double_t time = 0;
...@@ -203,6 +241,8 @@ void AEvent::FindFrontProperties() { ...@@ -203,6 +241,8 @@ void AEvent::FindFrontProperties() {
fEdgeSlope = fit1->GetParameter(1); fEdgeSlope = fit1->GetParameter(1);
fEdgeXi = fit1->GetChisquare(); fEdgeXi = fit1->GetChisquare();
fTimeMid = (fTime90 -fTime10)*0.5 + fTime10; //time point between fTime90 and fTime10
//adding point where fit function crosses zero //adding point where fit function crosses zero
Double_t a = 0, b = 0; Double_t a = 0, b = 0;
TF1 *line = new TF1("line","[1]*x + [0]"); TF1 *line = new TF1("line","[1]*x + [0]");
......
...@@ -43,6 +43,7 @@ private: ...@@ -43,6 +43,7 @@ private:
Double_t fEdgeSlope; //slope coefficient for the rising edge of the signal 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 fTime10; //time of 10% of rising edge amplitude in ns
Double_t fTime90; //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) TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed)
Double_t fTimeCFD; //zero-crossing time Double_t fTimeCFD; //zero-crossing time
...@@ -55,6 +56,7 @@ private: ...@@ -55,6 +56,7 @@ private:
TGraph *fGraphSignal; TGraph *fGraphSignal;
TGraph *fGraphCFD; TGraph *fGraphCFD;
TGraph *fGraphSmooth;
RawEvent *fInputEvent; //! RawEvent *fInputEvent; //!
...@@ -114,6 +116,11 @@ public: ...@@ -114,6 +116,11 @@ public:
return fGraphSignal; return fGraphSignal;
} }
TGraph* GetGraphSmooth() {
return fGraphSmooth;
}
//draws signal shape graphs //draws signal shape graphs
void FindFrontProperties(); void FindFrontProperties();
...@@ -144,6 +151,7 @@ private: ...@@ -144,6 +151,7 @@ private:
void Init(); void Init();
void SetMaxAmplitudes(); void SetMaxAmplitudes();
void SetGraphs(); void SetGraphs();
void SmoothGraphs();
void SetCFD(); //constant fraction discriminator method void SetCFD(); //constant fraction discriminator method
}; };
......
#include <TTree.h>
#include <TGraph.h>
#include <TFile.h>
#include <TSystem.h>
#include <TCanvas.h>
#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("");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment