2 #ifndef FlavourHistograms_H
3 #define FlavourHistograms_H
33 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
34 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;
99 void fillVariable (
const int & flavour ,
const T & var ,
const T & w)
const;
150 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
151 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
156 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
157 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
158 theStatistics ( statistics_ ) , thePlotLog ( plotLog_ ) , thePlotNormalized ( plotNormalized_ ) ,
159 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
170 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
171 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
273 template <
class T>
void
277 fillVariable ( flavour , variable, 1.) ;
280 template <
class T>
void
284 fillVariable ( flavour , variable, w) ;
287 template <
class T>
void
290 if ( theArrayDimension == 0 ) {
292 fillVariable ( flavour , *variable, 1.) ;
295 int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
297 for (
int i = 0 ;
i != iMax ; ++
i ) {
299 if ( ( theIndexToPlot < 0 ) || (
i == theIndexToPlot ) ) {
300 fillVariable ( flavour , *(variable+
i) , 1.) ;
305 if ( theIndexToPlot >= iMax ) {
307 const T& theZero =
static_cast<T> ( 0.0 ) ;
308 fillVariable ( flavour , theZero , 1.) ;
316 if(theHisto_all) theHisto_all ->setAxisTitle(title) ;
319 theHisto_d ->setAxisTitle(title) ;
320 theHisto_u ->setAxisTitle(title) ;
321 theHisto_s ->setAxisTitle(title) ;
322 theHisto_g ->setAxisTitle(title) ;
323 theHisto_dus ->setAxisTitle(title) ;
325 theHisto_c ->setAxisTitle(title) ;
326 theHisto_b ->setAxisTitle(title) ;
327 theHisto_ni ->setAxisTitle(title) ;
328 theHisto_dusg->setAxisTitle(title) ;
329 theHisto_pu->setAxisTitle(title) ;
339 bool btppColour =
true;
345 gPad->UseCurrentStyle();
353 gPad->SetLogy ( 0 ) ;
354 if ( thePlotLog ) gPad->SetLogy ( 1 ) ;
355 gPad->SetGridx ( 0 ) ;
356 gPad->SetGridy ( 0 ) ;
357 gPad->SetTitle ( 0 ) ;
360 int col[4], lineStyle[4], markerStyle[4];
363 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
366 histo[0] = theHisto_dusg ;
368 histo[1] = theHisto_b ;
369 histo[2] = theHisto_c ;
374 max = theHisto_dusg->getTH1F()->GetMaximum();
375 if (theHisto_b->getTH1F()->GetMaximum() >
max) max = theHisto_b->getTH1F()->GetMaximum();
376 if (theHisto_c->getTH1F()->GetMaximum() >
max) max = theHisto_c->getTH1F()->GetMaximum();
380 histo[3] = theHisto_ni ;
381 if (theHisto_ni->getTH1F()->GetMaximum() >
max) max = theHisto_ni->
getTH1F()->GetMaximum();
393 markerStyle[0] = 20 ;
394 markerStyle[1] = 21 ;
395 markerStyle[2] = 22 ;
396 markerStyle[3] = 23 ;
408 markerStyle[0] = 20 ;
409 markerStyle[1] = 21 ;
410 markerStyle[2] = 22 ;
411 markerStyle[3] = 23 ;
417 if ( thePlotFirst ==
"c" ) {
418 histo[0] = theHisto_c ;
419 if ( btppColour ) col[0] = 6 ;
420 if ( !btppColour ) lineStyle[0] = 3 ;
421 histo[2] = theHisto_dusg ;
422 if ( btppColour ) col[2] = 4 ;
423 if ( !btppColour ) lineStyle[2] = 2 ;
427 if ( thePlotFirst ==
"b" ) {
428 histo[0] = theHisto_b ;
429 if ( btppColour ) col[0] = 2 ;
430 if ( !btppColour ) lineStyle[0] = 1 ;
431 histo[1] = theHisto_dusg ;
432 if ( btppColour ) col[1] = 4 ;
433 if ( !btppColour ) lineStyle[1] = 2 ;
437 histo[0] ->
getTH1F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
438 histo[0] ->
getTH1F()->GetYaxis()->SetTitle (
"Arbitrary Units" ) ;
439 histo[0] ->
getTH1F()->GetYaxis()->SetTitleOffset(1.25) ;
441 for (
int i=0;
i != 4; ++
i) {
442 if (histo[
i]== 0 )
continue;
443 histo[
i] ->
getTH1F()->SetStats (
false ) ;
444 histo[
i] ->
getTH1F()->SetLineStyle ( lineStyle[
i] ) ;
445 histo[
i] ->
getTH1F()->SetLineWidth ( lineWidth ) ;
446 histo[
i] ->
getTH1F()->SetLineColor ( col[i] ) ;
447 histo[
i] ->
getTH1F()->SetMarkerStyle ( markerStyle[i] ) ;
448 histo[
i] ->
getTH1F()->SetMarkerColor ( col[i] ) ;
449 histo[
i] ->
getTH1F()->SetMarkerSize ( markerSize ) ;
452 if ( thePlotNormalized ) {
454 if (histo[0]->
getTH1F()->GetEntries() != 0) {histo[0]->
getTH1F() ->DrawNormalized() ;}
else { histo[0]->
getTH1F() ->SetMaximum(1.0);
455 histo[0] ->
getTH1F()->Draw() ;}
456 if (histo[1]->
getTH1F()->GetEntries() != 0) histo[1] ->
getTH1F()->DrawNormalized(
"Same") ;
457 if (histo[2]->
getTH1F()->GetEntries() != 0) histo[2]->
getTH1F() ->DrawNormalized(
"Same") ;
458 if ((histo[3] != 0) && (histo[3]->
getTH1F()->GetEntries() != 0)) histo[3] ->
getTH1F()->DrawNormalized(
"Same") ;
461 histo[0]->
getTH1F()->SetMaximum(max*1.05);
462 if (theMin!=-1.) histo[0]->
getTH1F()->SetMinimum(theMin);
464 histo[1]->
getTH1F()->Draw(
"Same") ;
465 histo[2]->
getTH1F()->Draw(
"Same") ;
466 if ( histo[3] != 0 ) histo[3]->
getTH1F()->Draw(
"Same") ;
474 TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
477 tc.Print((name + theBaseNameTitle +
".eps").c_str());
490 if(theHisto_all) theHisto_all ->getTH1F()->
Divide ( theHisto_all->getTH1F() , bHD.
histo_all () , 1.0 , 1.0 ,
"b" ) ;
497 theHisto_dus ->getTH1F()->
Divide ( theHisto_dus->getTH1F() , bHD.
histo_dus () , 1.0 , 1.0 ,
"b" ) ;
501 theHisto_ni ->getTH1F()->
Divide ( theHisto_ni->getTH1F() , bHD.
histo_ni () , 1.0 , 1.0 ,
"b" ) ;
502 theHisto_dusg ->getTH1F()->
Divide ( theHisto_dusg->getTH1F() , bHD.
histo_dusg() , 1.0 , 1.0 ,
"b" ) ;
503 theHisto_pu ->getTH1F()->
Divide ( theHisto_pu->getTH1F() , bHD.
histo_pu() , 1.0 , 1.0 ,
"b" ) ;
512 if( (theBaseNameDescription !=
"Jet Multiplicity" || flavour == -1) && theHisto_all) theHisto_all->Fill ( var ,w) ;
515 if (!mcPlots_ || (theBaseNameDescription ==
"Jet Multiplicity" && flavour == -1))
return;
520 theHisto_d->Fill( var ,w);
521 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
523 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
527 theHisto_u->Fill( var ,w);
528 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
530 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
534 theHisto_s->Fill( var ,w);
535 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
537 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
540 theHisto_c->Fill( var ,w);
543 theHisto_b->Fill( var ,w);
546 if (mcPlots_>2 ) theHisto_g->Fill( var ,w);
547 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
550 if (mcPlots_>2 && theBaseNameDescription ==
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
553 if (theBaseNameDescription ==
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
556 theHisto_pu->Fill( var ,w);
559 theHisto_ni->Fill( var ,w);
567 std::vector<TH1F*> histoVector;
568 if(theHisto_all) histoVector.push_back ( theHisto_all->getTH1F() );
571 histoVector.push_back ( theHisto_d->getTH1F() );
572 histoVector.push_back ( theHisto_u->getTH1F() );
573 histoVector.push_back ( theHisto_s->getTH1F() );
574 histoVector.push_back ( theHisto_g ->
getTH1F() );
575 histoVector.push_back ( theHisto_dus->getTH1F() );
577 histoVector.push_back ( theHisto_c->getTH1F() );
578 histoVector.push_back ( theHisto_b->getTH1F() );
579 histoVector.push_back ( theHisto_ni->getTH1F() );
580 histoVector.push_back ( theHisto_dusg->getTH1F());
581 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 * 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
virtual MonitorElement * access(const std::string &name)
double upperBound() const
MonitorElement * theHisto_s
int flavour(const Candidate &part)
TH1F * histo_dusg() const
MonitorElement * theHisto_dus
MonitorElement * theHisto_ni