CMS 3D CMS Logo

Public Member Functions | Private Attributes

LRHelpFunctions Class Reference

Help functionalities to implement and evaluate LR ratio method. More...

#include <TopQuarkAnalysis/TopTools/interface/LRHelpFunctions.h>

List of all members.

Public Member Functions

double calcLRval (std::vector< double >)
double calcProb (double)
double calcPtdrLRval (std::vector< double > vals, bool useCorrelation=false)
void fillLRBackgroundHist (double, double weight=1.0)
void fillLRSignalHist (double, double weight=1.0)
void fillToBackgroundHists (std::vector< double >, double weight=1.0)
void fillToBackgroundHists (int, double, double weight=1.0)
void fillToSignalCorrelation (int obsNbr1, double obsVal1, int obsNbr2, double obsVal2, double weight)
void fillToSignalHists (std::vector< double >, double weight=1.0)
void fillToSignalHists (int, double, double weight=1.0)
void initLRHistsAndFits (int, double, double, const char *)
 LRHelpFunctions (std::vector< int >, int, std::vector< double >, std::vector< double >, std::vector< const char * >)
 LRHelpFunctions ()
 LRHelpFunctions (int, double, double, const char *)
void makeAndFitPurityHists ()
void makeAndFitSoverSplusBHists ()
void normalizeSandBhists ()
bool obsFitIncluded (int)
void purityPlot (TString fname, TString extension=TString("eps"))
void readObsHistsAndFits (TString, std::vector< int >, bool)
void recreateFitFct (std::vector< int > obsNr, std::vector< const char * > functions)
void setObsFitParameters (int obs, std::vector< double >)
void setXlabels (const std::vector< std::string > &xLabels)
void setYlabels (const std::vector< std::string > &yLabels)
void singlePlot (TString fname, int obsNbr, TString extension=TString("eps"))
void storeControlPlots (TString)
void storeToROOTfile (TString)
 ~LRHelpFunctions ()

Private Attributes

bool constructPurity
TF1 * fLRtotSoverSplusB
std::vector< TF1 * > fObsSoverSplusB
TGraph * hEffvsPur
TH1F * hLRtotB
TH1F * hLRtotS
TH1F * hLRtotSoverSplusB
TGraph * hLRValvsEff
TGraph * hLRValvsPur
std::vector< TH1F * > hObsB
std::vector< TH2F * > hObsCorr
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsSoverSplusB
std::vector< int > obsNumbers

Detailed Description

Help functionalities to implement and evaluate LR ratio method.

Author:
Jan Heyninck
Version:
Id:
LRHelpFunctions.h,v 1.10 2008/06/19 12:28:27 rwolf Exp

Definition at line 37 of file LRHelpFunctions.h.


Constructor & Destructor Documentation

LRHelpFunctions::LRHelpFunctions ( )

Definition at line 5 of file LRHelpFunctions.cc.

References constructPurity, and plotscripts::setTDRStyle().

                                 {
  constructPurity = false;
  setTDRStyle();
  gStyle->SetCanvasDefW(900);
}
LRHelpFunctions::LRHelpFunctions ( std::vector< int >  obsNr,
int  nrBins,
std::vector< double >  obsMin,
std::vector< double >  obsMax,
std::vector< const char * >  functions 
)

Definition at line 12 of file LRHelpFunctions.cc.

References constructPurity, fObsSoverSplusB, hObsB, hObsCorr, hObsS, hObsSoverSplusB, python::connectstrParser::o, obsNumbers, and plotscripts::setTDRStyle().

                                                                                                                                                       { 
  obsNumbers = obsNr;
  constructPurity = false;
  setTDRStyle();
  gStyle->SetCanvasDefW(900);
  for(size_t o=0; o<obsNr.size(); o++){
    // create Signal, background and s/(s+b) histogram
    TString htS  = "Obs"; htS  += obsNr[o]; htS += "_S"; 
    TString htB  = "Obs"; htB  += obsNr[o]; htB += "_B"; 
    TString htSB = "Obs"; htSB += obsNr[o]; htSB += "_SoverSplusB"; 
    hObsS.push_back( new TH1F(htS,htS,nrBins,obsMin[o],obsMax[o]) );
    hObsB.push_back( new TH1F(htB,htB,nrBins,obsMin[o],obsMax[o]) );
    hObsSoverSplusB.push_back( new TH1F(htSB,htSB,nrBins,obsMin[o],obsMax[o]) );
    
    // create the correlation 2D plots among the observables (for signal)
    for (size_t o2 = o+1; o2 < obsNr.size(); o2++) {
      TString hcorr  = "Corr_Obs"; hcorr  += obsNr[o]; hcorr += "_Obs";  hcorr  += obsNr[o2]; 
      hObsCorr.push_back( new TH2F(hcorr,hcorr,nrBins,obsMin[o],obsMax[o],nrBins,obsMin[o2],obsMax[o2]) );
    }    
    
    // create fit functions
    TString ftSB = "F_Obs"; ftSB += obsNr[o]; ftSB += "_SoverSplusB"; 
    fObsSoverSplusB.push_back( new TF1(ftSB,functions[o],hObsS[o]->GetXaxis()->GetXmin(),hObsS[o]->GetXaxis()->GetXmax()) );
  }
}
LRHelpFunctions::LRHelpFunctions ( int  nrLRbins,
double  LRmin,
double  LRmax,
const char *  LRfunction 
)

