// @(#)root/roostats:$Id$
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//_________________________________________________________________
/**
   HypoTestInverter class for performing an hypothesis test inversion by scanning the hypothesis test results of an 
  HypoTestCalculator  for various values of the parameter of interest. By looking at the confidence level curve of 
 the result  an upper limit, where it intersects the desired confidence level, can be derived.
 The class implements the RooStats::IntervalCalculator interface and returns an  RooStats::HypoTestInverterResult class.
 The result is a SimpleInterval, which via the method UpperLimit returns to the user the upper limit value.

The  HypoTestInverter implements various option for performing the scan. HypoTestInverter::RunFixedScan will scan using a fixed grid the parameter of interest. HypoTestInverter::RunAutoScan will perform an automatic scan to find optimally the curve and it will stop until the desired precision is obtained.
The confidence level value at a given point can be done via  HypoTestInverter::RunOnePoint.
The class can scan the CLs+b values or alternativly CLs (if the method HypoTestInverter::UseCLs has been called).


   Contributions to this class have been written by Giovanni Petrucciani and Annapaola Decosa
**/

// include other header files

#include "RooAbsData.h"
#
#include "TMath.h"

#include "RooStats/HybridResult.h"

#include "RooStats/HypoTestInverter.h"
#include <cassert>
#include <cmath>

#include "TF1.h"
#include "TFile.h"
#include "TH1.h"
#include "TLine.h"
#include "TCanvas.h"
#include "TGraphErrors.h"
#include "RooRealVar.h"
#include "RooArgSet.h"
#include "RooAbsPdf.h"
#include "RooRandom.h"
#include "RooConstVar.h"
#include "RooMsgService.h"
#include "RooStats/ModelConfig.h"
#include "RooStats/HybridCalculator.h"
#include "RooStats/FrequentistCalculator.h"
#include "RooStats/AsymptoticCalculator.h"
#include "RooStats/SimpleLikelihoodRatioTestStat.h"
#include "RooStats/RatioOfProfiledLikelihoodsTestStat.h"
#include "RooStats/ProfileLikelihoodTestStat.h"
#include "RooStats/ToyMCSampler.h"
#include "RooStats/HypoTestPlot.h"
#include "RooStats/HypoTestInverterPlot.h"

#include "RooStats/ProofConfig.h"

ClassImp(RooStats::HypoTestInverter)

using namespace RooStats;
using namespace std;

// static variable definitions
double HypoTestInverter::fgCLAccuracy = 0.005;
unsigned int HypoTestInverter::fgNToys = 500;

double HypoTestInverter::fgAbsAccuracy = 0.05;
double HypoTestInverter::fgRelAccuracy = 0.05;
std::string HypoTestInverter::fgAlgo = "logSecant";

bool HypoTestInverter::fgCloseProof = false;

// helper class to wrap the functionality of the various HypoTestCalculators

template<class HypoTestType> 
struct HypoTestWrapper { 

   static void SetToys(HypoTestType * h, int toyNull, int toyAlt) { h->SetToys(toyNull,toyAlt); }
   
};


void HypoTestInverter::SetCloseProof(Bool_t flag) {
// set flag to close proof for every new run
   fgCloseProof  = flag;
}

 
RooRealVar * HypoTestInverter::GetVariableToScan(const HypoTestCalculatorGeneric &hc) { 
    // get  the variable to scan 
   // try first with null model if not go to alternate model
   
   RooRealVar * varToScan = 0;
   const ModelConfig * mc = hc.GetNullModel();
   if (mc) { 
      const RooArgSet * poi  = mc->GetParametersOfInterest();
      if (poi) varToScan = dynamic_cast<RooRealVar*> (poi->first() );
   }
   if (!varToScan) { 
      mc = hc.GetAlternateModel();
      if (mc) { 
         const RooArgSet * poi  = mc->GetParametersOfInterest();
         if (poi) varToScan = dynamic_cast<RooRealVar*> (poi->first() );
      }
   }
   return varToScan;
}

void HypoTestInverter::CheckInputModels(const HypoTestCalculatorGeneric &hc,const RooRealVar & scanVariable) { 
    // check  the model given the given hypotestcalculator  
   const ModelConfig * modelSB = hc.GetNullModel();
   const ModelConfig * modelB = hc.GetAlternateModel();
   if (!modelSB || ! modelB) 
      oocoutF((TObject*)0,InputArguments) << "HypoTestInverter - model are not existing" << std::endl;    
   assert(modelSB && modelB);

   oocoutI((TObject*)0,InputArguments) << "HypoTestInverter ---- Input models: \n"
                                       << "\t\t using as S+B (null) model     : " 
                                       << modelSB->GetName() << "\n" 
                                       << "\t\t using as B (alternate) model  : " 
                                       << modelB->GetName() << "\n" << std::endl; 

   // check if scanVariable is included in B model pdf 
   RooAbsPdf * bPdf = modelB->GetPdf();
   const RooArgSet * bObs = modelB->GetObservables();
   if (!bPdf || !bObs) { 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - B model has no pdf or observables defined" <<  std::endl; 
      return;
   }
   RooArgSet * bParams = bPdf->getParameters(*bObs);
   if (!bParams) { 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - pdf of B model has no parameters" << std::endl; 
      return;
   }
   if (bParams->find(scanVariable.GetName() ) ) { 
      const RooArgSet * poiB  = modelB->GetSnapshot();
      if (!poiB ||  !poiB->find(scanVariable.GetName()) || 
          ( (RooRealVar*)  poiB->find(scanVariable.GetName()) )->getVal() != 0 )
         oocoutW((TObject*)0,InputArguments) << "HypoTestInverter - using a B model  with POI " 
                                             <<    scanVariable.GetName()  << " not equal to zero "
                                             << " user must check input model configurations " << endl;
      if (poiB) delete poiB;
   }
   delete bParams;
}

HypoTestInverter::HypoTestInverter( ) :
   fTotalToysRun(0),
   fMaxToys(0),
   fCalculator0(0),
   fScannedVariable(0),
   fResults(0),
   fUseCLs(false),
   fScanLog(false),
   fSize(0),
   fVerbose(0),
   fCalcType(kUndefined), 
   fNBins(0), fXmin(1), fXmax(1),
   fNumErr(0)
{
  // default constructor (doesn't do anything) 
}

HypoTestInverter::HypoTestInverter( HypoTestCalculatorGeneric& hc,
                                    RooRealVar* scannedVariable, double size ) :
   fTotalToysRun(0),
   fMaxToys(0),
   fCalculator0(0),
   fScannedVariable(scannedVariable), 
   fResults(0),
   fUseCLs(false),
   fScanLog(false),
   fSize(size),
   fVerbose(0),
   fCalcType(kUndefined), 
   fNBins(0), fXmin(1), fXmax(1),
   fNumErr(0)
{
   // Constructor from a HypoTestCalculatorGeneric
   // The HypoTest calculator must be a FrequentistCalculator or HybridCalculator type 
   // Other type of calculators are not supported.
   // The calculator must be created before by using the S+B model for the null and 
   // the B model for the alt
   // If no variable to scan are given they are assumed to be the first variable
   // from the parameter of interests of the null model

   if (!fScannedVariable) { 
      fScannedVariable = HypoTestInverter::GetVariableToScan(hc);
   }
   if (!fScannedVariable) 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - Cannot guess the variable to scan " << std::endl;    
   else 
      CheckInputModels(hc,*fScannedVariable);

   HybridCalculator * hybCalc = dynamic_cast<HybridCalculator*>(&hc);
   if (hybCalc) { 
      fCalcType = kHybrid;
      fCalculator0 = hybCalc;
      return;
   }
   FrequentistCalculator * freqCalc = dynamic_cast<FrequentistCalculator*>(&hc);
   if (freqCalc) { 
      fCalcType = kFrequentist;
      fCalculator0 = freqCalc;
      return;
   }
   AsymptoticCalculator * asymCalc = dynamic_cast<AsymptoticCalculator*>(&hc);
   if (asymCalc) { 
      fCalcType = kAsymptotic;
      fCalculator0 = asymCalc;
      return;
   }
   oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - Type of hypotest calculator is not supported " <<std::endl;    
   fCalculator0 = &hc;
}


HypoTestInverter::HypoTestInverter( HybridCalculator& hc,
                                          RooRealVar* scannedVariable, double size ) :
   fTotalToysRun(0),
   fMaxToys(0),
   fCalculator0(&hc),
   fScannedVariable(scannedVariable), 
   fResults(0),
   fUseCLs(false),
   fScanLog(false),
   fSize(size),
   fVerbose(0),
   fCalcType(kHybrid), 
   fNBins(0), fXmin(1), fXmax(1),
   fNumErr(0)
{
   // Constructor from a reference to a HybridCalculator 
   // The calculator must be created before by using the S+B model for the null and 
   // the B model for the alt
   // If no variable to scan are given they are assumed to be the first variable
   // from the parameter of interests of the null model

   if (!fScannedVariable) { 
      fScannedVariable = GetVariableToScan(hc);
   }
   if (!fScannedVariable) 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - Cannot guess the variable to scan " << std::endl;    
   else 
      CheckInputModels(hc,*fScannedVariable);

}




HypoTestInverter::HypoTestInverter( FrequentistCalculator& hc,
                                    RooRealVar* scannedVariable, double size ) :
   fTotalToysRun(0),
   fMaxToys(0),
   fCalculator0(&hc),
   fScannedVariable(scannedVariable), 
   fResults(0),
   fUseCLs(false),
   fScanLog(false),
   fSize(size),
   fVerbose(0),
   fCalcType(kFrequentist), 
   fNBins(0), fXmin(1), fXmax(1),
   fNumErr(0)
{
   // Constructor from a reference to a FrequentistCalculator  
   // The calculator must be created before by using the S+B model for the null and 
   // the B model for the alt
   // If no variable to scan are given they are assumed to be the first variable
   // from the parameter of interests of the null model

   if (!fScannedVariable) { 
      fScannedVariable = GetVariableToScan(hc);
   }
   if (!fScannedVariable) 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - Cannot guess the variable to scan " << std::endl;    
   else 
      CheckInputModels(hc,*fScannedVariable);
}

HypoTestInverter::HypoTestInverter( AsymptoticCalculator& hc,
                                          RooRealVar* scannedVariable, double size ) :
   fTotalToysRun(0),
   fMaxToys(0),
   fCalculator0(&hc),
   fScannedVariable(scannedVariable), 
   fResults(0),
   fUseCLs(false),
   fScanLog(false),
   fSize(size),
   fVerbose(0),
   fCalcType(kAsymptotic), 
   fNBins(0), fXmin(1), fXmax(1),
   fNumErr(0)
{
   // Constructor from a reference to a AsymptoticCalculator 
   // The calculator must be created before by using the S+B model for the null and 
   // the B model for the alt
   // If no variable to scan are given they are assumed to be the first variable
   // from the parameter of interests of the null model

   if (!fScannedVariable) { 
      fScannedVariable = GetVariableToScan(hc);
   }
   if (!fScannedVariable) 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - Cannot guess the variable to scan " << std::endl;    
   else 
      CheckInputModels(hc,*fScannedVariable);

}


//_________________________________________________________________________________________________
HypoTestInverter::HypoTestInverter( RooAbsData& data, ModelConfig &sbModel, ModelConfig &bModel,
				    RooRealVar * scannedVariable,  ECalculatorType type, double size) :
   fTotalToysRun(0),
   fMaxToys(0),
   fCalculator0(0),
   fScannedVariable(scannedVariable), 
   fResults(0),
   fUseCLs(false),
   fScanLog(false),
   fSize(size),
   fVerbose(0),
   fCalcType(type), 
   fNBins(0), fXmin(1), fXmax(1),
   fNumErr(0)
{
   // Constructor from a model for B model and a model for S+B. 
   // An HypoTestCalculator (Hybrid of Frequentis) will be created using the 
   // S+B model as the null and the B model as the alternate
   // If no variable to scan are given they are assumed to be the first variable
   // from the parameter of interests of the null model

   if(fCalcType==kFrequentist) fHC.reset(new FrequentistCalculator(data, bModel, sbModel)); 
   if(fCalcType==kHybrid) fHC.reset( new HybridCalculator(data, bModel, sbModel)) ; 
   if(fCalcType==kAsymptotic) fHC.reset( new AsymptoticCalculator(data, bModel, sbModel)); 
   fCalculator0 = fHC.get();
   // get scanned variabke
   if (!fScannedVariable) { 
      fScannedVariable = GetVariableToScan(*fCalculator0);
   }
   if (!fScannedVariable) 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - Cannot guess the variable to scan " << std::endl;    
   else
      CheckInputModels(*fCalculator0,*fScannedVariable);
   
}


HypoTestInverter::HypoTestInverter(const HypoTestInverter & rhs) :
   IntervalCalculator(),
   fTotalToysRun(0),
   fCalculator0(0), fScannedVariable(0),  // add these for Coverity
   fResults(0)
{
   // copy-constructor
   // NOTE: this class does not copy the contained result and 
   // the HypoTestCalculator, but only the pointers
   // It requires the original HTI to be alive
   (*this) = rhs;
}

