CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
LRHelpFunctions Class Reference

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

#include "TopQuarkAnalysis/TopTools/interface/LRHelpFunctions.h"

Public Member Functions

double calcLRval (const std::vector< double > &)
 
double calcProb (double)
 
double calcPtdrLRval (const std::vector< double > &vals, bool useCorrelation=false)
 
void fillLRBackgroundHist (double, double weight=1.0)
 
void fillLRSignalHist (double, double weight=1.0)
 
void fillToBackgroundHists (const 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 (const std::vector< double > &, double weight=1.0)
 
void fillToSignalHists (int, double, double weight=1.0)
 
void initLRHistsAndFits (int, double, double, const char *)
 
 LRHelpFunctions ()
 
 LRHelpFunctions (const std::vector< int > &, int, const std::vector< double > &, const std::vector< double > &, const std::vector< const char *> &)
 
 LRHelpFunctions (int, double, double, const char *)
 
void makeAndFitPurityHists ()
 
void makeAndFitSoverSplusBHists ()
 
void normalizeSandBhists ()
 
bool obsFitIncluded (int)
 
void purityPlot (const TString &fname, const TString &extension=TString("eps"))
 
void readObsHistsAndFits (const TString &, const std::vector< int > &, bool)
 
void recreateFitFct (const std::vector< int > &obsNr, const std::vector< const char *> &functions)
 
void setObsFitParameters (int obs, const std::vector< double > &)
 
void setXlabels (const std::vector< std::string > &xLabels)
 
void setYlabels (const std::vector< std::string > &yLabels)
 
void singlePlot (const TString &fname, int obsNbr, const TString &extension=TString("eps"))
 
void storeControlPlots (const TString &)
 
void storeToROOTfile (const 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 35 of file LRHelpFunctions.h.

Constructor & Destructor Documentation

◆ LRHelpFunctions() [1/3]

LRHelpFunctions::LRHelpFunctions ( )

Definition at line 5 of file LRHelpFunctions.cc.

References constructPurity, and plotscripts::setTDRStyle().

5  {
6  constructPurity = false;
7  setTDRStyle();
8  gStyle->SetCanvasDefW(900);
9 }
def setTDRStyle()
Definition: plotscripts.py:89

◆ LRHelpFunctions() [2/3]

LRHelpFunctions::LRHelpFunctions ( const std::vector< int > &  obsNr,
int  nrBins,
const std::vector< double > &  obsMin,
const std::vector< double > &  obsMax,
const std::vector< const char *> &  functions 
)

Definition at line 11 of file LRHelpFunctions.cc.

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

15  {
16  obsNumbers = obsNr;
17  constructPurity = false;
18  setTDRStyle();
19  gStyle->SetCanvasDefW(900);
20  for (size_t o = 0; o < obsNr.size(); o++) {
21  // create Signal, background and s/(s+b) histogram
22  TString htS = "Obs";
23  htS += obsNr[o];
24  htS += "_S";
25  TString htB = "Obs";
26  htB += obsNr[o];
27  htB += "_B";
28  TString htSB = "Obs";
29  htSB += obsNr[o];
30  htSB += "_SoverSplusB";
31  hObsS.push_back(new TH1F(htS, htS, nrBins, obsMin[o], obsMax[o]));
32  hObsB.push_back(new TH1F(htB, htB, nrBins, obsMin[o], obsMax[o]));
33  hObsSoverSplusB.push_back(new TH1F(htSB, htSB, nrBins, obsMin[o], obsMax[o]));
34 
35  // create the correlation 2D plots among the observables (for signal)
36  for (size_t o2 = o + 1; o2 < obsNr.size(); o2++) {
37  TString hcorr = "Corr_Obs";
38  hcorr += obsNr[o];
39  hcorr += "_Obs";
40  hcorr += obsNr[o2];
41  hObsCorr.push_back(new TH2F(hcorr, hcorr, nrBins, obsMin[o], obsMax[o], nrBins, obsMin[o2], obsMax[o2]));
42  }
43 
44  // create fit functions
45  TString ftSB = "F_Obs";
46  ftSB += obsNr[o];
47  ftSB += "_SoverSplusB";
48  fObsSoverSplusB.push_back(
49  new TF1(ftSB, functions[o], hObsS[o]->GetXaxis()->GetXmin(), hObsS[o]->GetXaxis()->GetXmax()));
50  }
51 }
std::vector< TH1F * > hObsSoverSplusB
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
std::vector< TH2F * > hObsCorr
def setTDRStyle()
Definition: plotscripts.py:89
std::vector< int > obsNumbers
std::vector< TF1 * > fObsSoverSplusB

◆ LRHelpFunctions() [3/3]

LRHelpFunctions::LRHelpFunctions ( int  nrLRbins,
double  LRmin,
double  LRmax,
const char *  LRfunction 
)

Definition at line 66 of file LRHelpFunctions.cc.

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

66  {
67  constructPurity = true;
68  setTDRStyle();
69  gStyle->SetCanvasDefW(900);
70 
71  // create LR histograms
72  hLRtotS = new TH1F("hLRtotS", "hLRtotS", nrLRbins, LRmin, LRmax);
73  hLRtotS->GetXaxis()->SetTitle("Combined LR");
74  hLRtotB = new TH1F("hLRtotB", "hLRtotB", nrLRbins, LRmin, LRmax);
75  hLRtotB->GetXaxis()->SetTitle("Combined LR");
76  hLRtotSoverSplusB = new TH1F("hLRtotSoverSplusB", "hLRtotSoverSplusB", nrLRbins, LRmin, LRmax);
77 
78  // create LR fit function
79  fLRtotSoverSplusB = new TF1("fLRtotSoverSplusB", LRfunction, LRmin, LRmax);
80 }
def setTDRStyle()
Definition: plotscripts.py:89
TH1F * hLRtotSoverSplusB

◆ ~LRHelpFunctions()

LRHelpFunctions::~LRHelpFunctions ( )

Definition at line 83 of file LRHelpFunctions.cc.

83 {}

Member Function Documentation

◆ calcLRval()

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

Definition at line 378 of file LRHelpFunctions.cc.

References fObsSoverSplusB, dqm-mbProfile::log, and EcalTangentSkim_cfg::o.

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

378  {
379  double logLR = 0.;
380  for (size_t o = 0; o < fObsSoverSplusB.size(); o++) {
381  double SoverSplusN = fObsSoverSplusB[o]->Eval(vals[o]);
382  double SoverN = 1. / ((1. / SoverSplusN) - 1.);
383  logLR += log(SoverN);
384  }
385  return logLR;
386 }
std::vector< TF1 * > fObsSoverSplusB

◆ calcProb()

double LRHelpFunctions::calcProb ( double  logLR)

◆ calcPtdrLRval()

double LRHelpFunctions::calcPtdrLRval ( const std::vector< double > &  vals,
bool  useCorrelation = false 
)

Definition at line 391 of file LRHelpFunctions.cc.

References alignCSCRings::corr, fObsSoverSplusB, hObsCorr, mps_fire::i, dqmiolumiharvest::j, SiStripPI::max, SiStripPI::min, EcalTangentSkim_cfg::o, obsNumbers, funct::pow(), and muonME0PseudoDigis_cfi::useCorrelation.

391  {
392  double logLR = 1.;
393  for (size_t o = 0; o < fObsSoverSplusB.size(); o++) {
394  double SoverSplusN = fObsSoverSplusB[o]->Eval(vals[o]);
395  if (SoverSplusN < 0.0001)
396  SoverSplusN = 0.0001;
397  if (useCorrelation) {
398  double corr = 0;
399  for (size_t j = 0; j < fObsSoverSplusB.size(); j++) {
400  if (o == j)
401  ++corr;
402  else {
403  TString hcorr = "Corr_Obs";
404  hcorr += std::min(obsNumbers[o], obsNumbers[j]);
405  hcorr += "_Obs";
406  hcorr += std::max(obsNumbers[o], obsNumbers[j]);
407  for (size_t i = 0; i < hObsCorr.size(); i++) {
408  if (((TString)(hObsCorr[i]->GetName())) == hcorr)
409  corr += fabs(hObsCorr[i]->GetCorrelationFactor());
410  }
411  }
412  }
413  logLR *= pow(SoverSplusN / fObsSoverSplusB[o]->GetMaximum(), 1. / corr);
414  } else
415  logLR *= SoverSplusN / fObsSoverSplusB[o]->GetMaximum();
416  }
417  //std::cout <<logLR<<std::endl;
418  return logLR;
419 }
std::vector< TH2F * > hObsCorr
dictionary corr
std::vector< int > obsNumbers
std::vector< TF1 * > fObsSoverSplusB
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ fillLRBackgroundHist()

void LRHelpFunctions::fillLRBackgroundHist ( double  val,
double  weight = 1.0 
)

Definition at line 428 of file LRHelpFunctions.cc.

References hLRtotB, and heppy_batch::val.

428  {
429  // std::cout<< "@@@===> LRHelpf Backgroud LRval = "<< val<<std::endl;
430  hLRtotB->Fill(val, weight);
431 }
Definition: weight.py:1

◆ fillLRSignalHist()

void LRHelpFunctions::fillLRSignalHist ( double  val,
double  weight = 1.0 
)

Definition at line 422 of file LRHelpFunctions.cc.

References hLRtotS, and heppy_batch::val.

422  {
423  // std::cout<< "@@@===> LRHelpf Signal LRval = "<< val<<std::endl;
424  hLRtotS->Fill(val, weight);
425 }
Definition: weight.py:1

◆ fillToBackgroundHists() [1/2]

void LRHelpFunctions::fillToBackgroundHists ( const std::vector< double > &  obsVals,
double  weight = 1.0 
)

Definition at line 153 of file LRHelpFunctions.cc.

References HcalObjRepresent::Fill(), hObsB, and EcalTangentSkim_cfg::o.

153  {
154  for (size_t o = 0; o < obsVals.size(); o++)
155  hObsB[o]->Fill(obsVals[o], weight);
156 }
Definition: weight.py:1
std::vector< TH1F * > hObsB
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)

◆ fillToBackgroundHists() [2/2]

void LRHelpFunctions::fillToBackgroundHists ( int  obsNbr,
double  obsVal,
double  weight = 1.0 
)

Definition at line 159 of file LRHelpFunctions.cc.

References f, and hObsB.

159  {
160  TString obs = "Obs";
161  obs += obsNbr;
162  obs += "_";
163  for (size_t f = 0; f < hObsB.size(); f++) {
164  if (((TString)(hObsB[f]->GetName())).Contains(obs)) {
165  hObsB[f]->Fill(obsVal, weight);
166  return;
167  }
168  }
169 }
Definition: weight.py:1
std::vector< TH1F * > hObsB
double f[11][100]

◆ fillToSignalCorrelation()

void LRHelpFunctions::fillToSignalCorrelation ( int  obsNbr1,
double  obsVal1,
int  obsNbr2,
double  obsVal2,
double  weight 
)

Definition at line 135 of file LRHelpFunctions.cc.

References hObsCorr, mps_fire::i, SiStripPI::max, and SiStripPI::min.

135  {
136  TString hcorr = "Corr_Obs";
137  hcorr += std::min(obsNbr1, obsNbr2);
138  hcorr += "_Obs";
139  hcorr += std::max(obsNbr1, obsNbr2);
140  for (size_t i = 0; i < hObsCorr.size(); i++) {
141  if (((TString)(hObsCorr[i]->GetName())) == hcorr) {
142  if (obsNbr1 < obsNbr2) {
143  hObsCorr[i]->Fill(obsVal1, obsVal2, weight);
144  } else {
145  hObsCorr[i]->Fill(obsVal2, obsVal1, weight);
146  }
147  return;
148  }
149  }
150 }
Definition: weight.py:1
std::vector< TH2F * > hObsCorr

◆ fillToSignalHists() [1/2]

void LRHelpFunctions::fillToSignalHists ( const std::vector< double > &  obsVals,
double  weight = 1.0 
)

Definition at line 110 of file LRHelpFunctions.cc.

References hObsCorr, hObsS, and EcalTangentSkim_cfg::o.

110  {
111  int hIndex = 0;
112  for (size_t o = 0; o < obsVals.size(); o++) {
113  hObsS[o]->Fill(obsVals[o], weight);
114  for (size_t o2 = o + 1; o2 < obsVals.size(); o2++) {
115  hObsCorr[hIndex]->Fill(obsVals[o], obsVals[o2], weight);
116  ++hIndex;
117  }
118  }
119 }
std::vector< TH1F * > hObsS
Definition: weight.py:1
std::vector< TH2F * > hObsCorr

◆ fillToSignalHists() [2/2]

void LRHelpFunctions::fillToSignalHists ( int  obsNbr,
double  obsVal,
double  weight = 1.0 
)

Definition at line 122 of file LRHelpFunctions.cc.

References f, and hObsS.

122  {
123  TString obs = "Obs";
124  obs += obsNbr;
125  obs += "_";
126  for (size_t f = 0; f < hObsS.size(); f++) {
127  if (((TString)(hObsS[f]->GetName())).Contains(obs)) {
128  hObsS[f]->Fill(obsVal, weight);
129  return;
130  }
131  }
132 }
std::vector< TH1F * > hObsS
Definition: weight.py:1
double f[11][100]

◆ initLRHistsAndFits()

void LRHelpFunctions::initLRHistsAndFits ( int  nrLRbins,
double  LRmin,
double  LRmax,
const char *  LRfunction 
)

Definition at line 86 of file LRHelpFunctions.cc.

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

86  {
87  constructPurity = true;
88  // create LR histograms
89  hLRtotS = new TH1F("hLRtotS", "hLRtotS", nrLRbins, LRmin, LRmax);
90  hLRtotB = new TH1F("hLRtotB", "hLRtotB", nrLRbins, LRmin, LRmax);
91  hLRtotSoverSplusB = new TH1F("hLRtotSoverSplusB", "hLRtotSoverSplusB", nrLRbins, LRmin, LRmax);
92  // create LR fit function
93  fLRtotSoverSplusB = new TF1("fLRtotSoverSplusB", LRfunction, LRmin, LRmax);
94 }
TH1F * hLRtotSoverSplusB

◆ makeAndFitPurityHists()

void LRHelpFunctions::makeAndFitPurityHists ( )

Definition at line 434 of file LRHelpFunctions.cc.

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

434  {
435  for (int b = 0; b <= hLRtotS->GetNbinsX(); b++) {
436  float Sint = hLRtotS->Integral(b, hLRtotS->GetNbinsX() + 1);
437  float Bint = hLRtotB->Integral(b, hLRtotB->GetNbinsX() + 1);
438  if (Sint + Bint > 0) {
439  hLRtotSoverSplusB->SetBinContent(b, 1. * Sint / (Sint + Bint));
440  hLRtotSoverSplusB->SetBinError(
441  b, sqrt((pow(Sint * sqrt(Bint), 2) + pow(Bint * sqrt(Sint), 2))) / pow((Sint + Bint), 2));
442  }
443  }
444 
445  hLRtotS->GetXaxis()->SetTitle("Combined LR ratio");
446  hLRtotB->GetXaxis()->SetTitle("Combined LR ratio");
447  hLRtotSoverSplusB->GetXaxis()->SetTitle("Cut on Combined LR");
448  hLRtotSoverSplusB->GetYaxis()->SetTitle("Purity");
449 
450  hLRtotSoverSplusB->Fit(fLRtotSoverSplusB->GetName(), "RQ");
451  double totSignal = hLRtotS->Integral(0, hLRtotS->GetNbinsX() + 1);
452  double Eff[200], Pur[200], LRVal[200];
453  if (hLRtotS->GetNbinsX() > 200) {
454  std::cout << "Number of bins of LR histograms can not execeed 200!" << std::endl;
455  return;
456  }
457  for (int cut = 0; (cut <= hLRtotS->GetNbinsX()) && (cut < 200); cut++) {
458  double LRcutVal = hLRtotS->GetBinLowEdge(cut);
459  Eff[cut] = hLRtotS->Integral(cut, hLRtotS->GetNbinsX() + 1) / totSignal;
460  Pur[cut] = fLRtotSoverSplusB->Eval(LRcutVal);
461  LRVal[cut] = LRcutVal;
462  }
463  hEffvsPur = new TGraph(hLRtotS->GetNbinsX(), Eff, Pur);
464  hEffvsPur->SetName("hEffvsPur");
465  hEffvsPur->SetTitle("");
466  hEffvsPur->GetXaxis()->SetTitle((TString)("Efficiency of cut on log combined LR"));
467  hEffvsPur->GetYaxis()->SetTitle((TString)("Purity"));
468  hEffvsPur->GetYaxis()->SetRangeUser(0, 1.1);
469 
470  hLRValvsPur = new TGraph(hLRtotS->GetNbinsX(), LRVal, Pur);
471  hLRValvsPur->SetName("hLRValvsPur");
472  hLRValvsPur->SetTitle("");
473  hLRValvsPur->GetXaxis()->SetTitle((TString)("Cut on the log combined LR value"));
474  hLRValvsPur->GetYaxis()->SetTitle((TString)("Purity"));
475  hLRValvsPur->GetYaxis()->SetRangeUser(0, 1.1);
476 
477  hLRValvsEff = new TGraph(hLRtotS->GetNbinsX(), LRVal, Eff);
478  hLRValvsEff->SetName("hLRValvsEff");
479  hLRValvsEff->SetTitle("");
480  hLRValvsEff->GetXaxis()->SetTitle((TString)("Cut on the log combined LR value"));
481  hLRValvsEff->GetYaxis()->SetTitle((TString)("Efficiency of cut on log combined LR"));
482  hLRValvsEff->GetYaxis()->SetRangeUser(0, 1.1);
483 }
TGraph * hLRValvsEff
TGraph * hLRValvsPur
T sqrt(T t)
Definition: SSEVec.h:19
double b
Definition: hdecay.h:120
TH1F * hLRtotSoverSplusB
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ makeAndFitSoverSplusBHists()

void LRHelpFunctions::makeAndFitSoverSplusBHists ( )

Definition at line 192 of file LRHelpFunctions.cc.

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

192  {
193  for (size_t o = 0; o < hObsS.size(); o++) {
194  for (int b = 0; b <= hObsS[o]->GetNbinsX() + 1; b++) {
195  if ((hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b)) > 0) {
196  hObsSoverSplusB[o]->SetBinContent(
197  b, hObsS[o]->GetBinContent(b) / (hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b)));
198  double error = sqrt(pow(hObsS[o]->GetBinError(b) * hObsB[o]->GetBinContent(b) /
199  pow(hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b), 2),
200  2) +
201  pow(hObsB[o]->GetBinError(b) * hObsS[o]->GetBinContent(b) /
202  pow(hObsS[o]->GetBinContent(b) + hObsB[o]->GetBinContent(b), 2),
203  2));
204  hObsSoverSplusB[o]->SetBinError(b, error);
205  }
206  }
207  hObsSoverSplusB[o]->Fit(fObsSoverSplusB[o]->GetName(), "RQ");
208  }
209 }
std::vector< TH1F * > hObsSoverSplusB
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
T sqrt(T t)
Definition: SSEVec.h:19
double b
Definition: hdecay.h:120
std::vector< TF1 * > fObsSoverSplusB
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ normalizeSandBhists()