Definition at line 47 of file LRHelpFunctions.cc.

References constructPurity, fLRtotSoverSplusB, hLRtotB, hLRtotS, hLRtotSoverSplusB, and plotscripts::setTDRStyle().

                                                                                                 { 
  constructPurity = true;
  setTDRStyle();
  gStyle->SetCanvasDefW(900);

  // create LR histograms
  hLRtotS = new TH1F("hLRtotS","hLRtotS",nrLRbins,LRmin,LRmax);
  hLRtotS->GetXaxis()->SetTitle("Combined LR");
  hLRtotB = new TH1F("hLRtotB","hLRtotB",nrLRbins,LRmin,LRmax);
  hLRtotB->GetXaxis()->SetTitle("Combined LR");
  hLRtotSoverSplusB = new TH1F("hLRtotSoverSplusB","hLRtotSoverSplusB",nrLRbins,LRmin,LRmax);
    
  // create LR fit function
  fLRtotSoverSplusB = new TF1("fLRtotSoverSplusB",LRfunction,LRmin,LRmax);
}
LRHelpFunctions::~LRHelpFunctions ( )

Definition at line 65 of file LRHelpFunctions.cc.

{}

Member Function Documentation

double LRHelpFunctions::calcLRval ( std::vector< double >  vals)

Definition at line 361 of file LRHelpFunctions.cc.

References fObsSoverSplusB, create_public_lumi_plots::log, and python::connectstrParser::o.

Referenced by TtSemiLRJetCombCalc::operator()(), TtHadLRJetCombCalc::operator()(), TtSemiLRSignalSelCalc::operator()(), and TtHadLRSignalSelCalc::operator()().

                                                        {
  double logLR = 0.;
  for(size_t o=0; o<fObsSoverSplusB.size(); o++){
    double SoverSplusN = fObsSoverSplusB[o]->Eval(vals[o]);
    double SoverN = 1./((1./SoverSplusN) - 1.);
    logLR += log(SoverN);
  }  
  return logLR;
}
double LRHelpFunctions::calcProb ( double  logLR)
double LRHelpFunctions::calcPtdrLRval ( std::vector< double >  vals,
bool  useCorrelation = false 
)

Definition at line 375 of file LRHelpFunctions.cc.

References corr, fObsSoverSplusB, hObsCorr, i, j, max(), min, python::connectstrParser::o, obsNumbers, and funct::pow().

                                                                                 {
  double logLR = 1.;
  for(size_t o=0; o<fObsSoverSplusB.size(); o++){
    double SoverSplusN = fObsSoverSplusB[o]->Eval(vals[o]);
    if (SoverSplusN<0.0001) SoverSplusN=0.0001;
    if (useCorrelation){
      double corr = 0;
      for(size_t j=0; j<fObsSoverSplusB.size(); j++){
        if (o==j) ++corr;
        else {
          TString hcorr  = "Corr_Obs"; hcorr  += std::min(obsNumbers[o],obsNumbers[j]) ; hcorr += "_Obs";  hcorr  += std::max(obsNumbers[o],obsNumbers[j]);
          for(size_t i=0; i<hObsCorr.size(); i++) {
            if(((TString)(hObsCorr[i]->GetName())) == hcorr)
              corr += fabs(hObsCorr[i]->GetCorrelationFactor());
          }
        }
      }
     logLR *= pow(SoverSplusN/fObsSoverSplusB[o]->GetMaximum(), 1./corr);
    }
    else logLR *= SoverSplusN/fObsSoverSplusB[o]->GetMaximum();
  }
  //std::cout <<logLR<<std::endl;
  return logLR;
}
void LRHelpFunctions::fillLRBackgroundHist ( double  val,
double  weight = 1.0 
)

Definition at line 410 of file LRHelpFunctions.cc.

References HcalObjRepresent::Fill(), and hLRtotB.

                                                                    {
  // std::cout<< "@@@===> LRHelpf Backgroud LRval = "<< val<<std::endl;
  hLRtotB -> Fill(val, weight);
}
void LRHelpFunctions::fillLRSignalHist ( double  val,
double  weight = 1.0 
)

