Diana Software
Functions | Variables
CheckOFShape.C File Reference

Go to the source code of this file.

Functions

gSystem Load ("libpq")
 
gSystem Load ("libqroot")
 
gSystem Load ("libthreadwrapper")
 
gSystem Load ("libbase")
 
gSystem Load ("libcoretools")
 
gSystem Load ("libglobalrw")
 
gSystem Load ("libqstyle")
 
gSystem Load ("libdbbase")
 
gSystem Load ("librundatadb")
 
gSystem Load ("libdianadata")
 
gSystem Load ("libcalderdata")
 
gSystem Load ("libcaldertools")
 
gSystem Load ("libqstyleloader")
 
gSystem Load ("liboptimumfilter")
 
QVector an (N)
 
an Initialize (sigma *sigma *N)
 
QVector ap (N)
 
ap Initialize (0)
 
 for (int i=0;i< N;i++)
 
 for (int i=maxpos;i > 0;i--)
 
std::cout<< deltat20<<" "<< deltat50<<" "<< deltat80<< std::endl;double sigma_of=of.GetFilteredNoiseRMS();double sigma_of2=of2.GetFilteredNoiseRMS();std::cout<<"Simga OF: "<< sigma_of<<" amp: "<< amp<< std::endl;TH1D *ahisto=new TH1D("ahisto","ahisto", sqrt(Ne), amp *0.2, amp *1.5);TH1D *lhisto=new TH1D("lhisto","lhisto", sqrt(Ne), 0, 50);TH1D *rhisto=new TH1D("rhisto","rhisto", sqrt(Ne), 0, 50);TH1D *chisto=new TH1D("chisto","chisto", sqrt(Ne), 0, 2);TH1D *jhisto=new TH1D("jhisto","jhisto", 240,-30, 30);TH1D *shisto=new TH1D("shisto","shisto", sqrt(Ne), 0, amp);TH1D *ahisto2=new TH1D("ahisto2","ahisto2", sqrt(Ne), amp *0.2, amp *1.5);TH1D *lhisto2=new TH1D("lhisto2","lhisto2", sqrt(Ne), 0, 50);TH1D *rhisto2=new TH1D("rhisto2","rhisto2", sqrt(Ne), 0, 50);TH1D *chisto2=new TH1D("chisto2","chisto2", sqrt(Ne), 0, 2);TH1D *jhisto2=new TH1D("jhisto2","jhisto2", 50 *taur,-5 *taur, 5 *taur);TH1D *shisto2=new TH1D("shisto2","shisto2", sqrt(Ne), 0, amp);TRandom rand;rand.SetSeed(0);int success=0, success2=0;for(int e=0;e< Ne;e++) { if(e%100==0) cout<<"Event: "<< e<< std::endl;double shift=rand.Uniform(-4 *taur, 4 *taur);QVector signal(N), signal2(N);QVector noise(N), noise2(N);signal.Initialize(0);signal2.Initialize(0);noise.Initialize(0);noise2.Initialize(0);for(int i=0;i< N;i++) { double t=double(i-t0) -shift;noise[i]+=rand.Gaus(0, sigma);noise2[i]+=rand.Gaus(0, sigma);if(t< 0) continue;signal[i]+=(-exp(-t/taur)+exp(-t/taud));signal2[i]+=(-exp(-t/taur/taur_dev)+exp(-t/taud/taud_dev));} signal *=amp/signal.GetMax();signal2 *=amp/signal2.GetMax()/1.15;signal+=noise;signal2+=noise2;QError err;err=of.Filter(signal);if(err !=QERR_SUCCESS) continue;err=of.SetJitter(QOptimumFilter::J_LOCMAX);if(err !=QERR_SUCCESS) continue;double jitter, chi2, amplitude, integral, left, right;err=of.GetInterpolated(jitter, chi2, amplitude, integral, left, right);if(err !=QERR_SUCCESS) continue;ahisto-> Fill (amplitude)
 
lhisto Fill (left)
 
rhisto Fill (right)
 
chisto Fill (chi2)
 
jhisto Fill (jitter-shift)
 
 if (err !=QERR_SUCCESS)
 
shisto Fill (diff/cgain)
 
shisto2 Fill (diff2/cgain)
 
 if (success2==1)
 
std::cout<<"Successfull filtering : "<< double(success)/Ne *100<<" %"<< std::endl;std::cout<<"Successfull filtering 2: "<< double(success2)/Ne *100<<" %"<< std::endl;TCanvas *c1=new TCanvas("checkof","checkof", 1200, 800);c1-> Divide (3, 2)
 
c1 cd (1)
 
ahisto2 SetLineColor (kRed)
 
ahisto2 Draw ()
 
ahisto Draw ("SAME")
 
c1 cd (2)
 
c1 cd (3)
 
c1 cd (4)
 
c1 cd (5)
 
c1 cd (6)
 
shisto Fit (fg)
 
std::cout<<"DP: "<< dp<< std::endl;c1-> SaveAs ("checkof.pdf")
 

Variables

TF1 a
 
QVector b
 
double fs = 1
 
int N = 2048*fs
 
int Ne = 1e3
 
double t0 = 200*fs
 
double taur = 10*fs
 
double taud = 200*fs
 
double taur_dev = 1
 
double taud_dev = 1
 
double sigma = 1*sqrt(fs)
 
double amp = 10
 
int apmaxindex = ap.GetMaxIndex()
 
double max = ap.GetMax()-ap[0]
 
 ap =max
 
QOptimumFilter of (ap, an,-1, false)
 
QOptimumShapeFilter of2 (ap, an,-1, false, 2)
 
QVector ap1filtered2 = of2.GetOriginalAveragePulseFilteredShifted()
 
double cbase = ap1filtered2.GetMean(t0*3./4)
 
double cgain = ap1filtered2.GetMax()-ap1filtered2.GetMin()
 
double ofbase = ap1filtered2.GetMean(3./4*t0)
 
int maxpos = ap1filtered2.GetMaxIndex()
 
int deltat50 = maxpos
 
int deltat80 = maxpos
 
int deltat20 = maxpos
 
 err = of.Filter(signal2)
 
double diff = of2.GetFilteredShifted()[maxpos+jitter-deltat80]-of2.GetFilteredShifted()[maxpos+jitter-deltat20]
 
double diff2 = of2.GetFilteredShifted()[maxpos+jitter2-deltat80]-of2.GetFilteredShifted()[maxpos+jitter2-deltat20]
 
 success2
 
TF1 * fg = new TF1("fg","gaus")
 
double m1 = fg->GetParameter(1)
 
double s1 = fg->GetParameter(2)
 
double m2 = fg->GetParameter(1)
 
double s2 = fg->GetParameter(2)
 
double dp = (m1-m2)/sqrt(s1*s1+s2*s2)
 

Function Documentation

◆ an()

QVector an ( N  )

◆ ap()

QVector ap ( N  )

◆ cd() [1/6]

c1 cd ( )

◆ cd() [2/6]

c1 cd ( )

◆ cd() [3/6]

c1 cd ( )

◆ cd() [4/6]

c1 cd ( )

◆ cd() [5/6]

c1 cd ( )

◆ cd() [6/6]

c1 cd ( )

◆ Divide()

std::cout<<"Successfull filtering : "<<double(success)/Ne*100<<" %"<<std::endl; std::cout<<"Successfull filtering 2: "<<double(success2)/Ne*100<<" %"<<std::endl; TCanvas* c1 = new TCanvas("checkof","checkof",1200,800); c1-> Divide ( ,
 
)

◆ Draw() [1/2]

ahisto Draw ( "SAME"  )

◆ Draw() [2/2]

ahisto2 Draw ( )

◆ Fill() [1/7]

std::cout<<deltat20<<" "<<deltat50<<" "<<deltat80<<std::endl; double sigma_of = of.GetFilteredNoiseRMS(); double sigma_of2 = of2.GetFilteredNoiseRMS(); std::cout<<"Simga OF: "<<sigma_of<<" amp: "<<amp<<std::endl; TH1D* ahisto = new TH1D("ahisto","ahisto",sqrt(Ne),amp*0.2,amp*1.5); TH1D* lhisto = new TH1D("lhisto","lhisto",sqrt(Ne),0,50); TH1D* rhisto = new TH1D("rhisto","rhisto",sqrt(Ne),0,50); TH1D* chisto = new TH1D("chisto","chisto",sqrt(Ne),0,2); TH1D* jhisto = new TH1D("jhisto","jhisto",240,-30,30); TH1D* shisto = new TH1D("shisto","shisto",sqrt(Ne),0,amp); TH1D* ahisto2 = new TH1D("ahisto2","ahisto2",sqrt(Ne),amp*0.2,amp*1.5); TH1D* lhisto2 = new TH1D("lhisto2","lhisto2",sqrt(Ne),0,50); TH1D* rhisto2 = new TH1D("rhisto2","rhisto2",sqrt(Ne),0,50); TH1D* chisto2 = new TH1D("chisto2","chisto2",sqrt(Ne),0,2); TH1D* jhisto2 = new TH1D("jhisto2","jhisto2",50*taur,-5*taur,5*taur); TH1D* shisto2 = new TH1D("shisto2","shisto2",sqrt(Ne),0,amp); TRandom rand; rand.SetSeed(0); int success = 0, success2 = 0; for(int e = 0; e < Ne; e++) { if(e%100 == 0) cout<<"Event: "<<e<<std::endl; double shift=rand.Uniform(-4*taur,4*taur); QVector signal(N),signal2(N); QVector noise(N),noise2(N); signal.Initialize(0); signal2.Initialize(0); noise.Initialize(0); noise2.Initialize(0); for(int i = 0; i < N; i++) { double t = double(i-t0)-shift; noise[i] += rand.Gaus(0,sigma); noise2[i] += rand.Gaus(0,sigma); if(t < 0) continue; signal[i] += (-exp(-t/taur) + exp(-t/taud)); signal2[i] +=(-exp(-t/taur/taur_dev) + exp(-t/taud/taud_dev)); } signal *= amp/signal.GetMax(); signal2 *= amp/signal2.GetMax()/1.15; signal += noise; signal2 += noise2; QError err; err = of.Filter(signal); if(err != QERR_SUCCESS) continue; err = of.SetJitter(QOptimumFilter::J_LOCMAX); if(err != QERR_SUCCESS) continue; double jitter,chi2,amplitude,integral,left,right; err = of.GetInterpolated(jitter,chi2,amplitude,integral,left,right); if(err != QERR_SUCCESS) continue; ahisto-> Fill ( amplitude  )

◆ Fill() [2/7]

chisto Fill ( chi2  )

◆ Fill() [3/7]

shisto Fill ( diff cgain)

◆ Fill() [4/7]

shisto2 Fill ( diff2 cgain)

◆ Fill() [5/7]

jhisto Fill ( jitter-  shift)

◆ Fill() [6/7]

lhisto Fill ( left  )

◆ Fill() [7/7]

rhisto Fill ( right  )

◆ Fit()

shisto2 Fit ( fg  )

◆ for() [1/2]

for ( )

Definition at line 40 of file CheckOFShape.C.

References ap, exp(), t0, taud, and taur.

◆ for() [2/2]

for ( int  i = maxpos; i,
0;i--   
)

Definition at line 63 of file CheckOFShape.C.

References ap1filtered2, deltat20, deltat50, deltat80, and maxpos.

◆ if() [1/2]

if ( err = QERR_SUCCESS)

Definition at line 149 of file CheckOFShape.C.

References QOptimumFilter::GetFilteredShifted(), and of2.

◆ if() [2/2]

if ( success2  = = 1)

◆ Initialize() [1/2]

ap Initialize ( )

◆ Initialize() [2/2]

an Initialize ( sigma *sigma N)

◆ Load() [1/14]

gSystem Load ( "libbase"  )

◆ Load() [2/14]

gSystem Load ( "libcalderdata"  )

◆ Load() [3/14]

gSystem Load ( "libcaldertools"  )

◆ Load() [4/14]

gSystem Load ( "libcoretools"  )

◆ Load() [5/14]

gSystem Load ( "libdbbase"  )

◆ Load() [6/14]

gSystem Load ( "libdianadata"  )

◆ Load() [7/14]

gSystem Load ( "libglobalrw"  )

◆ Load() [8/14]

gSystem Load ( "liboptimumfilter"  )

◆ Load() [9/14]

gSystem Load ( "libpq"  )

◆ Load() [10/14]

gSystem Load ( "libqroot"  )

◆ Load() [11/14]

gSystem Load ( "libqstyle"  )

◆ Load() [12/14]

gSystem Load ( "libqstyleloader"  )

◆ Load() [13/14]

gSystem Load ( "librundatadb"  )

◆ Load() [14/14]

gSystem Load ( "libthreadwrapper"  )

◆ SaveAs()

std::cout<<"DP: "<<dp<<std::endl; c1-> SaveAs ( "checkof.pdf"  )

◆ SetLineColor()

ahisto2 SetLineColor ( kRed  )

Variable Documentation

◆ a

TF1 a

Definition at line 21 of file CheckOFShape.C.

◆ amp

double amp = 10

Definition at line 33 of file CheckOFShape.C.

Referenced by if().

◆ ap

ap =max

◆ ap1filtered2

ap1filtered2 = of2.GetOriginalAveragePulseFilteredShifted()

Definition at line 52 of file CheckOFShape.C.

Referenced by for().

◆ apmaxindex

int apmaxindex = ap.GetMaxIndex()

Definition at line 45 of file CheckOFShape.C.

◆ b

Definition at line 21 of file CheckOFShape.C.

◆ cbase

double cbase = ap1filtered2.GetMean(t0*3./4)

Definition at line 53 of file CheckOFShape.C.

◆ cgain

double cgain = ap1filtered2.GetMax()-ap1filtered2.GetMin()

Definition at line 54 of file CheckOFShape.C.

Referenced by if().

◆ deltat20

int deltat20 = maxpos

Definition at line 62 of file CheckOFShape.C.

Referenced by for().

◆ deltat50

int deltat50 = maxpos

Definition at line 60 of file CheckOFShape.C.

Referenced by for().

◆ deltat80

int deltat80 = maxpos

Definition at line 61 of file CheckOFShape.C.

Referenced by for().

◆ diff

double diff = of2.GetFilteredShifted()[maxpos+jitter-deltat80]-of2.GetFilteredShifted()[maxpos+jitter-deltat20]

◆ diff2

double diff2 = of2.GetFilteredShifted()[maxpos+jitter2-deltat80]-of2.GetFilteredShifted()[maxpos+jitter2-deltat20]

Definition at line 186 of file CheckOFShape.C.

◆ dp

double dp = (m1-m2)/sqrt(s1*s1+s2*s2)

Definition at line 254 of file CheckOFShape.C.

◆ err

err = of.Filter(signal2)

Definition at line 148 of file CheckOFShape.C.

◆ fg

TF1* fg = new TF1("fg","gaus")

Definition at line 246 of file CheckOFShape.C.

◆ fs

double fs = 1

Definition at line 24 of file CheckOFShape.C.

◆ m1

m1 = fg->GetParameter(1)

Definition at line 248 of file CheckOFShape.C.

◆ m2

m2 = fg->GetParameter(1)

Definition at line 248 of file CheckOFShape.C.

◆ max

max = ap.GetMax()-ap[0]

Definition at line 46 of file CheckOFShape.C.

Referenced by if().

◆ maxpos

int maxpos = ap1filtered2.GetMaxIndex()

◆ N

int N = 2048*fs

Definition at line 25 of file CheckOFShape.C.

◆ Ne

int Ne = 1e3

Definition at line 26 of file CheckOFShape.C.

◆ of

QOptimumFilter of(ap, an,-1, false) ( ap  ,
an  ,
1,
false   
)

◆ of2

QOptimumShapeFilter of2(ap, an,-1, false, 2) ( ap  ,
an  ,
1,
false  ,
 
)

Referenced by Fill(), and if().

◆ ofbase

double ofbase = ap1filtered2.GetMean(3./4*t0)

Definition at line 56 of file CheckOFShape.C.

Referenced by if().

◆ s1

s1 = fg->GetParameter(2)

Definition at line 248 of file CheckOFShape.C.

Referenced by QDianaProcessStatus::QDianaProcessStatus().

◆ s2

s2 = fg->GetParameter(2)

Definition at line 248 of file CheckOFShape.C.

◆ sigma

double sigma = 1*sqrt(fs)

Definition at line 32 of file CheckOFShape.C.

◆ success2

success2

Definition at line 189 of file CheckOFShape.C.

◆ t0

double t0 = 200*fs

Definition at line 27 of file CheckOFShape.C.

Referenced by for(), and if().

◆ taud

double taud = 200*fs

Definition at line 29 of file CheckOFShape.C.

Referenced by for().

◆ taud_dev

double taud_dev = 1

Definition at line 31 of file CheckOFShape.C.

◆ taur

double taur = 10*fs

Definition at line 28 of file CheckOFShape.C.

Referenced by for().

◆ taur_dev

double taur_dev = 1

Definition at line 30 of file CheckOFShape.C.