2 #ifndef FlavourHistograms_H
3 #define FlavourHistograms_H
32 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
37 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
38 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
46 void fill (
const int &
flavour,
const T & variable)
const;
47 void fill (
const int & flavour,
const T & variable,
const T &
w)
const;
50 void fill (
const int & flavour,
const T * variable)
const;
150 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
153 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
154 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
155 theStatistics (
false ) , thePlotLog (
false ) , thePlotNormalized (
false ) ,
156 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
167 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
168 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
213 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
214 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
217 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
218 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
219 theStatistics ( statistics_ ) , thePlotLog ( plotLog_ ) , thePlotNormalized ( plotNormalized_ ) ,
220 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
231 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
232 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
303 template <
class T>
void
307 fillVariable ( flavour , variable, 1.) ;
310 template <
class T>
void
314 fillVariable ( flavour , variable, w) ;
317 template <
class T>
void
320 if ( theArrayDimension == 0 ) {
322 fillVariable ( flavour , *variable, 1.) ;
325 int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
327 for (
int i = 0 ;
i != iMax ; ++
i ) {
329 if ( ( theIndexToPlot < 0 ) || (
i == theIndexToPlot ) ) {
330 fillVariable ( flavour , *(variable+
i) , 1.) ;
335 if ( theIndexToPlot >= iMax ) {
337 const T& theZero =
static_cast<T> ( 0.0 ) ;
338 fillVariable ( flavour , theZero , 1.) ;
346 if(theHisto_all) theHisto_all ->setAxisTitle(title) ;
349 theHisto_d ->setAxisTitle(title) ;
350 theHisto_u ->setAxisTitle(title) ;
351 theHisto_s ->setAxisTitle(title) ;
352 theHisto_g ->setAxisTitle(title) ;
353 theHisto_dus ->setAxisTitle(title) ;
355 theHisto_c ->setAxisTitle(title) ;
356 theHisto_b ->setAxisTitle(title) ;
357 theHisto_ni ->setAxisTitle(title) ;
358 theHisto_dusg->setAxisTitle(title) ;
359 theHisto_pu->setAxisTitle(title) ;
369 bool btppColour =
true;
375 gPad->UseCurrentStyle();
383 gPad->SetLogy ( 0 ) ;
384 if ( thePlotLog ) gPad->SetLogy ( 1 ) ;
385 gPad->SetGridx ( 0 ) ;
386 gPad->SetGridy ( 0 ) ;
387 gPad->SetTitle ( 0 ) ;
390 int col[4], lineStyle[4], markerStyle[4];
393 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
396 histo[0] = theHisto_dusg ;
398 histo[1] = theHisto_b ;
399 histo[2] = theHisto_c ;
404 max = theHisto_dusg->getTH1F()->GetMaximum();
405 if (theHisto_b->getTH1F()->GetMaximum() >
max) max = theHisto_b->getTH1F()->GetMaximum();
406 if (theHisto_c->getTH1F()->GetMaximum() >
max) max = theHisto_c->getTH1F()->GetMaximum();
410 histo[3] = theHisto_ni ;
411 if (theHisto_ni->getTH1F()->GetMaximum() >
max) max = theHisto_ni->
getTH1F()->GetMaximum();
423 markerStyle[0] = 20 ;
424 markerStyle[1] = 21 ;
425 markerStyle[2] = 22 ;
426 markerStyle[3] = 23 ;
438 markerStyle[0] = 20 ;
439 markerStyle[1] = 21 ;
440 markerStyle[2] = 22 ;
441 markerStyle[3] = 23 ;
447 if ( thePlotFirst ==
"c" ) {
448 histo[0] = theHisto_c ;
449 if ( btppColour ) col[0] = 6 ;
450 if ( !btppColour ) lineStyle[0] = 3 ;
451 histo[2] = theHisto_dusg ;
452 if ( btppColour ) col[2] = 4 ;
453 if ( !btppColour ) lineStyle[2] = 2 ;
457 if ( thePlotFirst ==
"b" ) {
458 histo[0] = theHisto_b ;
459 if ( btppColour ) col[0] = 2 ;
460 if ( !btppColour ) lineStyle[0] = 1 ;
461 histo[1] = theHisto_dusg ;
462 if ( btppColour ) col[1] = 4 ;
463 if ( !btppColour ) lineStyle[1] = 2 ;
467 histo[0] ->
getTH1F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
468 histo[0] ->
getTH1F()->GetYaxis()->SetTitle (
"Arbitrary Units" ) ;
469 histo[0] ->
getTH1F()->GetYaxis()->SetTitleOffset(1.25) ;
471 for (
int i=0;
i != 4; ++
i) {
472 if (histo[
i]== 0 )
continue;
473 histo[
i] ->
getTH1F()->SetStats (
false ) ;
474 histo[
i] ->
getTH1F()->SetLineStyle ( lineStyle[
i] ) ;
475 histo[
i] ->
getTH1F()->SetLineWidth ( lineWidth ) ;
476 histo[
i] ->
getTH1F()->SetLineColor ( col[i] ) ;
477 histo[
i] ->
getTH1F()->SetMarkerStyle ( markerStyle[i] ) ;
478 histo[
i] ->
getTH1F()->SetMarkerColor ( col[i] ) ;
479 histo[
i] ->
getTH1F()->SetMarkerSize ( markerSize ) ;
482 if ( thePlotNormalized ) {
483 if (histo[0]->
getTH1F()->GetEntries() != 0) {histo[0]->
getTH1F() ->DrawNormalized() ;}
else { histo[0]->
getTH1F() ->SetMaximum(1.0);
484 histo[0] ->
getTH1F()->Draw() ;}
485 if (histo[1]->
getTH1F()->GetEntries() != 0) histo[1] ->
getTH1F()->DrawNormalized(
"Same") ;
486 if (histo[2]->
getTH1F()->GetEntries() != 0) histo[2]->
getTH1F() ->DrawNormalized(
"Same") ;
487 if ((histo[3] != 0) && (histo[3]->
getTH1F()->GetEntries() != 0)) histo[3] ->
getTH1F()->DrawNormalized(
"Same") ;
490 histo[0]->
getTH1F()->SetMaximum(max*1.05);
491 if (theMin!=-1.) histo[0]->
getTH1F()->SetMinimum(theMin);
493 histo[1]->
getTH1F()->Draw(
"Same") ;
494 histo[2]->
getTH1F()->Draw(
"Same") ;
495 if ( histo[3] != 0 ) histo[3]->
getTH1F()->Draw(
"Same") ;
503 TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
506 tc.Print((name + theBaseNameTitle +
".eps").c_str());
519 if(theHisto_all) theHisto_all ->getTH1F()->
Divide ( theHisto_all->getTH1F() , bHD.
histo_all () , 1.0 , 1.0 ,
"b" ) ;
526 theHisto_dus ->getTH1F()->
Divide ( theHisto_dus->getTH1F() , bHD.
histo_dus () , 1.0 , 1.0 ,
"b" ) ;
530 theHisto_ni ->getTH1F()->
Divide ( theHisto_ni->getTH1F() , bHD.
histo_ni () , 1.0 , 1.0 ,
"b" ) ;
531 theHisto_dusg ->getTH1F()->
Divide ( theHisto_dusg->getTH1F() , bHD.
histo_dusg() , 1.0 , 1.0 ,
"b" ) ;
532 theHisto_pu ->getTH1F()->
Divide ( theHisto_pu->getTH1F() , bHD.
histo_pu() , 1.0 , 1.0 ,
"b" ) ;
541 if( (theBaseNameDescription !=
"Jet Multiplicity" || flavour == -1) && theHisto_all) theHisto_all->Fill ( var ,w) ;
544 if (!mcPlots_ || (theBaseNameDescription ==
"Jet Multiplicity" && flavour == -1))
return;
549 theHisto_d->Fill( var ,w);
550 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
552 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
556 theHisto_u->Fill( var ,w);
557 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
559 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
563 theHisto_s->Fill( var ,w);
564 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
566 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
569 theHisto_c->Fill( var ,w);
572 theHisto_b->Fill( var ,w);
575 if (mcPlots_>2 ) theHisto_g->Fill( var ,w);
576 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
579 if (mcPlots_>2 && theBaseNameDescription ==
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
582 if (theBaseNameDescription ==
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
585 theHisto_pu->Fill( var ,w);
588 theHisto_ni->Fill( var ,w);
596 std::vector<TH1F*> histoVector;
597 if(theHisto_all) histoVector.push_back ( theHisto_all->getTH1F() );
600 histoVector.push_back ( theHisto_d->getTH1F() );
601 histoVector.push_back ( theHisto_u->getTH1F() );
602 histoVector.push_back ( theHisto_s->getTH1F() );
603 histoVector.push_back ( theHisto_g ->
getTH1F() );
604 histoVector.push_back ( theHisto_dus->getTH1F() );
606 histoVector.push_back ( theHisto_c->getTH1F() );
607 histoVector.push_back ( theHisto_b->getTH1F() );
608 histoVector.push_back ( theHisto_ni->getTH1F() );
609 histoVector.push_back ( theHisto_dusg->getTH1F());
610 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 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
void divide(const FlavourHistograms< T > &bHD) const
std::string plotFirst() const
bool plotNormalized() const
std::string theBaseNameTitle
void fillVariable(const int &flavour, const T &var, const T &w) const
double upperBound() const
volatile std::atomic< bool > shutdown_flag false
MonitorElement * theHisto_s
int flavour(const Candidate &part)
TH1F * histo_dusg() const
MonitorElement * theHisto_dus
MonitorElement * theHisto_ni