Definition at line 402 of file LRHelpFunctions.cc.

References HcalObjRepresent::Fill(), and hLRtotS.

                                                                {
  //  std::cout<< "@@@===> LRHelpf Signal LRval = "<< val<<std::endl;
  hLRtotS -> Fill(val, weight);
}
void LRHelpFunctions::fillToBackgroundHists ( std::vector< double >  obsVals,
double  weight = 1.0 
)

Definition at line 138 of file LRHelpFunctions.cc.

References HcalObjRepresent::Fill(), hObsB, and python::connectstrParser::o.

                                                                                   {
  for(size_t o=0; o<obsVals.size(); o++) hObsB[o]->Fill(obsVals[o], weight);
}
void LRHelpFunctions::fillToBackgroundHists ( int  obsNbr,
double  obsVal,
double  weight = 1.0 
)

Definition at line 143 of file LRHelpFunctions.cc.

References f, and hObsB.

                                                                                   {
  TString obs = "Obs"; obs += obsNbr; obs += "_";
  for(size_t f = 0; f<hObsB.size(); f++){
    if(((TString)(hObsB[f]->GetName())).Contains(obs)) {
      hObsB[f]->Fill(obsVal, weight);
      return;
    }
  }
}
void LRHelpFunctions::fillToSignalCorrelation ( int  obsNbr1,
double  obsVal1,
int  obsNbr2,
double  obsVal2,
double  weight 
)

Definition at line 121 of file LRHelpFunctions.cc.

References HcalObjRepresent::Fill(), hObsCorr, i, max(), and min.

                                      {
  TString hcorr  = "Corr_Obs"; hcorr  += std::min(obsNbr1,obsNbr2) ; hcorr += "_Obs";  hcorr  += std::max(obsNbr1, obsNbr2);
  for(size_t i=0; i<hObsCorr.size(); i++) {
    if(((TString)(hObsCorr[i]->GetName())) == hcorr) {
      if (obsNbr1 < obsNbr2) {
        hObsCorr[i] -> Fill(obsVal1,obsVal2, weight);
      } else {
        hObsCorr[i] -> Fill(obsVal2,obsVal1, weight);
      }
      return;
    }
  }
}
void LRHelpFunctions::fillToSignalHists ( std::vector< double >  obsVals,
double  weight = 1.0 
)

Definition at line 98 of file LRHelpFunctions.cc.

References HcalObjRepresent::Fill(), hObsCorr, hObsS, and python::connectstrParser::o.

                                                                               {
  int hIndex = 0;
  for(size_t o=0; o<obsVals.size(); o++) {
    hObsS[o]->Fill(obsVals[o], weight);
    for(size_t o2=o+1; o2<obsVals.size(); o2++) {
      hObsCorr[hIndex] -> Fill(obsVals[o],obsVals[o2], weight);
      ++hIndex;
    }
  }
}
void LRHelpFunctions::fillToSignalHists ( int  obsNbr,
double  obsVal,
double  weight = 1.0 
)

Definition at line 110 of file LRHelpFunctions.cc.

References f, and hObsS.

                                                                               {
  TString obs = "Obs"; obs += obsNbr; obs += "_";
  for(size_t f = 0; f<hObsS.size(); f++){
    if(((TString)(hObsS[f]->GetName())).Contains(obs)) {
      hObsS[f]->Fill(obsVal, weight);
      return;
    }
  }
}
void LRHelpFunctions::initLRHistsAndFits ( int  nrLRbins,
double  LRmin,
double  LRmax,
const char *  LRfunction 
)

Definition at line 69 of file LRHelpFunctions.cc.

References constructPurity, fLRtotSoverSplusB, hLRtotB, hLRtotS, and hLRtotSoverSplusB.

                                                                                                        { 
  constructPurity = true;
  // create LR histograms
  hLRtotS = new TH1F("hLRtotS","hLRtotS",nrLRbins,LRmin,LRmax);
  hLRtotB = new TH1F("hLRtotB","hLRtotB",nrLRbins,LRmin,LRmax);
  hLRtotSoverSplusB = new TH1F("hLRtotSoverSplusB","hLRtotSoverSplusB",nrLRbins,LRmin,LRmax);    
  // create LR fit function
  fLRtotSoverSplusB = new TF1("fLRtotSoverSplusB",LRfunction,LRmin,LRmax);
}
void LRHelpFunctions::makeAndFitPurityHists ( )

Definition at line 418 of file LRHelpFunctions.cc.