HypoTestInverter & HypoTestInverter::operator= (const HypoTestInverter & rhs) {
   // assignment operator
   // NOTE: this class does not copy the contained result and 
   // the HypoTestCalculator, but only the pointers
   // It requires the original HTI to be alive
   if (this == &rhs) return *this;
   fTotalToysRun = 0;
   fMaxToys = rhs.fMaxToys;
   fCalculator0 = rhs.fCalculator0;
   fScannedVariable = rhs.fScannedVariable; 
   fUseCLs = rhs.fUseCLs;
   fScanLog = rhs.fScanLog;
   fSize = rhs.fSize;
   fVerbose = rhs.fVerbose;
   fCalcType = rhs.fCalcType; 
   fNBins = rhs.fNBins;
   fXmin = rhs.fXmin;
   fXmax = rhs.fXmax;
   fNumErr = rhs.fNumErr;

   return *this;
}

HypoTestInverter::~HypoTestInverter()
{
   // destructor (delete the HypoTestInverterResult)
  
   if (fResults) delete fResults;
   fCalculator0 = 0;
}


TestStatistic * HypoTestInverter::GetTestStatistic( ) const
{
   // return the test statistic which is or will be used by the class
   if(fCalculator0 &&  fCalculator0->GetTestStatSampler()){
      return fCalculator0->GetTestStatSampler()->GetTestStatistic();
   }
   else 
      return 0;
} 

bool HypoTestInverter::SetTestStatistic(TestStatistic& stat)
{
   // set the test statistic to use
   if(fCalculator0 &&  fCalculator0->GetTestStatSampler()){
      fCalculator0->GetTestStatSampler()->SetTestStatistic(&stat);
      return true; 
   }
   else return false;
} 

void  HypoTestInverter::Clear()  { 
   // delete contained result and graph
   if (fResults) delete fResults; 
   fResults = 0;
   fLimitPlot.reset(nullptr);
}   

void  HypoTestInverter::CreateResults() const { 
   // create a new HypoTestInverterResult to hold all computed results
   if (fResults == 0) {
      TString results_name = "result_";
      results_name += fScannedVariable->GetName();
      fResults = new HypoTestInverterResult(results_name,*fScannedVariable,ConfidenceLevel());
      TString title = "HypoTestInverter Result For ";
      title += fScannedVariable->GetName();
      fResults->SetTitle(title);
   }
   fResults->UseCLs(fUseCLs);
   fResults->SetConfidenceLevel(1.-fSize);
   // check if one or two sided scan
   if (fCalculator0) {
      // if asymptotic calculator
      AsymptoticCalculator * ac = dynamic_cast<AsymptoticCalculator*>(fCalculator0);
      if (ac) 
         fResults->fIsTwoSided = ac->IsTwoSided();
      else { 
         // in case of the other calculators 
         TestStatSampler * sampler = fCalculator0->GetTestStatSampler();
         if (sampler) {
            ProfileLikelihoodTestStat * pl = dynamic_cast<ProfileLikelihoodTestStat*>(sampler->GetTestStatistic());
            if (pl && pl->IsTwoSided() ) fResults->fIsTwoSided = true;
         }
      }
   }
}

HypoTestInverterResult* HypoTestInverter::GetInterval() const { 
   // Run a fixed scan or the automatic scan depending on the configuration
   // Return if needed a copy of the result object which will be managed by the user

   // if having a result with at least  one point return it
   if (fResults && fResults->ArraySize() >= 1) { 
      oocoutI((TObject*)0,Eval) << "HypoTestInverter::GetInterval - return an already existing interval " << std::endl;          
      return  (HypoTestInverterResult*)(fResults->Clone());
   }

   if (fNBins > 0) {
      oocoutI((TObject*)0,Eval) << "HypoTestInverter::GetInterval - run a fixed scan" << std::endl;          
      bool ret = RunFixedScan(fNBins, fXmin, fXmax, fScanLog); 
      if (!ret) 
         oocoutE((TObject*)0,Eval) << "HypoTestInverter::GetInterval - error running a fixed scan " << std::endl;    
   }
   else { 
      oocoutI((TObject*)0,Eval) << "HypoTestInverter::GetInterval - run an automatic scan" << std::endl;          
      double limit(0),err(0);
      bool ret = RunLimit(limit,err);
      if (!ret) 
         oocoutE((TObject*)0,Eval) << "HypoTestInverter::GetInterval - error running an auto scan " << std::endl;    
   }

   if (fgCloseProof) ProofConfig::CloseProof();

   return (HypoTestInverterResult*) (fResults->Clone());
}



HypoTestResult * HypoTestInverter::Eval(HypoTestCalculatorGeneric &hc, bool adaptive, double clsTarget) const {
   // Run the Hypothesis test at a previous configured point
   //(internal function called by RunOnePoint)


   //for debug
   // std::cout << ">>>>>>>>>>> " << std::endl;
   // std::cout << "alternate model " << std::endl;
   // hc.GetAlternateModel()->GetNuisanceParameters()->Print("V");
   // hc.GetAlternateModel()->GetParametersOfInterest()->Print("V");
   // std::cout << "Null model " << std::endl;
   // hc.GetNullModel()->GetNuisanceParameters()->Print("V");
   // hc.GetNullModel()->GetParametersOfInterest()->Print("V");
   // std::cout << "<<<<<<<<<<<<<<< " << std::endl;

   // run the hypothesis test 
   HypoTestResult *  hcResult = hc.GetHypoTest();
   if (hcResult == 0) {
      oocoutE((TObject*)0,Eval) << "HypoTestInverter::Eval - HypoTest failed" << std::endl;
      return hcResult; 
   }

   // since the b model is the alt need to set the flag
   hcResult->SetBackgroundAsAlt(true);


   // bool flipPvalue = false;
   // if (flipPValues)
   //       hcResult->SetPValueIsRightTail(!hcResult->GetPValueIsRightTail());

   // adjust for some numerical error in discrete models and == is not anymore 
   if (hcResult->GetPValueIsRightTail() )
      hcResult->SetTestStatisticData(hcResult->GetTestStatisticData()-fNumErr); // issue with < vs <= in discrete models
   else 
      hcResult->SetTestStatisticData(hcResult->GetTestStatisticData()+fNumErr); // issue with < vs <= in discrete models

   double clsMid    = (fUseCLs ? hcResult->CLs()      : hcResult->CLsplusb());
   double clsMidErr = (fUseCLs ? hcResult->CLsError() : hcResult->CLsplusbError());

   //if (fVerbose) std::cout << (fUseCLs ? "\tCLs = " : "\tCLsplusb = ") << clsMid << " +/- " << clsMidErr << std::endl;
   
   if (adaptive) {
 
      if (fCalcType == kHybrid) HypoTestWrapper<HybridCalculator>::SetToys((HybridCalculator*)&hc, fUseCLs ? fgNToys : 1, 4*fgNToys);
      if (fCalcType == kFrequentist) HypoTestWrapper<FrequentistCalculator>::SetToys((FrequentistCalculator*)&hc, fUseCLs ? fgNToys : 1, 4*fgNToys);

   while (clsMidErr >= fgCLAccuracy && (clsTarget == -1 || fabs(clsMid-clsTarget) < 3*clsMidErr) ) {
      std::unique_ptr<HypoTestResult> more(hc.GetHypoTest());
      
      // if (flipPValues)
      //    more->SetPValueIsRightTail(!more->GetPValueIsRightTail());

      hcResult->Append(more.get());
      clsMid    = (fUseCLs ? hcResult->CLs()      : hcResult->CLsplusb());
      clsMidErr = (fUseCLs ? hcResult->CLsError() : hcResult->CLsplusbError());
      if (fVerbose) std::cout << (fUseCLs ? "\tCLs = " : "\tCLsplusb = ") << clsMid << " +/- " << clsMidErr << std::endl;
   }

   }
   if (fVerbose ) {
      oocoutP((TObject*)0,Eval) << "P values for  " << fScannedVariable->GetName()  << " =  " <<
         fScannedVariable->getVal() << "\n" <<
         "\tCLs      = " << hcResult->CLs()      << " +/- " << hcResult->CLsError()      << "\n" <<
         "\tCLb      = " << hcResult->CLb()      << " +/- " << hcResult->CLbError()      << "\n" <<
         "\tCLsplusb = " << hcResult->CLsplusb() << " +/- " << hcResult->CLsplusbError() << "\n" <<
         std::endl;
   }
   
   if (fCalcType == kFrequentist || fCalcType == kHybrid)  {
      fTotalToysRun += (hcResult->GetAltDistribution()->GetSize() + hcResult->GetNullDistribution()->GetSize());

      // set sampling distribution name
      TString nullDistName = TString::Format("%s_%s_%4.2f",hcResult->GetNullDistribution()->GetName(),
                                             fScannedVariable->GetName(), fScannedVariable->getVal() );
      TString altDistName = TString::Format("%s_%s_%4.2f",hcResult->GetAltDistribution()->GetName(),
                                            fScannedVariable->GetName(), fScannedVariable->getVal() );
      
      hcResult->GetNullDistribution()->SetName(nullDistName);
      hcResult->GetAltDistribution()->SetName(altDistName);
   }


   

   return hcResult;
} 


