2 #include "TopQuarkAnalysis/TopTools/test/tdrstyle.C"
8 gStyle->SetCanvasDefW(900);
12 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) {
16 gStyle->SetCanvasDefW(900);
17 for(
size_t o=0;
o<obsNr.size();
o++){
19 TString htS =
"Obs"; htS += obsNr[
o]; htS +=
"_S";
20 TString htB =
"Obs"; htB += obsNr[
o]; htB +=
"_B";
21 TString htSB =
"Obs"; htSB += obsNr[
o]; htSB +=
"_SoverSplusB";
22 hObsS.push_back(
new TH1F(htS,htS,nrBins,obsMin[
o],obsMax[o]) );
23 hObsB.push_back(
new TH1F(htB,htB,nrBins,obsMin[o],obsMax[o]) );
24 hObsSoverSplusB.push_back(
new TH1F(htSB,htSB,nrBins,obsMin[o],obsMax[o]) );
27 for (
size_t o2 = o+1; o2 < obsNr.size(); o2++) {
28 TString hcorr =
"Corr_Obs"; hcorr += obsNr[
o]; hcorr +=
"_Obs"; hcorr += obsNr[o2];
29 hObsCorr.push_back(
new TH2F(hcorr,hcorr,nrBins,obsMin[o],obsMax[o],nrBins,obsMin[o2],obsMax[o2]) );
33 TString ftSB =
"F_Obs"; ftSB += obsNr[
o]; ftSB +=
"_SoverSplusB";
40 for(
size_t o=0;
o<obsNr.size();
o++){
42 TString ftSB =
"F_Obs"; ftSB += obsNr[
o]; ftSB +=
"_SoverSplusB";
50 gStyle->SetCanvasDefW(900);
53 hLRtotS =
new TH1F(
"hLRtotS",
"hLRtotS",nrLRbins,LRmin,LRmax);
54 hLRtotS->GetXaxis()->SetTitle(
"Combined LR");
55 hLRtotB =
new TH1F(
"hLRtotB",
"hLRtotB",nrLRbins,LRmin,LRmax);
56 hLRtotB->GetXaxis()->SetTitle(
"Combined LR");
57 hLRtotSoverSplusB =
new TH1F(
"hLRtotSoverSplusB",
"hLRtotSoverSplusB",nrLRbins,LRmin,LRmax);
72 hLRtotS =
new TH1F(
"hLRtotS",
"hLRtotS",nrLRbins,LRmin,LRmax);
73 hLRtotB =
new TH1F(
"hLRtotB",
"hLRtotB",nrLRbins,LRmin,LRmax);
74 hLRtotSoverSplusB =
new TH1F(
"hLRtotSoverSplusB",
"hLRtotSoverSplusB",nrLRbins,LRmin,LRmax);
84 TString fn =
"_Obs"; fn += obs;
86 for(
size_t p=0;
p<fitPars.size();
p++){
100 for(
size_t o=0;
o<obsVals.size();
o++) {
101 hObsS[
o]->Fill(obsVals[
o], weight);
102 for(
size_t o2=o+1; o2<obsVals.size(); o2++) {
103 hObsCorr[hIndex] ->
Fill(obsVals[o],obsVals[o2], weight);
111 TString obs =
"Obs"; obs += obsNbr; obs +=
"_";
112 for(
size_t f = 0;
f<
hObsS.size();
f++){
113 if(((TString)(
hObsS[
f]->GetName())).Contains(obs)) {
114 hObsS[
f]->Fill(obsVal, weight);
122 double obsVal2,
double weight){
123 TString hcorr =
"Corr_Obs"; hcorr +=
std::min(obsNbr1,obsNbr2) ; hcorr +=
"_Obs"; hcorr +=
std::max(obsNbr1, obsNbr2);
125 if(((TString)(
hObsCorr[
i]->GetName())) == hcorr) {
126 if (obsNbr1 < obsNbr2) {
139 for(
size_t o=0;
o<obsVals.size();
o++)
hObsB[
o]->
Fill(obsVals[
o], weight);
144 TString obs =
"Obs"; obs += obsNbr; obs +=
"_";
145 for(
size_t f = 0;
f<
hObsB.size();
f++){
146 if(((TString)(
hObsB[
f]->GetName())).Contains(obs)) {
147 hObsB[
f]->Fill(obsVal, weight);
155 for(
size_t o=0;
o<
hObsS.size();
o++){
158 double nrSignEntries = 0, nrBackEntries = 0;
159 for (
int i=0;
i<=
hObsS[
o]->GetNbinsX()+1;
i++){
160 nrSignEntries +=
hObsS[
o]->GetBinContent(
i);
161 nrBackEntries +=
hObsB[
o]->GetBinContent(
i);
163 for(
int b=0;
b <=
hObsS[
o]->GetNbinsX()+1;
b++){
164 hObsS[
o]->SetBinContent(
b,
hObsS[
o]->GetBinContent(
b)/(nrSignEntries));
165 hObsB[
o]->SetBinContent(
b,
hObsB[
o]->GetBinContent(
b)/(nrBackEntries));
166 hObsS[
o]->SetBinError(
b,
hObsS[
o]->GetBinError(
b)/(nrSignEntries));
167 hObsB[
o]->SetBinError(
b,
hObsB[
o]->GetBinError(
b)/(nrBackEntries));
177 for(
size_t o=0;
o<
hObsS.size();
o++){
178 for(
int b=0;
b <=
hObsS[
o]->GetNbinsX()+1;
b++){
179 if ((
hObsS[
o]->GetBinContent(
b)+
hObsB[
o]->GetBinContent(
b)) > 0) {
197 TFile *fitFile =
new TFile(fileName,
"READ");
198 if(observables[0] == -1){
199 std::cout<<
" ... will read hists and fit for all available observables in file "<<fileName<<std::endl;
200 TList *
list = fitFile->GetListOfKeys();
203 while ((el = (TKey*)
next())) {
204 TString keyName = el->GetName();
205 if(keyName.Contains(
"F_") && keyName.Contains(
"_SoverSplusB")){
208 else if(keyName.Contains(
"_SoverSplusB")){
211 else if(keyName.Contains(
"_S")){
212 hObsS.push_back(
new TH1F(*((TH1F*) el -> ReadObj())));
214 else if(keyName.Contains(
"_B")){
215 hObsB.push_back(
new TH1F(*((TH1F*) el -> ReadObj())));
217 else if(keyName.Contains(
"Corr")){
218 hObsCorr.push_back(
new TH2F(*((TH2F*) el -> ReadObj())));
224 for(
unsigned int obs = 0; obs < observables.size(); obs++){
225 std::cout<<
" ... will read hists and fit for obs "<<observables[obs]<<
" from file "<<fileName<<std::endl;
226 TString hStitle =
"Obs"; hStitle += observables[obs]; hStitle +=
"_S";
227 hObsS.push_back(
new TH1F(*((TH1F*)fitFile->GetKey(hStitle)->ReadObj())));
228 TString hBtitle =
"Obs"; hBtitle += observables[obs]; hBtitle +=
"_B";
229 hObsB.push_back(
new TH1F(*((TH1F*)fitFile->GetKey(hBtitle)->ReadObj())));
230 TString hSBtitle =
"Obs"; hSBtitle += observables[obs]; hSBtitle +=
"_SoverSplusB";
231 TString fSBtitle =
"F_"; fSBtitle += hSBtitle;
232 hObsSoverSplusB.push_back(
new TH1F(*((TH1F*)fitFile->GetKey(hSBtitle)->ReadObj())));
233 fObsSoverSplusB.push_back(
new TF1(*((TF1*)fitFile->GetKey(fSBtitle)->ReadObj())));
234 for(
unsigned int obs2 = obs+1; obs2 < observables.size(); obs2++){
235 TString hCorrtitle =
"Corr_Obs"; hCorrtitle += observables[obs];
236 hCorrtitle +=
"_Obs"; hCorrtitle += observables[obs2];
237 hObsCorr.push_back(
new TH2F(*((TH2F*)fitFile->GetKey(hCorrtitle)->ReadObj())));
244 std::cout<<
" ... will LR s and B histos from file "<<fileName<<std::endl;
245 hLRtotS =
new TH1F(*((TH1F*)fitFile->GetKey(
"hLRtotS")->ReadObj()));
246 hLRtotB =
new TH1F(*((TH1F*)fitFile->GetKey(
"hLRtotB")->ReadObj()));
247 hLRtotSoverSplusB =
new TH1F(*((TH1F*)fitFile->GetKey(
"hLRtotSoverSplusB")->ReadObj()));
248 fLRtotSoverSplusB =
new TF1(*((TF1*)fitFile->GetKey(
"fLRtotSoverSplusB") -> ReadObj()));
257 TFile fOut(fname,
"RECREATE");
259 for(
size_t o=0;
o<
hObsS.size();
o++){
266 for(
size_t o=0;
o<
hObsS.size();
o++) {
267 for(
size_t o2=
o+1; o2<
hObsS.size(); o2++) {
292 TCanvas
c(
"dummy",
"",1);
293 c.Print(fname +
"[",
"landscape");
294 for(
size_t o=0;
o<
hObsS.size();
o++) {
295 TCanvas c2(
"c2",
"",1);
298 hObsS[
o] -> SetLineColor(2);
301 hObsS[
o] -> Draw(
"histsame");
306 hObsB[
o] -> Draw(
"histsame");
311 c2.Print(fname,
"Landscape");
315 for(
size_t o=0;
o<
hObsS.size();
o++) {
316 for(
size_t o2=
o+1; o2<
hObsS.size(); o2++) {
317 TCanvas cc(
"cc",
"",1);
319 TPaveText
pt(0.5,0.87,0.98,0.93,
"blNDC");
323 TString tcorr =
"Corr. of "; tcorr += (int)(100.*
hObsCorr[hIndex] -> GetCorrelationFactor()); tcorr +=
" %";
327 cc.Print(fname,
"Landscape");
332 TCanvas c3(
"c3",
"",1);
340 c3.Print(fname,
"Landscape");
342 TCanvas c4(
"c4",
"",1);
344 c4.Print(fname,
"Landscape");
346 TCanvas c5(
"c5",
"",1);
348 c5.Print(fname,
"Landscape");
350 TCanvas c6(
"c6",
"",1);
352 c6.Print(fname,
"Landscape");
354 c.Print(fname +
"]",
"landscape");
365 double SoverN = 1./((1./SoverSplusN) - 1.);
366 logLR +=
log(SoverN);
379 if (SoverSplusN<0.0001) SoverSplusN=0.0001;
387 if(((TString)(
hObsCorr[
i]->GetName())) == hcorr)
388 corr += fabs(
hObsCorr[
i]->GetCorrelationFactor());
423 if (Sint + Bint > 0) {
429 hLRtotS->GetXaxis()->SetTitle(
"Combined LR ratio");
430 hLRtotB->GetXaxis()->SetTitle(
"Combined LR ratio");
436 double Eff[200], Pur[200], LRVal[200];
437 if (
hLRtotS->GetNbinsX()>200) {
438 std::cout <<
"Number of bins of LR histograms can not execeed 200!"<<std::endl;
442 double LRcutVal =
hLRtotS->GetBinLowEdge(
cut);
445 LRVal[
cut] = LRcutVal;
450 hEffvsPur -> GetXaxis() -> SetTitle((TString)(
"Efficiency of cut on log combined LR"));
451 hEffvsPur -> GetYaxis() -> SetTitle((TString)(
"Purity"));
452 hEffvsPur -> GetYaxis() -> SetRangeUser(0,1.1);
457 hLRValvsPur -> GetXaxis() -> SetTitle((TString)(
"Cut on the log combined LR value"));
458 hLRValvsPur -> GetYaxis() -> SetTitle((TString)(
"Purity"));
464 hLRValvsEff -> GetXaxis() -> SetTitle((TString)(
"Cut on the log combined LR value"));
465 hLRValvsEff -> GetYaxis() -> SetTitle((TString)(
"Efficiency of cut on log combined LR"));
481 bool included =
false;
482 TString obs =
"_Obs"; obs +=
o; obs +=
"_";
484 if(((TString)(
fObsSoverSplusB[
f]->GetName())).Contains(obs)) included =
true;
491 if (
hObsS.size() != xLabels.size()) {
492 std::cout <<
"LRHelpFunctions::setXlabels: Number of labels ("
493 << xLabels.size()<<
") does not match number of obervables("
494 <<
hObsS.size()<<
").\n";
497 for(
size_t i = 0;
i<
hObsS.size(); ++
i){
498 hObsS[
i]->GetXaxis()->SetTitle(TString(xLabels[
i]));
499 hObsB[
i]->GetXaxis()->SetTitle(TString(xLabels[i]));
507 if (
hObsS.size() != yLabels.size()) {
508 std::cout <<
"LRHelpFunctions::setYlabels: Number of labels ("
509 << yLabels.size()<<
") does not match number of obervables("
510 <<
hObsS.size()<<
").\n";
513 for(
size_t i = 0;
i<
hObsS.size(); ++
i){
514 hObsS[
i]->GetYaxis()->SetTitle(TString(yLabels[
i]));
515 hObsB[
i]->GetYaxis()->SetTitle(TString(yLabels[i]));
522 TStyle *
tdrStyle = gROOT->GetStyle(
"tdrStyle");
523 tdrStyle->SetOptFit(0);
524 tdrStyle->SetOptStat(0);
525 tdrStyle->SetOptTitle(0);
531 TCanvas c2(
"c2",
"",600,300);
532 c2.SetTopMargin(0.01);
533 c2.SetBottomMargin(0.01);
534 c2.SetLeftMargin(0.01);
535 c2.SetRightMargin(0.01);
539 TString obs =
"Obs"; obs += obsNbr; obs +=
"_";
540 for(
size_t o = 0;
o<
hObsB.size(); ++
o){
541 if(((TString)(
hObsB[
o]->GetName())).Contains(obs)) {
543 hObsS[
o] -> SetLineColor(2);
546 hObsS[
o] -> Draw(
"histsame");
551 hObsB[
o] -> Draw(
"histsame");
559 std::cout << fname+
"."+extension<<std::endl;
560 c2.Print(fname+
"."+extension);
565 TStyle *
tdrStyle = gROOT->GetStyle(
"tdrStyle");
566 tdrStyle->SetOptFit(0);
567 tdrStyle->SetOptStat(0);
568 tdrStyle->SetOptTitle(0);
574 TCanvas c2(
"c2",
"",600,300);
575 c2.SetTopMargin(0.01);
576 c2.SetBottomMargin(0.01);
577 c2.SetLeftMargin(0.01);
578 c2.SetRightMargin(0.01);
586 c2.Print(fname+
"Purity."+extension);
588 hLRtotS->GetXaxis()->SetNdivisions(505);
589 hLRtotB->GetXaxis()->SetNdivisions(505);
590 TCanvas c3(
"c2",
"",300,300);
595 hLRtotS->GetXaxis()->SetTitle(
"Combined LR");
596 hLRtotB->GetXaxis()->SetTitle(
"Combined LR");
601 c3.Print(fname+
"Dist."+extension);
604 TCanvas c5(
"c3",
"",900,600);
616 c5.Print(fname+
"all."+extension);
void storeControlPlots(const TString &)
double calcLRval(const std::vector< double > &)
std::vector< TH1F * > hObsSoverSplusB
void setXlabels(const std::vector< std::string > &xLabels)
static std::vector< std::string > checklist log
void recreateFitFct(const std::vector< int > &obsNr, const std::vector< const char * > &functions)
std::vector< TH1F * > hObsS
double calcPtdrLRval(const std::vector< double > &vals, bool useCorrelation=false)
void makeAndFitPurityHists()
std::vector< TH1F * > hObsB
void setYlabels(const std::vector< std::string > &yLabels)
std::vector< TH2F * > hObsCorr
void fillToBackgroundHists(const std::vector< double > &, double weight=1.0)
void fillToSignalCorrelation(int obsNbr1, double obsVal1, int obsNbr2, double obsVal2, double weight)
void makeAndFitSoverSplusBHists()
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void storeToROOTfile(const TString &)
std::vector< int > obsNumbers
void fillLRSignalHist(double, double weight=1.0)
void singlePlot(const TString &fname, int obsNbr, const TString &extension=TString("eps"))
void readObsHistsAndFits(const TString &, const std::vector< int > &, bool)
void fillToSignalHists(const std::vector< double > &, double weight=1.0)
void setObsFitParameters(int obs, const std::vector< double > &)
std::vector< TF1 * > fObsSoverSplusB
void initLRHistsAndFits(int, double, double, const char *)
void fillLRBackgroundHist(double, double weight=1.0)
Power< A, B >::type pow(const A &a, const B &b)
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
void normalizeSandBhists()
void purityPlot(const TString &fname, const TString &extension=TString("eps"))