2 #ifndef FlavourHistograms_H
3 #define FlavourHistograms_H
16 #include "TEfficiency.h"
33 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
38 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
39 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
47 void fill (
const int &
flavour,
const T & variable)
const;
48 void fill (
const int & flavour,
const T & variable,
const T &
w)
const;
51 void fill (
const int & flavour,
const T * variable)
const;
152 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
155 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
156 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
157 theStatistics (
false ) , thePlotLog (
false ) , thePlotNormalized (
false ) ,
158 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
169 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
170 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
215 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
216 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
219 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
220 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
221 theStatistics ( statistics_ ) , thePlotLog ( plotLog_ ) , thePlotNormalized ( plotNormalized_ ) ,
222 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
233 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
234 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
305 template <
class T>
void
309 fillVariable ( flavour , variable, 1.) ;
312 template <
class T>
void
316 fillVariable ( flavour , variable, w) ;
319 template <
class T>
void
322 if ( theArrayDimension == 0 ) {
324 fillVariable ( flavour , *variable, 1.) ;
327 int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
329 for (
int i = 0 ;
i != iMax ; ++
i ) {
331 if ( ( theIndexToPlot < 0 ) || (
i == theIndexToPlot ) ) {
332 fillVariable ( flavour , *(variable+
i) , 1.) ;
337 if ( theIndexToPlot >= iMax ) {
339 const T& theZero =
static_cast<T> ( 0.0 ) ;
340 fillVariable ( flavour , theZero , 1.) ;
348 if(theHisto_all) theHisto_all ->setAxisTitle(title) ;
351 theHisto_d ->setAxisTitle(title) ;
352 theHisto_u ->setAxisTitle(title) ;
353 theHisto_s ->setAxisTitle(title) ;
354 theHisto_g ->setAxisTitle(title) ;
355 theHisto_dus ->setAxisTitle(title) ;
357 theHisto_c ->setAxisTitle(title) ;
358 theHisto_b ->setAxisTitle(title) ;
359 theHisto_ni ->setAxisTitle(title) ;
360 theHisto_dusg->setAxisTitle(title) ;
361 theHisto_pu->setAxisTitle(title) ;
371 bool btppColour =
true;
377 gPad->UseCurrentStyle();
385 gPad->SetLogy ( 0 ) ;
386 if ( thePlotLog ) gPad->SetLogy ( 1 ) ;
387 gPad->SetGridx ( 0 ) ;
388 gPad->SetGridy ( 0 ) ;
389 gPad->SetTitle ( 0 ) ;
392 int col[4], lineStyle[4], markerStyle[4];
395 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
398 histo[0] = theHisto_dusg ;
400 histo[1] = theHisto_b ;
401 histo[2] = theHisto_c ;
406 max = theHisto_dusg->getTH1F()->GetMaximum();
407 if (theHisto_b->getTH1F()->GetMaximum() >
max) max = theHisto_b->getTH1F()->GetMaximum();
408 if (theHisto_c->getTH1F()->GetMaximum() >
max) max = theHisto_c->getTH1F()->GetMaximum();
412 histo[3] = theHisto_ni ;
413 if (theHisto_ni->getTH1F()->GetMaximum() >
max) max = theHisto_ni->
getTH1F()->GetMaximum();
425 markerStyle[0] = 20 ;
426 markerStyle[1] = 21 ;
427 markerStyle[2] = 22 ;
428 markerStyle[3] = 23 ;
440 markerStyle[0] = 20 ;
441 markerStyle[1] = 21 ;
442 markerStyle[2] = 22 ;
443 markerStyle[3] = 23 ;
449 if ( thePlotFirst ==
"c" ) {
450 histo[0] = theHisto_c ;
451 if ( btppColour ) col[0] = 6 ;
452 if ( !btppColour ) lineStyle[0] = 3 ;
453 histo[2] = theHisto_dusg ;
454 if ( btppColour ) col[2] = 4 ;
455 if ( !btppColour ) lineStyle[2] = 2 ;
459 if ( thePlotFirst ==
"b" ) {
460 histo[0] = theHisto_b ;
461 if ( btppColour ) col[0] = 2 ;
462 if ( !btppColour ) lineStyle[0] = 1 ;
463 histo[1] = theHisto_dusg ;
464 if ( btppColour ) col[1] = 4 ;
465 if ( !btppColour ) lineStyle[1] = 2 ;
469 histo[0] ->
getTH1F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
470 histo[0] ->
getTH1F()->GetYaxis()->SetTitle (
"Arbitrary Units" ) ;
471 histo[0] ->
getTH1F()->GetYaxis()->SetTitleOffset(1.25) ;
473 for (
int i=0;
i != 4; ++
i) {
474 if (histo[
i]== 0 )
continue;
475 histo[
i] ->
getTH1F()->SetStats (
false ) ;
476 histo[
i] ->
getTH1F()->SetLineStyle ( lineStyle[
i] ) ;
477 histo[
i] ->
getTH1F()->SetLineWidth ( lineWidth ) ;
478 histo[
i] ->
getTH1F()->SetLineColor ( col[i] ) ;
479 histo[
i] ->
getTH1F()->SetMarkerStyle ( markerStyle[i] ) ;
480 histo[
i] ->
getTH1F()->SetMarkerColor ( col[i] ) ;
481 histo[
i] ->
getTH1F()->SetMarkerSize ( markerSize ) ;
484 if ( thePlotNormalized ) {
485 if (histo[0]->
getTH1F()->GetEntries() != 0) {histo[0]->
getTH1F() ->DrawNormalized() ;}
else { histo[0]->
getTH1F() ->SetMaximum(1.0);
486 histo[0] ->
getTH1F()->Draw() ;}
487 if (histo[1]->
getTH1F()->GetEntries() != 0) histo[1] ->
getTH1F()->DrawNormalized(
"Same") ;
488 if (histo[2]->
getTH1F()->GetEntries() != 0) histo[2]->
getTH1F() ->DrawNormalized(
"Same") ;
489 if ((histo[3] != 0) && (histo[3]->
getTH1F()->GetEntries() != 0)) histo[3] ->
getTH1F()->DrawNormalized(
"Same") ;
492 histo[0]->
getTH1F()->SetMaximum(max*1.05);
493 if (theMin!=-1.) histo[0]->
getTH1F()->SetMinimum(theMin);
495 histo[1]->
getTH1F()->Draw(
"Same") ;
496 histo[2]->
getTH1F()->Draw(
"Same") ;
497 if ( histo[3] != 0 ) histo[3]->
getTH1F()->Draw(
"Same") ;
505 TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
508 tc.Print((name + theBaseNameTitle +
".eps").c_str());
513 double effVal = num->GetBinContent(bin)/den->GetBinContent(bin);
514 double errLo = TEfficiency::ClopperPearson((
int)den->GetBinContent(bin),
515 (int)num->GetBinContent(bin),
517 double errUp = TEfficiency::ClopperPearson((
int)den->GetBinContent(bin),
518 (int)num->GetBinContent(bin),
520 return (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
527 if (den->GetBinContent(bin)>0) {
528 effVal = num->GetBinContent(bin)/den->GetBinContent(bin);
529 errVal = ClopperPearsonUnc(num, den, bin);
531 num->SetBinContent(bin, effVal);
532 num->SetBinError(bin, errVal);
537 for(
int bin = 0;
bin < theNBins+2;
bin++){
558 if(theHisto_all) theHisto_all ->setEfficiencyFlag();
561 theHisto_d ->setEfficiencyFlag();
562 theHisto_u ->setEfficiencyFlag();
563 theHisto_s ->setEfficiencyFlag();
564 theHisto_g ->setEfficiencyFlag();
565 theHisto_dus ->setEfficiencyFlag();
567 theHisto_c ->setEfficiencyFlag();
568 theHisto_b ->setEfficiencyFlag();
569 theHisto_ni ->setEfficiencyFlag();
570 theHisto_dusg ->setEfficiencyFlag();
571 theHisto_pu ->setEfficiencyFlag();
580 if( (theBaseNameDescription !=
"Jet Multiplicity" || flavour == -1) && theHisto_all) theHisto_all->Fill ( var ,w) ;
583 if (!mcPlots_ || (theBaseNameDescription ==
"Jet Multiplicity" && flavour == -1))
return;
588 theHisto_d->Fill( var ,w);
589 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
591 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
595 theHisto_u->Fill( var ,w);
596 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
598 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
602 theHisto_s->Fill( var ,w);
603 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
605 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
608 theHisto_c->Fill( var ,w);
611 theHisto_b->Fill( var ,w);
614 if (mcPlots_>2 ) theHisto_g->Fill( var ,w);
615 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
618 if (mcPlots_>2 && theBaseNameDescription ==
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
621 if (theBaseNameDescription ==
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
624 theHisto_pu->Fill( var ,w);
627 theHisto_ni->Fill( var ,w);
635 std::vector<TH1F*> histoVector;
636 if(theHisto_all) histoVector.push_back ( theHisto_all->getTH1F() );
639 histoVector.push_back ( theHisto_d->getTH1F() );
640 histoVector.push_back ( theHisto_u->getTH1F() );
641 histoVector.push_back ( theHisto_s->getTH1F() );
642 histoVector.push_back ( theHisto_g ->
getTH1F() );
643 histoVector.push_back ( theHisto_dus->getTH1F() );
645 histoVector.push_back ( theHisto_c->getTH1F() );
646 histoVector.push_back ( theHisto_b->getTH1F() );
647 histoVector.push_back ( theHisto_ni->getTH1F() );
648 histoVector.push_back ( theHisto_dusg->getTH1F());
649 histoVector.push_back ( theHisto_pu->getTH1F());
double lowerBound() const
MonitorElement * theHisto_g
void plot(TPad *theCanvas=0)
MonitorElement * theHisto_c
void SetMinimum(const double &min)
MonitorElement * get(const std::string &path)
MonitorElement * theHisto_u
void fill(const int &flavour, const T &variable) const
MonitorElement * theHisto_all
std::string baseNameDescription() const
std::vector< TH1F * > getHistoVector() const
void ComputeEfficiency(TH1F *num, TH1F *den, int bin)
void SetMaximum(const double &max)
void epsPlot(const std::string &name)
virtual MonitorElement * book1D(const std::string &name, const std::string &title, const int &nchX, const double &lowX, const double &highX)
std::string baseNameTitle() const
MonitorElement * theHisto_pu
void settitle(const char *title)
TH1F * getTH1F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
int * arrayDimension() const
MonitorElement * theHisto_d
MonitorElement * theHisto_dusg
std::string theBaseNameDescription
virtual ~FlavourHistograms()
TH1F * getTH1F(void) const
MonitorElement * theHisto_b
std::string plotFirst() const
bool plotNormalized() const
std::string theBaseNameTitle
void fillVariable(const int &flavour, const T &var, const T &w) const
double ClopperPearsonUnc(TH1F *num, TH1F *den, int bin)
double upperBound() const
volatile std::atomic< bool > shutdown_flag false
MonitorElement * theHisto_s
int flavour(const Candidate &part)
void divide(const FlavourHistograms< T > &bHD)
TH1F * histo_dusg() const
MonitorElement * theHisto_dus
tuple folder
Histograms Source for live online DQM in P5
MonitorElement * theHisto_ni