2 #ifndef FlavourHistograms2D_H
3 #define FlavourHistograms2D_H
29 template <
class T,
class G>
35 int nBinsX_ ,
double lowerBoundX_ ,
double upperBoundX_ ,
36 int nBinsY_ ,
double lowerBoundY_ ,
double upperBoundY_ ,
41 int nBinsX_ ,
double lowerBoundX_ ,
double upperBoundX_ ,
42 int nBinsY_ ,
double lowerBoundY_ ,
double upperBoundY_ ,
43 bool statistics_ ,
std::string folder,
unsigned int mc,
54 void fill (
const int &
flavour,
const T & variableX,
const G & variableY)
const;
55 void fill (
const int & flavour,
const T & variableX,
const G & variableY,
const float &
w)
const;
58 void fill (
const int & flavour,
const T * variableX,
const G * variableY)
const;
59 void fill (
const int & flavour,
const T * variableX,
const G * variableY,
const float & w)
const;
62 void settitle(
const char* titleX,
const char* titleY) ;
64 void plot (TPad * theCanvas = 0) ;
120 void fillVariable (
const int & flavour ,
const T & varX ,
const G & varY ,
const float & w)
const;
184 template <
class T,
class G>
186 int nBinsX_ ,
double lowerBoundX_ ,
double upperBoundX_ ,
187 int nBinsY_ ,
double lowerBoundY_ ,
double upperBoundY_ ,
std::string folder,
191 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
192 theNBinsX ( nBinsX_ ) , theNBinsY (nBinsY_),
193 theLowerBoundX ( lowerBoundX_ ) , theUpperBoundX ( upperBoundX_ ) ,
194 theLowerBoundY ( lowerBoundY_ ) , theUpperBoundY ( upperBoundY_ ) ,
195 theMin(-1.), theMax(-1.), mcPlots_(mc), createProfile_(createProfile)
288 template <
class T,
class G>
290 int nBinsX_ ,
double lowerBoundX_ ,
double upperBoundX_ ,
291 int nBinsY_ ,
double lowerBoundY_ ,
double upperBoundY_ ,
294 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
295 theNBinsX ( nBinsX_ ) , theNBinsY (nBinsY_),
296 theLowerBoundX ( lowerBoundX_ ) , theUpperBoundX ( upperBoundX_ ) ,
297 theLowerBoundY ( lowerBoundY_ ) , theUpperBoundY ( upperBoundY_ ) ,
298 theStatistics ( statistics_ ) , theMin(-1.), theMax(-1.), mcPlots_(mc), createProfile_(createProfile)
425 template <
class T,
class G>
429 template <
class T,
class G>
void
433 fillVariable ( flavour , variableX , variableY , w ) ;
436 template <
class T,
class G>
void
439 fill ( flavour , variableX , variableY , 1. ) ;
442 template <
class T,
class G>
void
445 if ( theArrayDimension == 0 ) {
447 fillVariable ( flavour , *variableX, *variableY , w) ;
450 int iMax = *theArrayDimension ;
451 if ( *theArrayDimension > theMaxDimension ) iMax = theMaxDimension ;
453 for (
int i = 0 ;
i != iMax ; ++
i ) {
455 if ( ( theIndexToPlot < 0 ) || (
i == theIndexToPlot ) ) {
456 fillVariable ( flavour , *(variableX+
i) , *(variableY+
i) , w) ;
461 if ( theIndexToPlot >= iMax ) {
463 const T& theZeroT =
static_cast<T> ( 0.0) ;
464 const G& theZeroG =
static_cast<T> ( 0.0 );
465 fillVariable ( flavour , theZeroT , theZeroG , w ) ;
470 template <
class T,
class G>
void
473 fill ( flavour, variableX , variableY , 1. );
476 template <
class T,
class G>
478 if(theHisto_all) theHisto_all ->setAxisTitle(titleX) ;
479 if(theHisto_all) theHisto_all ->setAxisTitle(titleY, 2) ;
482 if(theHisto_d) theHisto_d ->setAxisTitle(titleX) ;
483 if(theHisto_u) theHisto_u ->setAxisTitle(titleX) ;
484 if(theHisto_s) theHisto_s ->setAxisTitle(titleX) ;
485 if(theHisto_c) theHisto_c ->setAxisTitle(titleX) ;
486 if(theHisto_b) theHisto_b ->setAxisTitle(titleX) ;
487 if(theHisto_g) theHisto_g ->setAxisTitle(titleX) ;
488 if(theHisto_ni) theHisto_ni ->setAxisTitle(titleX) ;
489 if(theHisto_dus) theHisto_dus ->setAxisTitle(titleX) ;
490 if(theHisto_dusg)theHisto_dusg->setAxisTitle(titleX) ;
491 if(theHisto_d) theHisto_d ->setAxisTitle(titleY, 2) ;
492 if(theHisto_u) theHisto_u ->setAxisTitle(titleY, 2) ;
493 if(theHisto_s) theHisto_s ->setAxisTitle(titleY, 2) ;
494 if(theHisto_c) theHisto_c ->setAxisTitle(titleY, 2) ;
495 if(theHisto_b) theHisto_b ->setAxisTitle(titleY, 2) ;
496 if(theHisto_g) theHisto_g ->setAxisTitle(titleY, 2) ;
497 if(theHisto_ni) theHisto_ni ->setAxisTitle(titleY, 2) ;
498 if(theHisto_dus) theHisto_dus ->setAxisTitle(titleY, 2) ;
499 if(theHisto_dusg)theHisto_dusg->setAxisTitle(titleY, 2) ;
500 if(theHisto_pu) theHisto_pu ->setAxisTitle(titleY, 2) ;
504 if(theProfile_all) theProfile_all ->setAxisTitle(titleX) ;
505 if(theProfile_all) theProfile_all ->setAxisTitle(titleY, 2) ;
508 if(theProfile_d) theProfile_d ->setAxisTitle(titleX) ;
509 if(theProfile_u) theProfile_u ->setAxisTitle(titleX) ;
510 if(theProfile_s) theProfile_s ->setAxisTitle(titleX) ;
511 if(theProfile_c) theProfile_c ->setAxisTitle(titleX) ;
512 if(theProfile_b) theProfile_b ->setAxisTitle(titleX) ;
513 if(theProfile_g) theProfile_g ->setAxisTitle(titleX) ;
514 if(theProfile_ni) theProfile_ni ->setAxisTitle(titleX) ;
515 if(theProfile_dus) theProfile_dus ->setAxisTitle(titleX) ;
516 if(theProfile_dusg)theProfile_dusg->setAxisTitle(titleX) ;
517 if(theProfile_d) theProfile_d ->setAxisTitle(titleY, 2) ;
518 if(theProfile_u) theProfile_u ->setAxisTitle(titleY, 2) ;
519 if(theProfile_s) theProfile_s ->setAxisTitle(titleY, 2) ;
520 if(theProfile_c) theProfile_c ->setAxisTitle(titleY, 2) ;
521 if(theProfile_b) theProfile_b ->setAxisTitle(titleY, 2) ;
522 if(theProfile_g) theProfile_g ->setAxisTitle(titleY, 2) ;
523 if(theProfile_ni) theProfile_ni ->setAxisTitle(titleY, 2) ;
524 if(theProfile_dus) theProfile_dus ->setAxisTitle(titleY, 2) ;
525 if(theProfile_dusg)theProfile_dusg->setAxisTitle(titleY, 2) ;
526 if(theProfile_pu) theProfile_pu ->setAxisTitle(titleY, 2) ;
531 template <
class T,
class G>
536 bool btppColour =
true;
542 gPad->UseCurrentStyle();
543 gPad->SetLogy ( 0 ) ;
544 gPad->SetGridx ( 0 ) ;
545 gPad->SetGridy ( 0 ) ;
546 gPad->SetTitle ( 0 ) ;
549 int col[4], lineStyle[4], markerStyle[4];
552 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
553 histo[0] = theHisto_dusg ;
554 histo[1] = theHisto_b ;
555 histo[2] = theHisto_c ;
560 max = theHisto_dusg->getTH2F()->GetMaximum();
561 if (theHisto_b->getTH2F()->GetMaximum() >
max) max = theHisto_b->getTH2F()->GetMaximum();
562 if (theHisto_c->getTH2F()->GetMaximum() >
max) max = theHisto_c->getTH2F()->GetMaximum();
566 histo[3] = theHisto_ni ;
567 if (theHisto_ni->getTH2F()->GetMaximum() >
max) max = theHisto_ni->
getTH2F()->GetMaximum();
579 markerStyle[0] = 20 ;
580 markerStyle[1] = 21 ;
581 markerStyle[2] = 22 ;
582 markerStyle[3] = 23 ;
594 markerStyle[0] = 20 ;
595 markerStyle[1] = 21 ;
596 markerStyle[2] = 22 ;
597 markerStyle[3] = 23 ;
600 histo[0] ->
getTH2F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
601 histo[0] ->
getTH2F()->GetYaxis()->SetTitle (
"Arbitrary Units" ) ;
602 histo[0] ->
getTH2F()->GetYaxis()->SetTitleOffset(1.25) ;
604 for (
int i=0;
i != 4; ++
i) {
605 if (histo[
i]== 0 )
continue;
606 histo[
i] ->
getTH2F()->SetStats (
false ) ;
607 histo[
i] ->
getTH2F()->SetLineStyle ( lineStyle[
i] ) ;
608 histo[
i] ->
getTH2F()->SetLineWidth ( lineWidth ) ;
609 histo[
i] ->
getTH2F()->SetLineColor ( col[i] ) ;
610 histo[
i] ->
getTH2F()->SetMarkerStyle ( markerStyle[i] ) ;
611 histo[
i] ->
getTH2F()->SetMarkerColor ( col[i] ) ;
612 histo[
i] ->
getTH2F()->SetMarkerSize ( markerSize ) ;
615 histo[0]->
getTH2F()->SetMaximum(max*1.05);
616 if (theMin!=-1.) histo[0]->
getTH2F()->SetMinimum(theMin);
618 histo[1]->
getTH2F()->Draw(
"Same") ;
619 histo[2]->
getTH2F()->Draw(
"Same") ;
620 if ( histo[3] != 0 ) histo[3]->
getTH2F()->Draw(
"Same") ;
624 template <
class T,
class G>
627 TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
630 tc.Print((name + theBaseNameTitle +
".eps").c_str());
635 template <
class T,
class G>
642 if(theHisto_all) theHisto_all ->getTH2F()->
Divide ( theHisto_all->getTH2F() , bHD.
histo_all () , 1.0 , 1.0 ,
"b" ) ;
649 theHisto_dus ->getTH2F()->
Divide ( theHisto_dus->getTH2F() , bHD.
histo_dus () , 1.0 , 1.0 ,
"b" ) ;
653 theHisto_ni ->getTH2F()->
Divide ( theHisto_ni->getTH2F() , bHD.
histo_ni () , 1.0 , 1.0 ,
"b" ) ;
654 theHisto_dusg ->getTH2F()->
Divide ( theHisto_dusg->getTH2F() , bHD.
histo_dusg() , 1.0 , 1.0 ,
"b" ) ;
655 theHisto_pu ->getTH2F()->
Divide ( theHisto_pu->getTH2F() , bHD.
histo_pu () , 1.0 , 1.0 ,
"b" ) ;
659 template <
class T,
class G>
661 if(theHisto_all) theHisto_all ->setEfficiencyFlag();
664 theHisto_d ->setEfficiencyFlag();
665 theHisto_u ->setEfficiencyFlag();
666 theHisto_s ->setEfficiencyFlag();
667 theHisto_g ->setEfficiencyFlag();
668 theHisto_dus ->setEfficiencyFlag();
670 theHisto_c ->setEfficiencyFlag();
671 theHisto_b ->setEfficiencyFlag();
672 theHisto_ni ->setEfficiencyFlag();
673 theHisto_dusg ->setEfficiencyFlag();
674 theHisto_pu ->setEfficiencyFlag();
678 template <
class T,
class G>
681 if(theHisto_all) theHisto_all->Fill ( varX, varY,w ) ;
684 if(theProfile_all) theProfile_all->Fill( varX, varY);
688 if (!mcPlots_)
return;
693 theHisto_d->Fill( varX, varY,w );
694 theHisto_dus->Fill( varX, varY,w );
696 theHisto_dusg->Fill( varX, varY,w );
702 theProfile_d->Fill(varX, varY);
703 theProfile_dus->Fill(varX, varY);
705 theProfile_dusg->Fill(varX, varY);
710 theHisto_u->Fill( varX, varY,w );
711 theHisto_dus->Fill( varX, varY,w );
713 theHisto_dusg->Fill( varX, varY,w );
719 theProfile_u->Fill(varX, varY);
720 theProfile_dus->Fill(varX, varY);
722 theProfile_dusg->Fill(varX, varY);
727 theHisto_s->Fill( varX, varY,w );
728 theHisto_dus->Fill( varX, varY,w );
730 theHisto_dusg->Fill( varX, varY,w );
736 theProfile_s->Fill(varX, varY);
737 theProfile_dus->Fill(varX, varY);
739 theProfile_dusg->Fill(varX, varY);
743 theHisto_c->Fill( varX, varY,w );
745 if(createProfile_) theProfile_c->Fill(varX, varY);
748 theHisto_b->Fill( varX, varY,w );
750 if(createProfile_) theProfile_b->Fill(varX, varY);
753 if (mcPlots_>2) theHisto_g->Fill( varX, varY,w );
754 theHisto_dusg->Fill( varX, varY,w );
758 if (mcPlots_>2) theProfile_g->Fill(varX, varY);
759 theProfile_dusg->Fill(varX, varY);
763 theHisto_pu->Fill( varX, varY,w );
765 if(createProfile_) theProfile_pu->Fill(varX, varY);
768 theHisto_ni->Fill( varX, varY,w );
770 if(createProfile_) theProfile_ni->Fill(varX, varY);
775 template <
class T,
class G>
778 std::vector<TH2F*> histoVector;
779 if(theHisto_all) histoVector.push_back ( theHisto_all->getTH2F() );
782 histoVector.push_back ( theHisto_d->getTH2F() );
783 histoVector.push_back ( theHisto_u->getTH2F() );
784 histoVector.push_back ( theHisto_s->getTH2F() );
785 histoVector.push_back ( theHisto_g ->
getTH2F() );
786 histoVector.push_back ( theHisto_dus->getTH2F() );
788 histoVector.push_back ( theHisto_c->getTH2F() );
789 histoVector.push_back ( theHisto_b->getTH2F() );
790 histoVector.push_back ( theHisto_ni->getTH2F() );
791 histoVector.push_back ( theHisto_dusg->getTH2F());
792 histoVector.push_back ( theHisto_pu->getTH2F() );
797 template <
class T,
class G>
800 std::vector<TProfile*> profileVector;
802 if(theProfile_all) profileVector.push_back ( theProfile_all->getTProfile() );
805 profileVector.push_back ( theProfile_d->getTProfile() );
806 profileVector.push_back ( theProfile_u->getTProfile() );
807 profileVector.push_back ( theProfile_s->getTProfile() );
808 profileVector.push_back ( theProfile_g ->
getTProfile() );
809 profileVector.push_back ( theProfile_dus->getTProfile() );
811 profileVector.push_back ( theProfile_c->getTProfile() );
812 profileVector.push_back ( theProfile_b->getTProfile() );
813 profileVector.push_back ( theProfile_ni->getTProfile() );
814 profileVector.push_back ( theProfile_dusg->getTProfile());
815 profileVector.push_back ( theProfile_pu->getTProfile() );
818 return profileVector;
TProfile * profile_c() const
std::string theBaseNameDescription
MonitorElement * theProfile_s
MonitorElement * theProfile_pu
double lowerBoundX() const
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
double lowerBoundY() const
MonitorElement * theHisto_g
void SetMaximum(const double &max)
MonitorElement * theProfile_dusg
void settitle(const char *titleX, const char *titleY)
MonitorElement * theHisto_dusg
MonitorElement * get(const std::string &path)
MonitorElement * theHisto_u
virtual MonitorElement * bookProfile(const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
TProfile * profile_pu() const
virtual MonitorElement * book2D(const std::string &name, const std::string &title, const int &nchX, const double &lowX, const double &highX, const int &nchY, const double &lowY, const double &highY)
void plot(TPad *theCanvas=0)
virtual ~FlavourHistograms2D()
std::string baseNameTitle() const
TProfile * profile_b() const
std::string theBaseNameTitle
void divide(const FlavourHistograms2D< T, G > &bHD) const
MonitorElement * theHisto_c
MonitorElement * theHisto_pu
void fill(const int &flavour, const T &variableX, const G &variableY) const
MonitorElement * theProfile_all
MonitorElement * theProfile_ni
MonitorElement * theHisto_dus
TH2F * histo_dusg() const
MonitorElement * theProfile_u
MonitorElement * theHisto_s
std::vector< TProfile * > getProfileVector() const
TProfile * profile_u() const
TProfile * profile_all() const
MonitorElement * theProfile_b
void SetMinimum(const double &min)
MonitorElement * theProfile_c
double upperBoundX() const
std::vector< TH2F * > getHistoVector() const
MonitorElement * theProfile_d
std::string baseNameDescription() const
TProfile * profile_d() const
MonitorElement * theProfile_dus
MonitorElement * theHisto_all
TProfile * profile_ni() const
void epsPlot(const std::string &name)
TProfile * getTProfile(void) const
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
TProfile * profile_s() const
TH2F * getTH2F(void) const
MonitorElement * theProfile_g
TProfile * profile_dusg() const
double upperBoundY() const
MonitorElement * theHisto_b
int flavour(const Candidate &part)
TProfile * profile_dus() const
void fillVariable(const int &flavour, const T &varX, const G &varY, const float &w) const
TProfile * profile_g() const
MonitorElement * theHisto_ni
MonitorElement * theHisto_d