References b, gather_cfg::cout, GOODCOLL_filter_cfg::cut, fLRtotSoverSplusB, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, funct::pow(), and mathSSE::sqrt().

                                            {

  for(int b=0; b<=hLRtotS->GetNbinsX(); b++) {
    float Sint = hLRtotS->Integral(b, hLRtotS->GetNbinsX()+1);
    float Bint = hLRtotB->Integral(b, hLRtotB->GetNbinsX()+1);
    if (Sint + Bint > 0) {
      hLRtotSoverSplusB->SetBinContent(b,1. * Sint / (Sint + Bint));
      hLRtotSoverSplusB->SetBinError(b,sqrt((pow(Sint*sqrt(Bint),2)+pow(Bint*sqrt(Sint),2)))/pow((Sint+Bint),2));
    }
  }

  hLRtotS->GetXaxis()->SetTitle("Combined LR ratio");
  hLRtotB->GetXaxis()->SetTitle("Combined LR ratio");
  hLRtotSoverSplusB->GetXaxis()->SetTitle("Cut on Combined LR");
  hLRtotSoverSplusB->GetYaxis()->SetTitle("Purity");

  hLRtotSoverSplusB -> Fit(fLRtotSoverSplusB->GetName(),"RQ");  
  double totSignal = hLRtotS->Integral(0,hLRtotS->GetNbinsX()+1);
  double Eff[200], Pur[200], LRVal[200];
  if (hLRtotS->GetNbinsX()>200) {
    std::cout << "Number of bins of LR histograms can not execeed 200!"<<std::endl;
    return;
  }
  for(int cut=0; (cut<=hLRtotS->GetNbinsX())&&(cut<200) ; cut ++){
        double LRcutVal = hLRtotS->GetBinLowEdge(cut);
        Eff[cut]   = hLRtotS->Integral(cut,hLRtotS->GetNbinsX()+1)/totSignal;
        Pur[cut]   = fLRtotSoverSplusB->Eval(LRcutVal);
        LRVal[cut] = LRcutVal;
  }
  hEffvsPur = new TGraph(hLRtotS->GetNbinsX(),Eff,Pur);
  hEffvsPur -> SetName("hEffvsPur");
  hEffvsPur -> SetTitle("");
  hEffvsPur -> GetXaxis() -> SetTitle((TString)("Efficiency of cut on log combined LR"));
  hEffvsPur -> GetYaxis() -> SetTitle((TString)("Purity"));
  hEffvsPur -> GetYaxis() -> SetRangeUser(0,1.1);

  hLRValvsPur = new TGraph(hLRtotS->GetNbinsX(),LRVal,Pur);
  hLRValvsPur -> SetName("hLRValvsPur");
  hLRValvsPur -> SetTitle("");
  hLRValvsPur -> GetXaxis() -> SetTitle((TString)("Cut on the log combined LR value"));
  hLRValvsPur -> GetYaxis() -> SetTitle((TString)("Purity"));
  hLRValvsPur -> GetYaxis() -> SetRangeUser(0,1.1);

  hLRValvsEff = new TGraph(hLRtotS->GetNbinsX(),LRVal,Eff);
  hLRValvsEff -> SetName("hLRValvsEff");
  hLRValvsEff -> SetTitle("");
  hLRValvsEff -> GetXaxis() -> SetTitle((TString)("Cut on the log combined LR value"));
  hLRValvsEff -> GetYaxis() -> SetTitle((TString)("Efficiency of cut on log combined LR"));
  hLRValvsEff -> GetYaxis() -> SetRangeUser(0,1.1);

}   
void LRHelpFunctions::makeAndFitSoverSplusBHists ( )

Definition at line 176 of file LRHelpFunctions.cc.

References b, error, fObsSoverSplusB, hObsB, hObsS, hObsSoverSplusB, python::connectstrParser::o, funct::pow(), and mathSSE::sqrt().

                                                {
  for(size_t o=0; o<hObsS.size(); o++){
    for(int b=0; b <= hObsS[o]->GetNbinsX()+1; b++){
      if ((hObsS[o]->GetBinContent(b)+ hObsB[o]->GetBinContent(b)) > 0) {
        hObsSoverSplusB[o]->SetBinContent(b, hObsS[o]->GetBinContent(b) / (hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b)));
        double error = sqrt( pow(hObsS[o]->GetBinError(b) * hObsB[o]->GetBinContent(b)/pow(hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b),2),2)
                           + pow(hObsB[o]->GetBinError(b) * hObsS[o]->GetBinContent(b)/pow(hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b),2),2) );
        hObsSoverSplusB[o]->SetBinError(b,error);
      }
    }
    hObsSoverSplusB[o]->Fit(fObsSoverSplusB[o]->GetName(),"RQ");
  }
}
void LRHelpFunctions::normalizeSandBhists ( )

