From 555b182c48e18c19ef57e1833e6b684834c8cb56 Mon Sep 17 00:00:00 2001
From: Philipp Klaus <klaus@physik.uni-frankfurt.de>
Date: Tue, 19 Aug 2014 16:19:03 +0200
Subject: [PATCH] s-curves: view_ scripts added to analyze ROOT script

---
 s-curves/README.txt          |   3 +-
 s-curves/view_all_averages.c | 231 ++++++++++++++++++++++++
 s-curves/view_rootfile.c     | 328 +++++++++++++++++++++++++++++++++++
 3 files changed, 561 insertions(+), 1 deletion(-)
 create mode 100644 s-curves/view_all_averages.c
 create mode 100644 s-curves/view_rootfile.c

diff --git a/s-curves/README.txt b/s-curves/README.txt
index 99f4373..0e36b24 100644
--- a/s-curves/README.txt
+++ b/s-curves/README.txt
@@ -8,7 +8,8 @@ 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_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.
+The ROOT data file can then be further analyzed with a simple ROOT macro,
+such as `view_all_averages.c` and `view_rootfile.c`.
 
 Authors
 -------
diff --git a/s-curves/view_all_averages.c b/s-curves/view_all_averages.c
new file mode 100644
index 0000000..16aff4f
--- /dev/null
+++ b/s-curves/view_all_averages.c
@@ -0,0 +1,231 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <cmath>
+
+#include <TTree.h>
+#include <TFile.h>
+#include "TROOT.h"
+#include "TObject.h"
+#include "TBrowser.h"
+#include "TH1F.h"
+#include "TMath.h"
+#include "TF1.h"
+#include "TCanvas.h"
+#include "TRandom3.h"
+#include "TApplication.h"
+
+
+int view_all_averages() {
+    
+    cout << "Starting ROOT File analysis\n" << endl;
+
+    //TFile *rfile1 = new TFile("dis_discri_test4.root","READ");
+    //TFile *rfile1 = new TFile("from_Samir/output.root","READ");
+    TFile *rfile1 = new TFile("./output.root","READ");
+    //TFile *rfile1 = new TFile("../hld/sensor_blackbox1/test_10.root","READ");
+    //TFile *rfile1 = new TFile("../hld/sensor_blackbox1/final_multi_50.root","READ");
+    if ( rfile1->IsOpen() ) printf("file opened successfully\n");
+    
+    UShort_t threshold;
+    //Float_t* pixelprob;
+    Float_t pixelprob[576*1152];
+    int A_best_1e7 = 0;
+    int A_best_1e6 = 0;
+    int A_best_1e5 = 0;
+    Float_t A_best_1e7f = 1.;
+    Float_t A_best_1e6f = 1.;
+    Float_t A_best_1e5f = 1.;
+    int B_best_1e7 = 0;
+    int B_best_1e6 = 0;
+    int B_best_1e5 = 0;
+    Float_t B_best_1e7f = 1.;
+    Float_t B_best_1e6f = 1.;
+    Float_t B_best_1e5f = 1.;
+    int C_best_1e7 = 0;
+    int C_best_1e6 = 0;
+    int C_best_1e5 = 0;
+    Float_t C_best_1e7f = 1.;
+    Float_t C_best_1e6f = 1.;
+    Float_t C_best_1e5f = 1.;
+    int D_best_1e7 = 0;
+    int D_best_1e6 = 0;
+    int D_best_1e5 = 0;
+    Float_t D_best_1e7f = 1.;
+    Float_t D_best_1e6f = 1.;
+    Float_t D_best_1e5f = 1.;
+
+    canv    = new TCanvas("canv","canv",600,400);
+    canv->cd(1);
+    hist1   = new TH1F( "scurve1",  "S-Curve" , 255,0.,255.);
+    hist2   = new TH1F( "scurve2",  "S-Curve" , 255,0.,255.);
+    hist3   = new TH1F( "scurve3",  "S-Curve" , 255,0.,255.);
+    hist4   = new TH1F( "scurve4",  "S-Curve" , 255,0.,255.);
+    hist1->SetLineColor( 1);
+    hist2->SetLineColor( 2);
+    hist3->SetLineColor( 3);
+    hist4->SetLineColor( 4);
+
+    TTree *scurveTree = (TTree *)rfile1->Get("scurves0");
+    scurveTree->SetBranchAddress( "threshold"   , &threshold);
+    scurveTree->SetBranchAddress( "pixelprob"   , pixelprob);
+
+    int entries = (int) scurveTree->GetEntries();
+    int rest = 256 - (256 / entries) * entries;
+    int step = (256 - rest) / (entries-1);
+    int scalefactor = step;
+    cout << "Found " << entries << " entries (thresholds), using stepsize " << scalefactor << endl;
+    for(int i=0;i<entries;i++){
+        scurveTree->GetEntry(i);
+        Float_t pix_avg = 0.;
+        for (int pix_id = 0; pix_id < 576*1152; pix_id++){
+            pix_avg += pixelprob[pix_id];
+        }
+        pix_avg = pix_avg/(576*1152/4);
+        //printf(">>> %f\n",abs((pix_avg-0.00001)));
+        if ( abs((pix_avg-0.00001)) < abs((A_best_1e5f-0.00001)) ){
+            A_best_1e5f = pix_avg;
+            A_best_1e5  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.000001)) < abs((A_best_1e6f-0.000001)) ){
+            A_best_1e6f = pix_avg;
+            A_best_1e6  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.0000001)) < abs((A_best_1e7f-0.0000001)) ){
+            A_best_1e7f = pix_avg;
+            A_best_1e7  = i*scalefactor;
+        }
+        
+        hist1->Fill(i*scalefactor, pix_avg);
+    }
+    
+    TTree *scurveTree = (TTree *)rfile1->Get("scurves1");
+    scurveTree->SetBranchAddress( "threshold"   , &threshold);
+    scurveTree->SetBranchAddress( "pixelprob"   , pixelprob);
+    
+    int entries = (int) scurveTree->GetEntries();
+    rest = 256 - (256 / entries) * entries;
+    step = (256 - rest) / (entries-1);
+    scalefactor = step;
+    cout << "Found " << entries << " entries (thresholds), using stepsize " << scalefactor << endl;
+    for(int i=0;i<entries;i++){
+        scurveTree->GetEntry(i);
+        pix_avg = 0.;
+        for (int pix_id = 0; pix_id < 576*1152; pix_id++){
+            pix_avg += pixelprob[pix_id];
+        }
+        pix_avg = pix_avg/(576*1152/4);
+        if ( abs((pix_avg-0.00001)) < abs((B_best_1e5f-0.00001)) ){
+            B_best_1e5f = pix_avg;
+            B_best_1e5  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.000001)) < abs((B_best_1e6f-0.000001)) ){
+            B_best_1e6f = pix_avg;
+            B_best_1e6  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.0000001)) < abs((B_best_1e7f-0.0000001)) ){
+            B_best_1e7f = pix_avg;
+            B_best_1e7  = i*scalefactor;
+        }
+
+        hist2->Fill(i*scalefactor, pix_avg);
+    }
+    
+    TTree *scurveTree = (TTree *)rfile1->Get("scurves2");
+    scurveTree->SetBranchAddress( "threshold"   , &threshold);
+    scurveTree->SetBranchAddress( "pixelprob"   , pixelprob);
+    
+    int entries = (int) scurveTree->GetEntries();
+    rest = 256 - (256 / entries) * entries;
+    step = (256 - rest) / (entries-1);
+    scalefactor = step;
+    cout << "Found " << entries << " entries (thresholds), using stepsize " << scalefactor << endl;
+    for(int i=0;i<entries;i++){
+        scurveTree->GetEntry(i);
+        pix_avg = 0.;
+        for (int pix_id = 0; pix_id < 576*1152; pix_id++){
+            pix_avg += pixelprob[pix_id];
+        }
+        pix_avg = pix_avg/(576*1152/4);
+        if ( abs((pix_avg-0.00001)) < abs((C_best_1e5f-0.00001)) ){
+            C_best_1e5f = pix_avg;
+            C_best_1e5  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.000001)) < abs((C_best_1e6f-0.000001)) ){
+            C_best_1e6f = pix_avg;
+            C_best_1e6  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.0000001)) < abs((C_best_1e7f-0.0000001)) ){
+            C_best_1e7f = pix_avg;
+            C_best_1e7  = i*scalefactor;
+        }
+
+        hist3->Fill(i*scalefactor, pix_avg);
+    }
+
+    TTree *scurveTree = (TTree *)rfile1->Get("scurves3");
+    scurveTree->SetBranchAddress( "threshold"   , &threshold);
+    scurveTree->SetBranchAddress( "pixelprob"   , pixelprob);
+    
+    int entries = (int) scurveTree->GetEntries();
+    rest = 256 - (256 / entries) * entries;
+    step = (256 - rest) / (entries-1);
+    scalefactor = step;
+    cout << "Found " << entries << " entries (thresholds), using stepsize " << scalefactor << endl;
+    for(int i=0;i<entries;i++){
+        scurveTree->GetEntry(i);
+        pix_avg = 0.;
+        for (int pix_id = 0; pix_id < 576*1152; pix_id++){
+            pix_avg += pixelprob[pix_id];
+        }
+        pix_avg = pix_avg/(576*1152/4);
+        if ( abs((pix_avg-0.00001)) < abs((D_best_1e5f-0.00001)) ){
+            D_best_1e5f = pix_avg;
+            D_best_1e5  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.000001)) < abs((D_best_1e6f-0.000001)) ){
+            D_best_1e6f = pix_avg;
+            D_best_1e6  = i*scalefactor;
+        }
+        if ( abs((pix_avg-0.0000001)) < abs((D_best_1e7f-0.0000001)) ){
+            D_best_1e7f = pix_avg;
+            D_best_1e7  = i*scalefactor;
+        }
+
+        hist4->Fill(i*scalefactor, pix_avg);
+    }
+
+    hist1->RebinX(scalefactor);
+    hist1->Draw("");
+    hist2->RebinX(scalefactor);
+    hist2->Draw("same");
+    hist3->RebinX(scalefactor);
+    hist3->Draw("same");
+    hist4->RebinX(scalefactor);
+    hist4->Draw("same");
+    
+    leg = new TLegend(0.8,0.1,0.94,0.7);
+    leg->SetHeader("Average");
+    leg->AddEntry(hist1,"A","l");
+    leg->AddEntry(hist2,"B","l");
+    leg->AddEntry(hist3,"C","l");
+    leg->AddEntry(hist4,"D","l");
+
+    leg->Draw();
+    
+    printf("FHR analysis:     1e-7     1e-6     1e-5\n");
+    printf("      A           %03d      %03d      %03d\n", A_best_1e7, A_best_1e6, A_best_1e5);
+    printf("      B           %03d      %03d      %03d\n", B_best_1e7, B_best_1e6, B_best_1e5);
+    printf("      C           %03d      %03d      %03d\n", C_best_1e7, C_best_1e6, C_best_1e5);
+    printf("      D           %03d      %03d      %03d\n", D_best_1e7, D_best_1e6, D_best_1e5);
+    
+    //gApplication->Terminate();
+  return 1;
+    
+}
+
+
+
+
+
diff --git a/s-curves/view_rootfile.c b/s-curves/view_rootfile.c
new file mode 100644
index 0000000..327234b
--- /dev/null
+++ b/s-curves/view_rootfile.c
@@ -0,0 +1,328 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <TTree.h>
+#include <TFile.h>
+#include "TROOT.h"
+#include "TObject.h"
+#include "TBrowser.h"
+#include "TH1F.h"
+#include "TMath.h"
+#include "TF1.h"
+#include "TCanvas.h"
+#include "TRandom3.h"
+#include "TApplication.h"
+
+
+int view_rootfile() {
+    
+    cout << "Starting ROOT File analysis\n" << endl;
+
+    //TFile *rfile1 = new TFile("dis_discri_test4.root","READ");
+    TFile *rfile1 = new TFile("from_Samir/output.root","READ");
+    //TFile *rfile1 = new TFile("../hld/sensor_blackbox1/test_10.root","READ");
+    //TFile *rfile1 = new TFile("../hld/sensor_blackbox1/final_multi_50.root","READ");
+    if ( rfile1->IsOpen() ) printf("file opened successfully\n");
+    
+    TTree *scurveTree = (TTree *)rfile1->Get("scurves3");
+    
+    UShort_t threshold;
+    //Float_t* pixelprob;
+    Float_t pixelprob[576*1152];
+    
+//     // Tests
+//     Float_t number[] = { 31., 28., 31., 30., 31., 30., 31., 31., 30., 31., 30., 31. };
+//     printf("> %f\n",number[0]);
+//     printf("> %f\n",number[1]);
+//     pixelprob = number;
+//     printf("> %f\n",*pixelprob++);
+//     printf("> %f\n",*pixelprob);
+//     return 0;
+    
+    scurveTree->SetBranchAddress( "threshold"   , &threshold);
+    scurveTree->SetBranchAddress( "pixelprob"   , pixelprob);
+
+    canv    = new TCanvas("canv","canv",600,400);
+    canv->cd(1);
+    hist1   = new TH1F( "scurve1",  "S-Curve" , 255,0.,255.);
+    hist2   = new TH1F( "scurve2",  "S-Curve" , 255,0.,255.);
+    hist3   = new TH1F( "scurve3",  "S-Curve" , 255,0.,255.);
+    hist4   = new TH1F( "scurve4",  "S-Curve" , 255,0.,255.);
+    hist5   = new TH1F( "scurve5",  "S-Curve" , 255,0.,255.);
+    hist6   = new TH1F( "scurve6",  "S-Curve" , 255,0.,255.);
+    hist7   = new TH1F( "scurve7",  "S-Curve" , 255,0.,255.);
+    hist8   = new TH1F( "scurve8",  "S-Curve" , 255,0.,255.);
+    hist9   = new TH1F( "scurve9",  "S-Curve" , 255,0.,255.);
+    hist10  = new TH1F( "scurve10", "S-Curve" , 255,0.,255.);
+    hist11  = new TH1F( "scurve11", "S-Curve" , 255,0.,255.);
+    hist12  = new TH1F( "scurve12", "S-Curve" , 255,0.,255.);
+    hist13  = new TH1F( "scurve13", "S-Curve" , 255,0.,255.);
+    hist1->SetLineColor( 1);
+    hist2->SetLineColor( 2);
+    hist3->SetLineColor( 3);
+    hist4->SetLineColor( 4);
+    hist5->SetLineColor( 5);
+    hist6->SetLineColor( 6);
+    hist7->SetLineColor( 7);
+    hist8->SetLineColor( 8);
+    hist9->SetLineColor( 9);
+    hist10->SetLineColor(11);
+    hist11->SetLineColor(12);
+    hist12->SetLineColor(13);
+    hist13->SetLineColor(14);
+
+
+    int entries = (int) scurveTree->GetEntries();
+    cout << "Found " << entries << " entries (thresholds)" << endl;
+    for(int i=0;i<entries;i++){
+        scurveTree->GetEntry(i);
+// Block A
+// Row 500
+//         hist1->Fill(i, pixelprob[500*1152+0]);
+//         hist2->Fill(i, pixelprob[500*1152+23]);
+//         hist3->Fill(i, pixelprob[500*1152+47]);
+//         hist4->Fill(i, pixelprob[500*1152+71]);
+//         hist5->Fill(i, pixelprob[500*1152+95]);
+//         hist6->Fill(i, pixelprob[500*1152+119]);
+//         hist7->Fill(i, pixelprob[500*1152+143]);
+//         hist8->Fill(i, pixelprob[500*1152+167]);
+//         hist9->Fill(i, pixelprob[500*1152+191]);
+//         hist10->Fill(i,pixelprob[500*1152+215]);
+//         hist11->Fill(i,pixelprob[500*1152+239]);
+//         hist12->Fill(i,pixelprob[500*1152+263]);
+//         hist13->Fill(i,pixelprob[500*1152+287]);
+// Row 5
+//         hist1->Fill(i, pixelprob[5*1152+0]);
+//         hist2->Fill(i, pixelprob[5*1152+23]);
+//         hist3->Fill(i, pixelprob[5*1152+47]);
+//         hist4->Fill(i, pixelprob[5*1152+71]);
+//         hist5->Fill(i, pixelprob[5*1152+95]);
+//         hist6->Fill(i, pixelprob[5*1152+119]);
+//         hist7->Fill(i, pixelprob[5*1152+143]);
+//         hist8->Fill(i, pixelprob[5*1152+167]);
+//         hist9->Fill(i, pixelprob[5*1152+191]);
+//         hist10->Fill(i,pixelprob[5*1152+215]);
+//         hist11->Fill(i,pixelprob[5*1152+239]);
+//         hist12->Fill(i,pixelprob[5*1152+263]);
+//         hist13->Fill(i,pixelprob[5*1152+287]);
+
+// Block B
+// Row 5
+//         hist1->Fill(i, pixelprob[5*1152+288+0]);
+//         hist2->Fill(i, pixelprob[5*1152+288+23]);
+//         hist3->Fill(i, pixelprob[5*1152+288+47]);
+//         hist4->Fill(i, pixelprob[5*1152+288+71]);
+//         hist5->Fill(i, pixelprob[5*1152+288+95]);
+//         hist6->Fill(i, pixelprob[5*1152+288+119]);
+//         hist7->Fill(i, pixelprob[5*1152+288+143]);
+//         hist8->Fill(i, pixelprob[5*1152+288+167]);
+//         hist9->Fill(i, pixelprob[5*1152+288+191]);
+//         hist10->Fill(i,pixelprob[5*1152+288+215]);
+//         hist11->Fill(i,pixelprob[5*1152+288+239]);
+//         hist12->Fill(i,pixelprob[5*1152+288+263]);
+//         hist13->Fill(i,pixelprob[5*1152+288+287]);
+// Row 500
+//         hist1->Fill(i, pixelprob[500*1152+288+0]);
+//         hist2->Fill(i, pixelprob[500*1152+288+23]);
+//         hist3->Fill(i, pixelprob[500*1152+288+47]);
+//         hist4->Fill(i, pixelprob[500*1152+288+71]);
+//         hist5->Fill(i, pixelprob[500*1152+288+95]);
+//         hist6->Fill(i, pixelprob[500*1152+288+119]);
+//         hist7->Fill(i, pixelprob[500*1152+288+143]);
+//         hist8->Fill(i, pixelprob[500*1152+288+167]);
+//         hist9->Fill(i, pixelprob[500*1152+288+191]);
+//         hist10->Fill(i,pixelprob[500*1152+288+215]);
+//         hist11->Fill(i,pixelprob[500*1152+288+239]);
+//         hist12->Fill(i,pixelprob[500*1152+288+263]);
+//         hist13->Fill(i,pixelprob[500*1152+288+287]);
+
+// Block C
+// Row 5
+//         hist1->Fill(i, pixelprob[5*1152+576+0]);
+//         hist2->Fill(i, pixelprob[5*1152+576+23]);
+//         hist3->Fill(i, pixelprob[5*1152+576+47]);
+//         hist4->Fill(i, pixelprob[5*1152+576+71]);
+//         hist5->Fill(i, pixelprob[5*1152+576+95]);
+//         hist6->Fill(i, pixelprob[5*1152+576+119]);
+//         hist7->Fill(i, pixelprob[5*1152+576+143]);
+//         hist8->Fill(i, pixelprob[5*1152+576+167]);
+//         hist9->Fill(i, pixelprob[5*1152+576+191]);
+//         hist10->Fill(i,pixelprob[5*1152+576+215]);
+//         hist11->Fill(i,pixelprob[5*1152+576+239]);
+//         hist12->Fill(i,pixelprob[5*1152+576+263]);
+//         hist13->Fill(i,pixelprob[5*1152+576+287]);
+// Row 500
+//         hist1->Fill(i, pixelprob[500*1152+576+0]);
+//         hist2->Fill(i, pixelprob[500*1152+576+23]);
+//         hist3->Fill(i, pixelprob[500*1152+576+47]);
+//         hist4->Fill(i, pixelprob[500*1152+576+71]);
+//         hist5->Fill(i, pixelprob[500*1152+576+95]);
+//         hist6->Fill(i, pixelprob[500*1152+576+119]);
+//         hist7->Fill(i, pixelprob[500*1152+576+143]);
+//         hist8->Fill(i, pixelprob[500*1152+576+167]);
+//         hist9->Fill(i, pixelprob[500*1152+576+191]);
+//         hist10->Fill(i,pixelprob[500*1152+576+215]);
+//         hist11->Fill(i,pixelprob[500*1152+576+239]);
+//         hist12->Fill(i,pixelprob[500*1152+576+263]);
+//         hist13->Fill(i,pixelprob[500*1152+576+287]);
+
+// Block D
+// Row 5
+//         hist1->Fill(i, pixelprob[5*1152+864+0]);
+//         hist2->Fill(i, pixelprob[5*1152+864+23]);
+//         hist3->Fill(i, pixelprob[5*1152+864+47]);
+//         hist4->Fill(i, pixelprob[5*1152+864+71]);
+//         hist5->Fill(i, pixelprob[5*1152+864+95]);
+//         hist6->Fill(i, pixelprob[5*1152+864+119]);
+//         hist7->Fill(i, pixelprob[5*1152+864+143]);
+//         hist8->Fill(i, pixelprob[5*1152+864+167]);
+//         hist9->Fill(i, pixelprob[5*1152+864+191]);
+//         hist10->Fill(i,pixelprob[5*1152+864+215]);
+//         hist11->Fill(i,pixelprob[5*1152+864+239]);
+//         hist12->Fill(i,pixelprob[5*1152+864+263]);
+//         hist13->Fill(i,pixelprob[5*1152+864+287]);
+// Row 500
+//         hist1->Fill(i, pixelprob[500*1152+864+0]);
+//         hist2->Fill(i, pixelprob[500*1152+864+23]);
+//         hist3->Fill(i, pixelprob[500*1152+864+47]);
+//         hist4->Fill(i, pixelprob[500*1152+864+71]);
+//         hist5->Fill(i, pixelprob[500*1152+864+95]);
+//         hist6->Fill(i, pixelprob[500*1152+864+119]);
+//         hist7->Fill(i, pixelprob[500*1152+864+143]);
+//         hist8->Fill(i, pixelprob[500*1152+864+167]);
+//         hist9->Fill(i, pixelprob[500*1152+864+191]);
+//         hist10->Fill(i,pixelprob[500*1152+864+215]);
+//         hist11->Fill(i,pixelprob[500*1152+864+239]);
+//         hist12->Fill(i,pixelprob[500*1152+864+263]);
+//         hist13->Fill(i,pixelprob[500*1152+864+287]);
+
+
+// Mid Column A
+//         hist1->Fill(i, pixelprob[0*1152+144]);
+//         hist2->Fill(i, pixelprob[47*1152+144]);
+//         hist3->Fill(i, pixelprob[95*1152+144]);
+//         hist4->Fill(i, pixelprob[143*1152+144]);
+//         hist5->Fill(i, pixelprob[191*1152+144]);
+//         hist6->Fill(i, pixelprob[239*1152+144]);
+//         hist7->Fill(i, pixelprob[287*1152+144]);
+//         hist8->Fill(i, pixelprob[335*1152+144]);
+//         hist9->Fill(i, pixelprob[383*1152+144]);
+//         hist10->Fill(i,pixelprob[431*1152+144]);
+//         hist11->Fill(i,pixelprob[479*1152+144]);
+//         hist12->Fill(i,pixelprob[527*1152+144]);
+//         hist13->Fill(i,pixelprob[574*1152+144]);
+// Mid Column B
+//         hist1->Fill(i, pixelprob[0*1152+288+144]);
+//         hist2->Fill(i, pixelprob[47*1152+288+144]);
+//         hist3->Fill(i, pixelprob[95*1152+288+144]);
+//         hist4->Fill(i, pixelprob[143*1152+288+144]);
+//         hist5->Fill(i, pixelprob[191*1152+288+144]);
+//         hist6->Fill(i, pixelprob[239*1152+288+144]);
+//         hist7->Fill(i, pixelprob[287*1152+288+144]);
+//         hist8->Fill(i, pixelprob[335*1152+288+144]);
+//         hist9->Fill(i, pixelprob[383*1152+288+144]);
+//         hist10->Fill(i,pixelprob[431*1152+288+144]);
+//         hist11->Fill(i,pixelprob[479*1152+288+144]);
+//         hist12->Fill(i,pixelprob[527*1152+288+144]);
+//         hist13->Fill(i,pixelprob[574*1152+288+144]);
+// Mid Column C
+//         hist1->Fill(i, pixelprob[0*1152+576+144]);
+//         hist2->Fill(i, pixelprob[47*1152+576+144]);
+//         hist3->Fill(i, pixelprob[95*1152+576+144]);
+//         hist4->Fill(i, pixelprob[143*1152+576+144]);
+//         hist5->Fill(i, pixelprob[191*1152+576+144]);
+//         hist6->Fill(i, pixelprob[239*1152+576+144]);
+//         hist7->Fill(i, pixelprob[287*1152+576+144]);
+//         hist8->Fill(i, pixelprob[335*1152+576+144]);
+//         hist9->Fill(i, pixelprob[383*1152+576+144]);
+//         hist10->Fill(i,pixelprob[431*1152+576+144]);
+//         hist11->Fill(i,pixelprob[479*1152+576+144]);
+//         hist12->Fill(i,pixelprob[527*1152+576+144]);
+//         hist13->Fill(i,pixelprob[574*1152+576+144]);
+// Mid Column D
+        hist1->Fill(i, pixelprob[0*1152+864+144]);
+        hist2->Fill(i, pixelprob[47*1152+864+144]);
+        hist3->Fill(i, pixelprob[95*1152+864+144]);
+        hist4->Fill(i, pixelprob[143*1152+864+144]);
+        hist5->Fill(i, pixelprob[191*1152+864+144]);
+        hist6->Fill(i, pixelprob[239*1152+864+144]);
+        hist7->Fill(i, pixelprob[287*1152+864+144]);
+        hist8->Fill(i, pixelprob[335*1152+864+144]);
+        hist9->Fill(i, pixelprob[383*1152+864+144]);
+        hist10->Fill(i,pixelprob[431*1152+864+144]);
+        hist11->Fill(i,pixelprob[479*1152+864+144]);
+        hist12->Fill(i,pixelprob[527*1152+864+144]);
+        hist13->Fill(i,pixelprob[574*1152+864+144]);
+
+// Column from Block A
+//         int doit = 0;
+//         for (int j=0; j<288;j++){
+//             if (pixelprob[47*1152+j] != 0){
+//                 doit = 1;
+//             }
+//         }
+//         if (doit){
+//             printf(">>>  ");
+//             for (int j=0; j<288;j++){
+//                 if (pixelprob[47*1152+j] == 0){
+//                     printf("%d  ",j);
+//                 }
+//             }
+//             printf("\n------------------\n",j);
+//         }
+//         
+// 
+//          hist1->Fill(i, pixelprob[0*1152+144]);
+//         hist2->Fill(i, pixelprob[47*1152+144]);
+//         hist3->Fill(i, pixelprob[95*1152+144]);
+//         hist4->Fill(i, pixelprob[143*1152+144]);
+//         hist5->Fill(i, pixelprob[191*1152+144]);
+//         hist6->Fill(i, pixelprob[239*1152+144]);
+//         hist7->Fill(i, pixelprob[287*1152+144]);
+//         hist8->Fill(i, pixelprob[335*1152+144]);
+//         hist9->Fill(i, pixelprob[383*1152+144]);
+//         hist10->Fill(i,pixelprob[431*1152+144]);
+//         hist11->Fill(i,pixelprob[479*1152+144]);
+//         hist12->Fill(i,pixelprob[527*1152+144]);
+//         hist13->Fill(i,pixelprob[574*1152+144]);
+        
+    }
+    hist1->Draw("");
+    hist2->Draw("same");
+    hist3->Draw("same");
+    hist4->Draw("same");
+    hist5->Draw("same");
+    hist6->Draw("same");
+    hist7->Draw("same");
+    hist8->Draw("same");
+    hist9->Draw("same");
+    hist10->Draw("same");
+    hist11->Draw("same");
+    hist12->Draw("same");
+    hist13->Draw("same");
+    
+    leg = new TLegend(0.8,0.1,0.94,0.7);
+    leg->SetHeader("Rows");
+    leg->AddEntry(hist1,"1","l");
+    leg->AddEntry(hist2,"48","l");
+    leg->AddEntry(hist3,"96","l");
+    leg->AddEntry(hist4,"144","l");
+    leg->AddEntry(hist5,"192","l");
+    leg->AddEntry(hist6,"240","l");
+    leg->AddEntry(hist7,"288","l");
+    leg->AddEntry(hist8,"336","l");
+    leg->AddEntry(hist9,"384","l");
+    leg->AddEntry(hist10,"432","l");
+    leg->AddEntry(hist11,"480","l");
+    leg->AddEntry(hist12,"528","l");
+    leg->AddEntry(hist13,"575","l");
+
+    leg->Draw();
+  
+  return 1;
+    
+}
+
+
-- 
2.43.0