ROOT logo
// @(#)root/roostats:$Id: HypoTestInverterPlot.cxx 31322 2009-11-19 16:47:43Z moneta $
// 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.             *
 *************************************************************************/

/**
   HypoTestInverterPlot class
**/

// include other header files
#include "RooStats/HybridResult.h"

// include header file of this class 
#include "RooStats/HypoTestInverterPlot.h"
#include "RooStats/HypoTestInverterResult.h"

#include "TGraphErrors.h"

ClassImp(RooStats::HypoTestInverterPlot)

using namespace RooStats;



HypoTestInverterPlot::HypoTestInverterPlot( const char* name,
					    const char* title,
					    HypoTestInverterResult* results ) :
  TNamed( TString(name), TString(title) ),
  fResults(results)
{
  // constructor
}


TGraphErrors* HypoTestInverterPlot::MakePlot()
{
  const int nEntries = fResults->ArraySize();

  std::vector<Double_t> xArray(nEntries);
  std::vector<Double_t> yArray(nEntries);
  std::vector<Double_t> yErrArray(nEntries);
  for (int i=0; i<nEntries; i++) {
    xArray[i] = fResults->GetXValue(i);
    yArray[i] = fResults->GetYValue(i);
    yErrArray[i] = fResults->GetYError(i);
  }
  
  // sort the arrays based on the x values (using Gnome-sort algorithm)
  if (nEntries>1) {
    int i=1;
    int j=2;
    while ( i<nEntries ) {
      if ( i==0 || xArray[i-1] <= xArray[i] ) {
	i=j;
	j++;
      } else {
	double tmp = xArray[i-1];
	xArray[i-1] = xArray[i];
	xArray[i] = tmp;
	tmp = yArray[i-1];
	yArray[i-1] = yArray[i];
	yArray[i] = tmp;
	tmp = yErrArray[i-1];
	yErrArray[i-1] = yErrArray[i];
	yErrArray[i] = tmp;
	i--;
      }
    }
  }

  TGraphErrors* graph = new TGraphErrors(nEntries,&xArray.front(),&yArray.front(),0,&yErrArray.front());
  graph->SetMarkerStyle(kFullDotMedium);
  return graph;
}

HypoTestInverterPlot::~HypoTestInverterPlot()
{
  // destructor
}
 HypoTestInverterPlot.cxx:1
 HypoTestInverterPlot.cxx:2
 HypoTestInverterPlot.cxx:3
 HypoTestInverterPlot.cxx:4
 HypoTestInverterPlot.cxx:5
 HypoTestInverterPlot.cxx:6
 HypoTestInverterPlot.cxx:7
 HypoTestInverterPlot.cxx:8
 HypoTestInverterPlot.cxx:9
 HypoTestInverterPlot.cxx:10
 HypoTestInverterPlot.cxx:11
 HypoTestInverterPlot.cxx:12
 HypoTestInverterPlot.cxx:13
 HypoTestInverterPlot.cxx:14
 HypoTestInverterPlot.cxx:15
 HypoTestInverterPlot.cxx:16
 HypoTestInverterPlot.cxx:17
 HypoTestInverterPlot.cxx:18
 HypoTestInverterPlot.cxx:19
 HypoTestInverterPlot.cxx:20
 HypoTestInverterPlot.cxx:21
 HypoTestInverterPlot.cxx:22
 HypoTestInverterPlot.cxx:23
 HypoTestInverterPlot.cxx:24
 HypoTestInverterPlot.cxx:25
 HypoTestInverterPlot.cxx:26
 HypoTestInverterPlot.cxx:27
 HypoTestInverterPlot.cxx:28
 HypoTestInverterPlot.cxx:29
 HypoTestInverterPlot.cxx:30
 HypoTestInverterPlot.cxx:31
 HypoTestInverterPlot.cxx:32
 HypoTestInverterPlot.cxx:33
 HypoTestInverterPlot.cxx:34
 HypoTestInverterPlot.cxx:35
 HypoTestInverterPlot.cxx:36
 HypoTestInverterPlot.cxx:37
 HypoTestInverterPlot.cxx:38
 HypoTestInverterPlot.cxx:39
 HypoTestInverterPlot.cxx:40
 HypoTestInverterPlot.cxx:41
 HypoTestInverterPlot.cxx:42
 HypoTestInverterPlot.cxx:43
 HypoTestInverterPlot.cxx:44
 HypoTestInverterPlot.cxx:45
 HypoTestInverterPlot.cxx:46
 HypoTestInverterPlot.cxx:47
 HypoTestInverterPlot.cxx:48
 HypoTestInverterPlot.cxx:49
 HypoTestInverterPlot.cxx:50
 HypoTestInverterPlot.cxx:51
 HypoTestInverterPlot.cxx:52
 HypoTestInverterPlot.cxx:53
 HypoTestInverterPlot.cxx:54
 HypoTestInverterPlot.cxx:55
 HypoTestInverterPlot.cxx:56
 HypoTestInverterPlot.cxx:57
 HypoTestInverterPlot.cxx:58
 HypoTestInverterPlot.cxx:59
 HypoTestInverterPlot.cxx:60
 HypoTestInverterPlot.cxx:61
 HypoTestInverterPlot.cxx:62
 HypoTestInverterPlot.cxx:63
 HypoTestInverterPlot.cxx:64
 HypoTestInverterPlot.cxx:65
 HypoTestInverterPlot.cxx:66
 HypoTestInverterPlot.cxx:67
 HypoTestInverterPlot.cxx:68
 HypoTestInverterPlot.cxx:69
 HypoTestInverterPlot.cxx:70
 HypoTestInverterPlot.cxx:71
 HypoTestInverterPlot.cxx:72
 HypoTestInverterPlot.cxx:73
 HypoTestInverterPlot.cxx:74
 HypoTestInverterPlot.cxx:75
 HypoTestInverterPlot.cxx:76
 HypoTestInverterPlot.cxx:77
 HypoTestInverterPlot.cxx:78
 HypoTestInverterPlot.cxx:79
 HypoTestInverterPlot.cxx:80
 HypoTestInverterPlot.cxx:81
 HypoTestInverterPlot.cxx:82
 HypoTestInverterPlot.cxx:83
 HypoTestInverterPlot.cxx:84