Definition at line 154 of file LRHelpFunctions.cc.

References b, hObsB, hObsS, i, and python::connectstrParser::o.

                                         {
  for(size_t o=0; o<hObsS.size(); o++){
    // count entries in each histo. Do it this way instead of GetEntries method,
    // since the latter does not account for the weights.
    double nrSignEntries = 0, nrBackEntries = 0;
    for (int i=0; i<=hObsS[o]->GetNbinsX()+1; i++){
      nrSignEntries += hObsS[o]->GetBinContent(i);
      nrBackEntries += hObsB[o]->GetBinContent(i);
     }
    for(int b=0; b <= hObsS[o]->GetNbinsX()+1; b++){
      hObsS[o]->SetBinContent(b,hObsS[o]->GetBinContent(b)/(nrSignEntries));
      hObsB[o]->SetBinContent(b,hObsB[o]->GetBinContent(b)/(nrBackEntries));
      hObsS[o]->SetBinError(b,hObsS[o]->GetBinError(b)/(nrSignEntries));
      hObsB[o]->SetBinError(b,hObsB[o]->GetBinError(b)/(nrBackEntries));
    }
    //std::cout<<"Integral for obs"<<o<<" S: "<<hObsS[o]->Integral(0,10000)<<" & obs"<<o<<" B: "<<hObsB[o]->Integral(0,10000)<<std::endl;
  }
}
bool LRHelpFunctions::obsFitIncluded ( int  o)

Definition at line 480 of file LRHelpFunctions.cc.

References f, fObsSoverSplusB, and python::connectstrParser::o.

Referenced by TtSemiLRJetCombCalc::operator()(), TtHadLRJetCombCalc::operator()(), TtSemiLRSignalSelCalc::operator()(), TtHadLRSignalSelCalc::operator()(), and singlePlot().

                                            {
  bool included = false;
  TString obs = "_Obs"; obs += o; obs += "_";
  for(size_t f = 0; f<fObsSoverSplusB.size(); f++){    
    if(((TString)(fObsSoverSplusB[f]->GetName())).Contains(obs)) included = true;
  }
  return included;
}
void LRHelpFunctions::purityPlot ( TString  fname,
TString  extension = TString("eps") 
)

Definition at line 563 of file LRHelpFunctions.cc.

References HiggsCouplings::c5, gather_cfg::cout, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, and plotscripts::tdrStyle.

{
  TStyle *tdrStyle = gROOT->GetStyle("tdrStyle");
  tdrStyle->SetOptFit(0);
  tdrStyle->SetOptStat(0);
  tdrStyle->SetOptTitle(0);
//   tdrStyle->SetPadTopMargin(0.01);
//   tdrStyle->SetPadBottomMargin(0.01);
//   tdrStyle->SetPadLeftMargin(0.01);
//   tdrStyle->SetPadRightMargin(0.01);

  TCanvas c2("c2","",600,300);
  c2.SetTopMargin(0.01);
  c2.SetBottomMargin(0.01);
  c2.SetLeftMargin(0.01);
  c2.SetRightMargin(0.01);
  std::cout <<fname<<std::endl;
  c2.Divide(2,1);

  c2.cd(1);
  hLRValvsPur->Draw("AP");
  c2.cd(2);
  hEffvsPur->Draw("AP");
  c2.Print(fname+"Purity."+extension);

  hLRtotS->GetXaxis()->SetNdivisions(505);
  hLRtotB->GetXaxis()->SetNdivisions(505);
  TCanvas c3("c2","",300,300);
//   c3.SetTopMargin(0.01);
//   c3.SetBottomMargin(0.01);
//   c3.SetLeftMargin(0.01);
//   c3.SetRightMargin(0.01);
  hLRtotS->GetXaxis()->SetTitle("Combined LR");
  hLRtotB->GetXaxis()->SetTitle("Combined LR");

    hLRtotB -> Draw();
    hLRtotS -> SetLineColor(2);
    hLRtotS -> Draw("same");
  c3.Print(fname+"Dist."+extension);


    TCanvas c5("c3","",900,600);
    c5.Divide(2,2);
    c5.cd(1);
    hLRtotB -> Draw();
    hLRtotS -> SetLineColor(2);
    hLRtotS -> Draw("same");
    c5.cd(3);
    hLRValvsEff -> Draw("AP");
    c5.cd(2);
    hEffvsPur -> Draw("AP");
    c5.cd(4);
    hLRtotSoverSplusB -> Draw();
    c5.Print(fname+"all."+extension);
}
void LRHelpFunctions::readObsHistsAndFits ( TString  fileName,
std::vector< int >  observables,
bool  readLRplots 
)

Definition at line 192 of file LRHelpFunctions.cc.