void LRHelpFunctions::normalizeSandBhists ( )

Definition at line 172 of file LRHelpFunctions.cc.

References b, hObsB, hObsS, mps_fire::i, and EcalTangentSkim_cfg::o.

172  {
173  for (size_t o = 0; o < hObsS.size(); o++) {
174  // count entries in each histo. Do it this way instead of GetEntries method,
175  // since the latter does not account for the weights.
176  double nrSignEntries = 0, nrBackEntries = 0;
177  for (int i = 0; i <= hObsS[o]->GetNbinsX() + 1; i++) {
178  nrSignEntries += hObsS[o]->GetBinContent(i);
179  nrBackEntries += hObsB[o]->GetBinContent(i);
180  }
181  for (int b = 0; b <= hObsS[o]->GetNbinsX() + 1; b++) {
182  hObsS[o]->SetBinContent(b, hObsS[o]->GetBinContent(b) / (nrSignEntries));
183  hObsB[o]->SetBinContent(b, hObsB[o]->GetBinContent(b) / (nrBackEntries));
184  hObsS[o]->SetBinError(b, hObsS[o]->GetBinError(b) / (nrSignEntries));
185  hObsB[o]->SetBinError(b, hObsB[o]->GetBinError(b) / (nrBackEntries));
186  }
187  //std::cout<<"Integral for obs"<<o<<" S: "<<hObsS[o]->Integral(0,10000)<<" & obs"<<o<<" B: "<<hObsB[o]->Integral(0,10000)<<std::endl;
188  }
189 }
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
double b
Definition: hdecay.h:120

