void TestWithRealTrace(){ gROOT->Reset(); gStyle->SetOptStat(0); double *x = new double[1000]; float *y = new float[1000]; float *z = new float[1000]; int iter = 0, TankId, IsMisfired; long int EventId; double Signal, PredictedSignal, Distance, RiseTime, Energy, EnergyError, Theta, Zeta; double S1000, S1000Error; double ConvolvedRiseTime, DeConvolvedRiseTime; double ConvolvedSignal, DeconvolvedSignal; ifstream Data; Data.open("1178901_149.txt"); while (Data >> x[iter] >> y[iter]>> z[iter] >> Signal >>EventId >> TankId >> Distance >> RiseTime >> Zeta >> Energy >> EnergyError >> Theta >> S1000 >> S1000Error){ y[iter] /= 3; z[iter] /= 3; iter++; } Data.close(); const int NoBins = iter; TH1F *h = new TH1F(Form("h %d %d", EventId, TankId),"FADC trace",NoBins-1,x[0],x[iter-1]); h->GetXaxis()->SetRange(x[0], x[iter]); for (int i=0;iSetBinContent(i+1,y[i]); h->GetXaxis()->SetTitle("t [25 ns]"); h->GetYaxis()->SetTitle("Signal [VEM]"); //deconvolve original trace to see comparison, put in new histogram double SPRSignal = GoldDeconvolveTrace(y, NoBins); TH1F *h2 = new TH1F(Form("%d %d", EventId, TankId),Form("%d %d", EventId, TankId),NoBins-1 ,x[0],x[NoBins-1]); for (int i=0;iSetBinContent(i+1,y[i]); h2->GetXaxis()->SetTitle("t [ns]"); h2->GetYaxis()->SetTitle("Signal [VEM]"); h2->SetLineColor(kRed); h2->SetFillColor(kRed); //Reconvolve this trace to see comparison, put in new histogram ConvoluteTrace(y, NoBins); TH1F *h3 = new TH1F("Reconvolved","Reconvolved",NoBins-1 ,x[0],x[NoBins-1]); for (int i=0;iSetBinContent(i,y[i]/SPRSignal); h3->GetXaxis()->SetTitle("t [ns]"); h3->GetYaxis()->SetTitle("Signal [VEM]"); h3->SetLineColor(kBlue); TCanvas* Canvas=new TCanvas("c1","c1"); Canvas->cd(); h2->Draw("B"); h->Draw("same"); h3->Draw("same"); TLegend *legend=new TLegend(0.61,0.71,0.77,0.88); legend->SetTextFont(72); legend->SetTextSize(0.04); legend->SetFillStyle ( 0 ); legend->SetBorderSize ( 0 ); legend->SetFillColor ( 0 ); legend->AddEntry(h,"Before Deconvolution","l"); legend->AddEntry(h3,"After Re-convolution","l"); legend->Draw("same"); }; double GoldDeconvolveTrace(float Trace[], const int NoBins){ //Deconvolve trace by SPR //Define the spectrum TSpectrum *spec = new TSpectrum(); //set SPR in an array; const float *SPR = new float[NoBins]; const double SPRSignal = 0; const double BinSize = 25; for (int j = 0; j < NoBins; ++j){ //this is the response function SPR[j]=1*(exp(-1*((j*BinSize)+12.5)/67.0) - exp(-1*((j*BinSize)+12.5)/13.0)); //SPR[j]=1.*(exp(-1*((j*BinSize)+(BinSize/2))/67.0) - exp(-1*((j*BinSize)+(BinSize/2))/13.0)); SPRSignal += SPR[j]; } //deconvolve the trace spec->Deconvolution(Trace,SPR,NoBins, 100, 20, 1.5); delete [] SPR; return SPRSignal; }; void ConvoluteTrace(float Trace[], const int NoBins){ //set SPR in an array; float *SPR = new float[NoBins];//define the response function of the system for (int j = 0; j < NoBins; ++j) //this is the response function SPR[j]=1*(exp(-1*((j*25.0)+(25.0/2))/67.0) - exp(-1*((j*25.0)+(25.0/2))/13.0)); //convolute the trace float *convolutedTrace = new float[NoBins]; float convolutedTotalSignal = 0; for (int i=0;i