References constructPurity, gather_cfg::cout, fLRtotSoverSplusB, fObsSoverSplusB, hLRtotB, hLRtotS, hLRtotSoverSplusB, hObsB, hObsCorr, hObsS, hObsSoverSplusB, list(), GetRecoTauVFromDQM_MC_cff::next, and obsNumbers.

                                                                                                       {
  hObsS.clear();
  hObsB.clear();
  hObsSoverSplusB.clear();
  fObsSoverSplusB.clear();
  TFile *fitFile = new TFile(fileName, "READ");
  if(observables[0] == -1){  
    std::cout<<" ... will read hists and fit for all available observables in file "<<fileName<<std::endl;
    TList *list = fitFile->GetListOfKeys();
    TIter next(list);
    TKey *el;
    while ((el = (TKey*)next())) {
      TString keyName = el->GetName();
      if(keyName.Contains("F_") && keyName.Contains("_SoverSplusB")){
        fObsSoverSplusB.push_back( new TF1(*((TF1*) el -> ReadObj())));
      }
      else if(keyName.Contains("_SoverSplusB")){
        hObsSoverSplusB.push_back( new TH1F(*((TH1F*) el -> ReadObj())));
      }
      else if(keyName.Contains("_S")){
        hObsS.push_back( new TH1F(*((TH1F*) el -> ReadObj())));
      }
      else if(keyName.Contains("_B")){
        hObsB.push_back( new TH1F(*((TH1F*) el -> ReadObj())));
      }
      else if(keyName.Contains("Corr")){
        hObsCorr.push_back( new TH2F(*((TH2F*) el -> ReadObj())));
      }
    }
  }
  else{
    obsNumbers = observables;
    for(unsigned int obs = 0; obs < observables.size(); obs++){
      std::cout<<"  ... will read hists and fit for obs "<<observables[obs]<<" from file "<<fileName<<std::endl;
      TString hStitle  = "Obs";   hStitle  += observables[obs];   hStitle += "_S";
      hObsS.push_back( new TH1F(*((TH1F*)fitFile->GetKey(hStitle)->ReadObj())));
      TString hBtitle  = "Obs";   hBtitle  += observables[obs];   hBtitle += "_B";
      hObsB.push_back( new TH1F(*((TH1F*)fitFile->GetKey(hBtitle)->ReadObj())));
      TString hSBtitle = "Obs";   hSBtitle += observables[obs];   hSBtitle += "_SoverSplusB";
      TString fSBtitle = "F_";  fSBtitle += hSBtitle;
      hObsSoverSplusB.push_back( new TH1F(*((TH1F*)fitFile->GetKey(hSBtitle)->ReadObj())));
      fObsSoverSplusB.push_back( new TF1(*((TF1*)fitFile->GetKey(fSBtitle)->ReadObj())));
      for(unsigned int obs2 = obs+1; obs2 < observables.size(); obs2++){
        TString hCorrtitle  = "Corr_Obs"; hCorrtitle  += observables[obs];   
                hCorrtitle += "_Obs";     hCorrtitle  += observables[obs2]; 
        hObsCorr.push_back( new TH2F(*((TH2F*)fitFile->GetKey(hCorrtitle)->ReadObj())));
      }
    }
  }
  
  if(readLRplots){
    constructPurity = true;
    std::cout<<"  ... will LR s and B histos from file "<<fileName<<std::endl;
    hLRtotS = new TH1F(*((TH1F*)fitFile->GetKey("hLRtotS")->ReadObj()));
    hLRtotB = new TH1F(*((TH1F*)fitFile->GetKey("hLRtotB")->ReadObj()));
    hLRtotSoverSplusB = new TH1F(*((TH1F*)fitFile->GetKey("hLRtotSoverSplusB")->ReadObj()));
    fLRtotSoverSplusB = new TF1(*((TF1*)fitFile->GetKey("fLRtotSoverSplusB") -> ReadObj()));
  }
}
void LRHelpFunctions::recreateFitFct ( std::vector< int >  obsNr,
std::vector< const char * >  functions 
)

Definition at line 38 of file LRHelpFunctions.cc.

References fObsSoverSplusB, hObsS, and python::connectstrParser::o.

                                                                                           {
  if (!fObsSoverSplusB.empty()) fObsSoverSplusB.clear();
  for(size_t o=0; o<obsNr.size(); o++){
    // create fit functions
    TString ftSB = "F_Obs"; ftSB += obsNr[o]; ftSB += "_SoverSplusB";
    fObsSoverSplusB.push_back( new TF1(ftSB,functions[o],hObsS[o]->GetXaxis()->GetXmin(),hObsS[o]->GetXaxis()->GetXmax()) );
  }
}
void LRHelpFunctions::setObsFitParameters ( int  obs,
std::vector< double >  fitPars 
)