◆ obsFitIncluded()

bool LRHelpFunctions::obsFitIncluded ( int  o)

Definition at line 489 of file LRHelpFunctions.cc.

References f, fObsSoverSplusB, and EcalTangentSkim_cfg::o.

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

489  {
490  bool included = false;
491  TString obs = "_Obs";
492  obs += o;
493  obs += "_";
494  for (size_t f = 0; f < fObsSoverSplusB.size(); f++) {
495  if (((TString)(fObsSoverSplusB[f]->GetName())).Contains(obs))
496  included = true;
497  }
498  return included;
499 }
double f[11][100]
std::vector< TF1 * > fObsSoverSplusB

◆ purityPlot()

void LRHelpFunctions::purityPlot ( const TString &  fname,
const TString &  extension = TString("eps") 
)

Definition at line 572 of file LRHelpFunctions.cc.

References gather_cfg::cout, runGCPTkAlMap::extension, alignmentValidation::fname, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, and plotscripts::tdrStyle.

572  {
573  TStyle* tdrStyle = gROOT->GetStyle("tdrStyle");
574  tdrStyle->SetOptFit(0);
575  tdrStyle->SetOptStat(0);
576  tdrStyle->SetOptTitle(0);
577  // tdrStyle->SetPadTopMargin(0.01);
578  // tdrStyle->SetPadBottomMargin(0.01);
579  // tdrStyle->SetPadLeftMargin(0.01);
580  // tdrStyle->SetPadRightMargin(0.01);
581 
582  TCanvas c2("c2", "", 600, 300);
583  c2.SetTopMargin(0.01);
584  c2.SetBottomMargin(0.01);
585  c2.SetLeftMargin(0.01);
586  c2.SetRightMargin(0.01);
587  std::cout << fname << std::endl;
588  c2.Divide(2, 1);
589 
590  c2.cd(1);
591  hLRValvsPur->Draw("AP");
592  c2.cd(2);
593  hEffvsPur->Draw("AP");
594  c2.Print(fname + "Purity." + extension);
595 
596  hLRtotS->GetXaxis()->SetNdivisions(505);
597  hLRtotB->GetXaxis()->SetNdivisions(505);
598  TCanvas c3("c2", "", 300, 300);
599  // c3.SetTopMargin(0.01);
600  // c3.SetBottomMargin(0.01);
601  // c3.SetLeftMargin(0.01);
602  // c3.SetRightMargin(0.01);
603  hLRtotS->GetXaxis()->SetTitle("Combined LR");
604  hLRtotB->GetXaxis()->SetTitle("Combined LR");
605 
606  hLRtotB->Draw();
607  hLRtotS->SetLineColor(2);
608  hLRtotS->Draw("same");
609  c3.Print(fname + "Dist." + extension);
610 
611  TCanvas c5("c3", "", 900, 600);
612  c5.Divide(2, 2);
613  c5.cd(1);
614  hLRtotB->Draw();
615  hLRtotS->SetLineColor(2);
616  hLRtotS->Draw("same");
617  c5.cd(3);
618  hLRValvsEff->Draw("AP");
619  c5.cd(2);
620  hEffvsPur->Draw("AP");
621  c5.cd(4);
622  hLRtotSoverSplusB->Draw();
623  c5.Print(fname + "all." + extension);
624 }
TGraph * hLRValvsEff
TGraph * hLRValvsPur
string fname
main script
TH1F * hLRtotSoverSplusB

