Index: trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C	(revision 8485)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C	(revision 8489)
@@ -63,4 +63,5 @@
 
 #include <TFile.h>
+#include <TGraph.h>
 #include <TSQLResult.h>
 
@@ -69,4 +70,5 @@
 #include "MStatusArray.h"
 #include "MHCamera.h"
+#include "MHVsTime.h"
 
 #include "MCalibrationPulseTimeCam.h"
@@ -74,14 +76,4 @@
 
 using namespace std;
-
-Int_t CalcUnsuitable(const MHCamera &cam, Float_t f)
-{
-    Int_t n = 0;
-    for (int i=0; i<cam.GetNbinsX(); i++)
-        if (cam.GetBinContent(i+1)>f)
-            n++;
-
-    return n;
-}
 
 int Process(MSQLServer &serv, TString fname, Bool_t dummy)
@@ -257,6 +249,21 @@
     }
 
-    Int_t unsuitable50 = CalcUnsuitable(*cam, 0.50);
-    Int_t unsuitable01 = CalcUnsuitable(*cam, 0.01);
+    Int_t unsuitable50 = cam->GetNumBinsAboveThreshold(0.50);
+    Int_t unsuitable01 = cam->GetNumBinsAboveThreshold(0.01);
+
+    TString unsuitablemax = "NULL";
+    TString deadmax       = "NULL";
+
+    TGraph *gr = (TGraph*)arr.FindObjectInCanvas("BadPixTm", "TGraph", "BadPixTm");
+    if (gr)
+    {
+        const Int_t p = TMath::FloorNint(gr->GetN()*0.999);
+        unsuitablemax = Form("%d", TMath::Nint(TMath::KOrdStat(gr->GetN(), gr->GetY(), p)));
+    }
+
+    gr = (TGraph*)arr.FindObjectInCanvas("DeadPixTm", "TGraph", "DeadPixTm");
+    if (gr)
+        deadmax = Form("%d", TMath::Nint(TMath::MaxElement(gr->GetN(), gr->GetY())));
+
 
 /*
@@ -316,4 +323,6 @@
     cout << "  Unsuitable > 50%:       " << setw(6) << unsuitable50 << endl;
     cout << "  Unsuitable >  1%:       " << setw(6) << unsuitable01 << endl;
+    cout << "  UnsuitableMax (99.9%)   " << setw(6) << unsuitablemax << endl;
+    cout << "  DeadMax                 " << setw(6) << deadmax << endl;
     cout << endl;
 
@@ -331,5 +340,6 @@
                          " fPulsePosOffMed=%s,    fPulsePosOffDev=%s,   "
                          " fHiLoGainRatioMed=%s,  fHiLoGainRatioDev=%s,  "
-                         " fUnsuitable50=%d,  fUnsuitable01=%d  "
+                         " fUnsuitable50=%d,  fUnsuitable01=%d, "
+                         " fUnsuitableMax=%s, fDeadMax=%s "
                          " WHERE fSequenceFirst='%d' ",
                          meanrmsinner.Data(),  meanrmsouter.Data(),
@@ -342,4 +352,5 @@
                          medhilocal.Data(),   devhilocal.Data(),
                          unsuitable50, unsuitable01,
+                         unsuitablemax.Data(), deadmax.Data(),
                          seq);
 