Definition at line 82 of file LRHelpFunctions.cc.

References fObsSoverSplusB, and AlCaHLTBitMon_ParallelJobs::p.

                                                                          {
  for(size_t fit=0; fit<fObsSoverSplusB.size(); fit++){
    TString fn = "_Obs"; fn += obs;
    if(((TString)fObsSoverSplusB[fit]->GetName()).Contains(fn)){
      for(size_t p=0; p<fitPars.size(); p++){
        fObsSoverSplusB[fit]->SetParameter(p,fitPars[p]);
      }
    }
  }
}
void LRHelpFunctions::setXlabels ( const std::vector< std::string > &  xLabels)

Definition at line 489 of file LRHelpFunctions.cc.

References gather_cfg::cout, hObsB, hObsS, hObsSoverSplusB, and i.

{
  if (hObsS.size() != xLabels.size()) {
    std::cout << "LRHelpFunctions::setXlabels: Number of labels ("
         << xLabels.size()<< ") does not match number of obervables("
         << hObsS.size()<<").\n";
    return;
  }
  for(size_t i = 0; i<hObsS.size(); ++i){
    hObsS[i]->GetXaxis()->SetTitle(TString(xLabels[i]));
    hObsB[i]->GetXaxis()->SetTitle(TString(xLabels[i]));
    hObsSoverSplusB[i]->GetXaxis()->SetTitle(TString(xLabels[i]));
    hObsSoverSplusB[i]->GetYaxis()->SetTitle(TString("S/(S+B)"));
  }
}
void LRHelpFunctions::setYlabels ( const std::vector< std::string > &  yLabels)

Definition at line 505 of file LRHelpFunctions.cc.

References gather_cfg::cout, hObsB, hObsS, and i.

{
  if (hObsS.size() != yLabels.size()) {
    std::cout << "LRHelpFunctions::setYlabels: Number of labels ("
         << yLabels.size()<< ") does not match number of obervables("
         << hObsS.size()<<").\n";
    return;
  }
  for(size_t i = 0; i<hObsS.size(); ++i){
    hObsS[i]->GetYaxis()->SetTitle(TString(yLabels[i]));
    hObsB[i]->GetYaxis()->SetTitle(TString(yLabels[i]));
  }
}
void LRHelpFunctions::singlePlot ( TString  fname,
int  obsNbr,
TString  extension = TString("eps") 
)

Definition at line 519 of file LRHelpFunctions.cc.

References gather_cfg::cout, fObsSoverSplusB, hObsB, hObsS, hObsSoverSplusB, python::connectstrParser::o, obsFitIncluded(), and plotscripts::tdrStyle.

                                                                              {
  if (!obsFitIncluded(obsNbr)) return;

  TStyle *tdrStyle = gROOT->GetStyle("tdrStyle");
  tdrStyle->SetOptFit(0);
  tdrStyle->SetOptStat(0);
  tdrStyle->SetOptTitle(0);
//   tdrStyle->SetPadTopMargin(0.01);
//   tdrStyle->SetPadBottomMargin(0.01);
//   tdrStyle->SetPadLeftMargin(0.01);
//   tdrStyle->SetPadRightMargin(0.01);

  TCanvas c2("c2","",600,300);
  c2.SetTopMargin(0.01);
  c2.SetBottomMargin(0.01);
  c2.SetLeftMargin(0.01);
  c2.SetRightMargin(0.01);
  std::cout <<fname<<std::endl;
  c2.Divide(2,1);

  TString obs = "Obs"; obs += obsNbr; obs += "_";
  for(size_t o = 0; o<hObsB.size(); ++o){
    if(((TString)(hObsB[o]->GetName())).Contains(obs)) {
      c2.cd(1);
      hObsS[o] -> SetLineColor(2);
      if(hObsB[o]->GetMaximum() > hObsS[o]->GetMaximum()){
        hObsB[o] -> Draw("hist");
        hObsS[o] -> Draw("histsame");
      }
      else
      {
        hObsS[o] -> Draw("hist");
        hObsB[o] -> Draw("histsame");
      }
      c2.cd(2);

      hObsSoverSplusB[o] -> Draw();
      fObsSoverSplusB[o] -> Draw("same");
    }
  }
  std::cout << fname+"."+extension<<std::endl;
  c2.Print(fname+"."+extension);
}
void LRHelpFunctions::storeControlPlots ( TString  fname)

Definition at line 291 of file LRHelpFunctions.cc.