◆ readObsHistsAndFits()

void LRHelpFunctions::readObsHistsAndFits ( const TString &  fileName,
const std::vector< int > &  observables,
bool  readLRplots 
)

Definition at line 212 of file LRHelpFunctions.cc.

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

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

214  {
215  hObsS.clear();
216  hObsB.clear();
217  hObsSoverSplusB.clear();
218  fObsSoverSplusB.clear();
219  TFile* fitFile = new TFile(fileName, "READ");
220  if (observables[0] == -1) {
221  std::cout << " ... will read hists and fit for all available observables in file " << fileName << std::endl;
222  TList* list = fitFile->GetListOfKeys();
223  TIter next(list);
224  TKey* el;
225  while ((el = (TKey*)next())) {
226  TString keyName = el->GetName();
227  if (keyName.Contains("F_") && keyName.Contains("_SoverSplusB")) {
228  fObsSoverSplusB.push_back(new TF1(*((TF1*)el->ReadObj())));
229  } else if (keyName.Contains("_SoverSplusB")) {
230  hObsSoverSplusB.push_back(new TH1F(*((TH1F*)el->ReadObj())));
231  } else if (keyName.Contains("_S")) {
232  hObsS.push_back(new TH1F(*((TH1F*)el->ReadObj())));
233  } else if (keyName.Contains("_B")) {
234  hObsB.push_back(new TH1F(*((TH1F*)el->ReadObj())));
235  } else if (keyName.Contains("Corr")) {
236  hObsCorr.push_back(new TH2F(*((TH2F*)el->ReadObj())));
237  }
238  }
239  } else {
240  obsNumbers = observables;
241  for (unsigned int obs = 0; obs < observables.size(); obs++) {
242  std::cout << " ... will read hists and fit for obs " << observables[obs] << " from file " << fileName
243  << std::endl;
244  TString hStitle = "Obs";
245  hStitle += observables[obs];
246  hStitle += "_S";
247  hObsS.push_back(new TH1F(*((TH1F*)fitFile->GetKey(hStitle)->ReadObj())));
248  TString hBtitle = "Obs";
249  hBtitle += observables[obs];
250  hBtitle += "_B";
251  hObsB.push_back(new TH1F(*((TH1F*)fitFile->GetKey(hBtitle)->ReadObj())));
252  TString hSBtitle = "Obs";
253  hSBtitle += observables[obs];
254  hSBtitle += "_SoverSplusB";
255  TString fSBtitle = "F_";
256  fSBtitle += hSBtitle;
257  hObsSoverSplusB.push_back(new TH1F(*((TH1F*)fitFile->GetKey(hSBtitle)->ReadObj())));
258  fObsSoverSplusB.push_back(new TF1(*((TF1*)fitFile->GetKey(fSBtitle)->ReadObj())));
259  for (unsigned int obs2 = obs + 1; obs2 < observables.size(); obs2++) {
260  TString hCorrtitle = "Corr_Obs";
261  hCorrtitle += observables[obs];
262  hCorrtitle += "_Obs";
263  hCorrtitle += observables[obs2];
264  hObsCorr.push_back(new TH2F(*((TH2F*)fitFile->GetKey(hCorrtitle)->ReadObj())));
265  }
266  }
267  }
268 
269  if (readLRplots) {
270  constructPurity = true;
271  std::cout << " ... will LR s and B histos from file " << fileName << std::endl;
272  hLRtotS = new TH1F(*((TH1F*)fitFile->GetKey("hLRtotS")->ReadObj()));
273  hLRtotB = new TH1F(*((TH1F*)fitFile->GetKey("hLRtotB")->ReadObj()));
274  hLRtotSoverSplusB = new TH1F(*((TH1F*)fitFile->GetKey("hLRtotSoverSplusB")->ReadObj()));
275  fLRtotSoverSplusB = new TF1(*((TF1*)fitFile->GetKey("fLRtotSoverSplusB")->ReadObj()));
276  }
277 }
std::vector< TH1F * > hObsSoverSplusB
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
std::vector< TH2F * > hObsCorr
std::vector< int > obsNumbers
std::vector< TF1 * > fObsSoverSplusB
TH1F * hLRtotSoverSplusB