bool HypoTestInverter::RunFixedScan( int nBins, double xMin, double xMax, bool scanLog ) const
{
   // Run a Fixed scan in npoints between min and max

   CreateResults();
   // interpolate the limits
   fResults->fFittedLowerLimit = false; 
   fResults->fFittedUpperLimit = false; 

   // safety checks
   if ( nBins<=0 ) {
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::RunFixedScan - Please provide nBins>0\n";
      return false;
   }
   if ( nBins==1 && xMin!=xMax ) {
      oocoutW((TObject*)0,InputArguments) << "HypoTestInverter::RunFixedScan - nBins==1 -> I will run for xMin (" << xMin << ")\n";
   }
   if ( xMin==xMax && nBins>1 ) { 
      oocoutW((TObject*)0,InputArguments) << "HypoTestInverter::RunFixedScan - xMin==xMax -> I will enforce nBins==1\n";
      nBins = 1;
   }
   if ( xMin>xMax ) {
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::RunFixedScan - Please provide xMin (" 
                                          << xMin << ") smaller that xMax (" << xMax << ")\n";
      return false;
   } 

   if (xMin < fScannedVariable->getMin()) {
      xMin = fScannedVariable->getMin();
      oocoutW((TObject*)0,InputArguments) << "HypoTestInverter::RunFixedScan - xMin < lower bound, use xmin = "
                                          << xMin << std::endl; 
   }
   if (xMax > fScannedVariable->getMax()) { 
      xMax = fScannedVariable->getMax();
      oocoutW((TObject*)0,InputArguments) << "HypoTestInverter::RunFixedScan - xMax > upper bound, use xmax = "   
                                          << xMax << std::endl; 
   }         

   double thisX = xMin; 
   for (int i=0; i<nBins; i++) {
      
      if (i > 0) { // avoids case of nBins = 1
         if (scanLog) 
            thisX = exp(  log(xMin) +  i*(log(xMax)-log(xMin))/(nBins-1)  );  // scan in log x
         else
            thisX = xMin + i*(xMax-xMin)/(nBins-1);          // linear scan in x 
      }
         
      bool status = RunOnePoint(thisX);
      
      // check if failed status
      if ( status==false ) {
         std::cout << "\t\tLoop interrupted because of failed status\n";
         return false;
      }
   }



   return true;
}


bool HypoTestInverter::RunOnePoint( double rVal, bool adaptive, double clTarget) const
{
   // run only one point at the given POI value

   CreateResults();

   // check if rVal is in the range specified for fScannedVariable
   if ( rVal < fScannedVariable->getMin() ) {
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::RunOnePoint - Out of range: using the lower bound " 
                                          << fScannedVariable->getMin() 
                                          << " on the scanned variable rather than " << rVal<< "\n";
     rVal = fScannedVariable->getMin();
   }
   if ( rVal > fScannedVariable->getMax() ) {
      // print a message when you have a significative difference since rval is computed
      if ( rVal > fScannedVariable->getMax()*(1.+1.E-12) )
         oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::RunOnePoint - Out of range: using the upper bound " 
                                             << fScannedVariable->getMax() 
                                             << " on the scanned variable rather than " << rVal<< "\n";
     rVal = fScannedVariable->getMax();
   }

   // save old value 
   double oldValue = fScannedVariable->getVal();

   // evaluate hybrid calculator at a single point
   fScannedVariable->setVal(rVal);
   // need to set value of rval in hybridcalculator
   // assume null model is S+B and alternate is B only
   const ModelConfig * sbModel = fCalculator0->GetNullModel();
   RooArgSet poi; poi.add(*sbModel->GetParametersOfInterest());
   // set poi to right values 
   poi = RooArgSet(*fScannedVariable);
   const_cast<ModelConfig*>(sbModel)->SetSnapshot(poi);

   if (fVerbose > 0) 
      oocoutP((TObject*)0,Eval) << "Running for " << fScannedVariable->GetName() << " = " << fScannedVariable->getVal() << endl;
   
   // compute the results
   HypoTestResult* result =   Eval(*fCalculator0,adaptive,clTarget);
   if (!result) { 
      oocoutE((TObject*)0,Eval) << "HypoTestInverter - Error running point " << fScannedVariable->GetName() << " = " <<
   fScannedVariable->getVal() << endl;
      return false;
   }
   // in case of a dummy result
   if (TMath::IsNaN(result->NullPValue() ) && TMath::IsNaN(result->AlternatePValue() ) ) {
      oocoutW((TObject*)0,Eval) << "HypoTestInverter - Skip invalid result for  point " << fScannedVariable->GetName() << " = " <<
         fScannedVariable->getVal() << endl;
      return true;  // need to return true to avoid breaking the scan loop
   }
   
   double lastXtested;
   if ( fResults->ArraySize()!=0 ) lastXtested = fResults->GetXValue(fResults->ArraySize()-1);
   else lastXtested = -999;

   if ( (std::abs(rVal) < 1 && TMath::AreEqualAbs(rVal, lastXtested,1.E-12) ) || 
        (std::abs(rVal) >= 1 && TMath::AreEqualRel(rVal, lastXtested,1.E-12) ) ) {
     
      oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunOnePoint - Merge with previous result for "
                                << fScannedVariable->GetName() << " = " << rVal << std::endl;
      HypoTestResult* prevResult =  fResults->GetResult(fResults->ArraySize()-1);
      if (prevResult && prevResult->GetNullDistribution() && prevResult->GetAltDistribution()) { 
         prevResult->Append(result);
         delete result;  // we can delete the result
      }
      else { 
         // if it was empty we re-use it 
         oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunOnePoint - replace previous empty result\n";
         fResults->fYObjects.Remove( prevResult); 
         fResults->fYObjects.Add(result);            
      }

   } else {
     
     // fill the results in the HypoTestInverterResult array
     fResults->fXValues.push_back(rVal);
     fResults->fYObjects.Add(result);

   }

      // std::cout << "computed value for poi  " << rVal  << " : " << fResults->GetYValue(fResults->ArraySize()-1) 
      //        << " +/- " << fResults->GetYError(fResults->ArraySize()-1) << endl;

   fScannedVariable->setVal(oldValue);
   
   return true;
}



bool HypoTestInverter::RunLimit(double &limit, double &limitErr, double absAccuracy, double relAccuracy, const double*hint) const {
   // run an automatic scan until the desired accurancy is reached
   // Start by default from the full interval (min,max) of the POI and then via bisection find the line crossing 
   // the target line
   // Optionally an hint can be provided and the scan will be done closer to that value
   // If by bisection the desired accuracy will not be reached a fit to the points is performed
   

   // routine from G. Petrucciani (from HiggsCombination CMS package)
// bool HybridNew::runLimit(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint) {

   RooRealVar *r = fScannedVariable; 
   //w->loadSnapshot("clean");

  if ((hint != 0) && (*hint > r->getMin())) {
     r->setMax(std::min<double>(3.0 * (*hint), r->getMax()));
     r->setMin(std::max<double>(0.3 * (*hint), r->getMin()));
     oocoutI((TObject*)0,InputArguments) << "HypoTestInverter::RunLimit - Use hint value " << *hint 
                                         << " search in interval " << r->getMin() << " , " << r->getMax() << std::endl;
  }

  // if not specified use the default values for rel and absolute accuracy
  if (absAccuracy <= 0) absAccuracy = fgAbsAccuracy;
  if (relAccuracy <= 0) relAccuracy = fgRelAccuracy;  

  typedef std::pair<double,double> CLs_t;
  double clsTarget = fSize; 
  CLs_t clsMin(1,0), clsMax(0,0), clsMid(0,0);
  double rMin = r->getMin(), rMax = r->getMax(); 
  limit    = 0.5*(rMax + rMin);
  limitErr = 0.5*(rMax - rMin);
  bool done = false;

  TF1 expoFit("expoFit","[0]*exp([1]*(x-[2]))", rMin, rMax);

  // if (readHybridResults_) { 
  //     if (verbose > 0) std::cout << "Search for upper limit using pre-computed grid of p-values" << std::endl;

  //     readAllToysFromFile(); 
  //     double minDist=1e3;
  //     for (int i = 0, n = limitPlot_->GetN(); i < n; ++i) {
  //         double x = limitPlot_->GetX()[i], y = limitPlot_->GetY()[i], ey = limitPlot_->GetErrorY(i);
  //         if (verbose > 0) std::cout << "  r " << x << (CLs_ ? ", CLs = " : ", CLsplusb = ") << y << " +/- " << ey << std::endl;
  //         if (y-3*ey >= clsTarget) { rMin = x; clsMin = CLs_t(y,ey); }
  //         if (y+3*ey <= clsTarget) { rMax = x; clsMax = CLs_t(y,ey); }
  //         if (fabs(y-clsTarget) < minDist) { limit = x; minDist = fabs(y-clsTarget); }
  //     }
  //     if (verbose > 0) std::cout << " after scan x ~ " << limit << ", bounds [ " << rMin << ", " << rMax << "]" << std::endl;
  //     limitErr = std::max(limit-rMin, rMax-limit);
  //     expoFit.SetRange(rMin,rMax);

  //     if (limitErr < std::max(rAbsAccuracy_, rRelAccuracy_ * limit)) {
  //         if (verbose > 1) std::cout << "  reached accuracy " << limitErr << " below " << std::max(rAbsAccuracy_, rRelAccuracy_ * limit) << std::endl;
  //         done = true; 
  //     }
  // } else {

  fLimitPlot.reset(new TGraphErrors());

  if (fVerbose > 0) std::cout << "Search for upper limit to the limit" << std::endl;
  for (int tries = 0; tries < 6; ++tries) {
     //clsMax = eval(w, mc_s, mc_b, data, rMax);
     if (! RunOnePoint(rMax) ) { 
        oocoutE((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Hypotest failed" << std::endl;
        return false;
     }
     clsMax = std::make_pair( fResults->GetLastYValue(), fResults->GetLastYError() );
     if (clsMax.first == 0 || clsMax.first + 3 * fabs(clsMax.second) < clsTarget ) break;
     rMax += rMax;
     if (tries == 5) { 
        oocoutE((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Cannot set higher limit: at " << r->GetName() 
                                  << " = " << rMax  << " still get " 
                                  << (fUseCLs ? "CLs" : "CLsplusb") << " = " << clsMax.first << std::endl;
        return false;
     }
  }
  if (fVerbose > 0) { 
     oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Search for lower limit to the limit" << std::endl;
  }
  //clsMin = (fUseCLs && rMin == 0 ? CLs_t(1,0) : eval(w, mc_s, mc_b, data, rMin));
  if ( fUseCLs && rMin == 0 ) { 
     clsMin =  CLs_t(1,0); 
  }
  else { 
     if (! RunOnePoint(rMin) ) return false;
     clsMin = std::make_pair( fResults->GetLastYValue(), fResults->GetLastYError() );
  }
  if (clsMin.first != 1 && clsMin.first - 3 * fabs(clsMin.second) < clsTarget) {
     if (fUseCLs) { 
        rMin = 0;
        clsMin = CLs_t(1,0); // this is always true for CLs
     } else {
        rMin = -rMax / 4;
        for (int tries = 0; tries < 6; ++tries) {
           if (! RunOnePoint(rMax) ) return false;
           clsMin = std::make_pair( fResults->GetLastYValue(), fResults->GetLastYError() );
           if (clsMin.first == 1 || clsMin.first - 3 * fabs(clsMin.second) > clsTarget) break;
           rMin += rMin;
           if (tries == 5) { 
              oocoutE((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Cannot set lower limit: at " << r->GetName() 
                                        << " = " << rMin << " still get " << (fUseCLs ? "CLs" : "CLsplusb") 
                                        << " = " << clsMin.first << std::endl;
              return false;
           }
        }
     }
  }

  if (fVerbose > 0) 
      oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Now doing proper bracketing & bisection" << std::endl;
  do {

     // break loop in case max toys is reached
     if (fMaxToys > 0 && fTotalToysRun > fMaxToys ) { 
        oocoutW((TObject*)0,Eval) << "HypoTestInverter::RunLimit - maximum number of toys reached  " << std::endl;
        done = false; break;
     }


     // determine point by bisection or interpolation
     limit = 0.5*(rMin+rMax); limitErr = 0.5*(rMax-rMin);
     if (fgAlgo == "logSecant" && clsMax.first != 0) {
        double logMin = log(clsMin.first), logMax = log(clsMax.first), logTarget = log(clsTarget);
        limit = rMin + (rMax-rMin) * (logTarget - logMin)/(logMax - logMin);
        if (clsMax.second != 0 && clsMin.second != 0) {
           limitErr = hypot((logTarget-logMax) * (clsMin.second/clsMin.first), (logTarget-logMin) * (clsMax.second/clsMax.first));
           limitErr *= (rMax-rMin)/((logMax-logMin)*(logMax-logMin));
        }
     }
     r->setError(limitErr);

     // exit if reached accuracy on r 
     if (limitErr < std::max(absAccuracy, relAccuracy * limit)) {
        if (fVerbose > 1) 
            oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunLimit - reached accuracy " << limitErr 
                                      << " below " << std::max(absAccuracy, relAccuracy * limit)  << std::endl;
        done = true; break;
     }
     
     // evaluate point 
     
     //clsMid = eval(w, mc_s, mc_b, data, limit, true, clsTarget);
     if (! RunOnePoint(limit, true, clsTarget) ) return false;
     clsMid = std::make_pair( fResults->GetLastYValue(), fResults->GetLastYError() );

     if (clsMid.second == -1) {
        std::cerr << "Hypotest failed" << std::endl;
        return false;
     }

     // if sufficiently far away, drop one of the points
     if (fabs(clsMid.first-clsTarget) >= 2*clsMid.second) {
        if ((clsMid.first>clsTarget) == (clsMax.first>clsTarget)) {
           rMax = limit; clsMax = clsMid;
        } else {
                  rMin = limit; clsMin = clsMid;
              }
          } else {
              if (fVerbose > 0) std::cout << "Trying to move the interval edges closer" << std::endl;
              double rMinBound = rMin, rMaxBound = rMax;
              // try to reduce the size of the interval 
              while (clsMin.second == 0 || fabs(rMin-limit) > std::max(absAccuracy, relAccuracy * limit)) {
                  rMin = 0.5*(rMin+limit); 
                  if (!RunOnePoint(rMin,true, clsTarget) ) return false;
                  clsMin = std::make_pair( fResults->GetLastYValue(), fResults->GetLastYError() );
                  //clsMin = eval(w, mc_s, mc_b, data, rMin, true, clsTarget); 
                  if (fabs(clsMin.first-clsTarget) <= 2*clsMin.second) break;
                  rMinBound = rMin;
              } 
              while (clsMax.second == 0 || fabs(rMax-limit) > std::max(absAccuracy, relAccuracy * limit)) {
                  rMax = 0.5*(rMax+limit); 
//                  clsMax = eval(w, mc_s, mc_b, data, rMax, true, clsTarget); 
                  if (!RunOnePoint(rMax,true,clsTarget) ) return false;
                  clsMax = std::make_pair( fResults->GetLastYValue(), fResults->GetLastYError() );
                  if (fabs(clsMax.first-clsTarget) <= 2*clsMax.second) break;
                  rMaxBound = rMax;
              } 
              expoFit.SetRange(rMinBound,rMaxBound);
              break;
          }
  } while (true);
  
  if (!done) { // didn't reach accuracy with scan, now do fit
      if (fVerbose) {
         oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Before fit   --- \n"; 
         std::cout << "Limit: " << r->GetName() << " < " << limit << " +/- " << limitErr << " [" << rMin << ", " << rMax << "]\n";
      }
      
      expoFit.FixParameter(0,clsTarget);
      expoFit.SetParameter(1,log(clsMax.first/clsMin.first)/(rMax-rMin));
      expoFit.SetParameter(2,limit);
      double rMinBound, rMaxBound; expoFit.GetRange(rMinBound, rMaxBound);
      limitErr = std::max(fabs(rMinBound-limit), fabs(rMaxBound-limit));
      int npoints = 0; 
      
      HypoTestInverterPlot plot("plot","plot",fResults);
      fLimitPlot.reset(plot.MakePlot() );

      
      for (int j = 0; j < fLimitPlot->GetN(); ++j) { 
         if (fLimitPlot->GetX()[j] >= rMinBound && fLimitPlot->GetX()[j] <= rMaxBound) npoints++; 
      }
      for (int i = 0, imax = /*(readHybridResults_ ? 0 : */  8; i <= imax; ++i, ++npoints) {
          fLimitPlot->Sort();
          fLimitPlot->Fit(&expoFit,(fVerbose <= 1 ? "QNR EX0" : "NR EXO"));
          if (fVerbose) {
               oocoutI((TObject*)0,Eval) << "Fit to " << npoints << " points: " << expoFit.GetParameter(2) << " +/- " << expoFit.GetParError(2) << std::endl;
          }
          if ((rMin < expoFit.GetParameter(2))  && (expoFit.GetParameter(2) < rMax) && (expoFit.GetParError(2) < 0.5*(rMaxBound-rMinBound))) { 
              // sanity check fit result
              limit = expoFit.GetParameter(2);
              limitErr = expoFit.GetParError(2);
              if (limitErr < std::max(absAccuracy, relAccuracy * limit)) break;
          }
          // add one point in the interval. 
          double rTry = RooRandom::uniform()*(rMaxBound-rMinBound)+rMinBound; 
          if (i != imax) { 
             if (!RunOnePoint(rTry,true,clsTarget) ) return false;
             //eval(w, mc_s, mc_b, data, rTry, true, clsTarget);
          }

      } 
  }

//if (!plot_.empty() && fLimitPlot.get()) {
  if (fLimitPlot.get() && fLimitPlot->GetN() > 0) {
       //new TCanvas("c1","c1");
      fLimitPlot->Sort();
      fLimitPlot->SetLineWidth(2);
      double xmin = r->getMin(), xmax = r->getMax();
      for (int j = 0; j < fLimitPlot->GetN(); ++j) {
        if (fLimitPlot->GetY()[j] > 1.4*clsTarget || fLimitPlot->GetY()[j] < 0.6*clsTarget) continue;
        xmin = std::min(fLimitPlot->GetX()[j], xmin);
        xmax = std::max(fLimitPlot->GetX()[j], xmax);
      }
      fLimitPlot->GetXaxis()->SetRangeUser(xmin,xmax);
      fLimitPlot->GetYaxis()->SetRangeUser(0.5*clsTarget, 1.5*clsTarget);
      fLimitPlot->Draw("AP");
      expoFit.Draw("SAME");
      TLine line(fLimitPlot->GetX()[0], clsTarget, fLimitPlot->GetX()[fLimitPlot->GetN()-1], clsTarget);
      line.SetLineColor(kRed); line.SetLineWidth(2); line.Draw();
      line.DrawLine(limit, 0, limit, fLimitPlot->GetY()[0]);
      line.SetLineWidth(1); line.SetLineStyle(2);
      line.DrawLine(limit-limitErr, 0, limit-limitErr, fLimitPlot->GetY()[0]);
      line.DrawLine(limit+limitErr, 0, limit+limitErr, fLimitPlot->GetY()[0]);
      //c1->Print(plot_.c_str());
  }

  oocoutI((TObject*)0,Eval) << "HypoTestInverter::RunLimit - Result:    \n" 
                            << "\tLimit: " << r->GetName() << " < " << limit << " +/- " << limitErr << " @ " << (1-fSize) * 100 << "% CL\n";
  if (fVerbose > 1) oocoutI((TObject*)0,Eval) << "Total toys: " << fTotalToysRun << std::endl;

  // set value in results
  fResults->fUpperLimit = limit; 
  fResults->fUpperLimitError = limitErr;
  fResults->fFittedUpperLimit = true;
  // lower limit are always min of p value
  fResults->fLowerLimit = fScannedVariable->getMin(); 
  fResults->fLowerLimitError = 0;
  fResults->fFittedLowerLimit = true; 

  return true;
}

SamplingDistribution * HypoTestInverter::GetLowerLimitDistribution(bool rebuild, int nToys) {
   // get the distribution of lower limit
   // if rebuild = false (default) it will re-use the results of the scan done 
   // for obtained the observed limit and no extra toys will be generated
   // if rebuild a new set of B toys will be done and the procedure will be repeted
   // for each toy
   if (!rebuild) {
      if (!fResults) { 
         oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::GetLowerLimitDistribution(false) - result not existing\n";
         return 0;
      }
      return fResults->GetLowerLimitDistribution(); 
   }

   TList * clsDist = 0;
   TList * clsbDist = 0;
   if (fUseCLs) clsDist = &fResults->fExpPValues;
   else clsbDist = &fResults->fExpPValues;
                   
   return RebuildDistributions(false, nToys,clsDist, clsbDist);

}

SamplingDistribution * HypoTestInverter::GetUpperLimitDistribution(bool rebuild, int nToys) {
   // get the distribution of lower limit
   // if rebuild = false (default) it will re-use the results of the scan done 
   // for obtained the observed limit and no extra toys will be generated
   // if rebuild a new set of B toys will be done and the procedure will be repeted
   // for each toy
   // The nuisance parameter value used for rebuild is the current one in the model
   // so it is user responsability to set to the desired value (nomi
   if (!rebuild) {
      if (!fResults) { 
         oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::GetUpperLimitDistribution(false) - result not existing\n";
         return 0;
      }
      return fResults->GetUpperLimitDistribution(); 
   }
   
   TList * clsDist = 0;
   TList * clsbDist = 0;
   if (fUseCLs) clsDist = &fResults->fExpPValues;
   else clsbDist = &fResults->fExpPValues;
                   
   return RebuildDistributions(true, nToys,clsDist, clsbDist);
}

void HypoTestInverter::SetData(RooAbsData & data) {
   if (fCalculator0) fCalculator0->SetData(data);
}

SamplingDistribution * HypoTestInverter::RebuildDistributions(bool isUpper, int nToys, TList * clsDist, TList * clsbDist, TList * clbDist, const char *outputfile) { 
   // rebuild the sampling distributions by 
   // generating some toys and find for each of theam a new upper limit
   // Return the upper limit distribution and optionally also the pValue distributions for Cls, Clsb and Clbxs
   // as a TList for each scanned point
   // The method uses the present parameter value. It is user responsability to give the current parameters to rebuild the distributions
   // It returns a upper or lower limit distribution depending on the isUpper flag, however it computes also the lower limit distribution and it is saved in the 
   // output file as an histogram  

   if (!fScannedVariable || !fCalculator0) return 0;
   // get first background snapshot
   const ModelConfig * bModel = fCalculator0->GetAlternateModel();
   const ModelConfig * sbModel = fCalculator0->GetNullModel();
   if (!bModel || ! sbModel) return 0;
   RooArgSet paramPoint;
   if (!sbModel->GetParametersOfInterest()) return 0;
   paramPoint.add(*sbModel->GetParametersOfInterest());

   const RooArgSet * poibkg = bModel->GetSnapshot();
   if (!poibkg) { 
      oocoutW((TObject*)0,InputArguments) << "HypoTestInverter::RebuildDistribution - bakground snapshot not existing" 
                                          << " assume is for POI = 0" << std::endl;
      fScannedVariable->setVal(0);
      paramPoint = RooArgSet(*fScannedVariable);
   }
   else 
      paramPoint = *poibkg; 
   // generate data at bkg parameter point

   ToyMCSampler * toymcSampler = dynamic_cast<ToyMCSampler *>(fCalculator0->GetTestStatSampler() );
   if (!toymcSampler) {
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter::RebuildDistribution - no toy MC sampler existing" << std::endl;
      return 0;
   }
   // set up test stat sampler in case of asymptotic calculator
   if (dynamic_cast<RooStats::AsymptoticCalculator*>(fCalculator0) ) { 
      toymcSampler->SetObservables(*sbModel->GetObservables() );
      toymcSampler->SetParametersForTestStat(*sbModel->GetParametersOfInterest());
      toymcSampler->SetPdf(*sbModel->GetPdf());
      toymcSampler->SetNuisanceParameters(*sbModel->GetNuisanceParameters());
      if (sbModel->GetGlobalObservables() )  toymcSampler->SetGlobalObservables(*sbModel->GetGlobalObservables() );
      // set number of events
      if (!sbModel->GetPdf()->canBeExtended())
         toymcSampler->SetNEventsPerToy(1);
   }

   // loop on data to generate 
   int nPoints = fNBins;

   bool storePValues = clsDist || clsbDist || clbDist;
   if (fNBins <=0  && storePValues) { 
      oocoutW((TObject*)0,InputArguments) << "HypoTestInverter::RebuildDistribution - cannot return p values distribution with the auto scan" << std::endl; 
      storePValues = false;
      nPoints = 0;
   } 
   
   if (storePValues) { 
      if (fResults) nPoints = fResults->ArraySize();
      if (nPoints <=0) { 
         oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - result is not existing and number of point to scan is not set" 
                                             << std::endl;
         return 0;
      }
   }

   if (nToys <= 0) nToys = 100; // default value

   std::vector<std::vector<double> > CLs_values(nPoints);
   std::vector<std::vector<double> > CLsb_values(nPoints);
   std::vector<std::vector<double> > CLb_values(nPoints);

   if (storePValues) { 
      for (int i = 0; i < nPoints; ++i) { 
         CLs_values[i].reserve(nToys);
         CLb_values[i].reserve(nToys);
         CLsb_values[i].reserve(nToys);
      }
   }

   std::vector<double> limit_values; limit_values.reserve(nToys);

   oocoutI((TObject*)0,InputArguments) << "HypoTestInverter - rebuilding  the p value distributions by generating ntoys = "
                                       << nToys << std::endl;

   
   oocoutI((TObject*)0,InputArguments) << "Rebuilding using parameter of interest point:  ";
   RooStats::PrintListContent(paramPoint, oocoutI((TObject*)0,InputArguments) );
   if (sbModel->GetNuisanceParameters() ) { 
      oocoutI((TObject*)0,InputArguments) << "And using nuisance parameters: ";
      RooStats::PrintListContent(*sbModel->GetNuisanceParameters(), oocoutI((TObject*)0,InputArguments) );
   }
   // save all parameters to restore them later 
   assert(bModel->GetPdf() );
   assert(bModel->GetObservables() );
   RooArgSet * allParams = bModel->GetPdf()->getParameters( *bModel->GetObservables() );
   RooArgSet saveParams; 
   allParams->snapshot(saveParams);
      
   TFile * fileOut = TFile::Open(outputfile,"RECREATE"); 
   if (!fileOut) { 
      oocoutE((TObject*)0,InputArguments) << "HypoTestInverter - RebuildDistributions - Error opening file " << outputfile 
                                          << " - the resulting limits will not be stored" << std::endl; 
   }
   // create  temporary histograms to store the limit result 
   TH1D * hL = new TH1D("lowerLimitDist","Rebuilt lower limit distribution",100,1.,0.); 
   TH1D * hU = new TH1D("upperLimitDist","Rebuilt upper limit distribution",100,1.,0.); 
   TH1D * hN = new TH1D("nObs","Observed events",100,1.,0.); 
   hL->SetBuffer(2*nToys); 
   hU->SetBuffer(2*nToys); 
   std::vector<TH1*> hCLb;
   std::vector<TH1*> hCLsb;
   std::vector<TH1*> hCLs;
   if (storePValues) { 
      for (int i = 0; i < nPoints; ++i) { 
         hCLb.push_back(new TH1D(TString::Format("CLbDist_bin%d",i),"CLb distribution",100,1.,0.)); 
         hCLs.push_back(new TH1D(TString::Format("ClsDist_bin%d",i),"CLs distribution",100,1.,0.)); 
         hCLsb.push_back(new TH1D(TString::Format("CLsbDist_bin%d",i),"CLs+b distribution",100,1.,0.)); 
      }
   }


   // loop now on the toys 
   for (int itoy = 0; itoy < nToys; ++itoy) { 

      oocoutP((TObject*)0,Eval) << "\nHypoTestInverter - RebuildDistributions - running toy # " << itoy << " / " 
                                       << nToys << std::endl;      


      printf("\n\nshnapshot of s+b model \n");
      sbModel->GetSnapshot()->Print("v");

      // reset parameters to initial values to be sure in case they are not reset
      if (itoy> 0) *allParams = saveParams;
      
      // need to set th epdf to clear the cache in ToyMCSampler
      // pdf we must use is background pdf 
      toymcSampler->SetPdf(*bModel->GetPdf() );


      RooAbsData * bkgdata = toymcSampler->GenerateToyData(paramPoint);

      double nObs = bkgdata->sumEntries(); 
      // for debugging in case of number counting models
      if (bkgdata->numEntries() ==1 && !bModel->GetPdf()->canBeExtended()) {         
         oocoutP((TObject*)0,Generation) << "Generate observables are : ";
         RooArgList  genObs(*bkgdata->get(0)); 
         RooStats::PrintListContent(genObs, oocoutP((TObject*)0,Generation) );
         nObs = 0;
         for (int i = 0; i < genObs.getSize(); ++i) {
            RooRealVar * x = dynamic_cast<RooRealVar*>(&genObs[i]);
            if (x) nObs += x->getVal();
         }
      }
      hN->Fill(nObs);

      // by copying I will have the same min/max as previous ones
      HypoTestInverter inverter = *this; 
      inverter.SetData(*bkgdata);

      // print global observables
      auto gobs = bModel->GetPdf()->getVariables()->selectCommon(* sbModel->GetGlobalObservables() );
      gobs->Print("v");
      
      HypoTestInverterResult * r  = inverter.GetInterval();
      
      if (r == 0) continue;

      double value = (isUpper) ? r->UpperLimit() : r->LowerLimit();
      limit_values.push_back( value );
      hU->Fill(r->UpperLimit() );
      hL->Fill(r->LowerLimit() );


      std::cout << "The computed upper limit for toy #" << itoy << " is " << value << std::endl;

      // write every 10 toys 
      if (itoy%10 == 0 || itoy == nToys-1) { 
         hU->Write("",TObject::kOverwrite);
         hL->Write("",TObject::kOverwrite);
         hN->Write("",TObject::kOverwrite);
      }

      if (!storePValues) continue;

      if (nPoints < r->ArraySize()) {
         oocoutW((TObject*)0,InputArguments) << "HypoTestInverter: skip extra points" << std::endl;
      }
      else if (nPoints > r->ArraySize()) {
         oocoutW((TObject*)0,InputArguments) << "HypoTestInverter: missing some points" << std::endl;
      }
      

      for (int ipoint = 0; ipoint < nPoints; ++ipoint) {
         HypoTestResult * hr = r->GetResult(ipoint);
         if (hr) { 
            CLs_values[ipoint].push_back( hr->CLs() );
            CLsb_values[ipoint].push_back( hr->CLsplusb() );
            CLb_values[ipoint].push_back( hr->CLb() );
            hCLs[ipoint]->Fill(  hr->CLs() );
            hCLb[ipoint]->Fill(  hr->CLb() );
            hCLsb[ipoint]->Fill(  hr->CLsplusb() );
         }
         else { 
            oocoutW((TObject*)0,InputArguments) << "HypoTestInverter: missing result for point: x = " 
                                                << fResults->GetXValue(ipoint) <<  std::endl;            
         }
      }
      // write every 10 toys 
      if (itoy%10 == 0 || itoy == nToys-1) { 
         for (int ipoint = 0; ipoint < nPoints; ++ipoint) {
            hCLs[ipoint]->Write("",TObject::kOverwrite);
            hCLb[ipoint]->Write("",TObject::kOverwrite);
            hCLsb[ipoint]->Write("",TObject::kOverwrite);
         }
      }


      delete r; 
      delete bkgdata;
   }


   if (storePValues) { 
      if (clsDist) clsDist->SetOwner(true);
      if (clbDist) clbDist->SetOwner(true);
      if (clsbDist) clsbDist->SetOwner(true);

      oocoutI((TObject*)0,InputArguments) << "HypoTestInverter: storing rebuilt p values  " << std::endl;

      for (int ipoint = 0; ipoint < nPoints; ++ipoint) {
         if (clsDist) {
            TString name = TString::Format("CLs_distrib_%d",ipoint);
            clsDist->Add( new SamplingDistribution(name,name,CLs_values[ipoint] ) );
         }
         if (clbDist) {
            TString name = TString::Format("CLb_distrib_%d",ipoint);
            clbDist->Add( new SamplingDistribution(name,name,CLb_values[ipoint] ) );
         }
         if (clsbDist) {
            TString name = TString::Format("CLsb_distrib_%d",ipoint);
            clsbDist->Add( new SamplingDistribution(name,name,CLsb_values[ipoint] ) );
         }
      }
   }

   if (fileOut) { 
      fileOut->Close(); 
   }
   else { 
      // delete all the histograms 
      delete hL; 
      delete hU;
      for (int i = 0; i < nPoints && storePValues; ++i) {
         delete hCLs[i]; 
         delete hCLb[i]; 
         delete hCLsb[i]; 
      }
   }

   const char * disName = (isUpper) ? "upperLimit_dist" : "lowerLimit_dist";
   return new SamplingDistribution(disName, disName, limit_values);
}
 HypoTestInverter.cxx:1
 HypoTestInverter.cxx:2
 HypoTestInverter.cxx:3
 HypoTestInverter.cxx:4
 HypoTestInverter.cxx:5
 HypoTestInverter.cxx:6
 HypoTestInverter.cxx:7
 HypoTestInverter.cxx:8
 HypoTestInverter.cxx:9
 HypoTestInverter.cxx:10
 HypoTestInverter.cxx:11
 HypoTestInverter.cxx:12
 HypoTestInverter.cxx:13
 HypoTestInverter.cxx:14
 HypoTestInverter.cxx:15
 HypoTestInverter.cxx:16
 HypoTestInverter.cxx:17
 HypoTestInverter.cxx:18
 HypoTestInverter.cxx:19
 HypoTestInverter.cxx:20
 HypoTestInverter.cxx:21
 HypoTestInverter.cxx:22
 HypoTestInverter.cxx:23
 HypoTestInverter.cxx:24
 HypoTestInverter.cxx:25
 HypoTestInverter.cxx:26
 HypoTestInverter.cxx:27
 HypoTestInverter.cxx:28
 HypoTestInverter.cxx:29
 HypoTestInverter.cxx:30
 HypoTestInverter.cxx:31
 HypoTestInverter.cxx:32
 HypoTestInverter.cxx:33
 HypoTestInverter.cxx:34
 HypoTestInverter.cxx:35
 HypoTestInverter.cxx:36
 HypoTestInverter.cxx:37
 HypoTestInverter.cxx:38
 HypoTestInverter.cxx:39
 HypoTestInverter.cxx:40
 HypoTestInverter.cxx:41
 HypoTestInverter.cxx:42
 HypoTestInverter.cxx:43
 HypoTestInverter.cxx:44
 HypoTestInverter.cxx:45
 HypoTestInverter.cxx:46
 HypoTestInverter.cxx:47
 HypoTestInverter.cxx:48
 HypoTestInverter.cxx:49
 HypoTestInverter.cxx:50
 HypoTestInverter.cxx:51
 HypoTestInverter.cxx:52
 HypoTestInverter.cxx:53
 HypoTestInverter.cxx:54
 HypoTestInverter.cxx:55
 HypoTestInverter.cxx:56
 HypoTestInverter.cxx:57
 HypoTestInverter.cxx:58
 HypoTestInverter.cxx:59
 HypoTestInverter.cxx:60
 HypoTestInverter.cxx:61
 HypoTestInverter.cxx:62
 HypoTestInverter.cxx:63
 HypoTestInverter.cxx:64
 HypoTestInverter.cxx:65
 HypoTestInverter.cxx:66
 HypoTestInverter.cxx:67
 HypoTestInverter.cxx:68
 HypoTestInverter.cxx:69
 HypoTestInverter.cxx:70
 HypoTestInverter.cxx:71
 HypoTestInverter.cxx:72
 HypoTestInverter.cxx:73
 HypoTestInverter.cxx:74
 HypoTestInverter.cxx:75
 HypoTestInverter.cxx:76
 HypoTestInverter.cxx:77
 HypoTestInverter.cxx:78
 HypoTestInverter.cxx:79
 HypoTestInverter.cxx:80
 HypoTestInverter.cxx:81
 HypoTestInverter.cxx:82
 HypoTestInverter.cxx:83
 HypoTestInverter.cxx:84
 HypoTestInverter.cxx:85
 HypoTestInverter.cxx:86
 HypoTestInverter.cxx:87
 HypoTestInverter.cxx:88
 HypoTestInverter.cxx:89
 HypoTestInverter.cxx:90
 HypoTestInverter.cxx:91
 HypoTestInverter.cxx:92
 HypoTestInverter.cxx:93
 HypoTestInverter.cxx:94
 HypoTestInverter.cxx:95
 HypoTestInverter.cxx:96
 HypoTestInverter.cxx:97
 HypoTestInverter.cxx:98
 HypoTestInverter.cxx:99
 HypoTestInverter.cxx:100
 HypoTestInverter.cxx:101
 HypoTestInverter.cxx:102
 HypoTestInverter.cxx:103
 HypoTestInverter.cxx:104
 HypoTestInverter.cxx:105
 HypoTestInverter.cxx:106
 HypoTestInverter.cxx:107
 HypoTestInverter.cxx:108
 HypoTestInverter.cxx:109
 HypoTestInverter.cxx:110
 HypoTestInverter.cxx:111
 HypoTestInverter.cxx:112
 HypoTestInverter.cxx:113
 HypoTestInverter.cxx:114
 HypoTestInverter.cxx:115
 HypoTestInverter.cxx:116
 HypoTestInverter.cxx:117
 HypoTestInverter.cxx:118
 HypoTestInverter.cxx:119
 HypoTestInverter.cxx:120
 HypoTestInverter.cxx:121
 HypoTestInverter.cxx:122
 HypoTestInverter.cxx:123
 HypoTestInverter.cxx:124
 HypoTestInverter.cxx:125
 HypoTestInverter.cxx:126
 HypoTestInverter.cxx:127
 HypoTestInverter.cxx:128
 HypoTestInverter.cxx:129
 HypoTestInverter.cxx:130
 HypoTestInverter.cxx:131
 HypoTestInverter.cxx:132
 HypoTestInverter.cxx:133
 HypoTestInverter.cxx:134
 HypoTestInverter.cxx:135
 HypoTestInverter.cxx:136
 HypoTestInverter.cxx:137
 HypoTestInverter.cxx:138
 HypoTestInverter.cxx:139
 HypoTestInverter.cxx:140
 HypoTestInverter.cxx:141
 HypoTestInverter.cxx:142
 HypoTestInverter.cxx:143
 HypoTestInverter.cxx:144
 HypoTestInverter.cxx:145
 HypoTestInverter.cxx:146
 HypoTestInverter.cxx:147
 HypoTestInverter.cxx:148
 HypoTestInverter.cxx:149
 HypoTestInverter.cxx:150
 HypoTestInverter.cxx:151
 HypoTestInverter.cxx:152
 HypoTestInverter.cxx:153
 HypoTestInverter.cxx:154
 HypoTestInverter.cxx:155
 HypoTestInverter.cxx:156
 HypoTestInverter.cxx:157
 HypoTestInverter.cxx:158
 HypoTestInverter.cxx:159
 HypoTestInverter.cxx:160
 HypoTestInverter.cxx:161
 HypoTestInverter.cxx:162
 HypoTestInverter.cxx:163
 HypoTestInverter.cxx:164
 HypoTestInverter.cxx:165
 HypoTestInverter.cxx:166
 HypoTestInverter.cxx:167
 HypoTestInverter.cxx:168
 HypoTestInverter.cxx:169
 HypoTestInverter.cxx:170
 HypoTestInverter.cxx:171
 HypoTestInverter.cxx:172
 HypoTestInverter.cxx:173
 HypoTestInverter.cxx:174
 HypoTestInverter.cxx:175
 HypoTestInverter.cxx:176
 HypoTestInverter.cxx:177
 HypoTestInverter.cxx:178
 HypoTestInverter.cxx:179
 HypoTestInverter.cxx:180
 HypoTestInverter.cxx:181
 HypoTestInverter.cxx:182
 HypoTestInverter.cxx:183
 HypoTestInverter.cxx:184
 HypoTestInverter.cxx:185
 HypoTestInverter.cxx:186
 HypoTestInverter.cxx:187
 HypoTestInverter.cxx:188
 HypoTestInverter.cxx:189
 HypoTestInverter.cxx:190
 HypoTestInverter.cxx:191
 HypoTestInverter.cxx:192
 HypoTestInverter.cxx:193
 HypoTestInverter.cxx:194
 HypoTestInverter.cxx:195
 HypoTestInverter.cxx:196
 HypoTestInverter.cxx:197
 HypoTestInverter.cxx:198
 HypoTestInverter.cxx:199
 HypoTestInverter.cxx:200
 HypoTestInverter.cxx:201
 HypoTestInverter.cxx:202
 HypoTestInverter.cxx:203
 HypoTestInverter.cxx:204
 HypoTestInverter.cxx:205
 HypoTestInverter.cxx:206
 HypoTestInverter.cxx:207
 HypoTestInverter.cxx:208
 HypoTestInverter.cxx:209
 HypoTestInverter.cxx:210
 HypoTestInverter.cxx:211
 HypoTestInverter.cxx:212
 HypoTestInverter.cxx:213
 HypoTestInverter.cxx:214
 HypoTestInverter.cxx:215
 HypoTestInverter.cxx:216
 HypoTestInverter.cxx:217
 HypoTestInverter.cxx:218
 HypoTestInverter.cxx:219
 HypoTestInverter.cxx:220
 HypoTestInverter.cxx:221
 HypoTestInverter.cxx:222
 HypoTestInverter.cxx:223
 HypoTestInverter.cxx:224
 HypoTestInverter.cxx:225
 HypoTestInverter.cxx:226
 HypoTestInverter.cxx:227
 HypoTestInverter.cxx:228
 HypoTestInverter.cxx:229
 HypoTestInverter.cxx:230
 HypoTestInverter.cxx:231
 HypoTestInverter.cxx:232
 HypoTestInverter.cxx:233
 HypoTestInverter.cxx:234
 HypoTestInverter.cxx:235
 HypoTestInverter.cxx:236
 HypoTestInverter.cxx:237
 HypoTestInverter.cxx:238
 HypoTestInverter.cxx:239
 HypoTestInverter.cxx:240
 HypoTestInverter.cxx:241
 HypoTestInverter.cxx:242
 HypoTestInverter.cxx:243
 HypoTestInverter.cxx:244
 HypoTestInverter.cxx:245
 HypoTestInverter.cxx:246
 HypoTestInverter.cxx:247
 HypoTestInverter.cxx:248
 HypoTestInverter.cxx:249
 HypoTestInverter.cxx:250
 HypoTestInverter.cxx:251
 HypoTestInverter.cxx:252
 HypoTestInverter.cxx:253
 HypoTestInverter.cxx:254
 HypoTestInverter.cxx:255
 HypoTestInverter.cxx:256
 HypoTestInverter.cxx:257
 HypoTestInverter.cxx:258
 HypoTestInverter.cxx:259
 HypoTestInverter.cxx:260
 HypoTestInverter.cxx:261
 HypoTestInverter.cxx:262
 HypoTestInverter.cxx:263
 HypoTestInverter.cxx:264
 HypoTestInverter.cxx:265
 HypoTestInverter.cxx:266
 HypoTestInverter.cxx:267
 HypoTestInverter.cxx:268
 HypoTestInverter.cxx:269
 HypoTestInverter.cxx:270
 HypoTestInverter.cxx:271
 HypoTestInverter.cxx:272
 HypoTestInverter.cxx:273
 HypoTestInverter.cxx:274
 HypoTestInverter.cxx:275
 HypoTestInverter.cxx:276
 HypoTestInverter.cxx:277
 HypoTestInverter.cxx:278
 HypoTestInverter.cxx:279
 HypoTestInverter.cxx:280
 HypoTestInverter.cxx:281
 HypoTestInverter.cxx:282
 HypoTestInverter.cxx:283
 HypoTestInverter.cxx:284
 HypoTestInverter.cxx:285
 HypoTestInverter.cxx:286
 HypoTestInverter.cxx:287
 HypoTestInverter.cxx:288
 HypoTestInverter.cxx:289
 HypoTestInverter.cxx:290
 HypoTestInverter.cxx:291
 HypoTestInverter.cxx:292
 HypoTestInverter.cxx:293
 HypoTestInverter.cxx:294
 HypoTestInverter.cxx:295
 HypoTestInverter.cxx:296
 HypoTestInverter.cxx:297
 HypoTestInverter.cxx:298
 HypoTestInverter.cxx:299
 HypoTestInverter.cxx:300
 HypoTestInverter.cxx:301
 HypoTestInverter.cxx:302
 HypoTestInverter.cxx:303
 HypoTestInverter.cxx:304
 HypoTestInverter.cxx:305
 HypoTestInverter.cxx:306
 HypoTestInverter.cxx:307
 HypoTestInverter.cxx:308
 HypoTestInverter.cxx:309
 HypoTestInverter.cxx:310
 HypoTestInverter.cxx:311
 HypoTestInverter.cxx:312
 HypoTestInverter.cxx:313
 HypoTestInverter.cxx:314
 HypoTestInverter.cxx:315
 HypoTestInverter.cxx:316
 HypoTestInverter.cxx:317
 HypoTestInverter.cxx:318
 HypoTestInverter.cxx:319
 HypoTestInverter.cxx:320
 HypoTestInverter.cxx:321
 HypoTestInverter.cxx:322
 HypoTestInverter.cxx:323
 HypoTestInverter.cxx:324
 HypoTestInverter.cxx:325
 HypoTestInverter.cxx:326
 HypoTestInverter.cxx:327
 HypoTestInverter.cxx:328
 HypoTestInverter.cxx:329
 HypoTestInverter.cxx:330
 HypoTestInverter.cxx:331
 HypoTestInverter.cxx:332
 HypoTestInverter.cxx:333
 HypoTestInverter.cxx:334
 HypoTestInverter.cxx:335
 HypoTestInverter.cxx:336
 HypoTestInverter.cxx:337
 HypoTestInverter.cxx:338
 HypoTestInverter.cxx:339
 HypoTestInverter.cxx:340
 HypoTestInverter.cxx:341
 HypoTestInverter.cxx:342
 HypoTestInverter.cxx:343
 HypoTestInverter.cxx:344
 HypoTestInverter.cxx:345
 HypoTestInverter.cxx:346
 HypoTestInverter.cxx:347
 HypoTestInverter.cxx:348
 HypoTestInverter.cxx:349
 HypoTestInverter.cxx:350
 HypoTestInverter.cxx:351
 HypoTestInverter.cxx:352
 HypoTestInverter.cxx:353
 HypoTestInverter.cxx:354
 HypoTestInverter.cxx:355
 HypoTestInverter.cxx:356
 HypoTestInverter.cxx:357
 HypoTestInverter.cxx:358
 HypoTestInverter.cxx:359
 HypoTestInverter.cxx:360
 HypoTestInverter.cxx:361
 HypoTestInverter.cxx:362
 HypoTestInverter.cxx:363
 HypoTestInverter.cxx:364
 HypoTestInverter.cxx:365
 HypoTestInverter.cxx:366
 HypoTestInverter.cxx:367
 HypoTestInverter.cxx:368
 HypoTestInverter.cxx:369
 HypoTestInverter.cxx:370
 HypoTestInverter.cxx:371
 HypoTestInverter.cxx:372
 HypoTestInverter.cxx:373
 HypoTestInverter.cxx:374
 HypoTestInverter.cxx:375
 HypoTestInverter.cxx:376
 HypoTestInverter.cxx:377
 HypoTestInverter.cxx:378
 HypoTestInverter.cxx:379
 HypoTestInverter.cxx:380
 HypoTestInverter.cxx:381
 HypoTestInverter.cxx:382
 HypoTestInverter.cxx:383
 HypoTestInverter.cxx:384
 HypoTestInverter.cxx:385
 HypoTestInverter.cxx:386
 HypoTestInverter.cxx:387
 HypoTestInverter.cxx:388
 HypoTestInverter.cxx:389
 HypoTestInverter.cxx:390
 HypoTestInverter.cxx:391
 HypoTestInverter.cxx:392
 HypoTestInverter.cxx:393
 HypoTestInverter.cxx:394
 HypoTestInverter.cxx:395
 HypoTestInverter.cxx:396
 HypoTestInverter.cxx:397
 HypoTestInverter.cxx:398
 HypoTestInverter.cxx:399
 HypoTestInverter.cxx:400
 HypoTestInverter.cxx:401
 HypoTestInverter.cxx:402
 HypoTestInverter.cxx:403
 HypoTestInverter.cxx:404
 HypoTestInverter.cxx:405
 HypoTestInverter.cxx:406
 HypoTestInverter.cxx:407
 HypoTestInverter.cxx:408
 HypoTestInverter.cxx:409
 HypoTestInverter.cxx:410
 HypoTestInverter.cxx:411
 HypoTestInverter.cxx:412
 HypoTestInverter.cxx:413
 HypoTestInverter.cxx:414
 HypoTestInverter.cxx:415
 HypoTestInverter.cxx:416
 HypoTestInverter.cxx:417
 HypoTestInverter.cxx:418
 HypoTestInverter.cxx:419
 HypoTestInverter.cxx:420
 HypoTestInverter.cxx:421
 HypoTestInverter.cxx:422
 HypoTestInverter.cxx:423
 HypoTestInverter.cxx:424
 HypoTestInverter.cxx:425
 HypoTestInverter.cxx:426
 HypoTestInverter.cxx:427
 HypoTestInverter.cxx:428
 HypoTestInverter.cxx:429
 HypoTestInverter.cxx:430
 HypoTestInverter.cxx:431
 HypoTestInverter.cxx:432
 HypoTestInverter.cxx:433
 HypoTestInverter.cxx:434
 HypoTestInverter.cxx:435
 HypoTestInverter.cxx:436
 HypoTestInverter.cxx:437
 HypoTestInverter.cxx:438
 HypoTestInverter.cxx:439
 HypoTestInverter.cxx:440
 HypoTestInverter.cxx:441
 HypoTestInverter.cxx:442
 HypoTestInverter.cxx:443
 HypoTestInverter.cxx:444
 HypoTestInverter.cxx:445
 HypoTestInverter.cxx:446
 HypoTestInverter.cxx:447
 HypoTestInverter.cxx:448
 HypoTestInverter.cxx:449
 HypoTestInverter.cxx:450
 HypoTestInverter.cxx:451
 HypoTestInverter.cxx:452
 HypoTestInverter.cxx:453
 HypoTestInverter.cxx:454
 HypoTestInverter.cxx:455
 HypoTestInverter.cxx:456
 HypoTestInverter.cxx:457
 HypoTestInverter.cxx:458
 HypoTestInverter.cxx:459
 HypoTestInverter.cxx:460
 HypoTestInverter.cxx:461
 HypoTestInverter.cxx:462
 HypoTestInverter.cxx:463
 HypoTestInverter.cxx:464
 HypoTestInverter.cxx:465
 HypoTestInverter.cxx:466
 HypoTestInverter.cxx:467
 HypoTestInverter.cxx:468
 HypoTestInverter.cxx:469
 HypoTestInverter.cxx:470
 HypoTestInverter.cxx:471
 HypoTestInverter.cxx:472
 HypoTestInverter.cxx:473
 HypoTestInverter.cxx:474
 HypoTestInverter.cxx:475
 HypoTestInverter.cxx:476
 HypoTestInverter.cxx:477
 HypoTestInverter.cxx:478
 HypoTestInverter.cxx:479
 HypoTestInverter.cxx:480
 HypoTestInverter.cxx:481
 HypoTestInverter.cxx:482
 HypoTestInverter.cxx:483
 HypoTestInverter.cxx:484
 HypoTestInverter.cxx:485
 HypoTestInverter.cxx:486
 HypoTestInverter.cxx:487
 HypoTestInverter.cxx:488
 HypoTestInverter.cxx:489
 HypoTestInverter.cxx:490
 HypoTestInverter.cxx:491
 HypoTestInverter.cxx:492
 HypoTestInverter.cxx:493
 HypoTestInverter.cxx:494
 HypoTestInverter.cxx:495
 HypoTestInverter.cxx:496
 HypoTestInverter.cxx:497
 HypoTestInverter.cxx:498
 HypoTestInverter.cxx:499
 HypoTestInverter.cxx:500
 HypoTestInverter.cxx:501
 HypoTestInverter.cxx:502
 HypoTestInverter.cxx:503
 HypoTestInverter.cxx:504
 HypoTestInverter.cxx:505
 HypoTestInverter.cxx:506
 HypoTestInverter.cxx:507
 HypoTestInverter.cxx:508
 HypoTestInverter.cxx:509
 HypoTestInverter.cxx:510
 HypoTestInverter.cxx:511
 HypoTestInverter.cxx:512
 HypoTestInverter.cxx:513
 HypoTestInverter.cxx:514
 HypoTestInverter.cxx:515
 HypoTestInverter.cxx:516
 HypoTestInverter.cxx:517
 HypoTestInverter.cxx:518
 HypoTestInverter.cxx:519
 HypoTestInverter.cxx:520
 HypoTestInverter.cxx:521
 HypoTestInverter.cxx:522
 HypoTestInverter.cxx:523
 HypoTestInverter.cxx:524
 HypoTestInverter.cxx:525
 HypoTestInverter.cxx:526
 HypoTestInverter.cxx:527
 HypoTestInverter.cxx:528
 HypoTestInverter.cxx:529
 HypoTestInverter.cxx:530
 HypoTestInverter.cxx:531
 HypoTestInverter.cxx:532
 HypoTestInverter.cxx:533
 HypoTestInverter.cxx:534
 HypoTestInverter.cxx:535
 HypoTestInverter.cxx:536
 HypoTestInverter.cxx:537
 HypoTestInverter.cxx:538
 HypoTestInverter.cxx:539
 HypoTestInverter.cxx:540
 HypoTestInverter.cxx:541
 HypoTestInverter.cxx:542
 HypoTestInverter.cxx:543
 HypoTestInverter.cxx:544
 HypoTestInverter.cxx:545
 HypoTestInverter.cxx:546
 HypoTestInverter.cxx:547
 HypoTestInverter.cxx:548
 HypoTestInverter.cxx:549
 HypoTestInverter.cxx:550
 HypoTestInverter.cxx:551
 HypoTestInverter.cxx:552
 HypoTestInverter.cxx:553
 HypoTestInverter.cxx:554
 HypoTestInverter.cxx:555
 HypoTestInverter.cxx:556
 HypoTestInverter.cxx:557
 HypoTestInverter.cxx:558
 HypoTestInverter.cxx:559
 HypoTestInverter.cxx:560
 HypoTestInverter.cxx:561
 HypoTestInverter.cxx:562
 HypoTestInverter.cxx:563
 HypoTestInverter.cxx:564
 HypoTestInverter.cxx:565
 HypoTestInverter.cxx:566
 HypoTestInverter.cxx:567
 HypoTestInverter.cxx:568
 HypoTestInverter.cxx:569
 HypoTestInverter.cxx:570
 HypoTestInverter.cxx:571
 HypoTestInverter.cxx:572
 HypoTestInverter.cxx:573
 HypoTestInverter.cxx:574
 HypoTestInverter.cxx:575
 HypoTestInverter.cxx:576
 HypoTestInverter.cxx:577
 HypoTestInverter.cxx:578
 HypoTestInverter.cxx:579
 HypoTestInverter.cxx:580
 HypoTestInverter.cxx:581
 HypoTestInverter.cxx:582
 HypoTestInverter.cxx:583
 HypoTestInverter.cxx:584
 HypoTestInverter.cxx:585
 HypoTestInverter.cxx:586
 HypoTestInverter.cxx:587
 HypoTestInverter.cxx:588
 HypoTestInverter.cxx:589
 HypoTestInverter.cxx:590
 HypoTestInverter.cxx:591
 HypoTestInverter.cxx:592
 HypoTestInverter.cxx:593
 HypoTestInverter.cxx:594
 HypoTestInverter.cxx:595
 HypoTestInverter.cxx:596
 HypoTestInverter.cxx:597
 HypoTestInverter.cxx:598
 HypoTestInverter.cxx:599
 HypoTestInverter.cxx:600
 HypoTestInverter.cxx:601
 HypoTestInverter.cxx:602
 HypoTestInverter.cxx:603
 HypoTestInverter.cxx:604
 HypoTestInverter.cxx:605
 HypoTestInverter.cxx:606
 HypoTestInverter.cxx:607
 HypoTestInverter.cxx:608
 HypoTestInverter.cxx:609
 HypoTestInverter.cxx:610
 HypoTestInverter.cxx:611
 HypoTestInverter.cxx:612
 HypoTestInverter.cxx:613
 HypoTestInverter.cxx:614
 HypoTestInverter.cxx:615
 HypoTestInverter.cxx:616
 HypoTestInverter.cxx:617
 HypoTestInverter.cxx:618
 HypoTestInverter.cxx:619
 HypoTestInverter.cxx:620
 HypoTestInverter.cxx:621
 HypoTestInverter.cxx:622
 HypoTestInverter.cxx:623
 HypoTestInverter.cxx:624
 HypoTestInverter.cxx:625
 HypoTestInverter.cxx:626
 HypoTestInverter.cxx:627
 HypoTestInverter.cxx:628
 HypoTestInverter.cxx:629
 HypoTestInverter.cxx:630
 HypoTestInverter.cxx:631
 HypoTestInverter.cxx:632
 HypoTestInverter.cxx:633
 HypoTestInverter.cxx:634
 HypoTestInverter.cxx:635
 HypoTestInverter.cxx:636
 HypoTestInverter.cxx:637
 HypoTestInverter.cxx:638
 HypoTestInverter.cxx:639
 HypoTestInverter.cxx:640
 HypoTestInverter.cxx:641
 HypoTestInverter.cxx:642
 HypoTestInverter.cxx:643
 HypoTestInverter.cxx:644
 HypoTestInverter.cxx:645
 HypoTestInverter.cxx:646
 HypoTestInverter.cxx:647
 HypoTestInverter.cxx:648
 HypoTestInverter.cxx:649
 HypoTestInverter.cxx:650
 HypoTestInverter.cxx:651
 HypoTestInverter.cxx:652
 HypoTestInverter.cxx:653
 HypoTestInverter.cxx:654
 HypoTestInverter.cxx:655
 HypoTestInverter.cxx:656
 HypoTestInverter.cxx:657
 HypoTestInverter.cxx:658
 HypoTestInverter.cxx:659
 HypoTestInverter.cxx:660
 HypoTestInverter.cxx:661
 HypoTestInverter.cxx:662
 HypoTestInverter.cxx:663
 HypoTestInverter.cxx:664
 HypoTestInverter.cxx:665
 HypoTestInverter.cxx:666
 HypoTestInverter.cxx:667
 HypoTestInverter.cxx:668
 HypoTestInverter.cxx:669
 HypoTestInverter.cxx:670
 HypoTestInverter.cxx:671
 HypoTestInverter.cxx:672
 HypoTestInverter.cxx:673
 HypoTestInverter.cxx:674
 HypoTestInverter.cxx:675
 HypoTestInverter.cxx:676
 HypoTestInverter.cxx:677
 HypoTestInverter.cxx:678
 HypoTestInverter.cxx:679
 HypoTestInverter.cxx:680
 HypoTestInverter.cxx:681
 HypoTestInverter.cxx:682
 HypoTestInverter.cxx:683
 HypoTestInverter.cxx:684
 HypoTestInverter.cxx:685
 HypoTestInverter.cxx:686
 HypoTestInverter.cxx:687
 HypoTestInverter.cxx:688
 HypoTestInverter.cxx:689
 HypoTestInverter.cxx:690
 HypoTestInverter.cxx:691
 HypoTestInverter.cxx:692
 HypoTestInverter.cxx:693
 HypoTestInverter.cxx:694
 HypoTestInverter.cxx:695
 HypoTestInverter.cxx:696
 HypoTestInverter.cxx:697
 HypoTestInverter.cxx:698
 HypoTestInverter.cxx:699
 HypoTestInverter.cxx:700
 HypoTestInverter.cxx:701
 HypoTestInverter.cxx:702
 HypoTestInverter.cxx:703
 HypoTestInverter.cxx:704
 HypoTestInverter.cxx:705
 HypoTestInverter.cxx:706
 HypoTestInverter.cxx:707
 HypoTestInverter.cxx:708
 HypoTestInverter.cxx:709
 HypoTestInverter.cxx:710
 HypoTestInverter.cxx:711
 HypoTestInverter.cxx:712
 HypoTestInverter.cxx:713
 HypoTestInverter.cxx:714
 HypoTestInverter.cxx:715
 HypoTestInverter.cxx:716
 HypoTestInverter.cxx:717
 HypoTestInverter.cxx:718
 HypoTestInverter.cxx:719
 HypoTestInverter.cxx:720
 HypoTestInverter.cxx:721
 HypoTestInverter.cxx:722
 HypoTestInverter.cxx:723
 HypoTestInverter.cxx:724
 HypoTestInverter.cxx:725
 HypoTestInverter.cxx:726
 HypoTestInverter.cxx:727
 HypoTestInverter.cxx:728
 HypoTestInverter.cxx:729
 HypoTestInverter.cxx:730
 HypoTestInverter.cxx:731
 HypoTestInverter.cxx:732
 HypoTestInverter.cxx:733
 HypoTestInverter.cxx:734
 HypoTestInverter.cxx:735
 HypoTestInverter.cxx:736
 HypoTestInverter.cxx:737
 HypoTestInverter.cxx:738
 HypoTestInverter.cxx:739
 HypoTestInverter.cxx:740
 HypoTestInverter.cxx:741
 HypoTestInverter.cxx:742
 HypoTestInverter.cxx:743
 HypoTestInverter.cxx:744
 HypoTestInverter.cxx:745
 HypoTestInverter.cxx:746
 HypoTestInverter.cxx:747
 HypoTestInverter.cxx:748
 HypoTestInverter.cxx:749
 HypoTestInverter.cxx:750
 HypoTestInverter.cxx:751
 HypoTestInverter.cxx:752
 HypoTestInverter.cxx:753
 HypoTestInverter.cxx:754
 HypoTestInverter.cxx:755
 HypoTestInverter.cxx:756
 HypoTestInverter.cxx:757
 HypoTestInverter.cxx:758
 HypoTestInverter.cxx:759
 HypoTestInverter.cxx:760
 HypoTestInverter.cxx:761
 HypoTestInverter.cxx:762
 HypoTestInverter.cxx:763
 HypoTestInverter.cxx:764
 HypoTestInverter.cxx:765
 HypoTestInverter.cxx:766
 HypoTestInverter.cxx:767
 HypoTestInverter.cxx:768
 HypoTestInverter.cxx:769
 HypoTestInverter.cxx:770
 HypoTestInverter.cxx:771
 HypoTestInverter.cxx:772
 HypoTestInverter.cxx:773
 HypoTestInverter.cxx:774
 HypoTestInverter.cxx:775
 HypoTestInverter.cxx:776
 HypoTestInverter.cxx:777
 HypoTestInverter.cxx:778
 HypoTestInverter.cxx:779
 HypoTestInverter.cxx:780
 HypoTestInverter.cxx:781
 HypoTestInverter.cxx:782
 HypoTestInverter.cxx:783
 HypoTestInverter.cxx:784
 HypoTestInverter.cxx:785
 HypoTestInverter.cxx:786
 HypoTestInverter.cxx:787
 HypoTestInverter.cxx:788
 HypoTestInverter.cxx:789
 HypoTestInverter.cxx:790
 HypoTestInverter.cxx:791
 HypoTestInverter.cxx:792
 HypoTestInverter.cxx:793
 HypoTestInverter.cxx:794
 HypoTestInverter.cxx:795
 HypoTestInverter.cxx:796
 HypoTestInverter.cxx:797
 HypoTestInverter.cxx:798
 HypoTestInverter.cxx:799
 HypoTestInverter.cxx:800
 HypoTestInverter.cxx:801
 HypoTestInverter.cxx:802
 HypoTestInverter.cxx:803
 HypoTestInverter.cxx:804
 HypoTestInverter.cxx:805
 HypoTestInverter.cxx:806
 HypoTestInverter.cxx:807
 HypoTestInverter.cxx:808
 HypoTestInverter.cxx:809
 HypoTestInverter.cxx:810
 HypoTestInverter.cxx:811
 HypoTestInverter.cxx:812
 HypoTestInverter.cxx:813
 HypoTestInverter.cxx:814
 HypoTestInverter.cxx:815
 HypoTestInverter.cxx:816
 HypoTestInverter.cxx:817
 HypoTestInverter.cxx:818
 HypoTestInverter.cxx:819
 HypoTestInverter.cxx:820
 HypoTestInverter.cxx:821
 HypoTestInverter.cxx:822
 HypoTestInverter.cxx:823
 HypoTestInverter.cxx:824
 HypoTestInverter.cxx:825
 HypoTestInverter.cxx:826
 HypoTestInverter.cxx:827
 HypoTestInverter.cxx:828
 HypoTestInverter.cxx:829
 HypoTestInverter.cxx:830
 HypoTestInverter.cxx:831
 HypoTestInverter.cxx:832
 HypoTestInverter.cxx:833
 HypoTestInverter.cxx:834
 HypoTestInverter.cxx:835
 HypoTestInverter.cxx:836
 HypoTestInverter.cxx:837
 HypoTestInverter.cxx:838
 HypoTestInverter.cxx:839
 HypoTestInverter.cxx:840
 HypoTestInverter.cxx:841
 HypoTestInverter.cxx:842
 HypoTestInverter.cxx:843
 HypoTestInverter.cxx:844
 HypoTestInverter.cxx:845
 HypoTestInverter.cxx:846
 HypoTestInverter.cxx:847
 HypoTestInverter.cxx:848
 HypoTestInverter.cxx:849
 HypoTestInverter.cxx:850
 HypoTestInverter.cxx:851
 HypoTestInverter.cxx:852
 HypoTestInverter.cxx:853
 HypoTestInverter.cxx:854
 HypoTestInverter.cxx:855
 HypoTestInverter.cxx:856
 HypoTestInverter.cxx:857
 HypoTestInverter.cxx:858
 HypoTestInverter.cxx:859
 HypoTestInverter.cxx:860
 HypoTestInverter.cxx:861
 HypoTestInverter.cxx:862
 HypoTestInverter.cxx:863
 HypoTestInverter.cxx:864
 HypoTestInverter.cxx:865
 HypoTestInverter.cxx:866
 HypoTestInverter.cxx:867
 HypoTestInverter.cxx:868
 HypoTestInverter.cxx:869
 HypoTestInverter.cxx:870
 HypoTestInverter.cxx:871
 HypoTestInverter.cxx:872
 HypoTestInverter.cxx:873
 HypoTestInverter.cxx:874
 HypoTestInverter.cxx:875
 HypoTestInverter.cxx:876
 HypoTestInverter.cxx:877
 HypoTestInverter.cxx:878
 HypoTestInverter.cxx:879
 HypoTestInverter.cxx:880
 HypoTestInverter.cxx:881
 HypoTestInverter.cxx:882
 HypoTestInverter.cxx:883
 HypoTestInverter.cxx:884
 HypoTestInverter.cxx:885
 HypoTestInverter.cxx:886
 HypoTestInverter.cxx:887
 HypoTestInverter.cxx:888
 HypoTestInverter.cxx:889
 HypoTestInverter.cxx:890
 HypoTestInverter.cxx:891
 HypoTestInverter.cxx:892
 HypoTestInverter.cxx:893
 HypoTestInverter.cxx:894
 HypoTestInverter.cxx:895
 HypoTestInverter.cxx:896
 HypoTestInverter.cxx:897
 HypoTestInverter.cxx:898
 HypoTestInverter.cxx:899
 HypoTestInverter.cxx:900
 HypoTestInverter.cxx:901
 HypoTestInverter.cxx:902
 HypoTestInverter.cxx:903
 HypoTestInverter.cxx:904
 HypoTestInverter.cxx:905
 HypoTestInverter.cxx:906
 HypoTestInverter.cxx:907
 HypoTestInverter.cxx:908
 HypoTestInverter.cxx:909
 HypoTestInverter.cxx:910
 HypoTestInverter.cxx:911
 HypoTestInverter.cxx:912
 HypoTestInverter.cxx:913
 HypoTestInverter.cxx:914
 HypoTestInverter.cxx:915
 HypoTestInverter.cxx:916
 HypoTestInverter.cxx:917
 HypoTestInverter.cxx:918
 HypoTestInverter.cxx:919
 HypoTestInverter.cxx:920
 HypoTestInverter.cxx:921
 HypoTestInverter.cxx:922
 HypoTestInverter.cxx:923
 HypoTestInverter.cxx:924
 HypoTestInverter.cxx:925
 HypoTestInverter.cxx:926
 HypoTestInverter.cxx:927
 HypoTestInverter.cxx:928
 HypoTestInverter.cxx:929
 HypoTestInverter.cxx:930
 HypoTestInverter.cxx:931
 HypoTestInverter.cxx:932
 HypoTestInverter.cxx:933
 HypoTestInverter.cxx:934
 HypoTestInverter.cxx:935
 HypoTestInverter.cxx:936
 HypoTestInverter.cxx:937
 HypoTestInverter.cxx:938
 HypoTestInverter.cxx:939
 HypoTestInverter.cxx:940
 HypoTestInverter.cxx:941
 HypoTestInverter.cxx:942
 HypoTestInverter.cxx:943
 HypoTestInverter.cxx:944
 HypoTestInverter.cxx:945
 HypoTestInverter.cxx:946
 HypoTestInverter.cxx:947
 HypoTestInverter.cxx:948
 HypoTestInverter.cxx:949
 HypoTestInverter.cxx:950
 HypoTestInverter.cxx:951
 HypoTestInverter.cxx:952
 HypoTestInverter.cxx:953
 HypoTestInverter.cxx:954
 HypoTestInverter.cxx:955
 HypoTestInverter.cxx:956
 HypoTestInverter.cxx:957
 HypoTestInverter.cxx:958
 HypoTestInverter.cxx:959
 HypoTestInverter.cxx:960
 HypoTestInverter.cxx:961
 HypoTestInverter.cxx:962
 HypoTestInverter.cxx:963
 HypoTestInverter.cxx:964
 HypoTestInverter.cxx:965
 HypoTestInverter.cxx:966
 HypoTestInverter.cxx:967
 HypoTestInverter.cxx:968
 HypoTestInverter.cxx:969
 HypoTestInverter.cxx:970
 HypoTestInverter.cxx:971
 HypoTestInverter.cxx:972
 HypoTestInverter.cxx:973
 HypoTestInverter.cxx:974
 HypoTestInverter.cxx:975
 HypoTestInverter.cxx:976
 HypoTestInverter.cxx:977
 HypoTestInverter.cxx:978
 HypoTestInverter.cxx:979
 HypoTestInverter.cxx:980
 HypoTestInverter.cxx:981
 HypoTestInverter.cxx:982
 HypoTestInverter.cxx:983
 HypoTestInverter.cxx:984
 HypoTestInverter.cxx:985
 HypoTestInverter.cxx:986
 HypoTestInverter.cxx:987
 HypoTestInverter.cxx:988
 HypoTestInverter.cxx:989
 HypoTestInverter.cxx:990
 HypoTestInverter.cxx:991
 HypoTestInverter.cxx:992
 HypoTestInverter.cxx:993
 HypoTestInverter.cxx:994
 HypoTestInverter.cxx:995
 HypoTestInverter.cxx:996
 HypoTestInverter.cxx:997
 HypoTestInverter.cxx:998
 HypoTestInverter.cxx:999
 HypoTestInverter.cxx:1000
 HypoTestInverter.cxx:1001
 HypoTestInverter.cxx:1002
 HypoTestInverter.cxx:1003
 HypoTestInverter.cxx:1004
 HypoTestInverter.cxx:1005
 HypoTestInverter.cxx:1006
 HypoTestInverter.cxx:1007
 HypoTestInverter.cxx:1008
 HypoTestInverter.cxx:1009
 HypoTestInverter.cxx:1010
 HypoTestInverter.cxx:1011
 HypoTestInverter.cxx:1012
 HypoTestInverter.cxx:1013
 HypoTestInverter.cxx:1014
 HypoTestInverter.cxx:1015
 HypoTestInverter.cxx:1016
 HypoTestInverter.cxx:1017
 HypoTestInverter.cxx:1018
 HypoTestInverter.cxx:1019
 HypoTestInverter.cxx:1020
 HypoTestInverter.cxx:1021
 HypoTestInverter.cxx:1022
 HypoTestInverter.cxx:1023
 HypoTestInverter.cxx:1024
 HypoTestInverter.cxx:1025
 HypoTestInverter.cxx:1026
 HypoTestInverter.cxx:1027
 HypoTestInverter.cxx:1028
 HypoTestInverter.cxx:1029
 HypoTestInverter.cxx:1030
 HypoTestInverter.cxx:1031
 HypoTestInverter.cxx:1032
 HypoTestInverter.cxx:1033
 HypoTestInverter.cxx:1034
 HypoTestInverter.cxx:1035
 HypoTestInverter.cxx:1036
 HypoTestInverter.cxx:1037
 HypoTestInverter.cxx:1038
 HypoTestInverter.cxx:1039
 HypoTestInverter.cxx:1040
 HypoTestInverter.cxx:1041
 HypoTestInverter.cxx:1042
 HypoTestInverter.cxx:1043
 HypoTestInverter.cxx:1044
 HypoTestInverter.cxx:1045
 HypoTestInverter.cxx:1046
 HypoTestInverter.cxx:1047
 HypoTestInverter.cxx:1048
 HypoTestInverter.cxx:1049
 HypoTestInverter.cxx:1050
 HypoTestInverter.cxx:1051
 HypoTestInverter.cxx:1052
 HypoTestInverter.cxx:1053
 HypoTestInverter.cxx:1054
 HypoTestInverter.cxx:1055
 HypoTestInverter.cxx:1056
 HypoTestInverter.cxx:1057
 HypoTestInverter.cxx:1058
 HypoTestInverter.cxx:1059
 HypoTestInverter.cxx:1060
 HypoTestInverter.cxx:1061
 HypoTestInverter.cxx:1062
 HypoTestInverter.cxx:1063
 HypoTestInverter.cxx:1064
 HypoTestInverter.cxx:1065
 HypoTestInverter.cxx:1066
 HypoTestInverter.cxx:1067
 HypoTestInverter.cxx:1068
 HypoTestInverter.cxx:1069
 HypoTestInverter.cxx:1070
 HypoTestInverter.cxx:1071
 HypoTestInverter.cxx:1072
 HypoTestInverter.cxx:1073
 HypoTestInverter.cxx:1074
 HypoTestInverter.cxx:1075
 HypoTestInverter.cxx:1076
 HypoTestInverter.cxx:1077
 HypoTestInverter.cxx:1078
 HypoTestInverter.cxx:1079
 HypoTestInverter.cxx:1080
 HypoTestInverter.cxx:1081
 HypoTestInverter.cxx:1082
 HypoTestInverter.cxx:1083
 HypoTestInverter.cxx:1084
 HypoTestInverter.cxx:1085
 HypoTestInverter.cxx:1086
 HypoTestInverter.cxx:1087
 HypoTestInverter.cxx:1088
 HypoTestInverter.cxx:1089
 HypoTestInverter.cxx:1090
 HypoTestInverter.cxx:1091
 HypoTestInverter.cxx:1092
 HypoTestInverter.cxx:1093
 HypoTestInverter.cxx:1094
 HypoTestInverter.cxx:1095
 HypoTestInverter.cxx:1096
 HypoTestInverter.cxx:1097
 HypoTestInverter.cxx:1098
 HypoTestInverter.cxx:1099
 HypoTestInverter.cxx:1100
 HypoTestInverter.cxx:1101
 HypoTestInverter.cxx:1102
 HypoTestInverter.cxx:1103
 HypoTestInverter.cxx:1104
 HypoTestInverter.cxx:1105
 HypoTestInverter.cxx:1106
 HypoTestInverter.cxx:1107
 HypoTestInverter.cxx:1108
 HypoTestInverter.cxx:1109
 HypoTestInverter.cxx:1110
 HypoTestInverter.cxx:1111
 HypoTestInverter.cxx:1112
 HypoTestInverter.cxx:1113
 HypoTestInverter.cxx:1114
 HypoTestInverter.cxx:1115
 HypoTestInverter.cxx:1116
 HypoTestInverter.cxx:1117
 HypoTestInverter.cxx:1118
 HypoTestInverter.cxx:1119
 HypoTestInverter.cxx:1120
 HypoTestInverter.cxx:1121
 HypoTestInverter.cxx:1122
 HypoTestInverter.cxx:1123
 HypoTestInverter.cxx:1124
 HypoTestInverter.cxx:1125
 HypoTestInverter.cxx:1126
 HypoTestInverter.cxx:1127
 HypoTestInverter.cxx:1128
 HypoTestInverter.cxx:1129
 HypoTestInverter.cxx:1130
 HypoTestInverter.cxx:1131
 HypoTestInverter.cxx:1132
 HypoTestInverter.cxx:1133
 HypoTestInverter.cxx:1134
 HypoTestInverter.cxx:1135
 HypoTestInverter.cxx:1136
 HypoTestInverter.cxx:1137
 HypoTestInverter.cxx:1138
 HypoTestInverter.cxx:1139
 HypoTestInverter.cxx:1140
 HypoTestInverter.cxx:1141
 HypoTestInverter.cxx:1142
 HypoTestInverter.cxx:1143
 HypoTestInverter.cxx:1144
 HypoTestInverter.cxx:1145
 HypoTestInverter.cxx:1146
 HypoTestInverter.cxx:1147
 HypoTestInverter.cxx:1148
 HypoTestInverter.cxx:1149
 HypoTestInverter.cxx:1150
 HypoTestInverter.cxx:1151
 HypoTestInverter.cxx:1152
 HypoTestInverter.cxx:1153
 HypoTestInverter.cxx:1154
 HypoTestInverter.cxx:1155
 HypoTestInverter.cxx:1156
 HypoTestInverter.cxx:1157
 HypoTestInverter.cxx:1158
 HypoTestInverter.cxx:1159
 HypoTestInverter.cxx:1160
 HypoTestInverter.cxx:1161
 HypoTestInverter.cxx:1162
 HypoTestInverter.cxx:1163
 HypoTestInverter.cxx:1164
 HypoTestInverter.cxx:1165
 HypoTestInverter.cxx:1166
 HypoTestInverter.cxx:1167
 HypoTestInverter.cxx:1168
 HypoTestInverter.cxx:1169
 HypoTestInverter.cxx:1170
 HypoTestInverter.cxx:1171
 HypoTestInverter.cxx:1172
 HypoTestInverter.cxx:1173
 HypoTestInverter.cxx:1174
 HypoTestInverter.cxx:1175
 HypoTestInverter.cxx:1176
 HypoTestInverter.cxx:1177
 HypoTestInverter.cxx:1178
 HypoTestInverter.cxx:1179
 HypoTestInverter.cxx:1180
 HypoTestInverter.cxx:1181
 HypoTestInverter.cxx:1182
 HypoTestInverter.cxx:1183
 HypoTestInverter.cxx:1184
 HypoTestInverter.cxx:1185
 HypoTestInverter.cxx:1186
 HypoTestInverter.cxx:1187
 HypoTestInverter.cxx:1188
 HypoTestInverter.cxx:1189
 HypoTestInverter.cxx:1190
 HypoTestInverter.cxx:1191
 HypoTestInverter.cxx:1192
 HypoTestInverter.cxx:1193
 HypoTestInverter.cxx:1194
 HypoTestInverter.cxx:1195
 HypoTestInverter.cxx:1196
 HypoTestInverter.cxx:1197
 HypoTestInverter.cxx:1198
 HypoTestInverter.cxx:1199
 HypoTestInverter.cxx:1200
 HypoTestInverter.cxx:1201
 HypoTestInverter.cxx:1202
 HypoTestInverter.cxx:1203
 HypoTestInverter.cxx:1204
 HypoTestInverter.cxx:1205
 HypoTestInverter.cxx:1206
 HypoTestInverter.cxx:1207
 HypoTestInverter.cxx:1208
 HypoTestInverter.cxx:1209
 HypoTestInverter.cxx:1210
 HypoTestInverter.cxx:1211
 HypoTestInverter.cxx:1212
 HypoTestInverter.cxx:1213
 HypoTestInverter.cxx:1214
 HypoTestInverter.cxx:1215
 HypoTestInverter.cxx:1216
 HypoTestInverter.cxx:1217
 HypoTestInverter.cxx:1218
 HypoTestInverter.cxx:1219
 HypoTestInverter.cxx:1220
 HypoTestInverter.cxx:1221
 HypoTestInverter.cxx:1222
 HypoTestInverter.cxx:1223
 HypoTestInverter.cxx:1224
 HypoTestInverter.cxx:1225
 HypoTestInverter.cxx:1226
 HypoTestInverter.cxx:1227
 HypoTestInverter.cxx:1228
 HypoTestInverter.cxx:1229
 HypoTestInverter.cxx:1230
 HypoTestInverter.cxx:1231
 HypoTestInverter.cxx:1232
 HypoTestInverter.cxx:1233
 HypoTestInverter.cxx:1234
 HypoTestInverter.cxx:1235
 HypoTestInverter.cxx:1236
 HypoTestInverter.cxx:1237
 HypoTestInverter.cxx:1238
 HypoTestInverter.cxx:1239
 HypoTestInverter.cxx:1240
 HypoTestInverter.cxx:1241
 HypoTestInverter.cxx:1242
 HypoTestInverter.cxx:1243
 HypoTestInverter.cxx:1244
 HypoTestInverter.cxx:1245
 HypoTestInverter.cxx:1246
 HypoTestInverter.cxx:1247
 HypoTestInverter.cxx:1248
 HypoTestInverter.cxx:1249
 HypoTestInverter.cxx:1250
 HypoTestInverter.cxx:1251
 HypoTestInverter.cxx:1252
 HypoTestInverter.cxx:1253
 HypoTestInverter.cxx:1254
 HypoTestInverter.cxx:1255
 HypoTestInverter.cxx:1256
 HypoTestInverter.cxx:1257
 HypoTestInverter.cxx:1258
 HypoTestInverter.cxx:1259
 HypoTestInverter.cxx:1260
 HypoTestInverter.cxx:1261
 HypoTestInverter.cxx:1262
 HypoTestInverter.cxx:1263
 HypoTestInverter.cxx:1264
 HypoTestInverter.cxx:1265
 HypoTestInverter.cxx:1266
 HypoTestInverter.cxx:1267
 HypoTestInverter.cxx:1268
 HypoTestInverter.cxx:1269
 HypoTestInverter.cxx:1270
 HypoTestInverter.cxx:1271
 HypoTestInverter.cxx:1272
 HypoTestInverter.cxx:1273
 HypoTestInverter.cxx:1274
 HypoTestInverter.cxx:1275
 HypoTestInverter.cxx:1276
 HypoTestInverter.cxx:1277
 HypoTestInverter.cxx:1278
 HypoTestInverter.cxx:1279
 HypoTestInverter.cxx:1280
 HypoTestInverter.cxx:1281
 HypoTestInverter.cxx:1282
 HypoTestInverter.cxx:1283
 HypoTestInverter.cxx:1284
 HypoTestInverter.cxx:1285
 HypoTestInverter.cxx:1286
 HypoTestInverter.cxx:1287
 HypoTestInverter.cxx:1288
 HypoTestInverter.cxx:1289
 HypoTestInverter.cxx:1290
 HypoTestInverter.cxx:1291
 HypoTestInverter.cxx:1292
 HypoTestInverter.cxx:1293
 HypoTestInverter.cxx:1294
 HypoTestInverter.cxx:1295
 HypoTestInverter.cxx:1296
 HypoTestInverter.cxx:1297
 HypoTestInverter.cxx:1298
 HypoTestInverter.cxx:1299
 HypoTestInverter.cxx:1300
 HypoTestInverter.cxx:1301
 HypoTestInverter.cxx:1302
 HypoTestInverter.cxx:1303
 HypoTestInverter.cxx:1304
 HypoTestInverter.cxx:1305
 HypoTestInverter.cxx:1306
 HypoTestInverter.cxx:1307
 HypoTestInverter.cxx:1308