From 68c7d73869b4c37f3230fc26816255789fdf266c Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Tue, 19 Aug 2014 16:08:54 +0200 Subject: [PATCH] s-curves: 4xbanks version This version takes into account that the s-curve measurements for M-26 test one bank (out of the four banks) at a time. During the test of this one bank, the discriminator values of the other banks is set to 255 (max). The new version takes this into account assuming a certain order of measuring the s-curves for banks A, B, C, D. --- s-curves/Makefile | 10 +- s-curves/README.txt | 2 +- ...ti_short.c => process_rootmulti_4xbanks.c} | 102 +++++---- ...lti.c => process_rootmulti_4xbanks_long.c} | 212 +++++++++--------- 4 files changed, 170 insertions(+), 156 deletions(-) rename s-curves/{process_hld_rootmulti_short.c => process_rootmulti_4xbanks.c} (93%) rename s-curves/{process_hld_rootmulti.c => process_rootmulti_4xbanks_long.c} (85%) diff --git a/s-curves/Makefile b/s-curves/Makefile index ec9fb7d..d4ef599 100644 --- a/s-curves/Makefile +++ b/s-curves/Makefile @@ -3,11 +3,11 @@ CFLAGS=-c -g -Wall -std=c++11 `root-config --cflags` LDFLAGS=`root-config --glibs` CLDFLAGS = -std=c++11 `root-config --cflags --glibs` -lboost_system -lboost_filesystem -all: process_hld_rootmulti.c process_hld_rootmulti_short.c - $(CC) $(CLDFLAGS) process_hld_rootmulti.c -o process_hld_rootmulti - $(CC) $(CLDFLAGS) process_hld_rootmulti_short.c -o process_hld_rootmulti_short +all: process_rootmulti_4xbanks.c process_rootmulti_4xbanks_long.c + $(CC) $(CLDFLAGS) process_rootmulti_4xbanks.c -o process_rootmulti_4xbanks + $(CC) $(CLDFLAGS) process_rootmulti_4xbanks_long.c -o process_rootmulti_4xbanks_long clean: - rm -f process_hld_rootmulti - rm -f process_hld_rootmulti_short + rm -f process_rootmulti_4xbanks + rm -f process_rootmulti_4xbanks_long diff --git a/s-curves/README.txt b/s-curves/README.txt index fb04bc1..99f4373 100644 --- a/s-curves/README.txt +++ b/s-curves/README.txt @@ -7,7 +7,7 @@ was then reconstructed to be put into this Git repository. Sensors running in the S-Curve test mode create a custom output stream. The data is is received from the event builder and written to HLD files. Those .hld files then have to be processed by the C++ program -`process_hld_rootmulti` which organizes the data as a TTree in a ROOT file. +`process_rootmulti_4xbanks` which organizes the data as a TTree in a ROOT file. The ROOT data file can then be further analyzed with a simple ROOT macro. Authors diff --git a/s-curves/process_hld_rootmulti_short.c b/s-curves/process_rootmulti_4xbanks.c similarity index 93% rename from s-curves/process_hld_rootmulti_short.c rename to s-curves/process_rootmulti_4xbanks.c index aff41f5..a7bbaa1 100644 --- a/s-curves/process_hld_rootmulti_short.c +++ b/s-curves/process_rootmulti_4xbanks.c @@ -1,6 +1,4 @@ #include - - #include #include #include @@ -601,7 +599,7 @@ int main(int argc, char *argv[]) { printf("\n-------------\n"); printf("Entries: %i\n",entries); - printf("Seperate runs for different banks!\n"); + printf("Seperate runs for 4 different banks!\n"); scurveTree->SetBranchAddress( "threshold" , &threshold ); scurveTree->SetBranchAddress( "pixelprob" , pixelprob ); @@ -612,37 +610,43 @@ int main(int argc, char *argv[]) { int thresh_tmp=255; int bank=-1; - for(int i=0;iGetEntry(i); - - if ( thresh_tmp>threshold ) - { - printf("X "); - if( bank!=-1 ) { printf("%i !\n", thresh_tmp); } - bank++; - scurveTreeInd[bank] = new TTree( Form("scurves%i",bank), Form("scurves%i",bank) ); - scurveTreeInd[bank] -> Branch("threshold" , &threshold , "threshold/s" , 32000); - scurveTreeInd[bank] -> Branch("pixelprob" , pixelprob , "pixelprob[663552]/F" , 32000); - scurveTreeInd[bank] -> Branch("frames" , rowcount , "frames[576]/s" , 32000); - - printf("Entries for bank %i found! Process threshold %i ... ", bank, threshold ); - } - else if ( thresh_tmp+1Fill(); - thresh_tmp = threshold; - } - - printf("%i !\n", thresh_tmp); - + if (entries % 4 != 0){ + printf("Error: %d not divisible by 4!", entries); + exit(1); + } + + int rest; + int step; + rest = 256 - (256 / (entries / 4)) * (entries / 4); + step = (256 - rest) / ((entries / 4)-1); + //printf("rest,step: %d %d\n", rest, step); + + for (int j=0;j<4;j++){ + for(int i=0;i<(entries/4);i++) + { + + if (i == 0){ + printf("Filling bank %i: thresholds ", j); + scurveTreeInd[j] = new TTree( Form("scurves%i",j), Form("scurves%i",j) ); + scurveTreeInd[j] -> Branch("threshold" , &threshold , "threshold/s" , 32000); + scurveTreeInd[j] -> Branch("pixelprob" , pixelprob , "pixelprob[663552]/F" , 32000); + scurveTreeInd[j] -> Branch("frames" , rowcount , "frames[576]/s" , 32000); + } + scurveTree->GetEntry(j*(entries/4)+i); + printf("%i ... ", threshold ); + + scurveTreeInd[j]->Fill(); + + if (i==(entries/4)-1){ + printf("\n"); + } + + } + } + printf("-------------\n"); - for(int i=0;iWrite("",TObject::kOverwrite); outFile->Write(); @@ -651,23 +655,23 @@ int main(int argc, char *argv[]) { } printf("-------------\n"); - pixelprob_arr = new Float_t[entries*1152*576]; - //canv = new TCanvas("canv","canv",600,400); - //canv->cd(); - - TH1F *histos, *histo[3]; - histos = new TH1F( "test", "test" , 255,0.,255.); - histo[0] = new TH1F( "mean" , "mean" , 2550,0.,255.); - histo[1] = new TH1F( "sigma" , "sigma" , 1000,0.,100.); - histo[2] = new TH1F( "chi2" , "chi2" , 1000,0.,1.); - - TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100); - - int chicount; - int meanmin, meanmax; - float meanmean; - float vsigma; - float vtmp=1; +// pixelprob_arr = new Float_t[entries*1152*576]; +// //canv = new TCanvas("canv","canv",600,400); +// //canv->cd(); +// +// TH1F *histos, *histo[3]; +// histos = new TH1F( "test", "test" , 255,0.,255.); +// histo[0] = new TH1F( "mean" , "mean" , 2550,0.,255.); +// histo[1] = new TH1F( "sigma" , "sigma" , 1000,0.,100.); +// histo[2] = new TH1F( "chi2" , "chi2" , 1000,0.,1.); +// +// TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100); +// +// int chicount; +// int meanmin, meanmax; +// float meanmean; +// float vsigma; +// float vtmp=1; // printf("Perform fitting of S-Curces:\n"); // diff --git a/s-curves/process_hld_rootmulti.c b/s-curves/process_rootmulti_4xbanks_long.c similarity index 85% rename from s-curves/process_hld_rootmulti.c rename to s-curves/process_rootmulti_4xbanks_long.c index 88fd1a5..f09d347 100644 --- a/s-curves/process_hld_rootmulti.c +++ b/s-curves/process_rootmulti_4xbanks_long.c @@ -1,6 +1,4 @@ #include - - #include #include #include @@ -155,7 +153,7 @@ void analyze(void){ // printf("Error: aaa0aaa0 not found (%s)! Wrong ID.\n",hword); // exit(0); // } - an_mode++; // Dont care about the ID + an_mode++; break; case 4: an_mode++; // ignore status @@ -266,7 +264,7 @@ void analyze(void){ if(row>=576) {printf("%s %i","Wrong Row Number in 'row' =", row); exit(0);} rowcount[row]++; // printf("%i %i\n", threshold, row); - for(unsigned int strpos=0;strposSetBranchAddress( "threshold" , &threshold ); scurveTree->SetBranchAddress( "pixelprob" , pixelprob ); @@ -612,35 +610,43 @@ int main(int argc, char *argv[]) { int thresh_tmp=255; int bank=-1; - for(int i=0;iGetEntry(i); - - if ( thresh_tmp>threshold ) - { - if( bank!=-1 ) { printf("%i !\n", thresh_tmp); } - bank++; - scurveTreeInd[bank] = new TTree( Form("scurves%i",bank), Form("scurves%i",bank) ); - scurveTreeInd[bank] -> Branch("threshold" , &threshold , "threshold/s" , 32000); - scurveTreeInd[bank] -> Branch("pixelprob" , pixelprob , "pixelprob[663552]/F" , 32000); - scurveTreeInd[bank] -> Branch("frames" , rowcount , "frames[576]/s" , 32000); - - printf("Entries for bank %i found! Process threshold %i ... ", bank, threshold ); - } - else if ( thresh_tmp+1Fill(); - thresh_tmp = threshold; - } - - printf("%i !\n", thresh_tmp); - + if (entries % 4 != 0){ + printf("Error: %d not divisible by 4!", entries); + exit(1); + } + + int rest; + int step; + rest = 256 - (256 / (entries / 4)) * (entries / 4); + step = (256 - rest) / ((entries / 4)-1); + //printf("rest,step: %d %d\n", rest, step); + + for (int j=0;j<4;j++){ + for(int i=0;i<(entries/4);i++) + { + + if (i == 0){ + printf("Filling bank %i: thresholds ", j); + scurveTreeInd[j] = new TTree( Form("scurves%i",j), Form("scurves%i",j) ); + scurveTreeInd[j] -> Branch("threshold" , &threshold , "threshold/s" , 32000); + scurveTreeInd[j] -> Branch("pixelprob" , pixelprob , "pixelprob[663552]/F" , 32000); + scurveTreeInd[j] -> Branch("frames" , rowcount , "frames[576]/s" , 32000); + } + scurveTree->GetEntry(j*(entries/4)+i); + printf("%i ... ", threshold ); + + scurveTreeInd[j]->Fill(); + + if (i==(entries/4)-1){ + printf("\n"); + } + + } + } + printf("-------------\n"); - for(int i=0;iWrite("",TObject::kOverwrite); outFile->Write(); @@ -649,27 +655,27 @@ int main(int argc, char *argv[]) { } printf("-------------\n"); - pixelprob_arr = new Float_t[entries*1152*576]; - canv = new TCanvas("canv","canv",600,400); - canv->cd(); - - TH1F *histos, *histo[3]; - histos = new TH1F( "test", "test" , 255,0.,255.); - histo[0] = new TH1F( "mean" , "mean" , 2550,0.,255.); - histo[1] = new TH1F( "sigma" , "sigma" , 1000,0.,100.); - histo[2] = new TH1F( "chi2" , "chi2" , 1000,0.,1.); - - TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100); - - int chicount; - int meanmin, meanmax; - float meanmean; - float vsigma; - float vtmp=1; - - printf("Perform fitting of S-Curces:\n"); - - for(int ba=0;bacd(); + + TH1F *histos, *histo[3]; + histos = new TH1F( "test", "test" , 255,0.,255.); + histo[0] = new TH1F( "mean" , "mean" , 2550,0.,255.); + histo[1] = new TH1F( "sigma" , "sigma" , 1000,0.,100.); + histo[2] = new TH1F( "chi2" , "chi2" , 1000,0.,1.); + + TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100); + + int chicount; + int meanmin, meanmax; + float meanmean; + float vsigma; + float vtmp=1; + + printf("Perform fitting of S-Curces:\n"); + + for(int ba=0;ba<4;ba++) { paraTree[ba] = new TTree( Form("para%i",ba), Form("para%i",ba)); paraTree[ba] -> Branch("pixel" , &pixel , "pixel/i" , 32000); @@ -697,15 +703,15 @@ int main(int argc, char *argv[]) { } if( TMath::RMS(entries,&pixelprob_arr[pix*entries])!=0 ) { - delete histos; - histos = new TH1F( "test", "test" , 255,0.,255.); + delete histos; + histos = new TH1F( "test", "test" , 255,0.,255.); meanmin=0; meanmax=255; for(int thr=0;thrFill(thr,pixelprob_arr[pix*entries+thr]); + histos->Fill(thr,pixelprob_arr[pix*entries+thr]); if( pixelprob_arr[pix*entries+thr]!=1 && meanmin==0 ) { meanmin=thr-1; } if( pixelprob_arr[pix*entries+thr]==0 && vtmp!=0 ) { meanmax=thr; } @@ -715,8 +721,8 @@ int main(int argc, char *argv[]) { vsigma = (meanmax-meanmin)/2.; meanmean = (meanmax+meanmin)/2.; erf->SetParameters(meanmean,vsigma); - histos->Fit(erf,"Q"); - + histos->Fit(erf,"Q"); + pixel = pix; mean = erf->GetParameter(0); sigma = erf->GetParameter(1)/TMath::Sqrt(2); @@ -731,7 +737,7 @@ int main(int argc, char *argv[]) { while( (meanmeanmax || sigma>75 || sigma<1) && chicount<10) { erf->SetParameters(meanmean,1.*(chicount+1)); - histos->Fit(erf,"QM"); + histos->Fit(erf,"QM"); pixel = pix; mean = erf->GetParameter(0); sigma = erf->GetParameter(1)/TMath::Sqrt(2); @@ -744,36 +750,36 @@ int main(int argc, char *argv[]) { //canv->Update(); } - histo[0]->Fill(mean); - histo[1]->Fill(sigma); - histo[2]->Fill(chi2); - - if(sigma>=75 || chi2>=100) - { - //printf("\r----- \n"); - //printf("\r--> "); - //printf("%7i (%10i) %10.2f (%10i) %10.2f (%10f) %10.3f\n", pixel, meanmin, mean,meanmax, sigma,vsigma, chi2); - //histos->Draw(); - //canv->Update(); - } - - if( sigma<1 ) - { - //printf("\r----- \n"); - //printf("\r--> "); - //printf("%7i (%10i) %10.2f (%10i) %10.2f (%10f) %10.3f\n", pixel, meanmin, mean,meanmax, sigma,vsigma, chi2); - //histos->Draw(); - //canv->Update(); - } - + histo[0]->Fill(mean); + histo[1]->Fill(sigma); + histo[2]->Fill(chi2); +// +// if(sigma>=75 || chi2>=100) +// { +// //printf("\r----- \n"); +// //printf("\r--> "); +// //printf("%7i (%10i) %10.2f (%10i) %10.2f (%10f) %10.3f\n", pixel, meanmin, mean,meanmax, sigma,vsigma, chi2); +// //histos->Draw(); +// //canv->Update(); +// } +// +// if( sigma<1 ) +// { +// //printf("\r----- \n"); +// //printf("\r--> "); +// //printf("%7i (%10i) %10.2f (%10i) %10.2f (%10f) %10.3f\n", pixel, meanmin, mean,meanmax, sigma,vsigma, chi2); +// //histos->Draw(); +// //canv->Update(); +// } +// paraTree[ba]->Fill(); - - // if(1) - // { - // canv->Update(); - // } - - // printf("\r%9i %5i %5i (%i) : %6.2f \u00b1 %5.2f %6.2f \u00b1 %5.2f %6.2f\n", pix, (int)(pix/1152),pix%1152, int((pix%1152)/288), erf->GetParameter(0), erf->GetParError(0), erf->GetParameter(1)/TMath::Sqrt(2), erf->GetParError(1)/TMath::Sqrt(2), erf->GetChisquare()); +// +// // if(1) +// // { +// // canv->Update(); +// // } +// +// // printf("\r%9i %5i %5i (%i) : %6.2f \u00b1 %5.2f %6.2f \u00b1 %5.2f %6.2f\n", pix, (int)(pix/1152),pix%1152, int((pix%1152)/288), erf->GetParameter(0), erf->GetParError(0), erf->GetParameter(1)/TMath::Sqrt(2), erf->GetParError(1)/TMath::Sqrt(2), erf->GetChisquare()); } } @@ -781,16 +787,16 @@ int main(int argc, char *argv[]) { outFile->Write(); // outFile->Save(); } - - canv->Divide(3,1); - canv->cd(1); - histo[0]->Draw(); - canv->cd(2); - histo[1]->Draw(); - canv->cd(3); - histo[2]->Draw(); - - canv->Update(); +// +// canv->Divide(3,1); +// canv->cd(1); +// histo[0]->Draw(); +// canv->cd(2); +// histo[1]->Draw(); +// canv->cd(3); +// histo[2]->Draw(); +// +// canv->Update(); outFile->Write(); outFile->Save(); @@ -811,8 +817,12 @@ int main(int argc, char *argv[]) { printf("\n%s created\n",Form("%s",outFileName.Data())); printf("Finished!\n"); printf("-------------\n"); - theApp.Run(kTRUE); + gApplication->Terminate(); + //theApp.Run(kTRUE); // ------------------------------------------ - return 0; + + + + } -- 2.43.0