◆ recreateFitFct()

void LRHelpFunctions::recreateFitFct ( const std::vector< int > &  obsNr,
const std::vector< const char *> &  functions 
)

Definition at line 53 of file LRHelpFunctions.cc.

References fObsSoverSplusB, hObsS, and EcalTangentSkim_cfg::o.

53  {
54  if (!fObsSoverSplusB.empty())
55  fObsSoverSplusB.clear();
56  for (size_t o = 0; o < obsNr.size(); o++) {
57  // create fit functions
58  TString ftSB = "F_Obs";
59  ftSB += obsNr[o];
60  ftSB += "_SoverSplusB";
61  fObsSoverSplusB.push_back(
62  new TF1(ftSB, functions[o], hObsS[o]->GetXaxis()->GetXmin(), hObsS[o]->GetXaxis()->GetXmax()));
63  }
64 }
std::vector< TH1F * > hObsS
std::vector< TF1 * > fObsSoverSplusB

◆ setObsFitParameters()

void LRHelpFunctions::setObsFitParameters ( int  obs,
const std::vector< double > &  fitPars 
)

Definition at line 97 of file LRHelpFunctions.cc.

References l1tPhase2CaloJetEmulator_cfi::fit, personalPlayback::fn, fObsSoverSplusB, and AlCaHLTBitMon_ParallelJobs::p.

