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_ ,
45 void fill (
const int &
flavour,
const T & variable)
const;
46 void fill (
const int & flavour,
const T & variable,
const T &
w)
const;
49 void fill (
const int & flavour,
const T * variable)
const;
97 void fillVariable (
const int & flavour ,
const T & var ,
const T & w)
const;
147 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
148 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
152 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
153 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
154 theStatistics ( statistics_ ) , thePlotLog ( plotLog_ ) , thePlotNormalized ( plotNormalized_ ) ,
155 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
166 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
167 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
264 template <
class T>
void
268 fillVariable ( flavour , variable, 1.) ;
271 template <
class T>
void
275 fillVariable ( flavour , variable, w) ;
278 template <
class T>
void
281 if ( theArrayDimension == 0 ) {
283 fillVariable ( flavour , *variable, 1.) ;
286 int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
288 for (
int i = 0 ;
i != iMax ; ++
i ) {
290 if ( ( theIndexToPlot < 0 ) || (
i == theIndexToPlot ) ) {
291 fillVariable ( flavour , *(variable+
i) , 1.) ;
296 if ( theIndexToPlot >= iMax ) {
298 const T& theZero =
static_cast<T> ( 0.0 ) ;
299 fillVariable ( flavour , theZero , 1.) ;
307 if(theHisto_all) theHisto_all ->setAxisTitle(title) ;
310 theHisto_d ->setAxisTitle(title) ;
311 theHisto_u ->setAxisTitle(title) ;
312 theHisto_s ->setAxisTitle(title) ;
313 theHisto_g ->setAxisTitle(title) ;
314 theHisto_dus ->setAxisTitle(title) ;
316 theHisto_c ->setAxisTitle(title) ;
317 theHisto_b ->setAxisTitle(title) ;
318 theHisto_ni ->setAxisTitle(title) ;
319 theHisto_dusg->setAxisTitle(title) ;
329 bool btppColour =
true;
335 gPad->UseCurrentStyle();
343 gPad->SetLogy ( 0 ) ;
344 if ( thePlotLog ) gPad->SetLogy ( 1 ) ;
345 gPad->SetGridx ( 0 ) ;
346 gPad->SetGridy ( 0 ) ;
347 gPad->SetTitle ( 0 ) ;
350 int col[4], lineStyle[4], markerStyle[4];
353 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
356 histo[0] = theHisto_dusg ;
358 histo[1] = theHisto_b ;
359 histo[2] = theHisto_c ;
364 max = theHisto_dusg->getTH1F()->GetMaximum();
365 if (theHisto_b->getTH1F()->GetMaximum() >
max) max = theHisto_b->getTH1F()->GetMaximum();
366 if (theHisto_c->getTH1F()->GetMaximum() >
max) max = theHisto_c->getTH1F()->GetMaximum();
370 histo[3] = theHisto_ni ;
371 if (theHisto_ni->getTH1F()->GetMaximum() >
max) max = theHisto_ni->
getTH1F()->GetMaximum();
383 markerStyle[0] = 20 ;
384 markerStyle[1] = 21 ;
385 markerStyle[2] = 22 ;
386 markerStyle[3] = 23 ;
398 markerStyle[0] = 20 ;
399 markerStyle[1] = 21 ;
400 markerStyle[2] = 22 ;
401 markerStyle[3] = 23 ;
407 if ( thePlotFirst ==
"c" ) {
408 histo[0] = theHisto_c ;
409 if ( btppColour ) col[0] = 6 ;
410 if ( !btppColour ) lineStyle[0] = 3 ;
411 histo[2] = theHisto_dusg ;
412 if ( btppColour ) col[2] = 4 ;
413 if ( !btppColour ) lineStyle[2] = 2 ;
417 if ( thePlotFirst ==
"b" ) {
418 histo[0] = theHisto_b ;
419 if ( btppColour ) col[0] = 2 ;
420 if ( !btppColour ) lineStyle[0] = 1 ;
421 histo[1] = theHisto_dusg ;
422 if ( btppColour ) col[1] = 4 ;
423 if ( !btppColour ) lineStyle[1] = 2 ;
427 histo[0] ->
getTH1F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
428 histo[0] ->
getTH1F()->GetYaxis()->SetTitle (
"Arbitrary Units" ) ;
429 histo[0] ->
getTH1F()->GetYaxis()->SetTitleOffset(1.25) ;
431 for (
int i=0;
i != 4; ++
i) {
432 if (histo[
i]== 0 )
continue;
433 histo[
i] ->
getTH1F()->SetStats (
false ) ;
434 histo[
i] ->
getTH1F()->SetLineStyle ( lineStyle[
i] ) ;
435 histo[
i] ->
getTH1F()->SetLineWidth ( lineWidth ) ;
436 histo[
i] ->
getTH1F()->SetLineColor ( col[i] ) ;
437 histo[
i] ->
getTH1F()->SetMarkerStyle ( markerStyle[i] ) ;
438 histo[
i] ->
getTH1F()->SetMarkerColor ( col[i] ) ;
439 histo[
i] ->
getTH1F()->SetMarkerSize ( markerSize ) ;
442 if ( thePlotNormalized ) {
444 if (histo[0]->
getTH1F()->GetEntries() != 0) {histo[0]->
getTH1F() ->DrawNormalized() ;}
else { histo[0]->
getTH1F() ->SetMaximum(1.0);
445 histo[0] ->
getTH1F()->Draw() ;}
446 if (histo[1]->
getTH1F()->GetEntries() != 0) histo[1] ->
getTH1F()->DrawNormalized(
"Same") ;
447 if (histo[2]->
getTH1F()->GetEntries() != 0) histo[2]->
getTH1F() ->DrawNormalized(
"Same") ;
448 if ((histo[3] != 0) && (histo[3]->
getTH1F()->GetEntries() != 0)) histo[3] ->
getTH1F()->DrawNormalized(
"Same") ;
451 histo[0]->
getTH1F()->SetMaximum(max*1.05);
452 if (theMin!=-1.) histo[0]->
getTH1F()->SetMinimum(theMin);
454 histo[1]->
getTH1F()->Draw(
"Same") ;
455 histo[2]->
getTH1F()->Draw(
"Same") ;
456 if ( histo[3] != 0 ) histo[3]->
getTH1F()->Draw(
"Same") ;
464 TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
467 tc.Print((name + theBaseNameTitle +
".eps").c_str());
480 if(theHisto_all) theHisto_all ->getTH1F()->
Divide ( theHisto_all->getTH1F() , bHD.
histo_all () , 1.0 , 1.0 ,
"b" ) ;
487 theHisto_dus ->getTH1F()->
Divide ( theHisto_dus->getTH1F() , bHD.
histo_dus () , 1.0 , 1.0 ,
"b" ) ;
491 theHisto_ni ->getTH1F()->
Divide ( theHisto_ni->getTH1F() , bHD.
histo_ni () , 1.0 , 1.0 ,
"b" ) ;
492 theHisto_dusg ->getTH1F()->
Divide ( theHisto_dusg->getTH1F() , bHD.
histo_dusg() , 1.0 , 1.0 ,
"b" ) ;
501 if( (theBaseNameDescription !=
"Jet Multiplicity" || flavour == -1) && theHisto_all) theHisto_all->Fill ( var ,w) ;
504 if (!mcPlots_ || (theBaseNameDescription ==
"Jet Multiplicity" && flavour == -1))
return;
509 theHisto_d->Fill( var ,w);
510 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
512 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
516 theHisto_u->Fill( var ,w);
517 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
519 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
523 theHisto_s->Fill( var ,w);
524 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
526 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
529 theHisto_c->Fill( var ,w);
532 theHisto_b->Fill( var ,w);
535 if (mcPlots_>2 ) theHisto_g->Fill( var ,w);
536 if(theBaseNameDescription !=
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
539 if (mcPlots_>2 && theBaseNameDescription ==
"Jet Multiplicity") theHisto_dus->Fill( var ,w);
542 if (theBaseNameDescription ==
"Jet Multiplicity") theHisto_dusg->Fill( var ,w);
545 theHisto_ni->Fill( var ,w);
553 std::vector<TH1F*> histoVector;
554 if(theHisto_all) histoVector.push_back ( theHisto_all->getTH1F() );
557 histoVector.push_back ( theHisto_d->getTH1F() );
558 histoVector.push_back ( theHisto_u->getTH1F() );
559 histoVector.push_back ( theHisto_s->getTH1F() );
560 histoVector.push_back ( theHisto_g ->
getTH1F() );
561 histoVector.push_back ( theHisto_dus->getTH1F() );
563 histoVector.push_back ( theHisto_c->getTH1F() );
564 histoVector.push_back ( theHisto_b->getTH1F() );
565 histoVector.push_back ( theHisto_ni->getTH1F() );
566 histoVector.push_back ( theHisto_dusg->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)
const T & max(const T &a, const T &b)
std::string baseNameTitle() const
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