Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 5328)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 5329)
@@ -20,4 +20,26 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+2004/11/01: David Paneque
+   
+   * mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc
+   
+     - Condition to assume a constant background in the fit 
+       of the ON and OFF data is softened: 
+	  1) Bins with zero content are allowed (if they are less than 10%
+	  of the total number of bins used). Yet their error is set to 
+	  a huge number 10E19; which means that they are not taken into account 
+	  in the fit.
+	  2) Maximum number of bins with low content (less than 9) is increased 
+	  from 5% to 20%. The error of these bins is set to 3.
+
+       The motivation of these changes is to allow the fitting procedures also 
+       in those cases where the background rejection is that large that very few 
+       events remain in the background region of the alpha plot. This situation 
+       is occuring quite often when using the Random Forest and SPECIALLY, when 
+       making large SIZE cuts.
+
+
+
  2004/10/30: Markus Gaug
    
@@ -25,4 +47,5 @@
    * msignal/MExtractTime.h
      - set the version number by 1 higher due to the changes on 12.10.
+
 
 
Index: /trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc	(revision 5328)
+++ /trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc	(revision 5329)
@@ -1047,6 +1047,10 @@
       // count bins with zero entry
       if (content <= 0.0)
-        fNzeroOFF++;
-     
+	{
+	  fNzeroOFF++;
+	  // The error of the bin is set to a huge number, 
+	  // so that it does not have any weight in the fit
+	  fHistOFF->SetBinError(i, dummy); 
+	}
       // set minimum error
       if (content < 9.0)
@@ -1151,5 +1155,20 @@
 
   fConstantBackg = kFALSE;
-  if ( fNzeroOFF > 0  ||  (Double_t)fMlowOFF>0.05*(Double_t)fMbinsOFF ) 
+
+  // Condition for disabling the fitting procedure and 
+  // assuming a constant background (before Nov 2004)
+
+  // if ( fNzeroOFF > 0  ||  (Double_t)fMlowOFF>0.05*(Double_t)fMbinsOFF )
+
+
+  // Condition for disabling the fitting procedure and 
+  // assuming a constant background (After Nov 01 2004)
+  // I softened the condition to allow the fit also in situations 
+  // where the reduction of the background is such that very 
+  // few events survived; which is 
+  // Specially frequent with Random Forest at high Sizes)
+
+   if ( (Double_t)fNzeroOFF > 0.1*(Double_t)fMbinsOFF ||  
+       (Double_t)fMlowOFF > 0.2*(Double_t)fMbinsOFF )
   {
     *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; polynomial fit not possible,  fNzeroOFF, fMlowOFF, fMbinsOFF = "
@@ -1182,5 +1201,5 @@
     Double_t val, err;
     val = mean;
-    err = sqrt( mean / (Double_t)fMbinsOFF );
+    err = rms; // sqrt( mean / (Double_t)fMbinsOFF );
 
     fPolyOFF->SetParameter(0, val);
@@ -1553,6 +1572,11 @@
       // count bins with zero entry
       if (content <= 0.0)
-        fNzero++;
-     
+	{
+	  fNzero++;
+	  // The error of the bin is set to a huge number, 
+	  // so that it does not have any weight in the fit
+	  fHistOFF->SetBinError(i, dummy); 
+	}
+
       // set minimum error
       if (content < 9.0)
@@ -1657,5 +1681,21 @@
 
   fConstantBackg = kFALSE;
-  if ( fNzero > 0  ||  (Double_t)fMlow>0.05*(Double_t)fMbins ) 
+
+  // Condition for disabling the fitting procedure and 
+  // assuming a constant background (before Nov 2004)
+
+  // if ( fNzero > 0  ||  (Double_t)fMlow>0.05*(Double_t)fMbins )
+
+
+  // Condition for disabling the fitting procedure and 
+  // assuming a constant background (After Nov 01 2004)
+  // I softened the condition to allow the fit also in situations 
+  // where the reduction of the background is such that very 
+  // few events survived; which is 
+  // Specially frequent with Random Forest at high Sizes)
+
+  if ( (Double_t)fNzero > 0.1*(Double_t)fMbins ||  
+       (Double_t)fMlow > 0.2*(Double_t)fMbins )
+
   {
     *fLog << "MHFindSignificanceONOFF::FitPolynomial; polynomial fit not possible,  fNzero, fMlow, fMbins = "
@@ -1688,5 +1728,5 @@
     Double_t val, err;
     val = mean;
-    err = sqrt( mean / (Double_t)fMbins );
+    err = rms; // sqrt( mean / (Double_t)fMbins );
 
     fPoly->SetParameter(0, val);