97  {
98  for (size_t fit = 0; fit < fObsSoverSplusB.size(); fit++) {
99  TString fn = "_Obs";
100  fn += obs;
101  if (((TString)fObsSoverSplusB[fit]->GetName()).Contains(fn)) {
102  for (size_t p = 0; p < fitPars.size(); p++) {
103  fObsSoverSplusB[fit]->SetParameter(p, fitPars[p]);
104  }
105  }
106  }
107 }
std::vector< TF1 * > fObsSoverSplusB

◆ setXlabels()

void LRHelpFunctions::setXlabels ( const std::vector< std::string > &  xLabels)

Definition at line 501 of file LRHelpFunctions.cc.

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

501  {
502  if (hObsS.size() != xLabels.size()) {
503  std::cout << "LRHelpFunctions::setXlabels: Number of labels (" << xLabels.size()
504  << ") does not match number of obervables(" << hObsS.size() << ").\n";
505  return;
506  }
507  for (size_t i = 0; i < hObsS.size(); ++i) {
508  hObsS[i]->GetXaxis()->SetTitle(TString(xLabels[i]));
509  hObsB[i]->GetXaxis()->SetTitle(TString(xLabels[i]));
510  hObsSoverSplusB[i]->GetXaxis()->SetTitle(TString(xLabels[i]));
511  hObsSoverSplusB[i]->GetYaxis()->SetTitle(TString("S/(S+B)"));
512  }
513 }
std::vector< TH1F * > hObsSoverSplusB
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB

