HypoTestInverterPlot.cxx

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: HypoTestInverterPlot.cxx 31322 2009-11-19 16:47:43Z moneta $
00002 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 /**
00012    HypoTestInverterPlot class
00013 **/
00014 
00015 // include other header files
00016 #include "RooStats/HybridResult.h"
00017 
00018 // include header file of this class 
00019 #include "RooStats/HypoTestInverterPlot.h"
00020 #include "RooStats/HypoTestInverterResult.h"
00021 
00022 #include "TGraphErrors.h"
00023 
00024 ClassImp(RooStats::HypoTestInverterPlot)
00025 
00026 using namespace RooStats;
00027 
00028 
00029 
00030 HypoTestInverterPlot::HypoTestInverterPlot( const char* name,
00031                                             const char* title,
00032                                             HypoTestInverterResult* results ) :
00033   TNamed( TString(name), TString(title) ),
00034   fResults(results)
00035 {
00036   // constructor
00037 }
00038 
00039 
00040 TGraphErrors* HypoTestInverterPlot::MakePlot()
00041 {
00042   const int nEntries = fResults->ArraySize();
00043 
00044   std::vector<Double_t> xArray(nEntries);
00045   std::vector<Double_t> yArray(nEntries);
00046   std::vector<Double_t> yErrArray(nEntries);
00047   for (int i=0; i<nEntries; i++) {
00048     xArray[i] = fResults->GetXValue(i);
00049     yArray[i] = fResults->GetYValue(i);
00050     yErrArray[i] = fResults->GetYError(i);
00051   }
00052   
00053   // sort the arrays based on the x values (using Gnome-sort algorithm)
00054   if (nEntries>1) {
00055     int i=1;
00056     int j=2;
00057     while ( i<nEntries ) {
00058       if ( i==0 || xArray[i-1] <= xArray[i] ) {
00059         i=j;
00060         j++;
00061       } else {
00062         double tmp = xArray[i-1];
00063         xArray[i-1] = xArray[i];
00064         xArray[i] = tmp;
00065         tmp = yArray[i-1];
00066         yArray[i-1] = yArray[i];
00067         yArray[i] = tmp;
00068         tmp = yErrArray[i-1];
00069         yErrArray[i-1] = yErrArray[i];
00070         yErrArray[i] = tmp;
00071         i--;
00072       }
00073     }
00074   }
00075 
00076   TGraphErrors* graph = new TGraphErrors(nEntries,&xArray.front(),&yArray.front(),0,&yErrArray.front());
00077   graph->SetMarkerStyle(kFullDotMedium);
00078   return graph;
00079 }
00080 
00081 HypoTestInverterPlot::~HypoTestInverterPlot()
00082 {
00083   // destructor
00084 }

Generated on Tue Jul 5 15:14:34 2011 for ROOT_528-00b_version by  doxygen 1.5.1