2 #ifndef FlavourHistograms2D_H
3 #define FlavourHistograms2D_H
27 template <
class T,
class G>
34 TString baseNameDescription_,
47 TString baseNameDescription_,
67 void fill(
const int &
flavour,
const T &variableX,
const G &variableY)
const;
68 void fill(
const int &
flavour,
const T &variableX,
const G &variableY,
const float &
w)
const;
71 void fill(
const int &
flavour,
const T *variableX,
const G *variableY)
const;
72 void fill(
const int &
flavour,
const T *variableX,
const G *variableY,
const float &
w)
const;
74 void settitle(
const char *titleX,
const char *titleY);
76 void plot(TPad *theCanvas =
nullptr);
188 template <
class T,
class G>
190 TString baseNameDescription_,
205 theBaseNameTitle(baseNameTitle_.Data()),
206 theBaseNameDescription(baseNameDescription_.Data()),
209 theLowerBoundX(lowerBoundX_),
210 theUpperBoundX(upperBoundX_),
211 theLowerBoundY(lowerBoundY_),
212 theUpperBoundY(upperBoundY_),
216 createProfile_(createProfile) {
307 template <
class T,
class G>
309 TString baseNameDescription_,
321 : theMaxDimension(-1),
323 theBaseNameTitle(baseNameTitle_.Data()),
324 theBaseNameDescription(baseNameDescription_.Data()),
327 theLowerBoundX(lowerBoundX_),
328 theUpperBoundX(upperBoundX_),
329 theLowerBoundY(lowerBoundY_),
330 theUpperBoundY(upperBoundY_),
331 theStatistics(statistics_),
335 createProfile_(createProfile) {
619 template <
class T,
class G>
623 template <
class T,
class G>
626 fillVariable(
flavour, variableX, variableY,
w);
629 template <
class T,
class G>
634 template <
class T,
class G>
636 if (theArrayDimension == 0) {
638 fillVariable(
flavour, *variableX, *variableY,
w);
641 int iMax = *theArrayDimension;
642 if (*theArrayDimension > theMaxDimension)
643 iMax = theMaxDimension;
645 for (
int i = 0;
i != iMax; ++
i) {
647 if ((theIndexToPlot < 0) || (
i == theIndexToPlot)) {
648 fillVariable(
flavour, *(variableX +
i), *(variableY +
i),
w);
653 if (theIndexToPlot >= iMax) {
655 const T &theZeroT = static_cast<T>(0.0);
656 const G &theZeroG = static_cast<T>(0.0);
657 fillVariable(
flavour, theZeroT, theZeroG,
w);
662 template <
class T,
class G>
667 template <
class T,
class G>
670 theHisto_all->setAxisTitle(titleX);
672 theHisto_all->setAxisTitle(titleY, 2);
675 theHisto_d->setAxisTitle(titleX);
677 theHisto_u->setAxisTitle(titleX);
679 theHisto_s->setAxisTitle(titleX);
681 theHisto_c->setAxisTitle(titleX);
683 theHisto_b->setAxisTitle(titleX);
685 theHisto_g->setAxisTitle(titleX);
687 theHisto_ni->setAxisTitle(titleX);
689 theHisto_dus->setAxisTitle(titleX);
691 theHisto_dusg->setAxisTitle(titleX);
693 theHisto_d->setAxisTitle(titleY, 2);
695 theHisto_u->setAxisTitle(titleY, 2);
697 theHisto_s->setAxisTitle(titleY, 2);
699 theHisto_c->setAxisTitle(titleY, 2);
701 theHisto_b->setAxisTitle(titleY, 2);
703 theHisto_g->setAxisTitle(titleY, 2);
705 theHisto_ni->setAxisTitle(titleY, 2);
707 theHisto_dus->setAxisTitle(titleY, 2);
709 theHisto_dusg->setAxisTitle(titleY, 2);
711 theHisto_pu->setAxisTitle(titleY, 2);
714 if (createProfile_) {
716 theProfile_all->setAxisTitle(titleX);
718 theProfile_all->setAxisTitle(titleY, 2);
721 theProfile_d->setAxisTitle(titleX);
723 theProfile_u->setAxisTitle(titleX);
725 theProfile_s->setAxisTitle(titleX);
727 theProfile_c->setAxisTitle(titleX);
729 theProfile_b->setAxisTitle(titleX);
731 theProfile_g->setAxisTitle(titleX);
733 theProfile_ni->setAxisTitle(titleX);
735 theProfile_dus->setAxisTitle(titleX);
737 theProfile_dusg->setAxisTitle(titleX);
739 theProfile_d->setAxisTitle(titleY, 2);
741 theProfile_u->setAxisTitle(titleY, 2);
743 theProfile_s->setAxisTitle(titleY, 2);
745 theProfile_c->setAxisTitle(titleY, 2);
747 theProfile_b->setAxisTitle(titleY, 2);
749 theProfile_g->setAxisTitle(titleY, 2);
751 theProfile_ni->setAxisTitle(titleY, 2);
753 theProfile_dus->setAxisTitle(titleY, 2);
755 theProfile_dusg->setAxisTitle(titleY, 2);
757 theProfile_pu->setAxisTitle(titleY, 2);
762 template <
class T,
class G>
766 bool btppColour =
true;
772 gPad->UseCurrentStyle();
776 gPad->SetTitle(
nullptr);
782 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
783 histo[0] = theHisto_dusg;
784 histo[1] = theHisto_b;
785 histo[2] = theHisto_c;
790 max = theHisto_dusg->getTH2F()->GetMaximum();
791 if (theHisto_b->getTH2F()->GetMaximum() >
max)
792 max = theHisto_b->getTH2F()->GetMaximum();
793 if (theHisto_c->getTH2F()->GetMaximum() >
max)
794 max = theHisto_c->getTH2F()->GetMaximum();
798 histo[3] = theHisto_ni;
799 if (theHisto_ni->getTH2F()->GetMaximum() >
max)
800 max = theHisto_ni->getTH2F()->GetMaximum();
832 histo[0]->setAxisTitle(theBaseNameDescription);
833 histo[0]->getTH2F()->GetYaxis()->SetTitle(
"Arbitrary Units");
834 histo[0]->getTH2F()->GetYaxis()->SetTitleOffset(1.25);
836 for (
int i = 0;
i != 4; ++
i) {
839 histo[
i]->getTH2F()->SetStats(
false);
848 histo[0]->getTH2F()->SetMaximum(
max * 1.05);
850 histo[0]->getTH2F()->SetMinimum(theMin);
851 histo[0]->getTH2F()->Draw();
852 histo[1]->getTH2F()->Draw(
"Same");
853 histo[2]->getTH2F()->Draw(
"Same");
854 if (
histo[3] !=
nullptr)
855 histo[3]->getTH2F()->Draw(
"Same");
858 template <
class T,
class G>
860 TCanvas tc(theBaseNameTitle.c_str(), theBaseNameDescription.c_str());
863 tc.Print((
name + theBaseNameTitle +
".eps").c_str());
868 template <
class T,
class G>
876 theHisto_all->getTH2F()->Divide(theHisto_all->getTH2F(), bHD.
histo_all(), 1.0, 1.0,
"b");
879 theHisto_d->getTH2F()->Divide(theHisto_d->getTH2F(), bHD.
histo_d(), 1.0, 1.0,
"b");
880 theHisto_u->getTH2F()->Divide(theHisto_u->getTH2F(), bHD.
histo_u(), 1.0, 1.0,
"b");
881 theHisto_s->getTH2F()->Divide(theHisto_s->getTH2F(), bHD.
histo_s(), 1.0, 1.0,
"b");
882 theHisto_g->getTH2F()->Divide(theHisto_g->getTH2F(), bHD.
histo_g(), 1.0, 1.0,
"b");
883 theHisto_dus->getTH2F()->Divide(theHisto_dus->getTH2F(), bHD.
histo_dus(), 1.0, 1.0,
"b");
885 theHisto_c->getTH2F()->Divide(theHisto_c->getTH2F(), bHD.
histo_c(), 1.0, 1.0,
"b");
886 theHisto_b->getTH2F()->Divide(theHisto_b->getTH2F(), bHD.
histo_b(), 1.0, 1.0,
"b");
887 theHisto_ni->getTH2F()->Divide(theHisto_ni->getTH2F(), bHD.
histo_ni(), 1.0, 1.0,
"b");
888 theHisto_dusg->getTH2F()->Divide(theHisto_dusg->getTH2F(), bHD.
histo_dusg(), 1.0, 1.0,
"b");
889 theHisto_pu->getTH2F()->Divide(theHisto_pu->getTH2F(), bHD.
histo_pu(), 1.0, 1.0,
"b");
893 template <
class T,
class G>
896 theHisto_all->setEfficiencyFlag();
899 theHisto_d->setEfficiencyFlag();
900 theHisto_u->setEfficiencyFlag();
901 theHisto_s->setEfficiencyFlag();
902 theHisto_g->setEfficiencyFlag();
903 theHisto_dus->setEfficiencyFlag();
905 theHisto_c->setEfficiencyFlag();
906 theHisto_b->setEfficiencyFlag();
907 theHisto_ni->setEfficiencyFlag();
908 theHisto_dusg->setEfficiencyFlag();
909 theHisto_pu->setEfficiencyFlag();
913 template <
class T,
class G>
917 theHisto_all->Fill(varX, varY,
w);
921 theProfile_all->Fill(varX, varY);
931 theHisto_d->Fill(varX, varY,
w);
932 theHisto_dus->Fill(varX, varY,
w);
934 theHisto_dusg->Fill(varX, varY,
w);
935 if (createProfile_) {
940 theProfile_d->Fill(varX, varY);
941 theProfile_dus->Fill(varX, varY);
943 theProfile_dusg->Fill(varX, varY);
948 theHisto_u->Fill(varX, varY,
w);
949 theHisto_dus->Fill(varX, varY,
w);
951 theHisto_dusg->Fill(varX, varY,
w);
952 if (createProfile_) {
957 theProfile_u->Fill(varX, varY);
958 theProfile_dus->Fill(varX, varY);
960 theProfile_dusg->Fill(varX, varY);
965 theHisto_s->Fill(varX, varY,
w);
966 theHisto_dus->Fill(varX, varY,
w);
968 theHisto_dusg->Fill(varX, varY,
w);
969 if (createProfile_) {
974 theProfile_s->Fill(varX, varY);
975 theProfile_dus->Fill(varX, varY);
977 theProfile_dusg->Fill(varX, varY);
981 theHisto_c->Fill(varX, varY,
w);
984 theProfile_c->Fill(varX, varY);
987 theHisto_b->Fill(varX, varY,
w);
990 theProfile_b->Fill(varX, varY);
994 theHisto_g->Fill(varX, varY,
w);
995 theHisto_dusg->Fill(varX, varY,
w);
996 if (createProfile_) {
1000 theProfile_g->Fill(varX, varY);
1001 theProfile_dusg->Fill(varX, varY);
1005 theHisto_pu->Fill(varX, varY,
w);
1008 theProfile_pu->Fill(varX, varY);
1011 theHisto_ni->Fill(varX, varY,
w);
1014 theProfile_ni->Fill(varX, varY);
1019 template <
class T,
class G>
1021 std::vector<TH2F *> histoVector;
1023 histoVector.push_back(theHisto_all->getTH2F());
1026 histoVector.push_back(theHisto_d->getTH2F());
1027 histoVector.push_back(theHisto_u->getTH2F());
1028 histoVector.push_back(theHisto_s->getTH2F());
1029 histoVector.push_back(theHisto_g->getTH2F());
1030 histoVector.push_back(theHisto_dus->getTH2F());
1032 histoVector.push_back(theHisto_c->getTH2F());
1033 histoVector.push_back(theHisto_b->getTH2F());
1034 histoVector.push_back(theHisto_ni->getTH2F());
1035 histoVector.push_back(theHisto_dusg->getTH2F());
1036 histoVector.push_back(theHisto_pu->getTH2F());
1041 template <
class T,
class G>
1043 std::vector<TProfile *> profileVector;
1044 if (createProfile_) {
1046 profileVector.push_back(theProfile_all->getTProfile());
1049 profileVector.push_back(theProfile_d->getTProfile());
1050 profileVector.push_back(theProfile_u->getTProfile());
1051 profileVector.push_back(theProfile_s->getTProfile());
1052 profileVector.push_back(theProfile_g->getTProfile());
1053 profileVector.push_back(theProfile_dus->getTProfile());
1055 profileVector.push_back(theProfile_c->getTProfile());
1056 profileVector.push_back(theProfile_b->getTProfile());
1057 profileVector.push_back(theProfile_ni->getTProfile());
1058 profileVector.push_back(theProfile_dusg->getTProfile());
1059 profileVector.push_back(theProfile_pu->getTProfile());
1062 return profileVector;