◆ setYlabels()

void LRHelpFunctions::setYlabels ( const std::vector< std::string > &  yLabels)

Definition at line 515 of file LRHelpFunctions.cc.

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

515  {
516  if (hObsS.size() != yLabels.size()) {
517  std::cout << "LRHelpFunctions::setYlabels: Number of labels (" << yLabels.size()
518  << ") does not match number of obervables(" << hObsS.size() << ").\n";
519  return;
520  }
521  for (size_t i = 0; i < hObsS.size(); ++i) {
522  hObsS[i]->GetYaxis()->SetTitle(TString(yLabels[i]));
523  hObsB[i]->GetYaxis()->SetTitle(TString(yLabels[i]));
524  }
525 }
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB

◆ singlePlot()

void LRHelpFunctions::singlePlot ( const TString &  fname,
int  obsNbr,
const TString &  extension = TString("eps") 
)

Definition at line 527 of file LRHelpFunctions.cc.

References gather_cfg::cout, runGCPTkAlMap::extension, alignmentValidation::fname, fObsSoverSplusB, hObsB, hObsS, hObsSoverSplusB, EcalTangentSkim_cfg::o, obsFitIncluded(), and plotscripts::tdrStyle.

527  {
528  if (!obsFitIncluded(obsNbr))
529  return;
530 
531  TStyle* tdrStyle = gROOT->GetStyle("tdrStyle");
532  tdrStyle->SetOptFit(0);
533  tdrStyle->SetOptStat(0);
534  tdrStyle->SetOptTitle(0);
535  // tdrStyle->SetPadTopMargin(0.01);
536  // tdrStyle->SetPadBottomMargin(0.01);
537  // tdrStyle->SetPadLeftMargin(0.01);
538  // tdrStyle->SetPadRightMargin(0.01);
539 
540  TCanvas c2("c2", "", 600, 300);
541  c2.SetTopMargin(0.01);
542  c2.SetBottomMargin(0.01);
543  c2.SetLeftMargin(0.01);
544  c2.SetRightMargin(0.01);
545  std::cout << fname << std::endl;
546  c2.Divide(2, 1);
547 
548  TString obs = "Obs";
549  obs += obsNbr;
550  obs += "_";
551  for (size_t o = 0; o < hObsB.size(); ++o) {
552  if (((TString)(hObsB[o]->GetName())).Contains(obs)) {
553  c2.cd(1);
554  hObsS[o]->SetLineColor(2);
555  if (hObsB[o]->GetMaximum() > hObsS[o]->GetMaximum()) {
556  hObsB[o]->Draw("hist");
557  hObsS[o]->Draw("histsame");
558  } else {
559  hObsS[o]->Draw("hist");
560  hObsB[o]->Draw("histsame");
561  }
562  c2.cd(2);
563 
564  hObsSoverSplusB[o]->Draw();
565  fObsSoverSplusB[o]->Draw("same");
566  }
567  }
568  std::cout << fname + "." + extension << std::endl;
569  c2.Print(fname + "." + extension);
570 }
std::vector< TH1F * > hObsSoverSplusB
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
bool obsFitIncluded(int)
string fname
main script
std::vector< TF1 * > fObsSoverSplusB

◆ storeControlPlots()

void LRHelpFunctions::storeControlPlots ( const TString &  fname)

Definition at line 311 of file LRHelpFunctions.cc.

References HltBtagPostValidation_cff::c, gpuPixelDoublets::cc, constructPurity, alignmentValidation::fname, fObsSoverSplusB, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, hObsB, hObsCorr, hObsS, hObsSoverSplusB, createfilelist::int, EcalTangentSkim_cfg::o, and DiDispStaMuonMonitor_cfi::pt.

