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.

5  {
6  constructPurity = false;
7  setTDRStyle();
8  gStyle->SetCanvasDefW(900);
9 }

References constructPurity, and plotscripts::setTDRStyle().

◆ 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.

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 }

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

◆ LRHelpFunctions() [3/3]

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

Definition at line 66 of file LRHelpFunctions.cc.

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 }

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

◆ ~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.

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 }

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

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

◆ 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.

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 }

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

◆ fillLRBackgroundHist()

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

Definition at line 428 of file LRHelpFunctions.cc.

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

References hLRtotB, and heppy_batch::val.

◆ fillLRSignalHist()

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

Definition at line 422 of file LRHelpFunctions.cc.

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

References hLRtotS, and heppy_batch::val.

◆ fillToBackgroundHists() [1/2]

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

Definition at line 153 of file LRHelpFunctions.cc.

153  {
154  for (size_t o = 0; o < obsVals.size(); o++)
155  hObsB[o]->Fill(obsVals[o], weight);
156 }

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

◆ fillToBackgroundHists() [2/2]

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

Definition at line 159 of file LRHelpFunctions.cc.

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 }

References f, and hObsB.

◆ fillToSignalCorrelation()

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

Definition at line 135 of file LRHelpFunctions.cc.

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 }

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

◆ fillToSignalHists() [1/2]

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

Definition at line 110 of file LRHelpFunctions.cc.

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 }

References hObsCorr, hObsS, and EcalTangentSkim_cfg::o.

◆ fillToSignalHists() [2/2]

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

Definition at line 122 of file LRHelpFunctions.cc.

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 }

References f, and hObsS.

◆ initLRHistsAndFits()

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

Definition at line 86 of file LRHelpFunctions.cc.

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 }

References constructPurity, fLRtotSoverSplusB, hLRtotB, hLRtotS, hLRtotSoverSplusB, and tools::TF1.

◆ makeAndFitPurityHists()

void LRHelpFunctions::makeAndFitPurityHists ( )

Definition at line 434 of file LRHelpFunctions.cc.

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 }

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

◆ makeAndFitSoverSplusBHists()

void LRHelpFunctions::makeAndFitSoverSplusBHists ( )

Definition at line 192 of file LRHelpFunctions.cc.

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 }

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

◆ normalizeSandBhists()

void LRHelpFunctions::normalizeSandBhists ( )

Definition at line 172 of file LRHelpFunctions.cc.

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 }

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

◆ obsFitIncluded()

bool LRHelpFunctions::obsFitIncluded ( int  o)

Definition at line 489 of file LRHelpFunctions.cc.

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 }

References f, fObsSoverSplusB, and EcalTangentSkim_cfg::o.

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

◆ purityPlot()

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

Definition at line 572 of file LRHelpFunctions.cc.

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 }

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

◆ readObsHistsAndFits()

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

Definition at line 212 of file LRHelpFunctions.cc.

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 }

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

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

◆ recreateFitFct()

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

Definition at line 53 of file LRHelpFunctions.cc.

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 }

References fObsSoverSplusB, stringResolutionProvider_cfi::functions, hObsS, EcalTangentSkim_cfg::o, and tools::TF1.

◆ setObsFitParameters()

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

Definition at line 97 of file LRHelpFunctions.cc.

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 }

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

◆ setXlabels()

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

Definition at line 501 of file LRHelpFunctions.cc.

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 }

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

◆ setYlabels()

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

Definition at line 515 of file LRHelpFunctions.cc.

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 }

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

◆ singlePlot()

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

Definition at line 527 of file LRHelpFunctions.cc.

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 }

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

◆ storeControlPlots()

void LRHelpFunctions::storeControlPlots ( const TString &  fname)

Definition at line 311 of file LRHelpFunctions.cc.

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 }

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

◆ storeToROOTfile()

void LRHelpFunctions::storeToROOTfile ( const TString &  fname)

Definition at line 280 of file LRHelpFunctions.cc.

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 }

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

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().

mps_fire.i
i
Definition: mps_fire.py:355
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
min
T min(T a, T b)
Definition: MathUtil.h:58
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edmStreamStallGrapher.extension
extension
Definition: edmStreamStallGrapher.py:893
L1TowerCalibrationProducer_cfi.fit
fit
Definition: L1TowerCalibrationProducer_cfi.py:36
LRHelpFunctions::hLRValvsEff
TGraph * hLRValvsEff
Definition: LRHelpFunctions.h:76
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
tools.TF1
TF1
Definition: tools.py:23
relativeConstraints.error
error
Definition: relativeConstraints.py:53
LRHelpFunctions::obsFitIncluded
bool obsFitIncluded(int)
Definition: LRHelpFunctions.cc:489
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
LRHelpFunctions::hObsCorr
std::vector< TH2F * > hObsCorr
Definition: LRHelpFunctions.h:72
plotscripts.setTDRStyle
def setTDRStyle()
Definition: plotscripts.py:89
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
LRHelpFunctions::fObsSoverSplusB
std::vector< TF1 * > fObsSoverSplusB
Definition: LRHelpFunctions.h:73
LRHelpFunctions::hLRtotSoverSplusB
TH1F * hLRtotSoverSplusB
Definition: LRHelpFunctions.h:74
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
LRHelpFunctions::hObsSoverSplusB
std::vector< TH1F * > hObsSoverSplusB
Definition: LRHelpFunctions.h:71
b
double b
Definition: hdecay.h:118
LRHelpFunctions::hLRtotB
TH1F * hLRtotB
Definition: LRHelpFunctions.h:74
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LRHelpFunctions::obsNumbers
std::vector< int > obsNumbers
Definition: LRHelpFunctions.h:78
LRHelpFunctions::constructPurity
bool constructPurity
Definition: LRHelpFunctions.h:77
createfilelist.int
int
Definition: createfilelist.py:10
LRHelpFunctions::hObsB
std::vector< TH1F * > hObsB
Definition: LRHelpFunctions.h:71
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cc
stringResolutionProvider_cfi.functions
functions
Definition: stringResolutionProvider_cfi.py:7
LRHelpFunctions::hObsS
std::vector< TH1F * > hObsS
Definition: LRHelpFunctions.h:71
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
muonME0PseudoDigis_cfi.useCorrelation
useCorrelation
Definition: muonME0PseudoDigis_cfi.py:12
LRHelpFunctions::hLRtotS
TH1F * hLRtotS
Definition: LRHelpFunctions.h:74
heppy_batch.val
val
Definition: heppy_batch.py:351
plotscripts.tdrStyle
tdrStyle
Definition: plotscripts.py:88
personalPlayback.fn
fn
Definition: personalPlayback.py:515
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
list
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*", "!HLTx*" if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL. It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of "!*" before the partial wildcard feature was incorporated). Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
LRHelpFunctions::hLRValvsPur
TGraph * hLRValvsPur
Definition: LRHelpFunctions.h:76
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
LRHelpFunctions::fLRtotSoverSplusB
TF1 * fLRtotSoverSplusB
Definition: LRHelpFunctions.h:75
LRHelpFunctions::hEffvsPur
TGraph * hEffvsPur
Definition: LRHelpFunctions.h:76
fit
Definition: CombinedChiSquaredLikelihood.h:6
weight
Definition: weight.py:1
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31