References trackerHits::c, HiggsCouplings::c5, constructPurity, fObsSoverSplusB, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, hObsB, hObsCorr, hObsS, hObsSoverSplusB, and python::connectstrParser::o.

                                                     {  
  TCanvas c("dummy","",1);
  c.Print(fname + "[","landscape");
  for(size_t o=0; o<hObsS.size(); o++) {
     TCanvas c2("c2","",1);
     c2.Divide(2,1);
     c2.cd(1);
     hObsS[o] -> SetLineColor(2);
     if(hObsB[o]->GetMaximum() > hObsS[o]->GetMaximum()){
       hObsB[o] -> Draw("hist");
       hObsS[o] -> Draw("histsame");
     }
     else
     {
       hObsS[o] -> Draw("hist");
       hObsB[o] -> Draw("histsame");
     }
     c2.cd(2);
     hObsSoverSplusB[o] -> Draw();
     fObsSoverSplusB[o] -> Draw("same");
     c2.Print(fname,"Landscape");
  }
  
  int hIndex = 0;
  for(size_t o=0; o<hObsS.size(); o++) {
    for(size_t o2=o+1; o2<hObsS.size(); o2++) {
      TCanvas cc("cc","",1);
      hObsCorr[hIndex] -> Draw("box");
      TPaveText pt(0.5,0.87,0.98,0.93,"blNDC");
      pt.SetFillStyle(1);
      pt.SetFillColor(0);
      pt.SetBorderSize(0);
      TString tcorr = "Corr. of "; tcorr += (int)(100.*hObsCorr[hIndex] -> GetCorrelationFactor()); tcorr += " %";
      //TText *text = pt.AddText(tcorr);
      pt.Draw("same");
      ++hIndex;
      cc.Print(fname,"Landscape");
    }
  }
  
  if(constructPurity){
    TCanvas c3("c3","",1);
    c3.Divide(2,1);
    c3.cd(1);
    hLRtotB -> Draw();
    hLRtotS -> SetLineColor(2);
    hLRtotS -> Draw("same");
    c3.cd(2);
    hLRtotSoverSplusB -> Draw();
    c3.Print(fname,"Landscape");
  
    TCanvas c4("c4","",1);
    hEffvsPur -> Draw("AL*");
    c4.Print(fname,"Landscape");

    TCanvas c5("c5","",1);
    hLRValvsPur -> Draw("AL*");
    c5.Print(fname,"Landscape");

    TCanvas c6("c6","",1);
    hLRValvsEff -> Draw("AL*");
    c6.Print(fname,"Landscape");
  } 
  c.Print(fname + "]","landscape");
}
void LRHelpFunctions::storeToROOTfile ( TString  fname)

Definition at line 256 of file LRHelpFunctions.cc.

References constructPurity, fLRtotSoverSplusB, fObsSoverSplusB, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, hObsB, hObsCorr, hObsS, hObsSoverSplusB, and python::connectstrParser::o.

                                                   {
  TFile fOut(fname,"RECREATE");
  fOut.cd();
  for(size_t o=0; o<hObsS.size(); o++){
    hObsS[o]            -> Write();
    hObsB[o]            -> Write();
    hObsSoverSplusB[o]  -> Write();
    fObsSoverSplusB[o]  -> Write();
  }
  int hIndex = 0;
  for(size_t o=0; o<hObsS.size(); o++) {
    for(size_t o2=o+1; o2<hObsS.size(); o2++) {
      hObsCorr[hIndex] -> Write();
      ++ hIndex;
    }
  }
  if(constructPurity){
    hLRtotS             -> Write();
    hLRtotB             -> Write();
    hLRtotSoverSplusB   -> Write();
    fLRtotSoverSplusB   -> Write();
    hEffvsPur           -> Write();
    hLRValvsPur         -> Write();
    hLRValvsEff         -> Write();
  }
  fOut.cd();
  fOut.Write();
  fOut.Close();
}

Member Data Documentation

std::vector<TF1*> LRHelpFunctions::fObsSoverSplusB [private]
TGraph* LRHelpFunctions::hEffvsPur [private]
TH1F * LRHelpFunctions::hLRtotB [private]
TH1F* LRHelpFunctions::hLRtotS [private]
TGraph * LRHelpFunctions::hLRValvsEff [private]
TGraph * LRHelpFunctions::hLRValvsPur [private]
std::vector<TH1F*> LRHelpFunctions::hObsB [private]
std::vector<TH2F*> LRHelpFunctions::hObsCorr [private]
std::vector<TH1F*> LRHelpFunctions::hObsS [private]
std::vector<TH1F*> LRHelpFunctions::hObsSoverSplusB [private]
std::vector<int> LRHelpFunctions::obsNumbers [private]

Definition at line 79 of file LRHelpFunctions.h.

Referenced by calcPtdrLRval(), LRHelpFunctions(), and readObsHistsAndFits().