311  {
312  TCanvas c("dummy", "", 1);
313  c.Print(fname + "[", "landscape");
314  for (size_t o = 0; o < hObsS.size(); o++) {
315  TCanvas c2("c2", "", 1);
316  c2.Divide(2, 1);
317  c2.cd(1);
318  hObsS[o]->SetLineColor(2);
319  if (hObsB[o]->GetMaximum() > hObsS[o]->GetMaximum()) {
320  hObsB[o]->Draw("hist");
321  hObsS[o]->Draw("histsame");
322  } else {
323  hObsS[o]->Draw("hist");
324  hObsB[o]->Draw("histsame");
325  }
326  c2.cd(2);
327  hObsSoverSplusB[o]->Draw();
328  fObsSoverSplusB[o]->Draw("same");
329  c2.Print(fname, "Landscape");
330  }
331 
332  int hIndex = 0;
333  for (size_t o = 0; o < hObsS.size(); o++) {
334  for (size_t o2 = o + 1; o2 < hObsS.size(); o2++) {
335  TCanvas cc("cc", "", 1);
336  hObsCorr[hIndex]->Draw("box");
337  TPaveText pt(0.5, 0.87, 0.98, 0.93, "blNDC");
338  pt.SetFillStyle(1);
339  pt.SetFillColor(0);
340  pt.SetBorderSize(0);
341  TString tcorr = "Corr. of ";
342  tcorr += (int)(100. * hObsCorr[hIndex]->GetCorrelationFactor());
343  tcorr += " %";
344  //TText *text = pt.AddText(tcorr);
345  pt.Draw("same");
346  ++hIndex;
347  cc.Print(fname, "Landscape");
348  }
349  }
350 
351  if (constructPurity) {
352  TCanvas c3("c3", "", 1);
353  c3.Divide(2, 1);
354  c3.cd(1);
355  hLRtotB->Draw();
356  hLRtotS->SetLineColor(2);
357  hLRtotS->Draw("same");
358  c3.cd(2);
359  hLRtotSoverSplusB->Draw();
360  c3.Print(fname, "Landscape");
361 
362  TCanvas c4("c4", "", 1);
363  hEffvsPur->Draw("AL*");
364  c4.Print(fname, "Landscape");
365 
366  TCanvas c5("c5", "", 1);
367  hLRValvsPur->Draw("AL*");
368  c5.Print(fname, "Landscape");
369 
370  TCanvas c6("c6", "", 1);
371  hLRValvsEff->Draw("AL*");
372  c6.Print(fname, "Landscape");
373  }
374  c.Print(fname + "]", "landscape");
375 }
std::vector< TH1F * > hObsSoverSplusB
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
TGraph * hLRValvsEff
std::vector< TH2F * > hObsCorr
TGraph * hLRValvsPur
string fname
main script
std::vector< TF1 * > fObsSoverSplusB
TH1F * hLRtotSoverSplusB

◆ storeToROOTfile()

void LRHelpFunctions::storeToROOTfile ( const TString &  fname)

Definition at line 280 of file LRHelpFunctions.cc.

References constructPurity, fLRtotSoverSplusB, alignmentValidation::fname, fObsSoverSplusB, hEffvsPur, hLRtotB, hLRtotS, hLRtotSoverSplusB, hLRValvsEff, hLRValvsPur, hObsB, hObsCorr, hObsS, hObsSoverSplusB, and EcalTangentSkim_cfg::o.

280  {
281  TFile fOut(fname, "RECREATE");
282  fOut.cd();
283  for (size_t o = 0; o < hObsS.size(); o++) {
284  hObsS[o]->Write();
285  hObsB[o]->Write();
286  hObsSoverSplusB[o]->Write();
287  fObsSoverSplusB[o]->Write();
288  }
289  int hIndex = 0;
290  for (size_t o = 0; o < hObsS.size(); o++) {
291  for (size_t o2 = o + 1; o2 < hObsS.size(); o2++) {
292  hObsCorr[hIndex]->Write();
293  ++hIndex;
294  }
295  }
296  if (constructPurity) {
297  hLRtotS->Write();
298  hLRtotB->Write();
299  hLRtotSoverSplusB->Write();
300  fLRtotSoverSplusB->Write();
301  hEffvsPur->Write();
302  hLRValvsPur->Write();
303  hLRValvsEff->Write();
304  }
305  fOut.cd();
306  fOut.Write();
307  fOut.Close();
308 }
std::vector< TH1F * > hObsSoverSplusB
std::vector< TH1F * > hObsS
std::vector< TH1F * > hObsB
TGraph * hLRValvsEff
std::vector< TH2F * > hObsCorr
TGraph * hLRValvsPur
string fname
main script
std::vector< TF1 * > fObsSoverSplusB
TH1F * hLRtotSoverSplusB

Member Data Documentation

◆ constructPurity

bool LRHelpFunctions::constructPurity
private

◆ fLRtotSoverSplusB

TF1* LRHelpFunctions::fLRtotSoverSplusB
private

◆ fObsSoverSplusB

std::vector<TF1*> LRHelpFunctions::fObsSoverSplusB
private

◆ hEffvsPur

TGraph* LRHelpFunctions::hEffvsPur
private

◆ hLRtotB

TH1F * LRHelpFunctions::hLRtotB
private

◆ hLRtotS

TH1F* LRHelpFunctions::hLRtotS
private

◆ hLRtotSoverSplusB

TH1F * LRHelpFunctions::hLRtotSoverSplusB
private

◆ hLRValvsEff

TGraph * LRHelpFunctions::hLRValvsEff
private

◆ hLRValvsPur

TGraph * LRHelpFunctions::hLRValvsPur
private

◆ hObsB

std::vector<TH1F*> LRHelpFunctions::hObsB
private

◆ hObsCorr

std::vector<TH2F*> LRHelpFunctions::hObsCorr
private

◆ hObsS

std::vector<TH1F*> LRHelpFunctions::hObsS
private

◆ hObsSoverSplusB

std::vector<TH1F*> LRHelpFunctions::hObsSoverSplusB
private

◆ obsNumbers

std::vector<int> LRHelpFunctions::obsNumbers
private

Definition at line 78 of file LRHelpFunctions.h.

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