2 #ifndef FlavourHistograms_H
3 #define FlavourHistograms_H
32 FlavourHistograms (
const std::string& baseNameTitle_ ,
const std::string& baseNameDescription_ ,
33 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
34 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
35 const std::string& plotFirst_ ,
const bool&
update,
const std::string& folder,
const bool& mc) ;
45 void fill (
const int &
flavour,
const T & variable)
const;
48 void fill (
const int & flavour,
const T * variable)
const;
96 void fillVariable (
const int & flavour ,
const T & var )
const;
146 const int& nBins_ ,
const double& lowerBound_ ,
const double& upperBound_ ,
147 const bool& statistics_ ,
const bool& plotLog_ ,
const bool& plotNormalized_ ,
148 const std::string& plotFirst_,
const bool&
update,
const std::string& folder,
const bool& mc) :
151 theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
152 theNBins ( nBins_ ) , theLowerBound ( lowerBound_ ) , theUpperBound ( upperBound_ ) ,
153 theStatistics ( statistics_ ) , thePlotLog ( plotLog_ ) , thePlotNormalized ( plotNormalized_ ) ,
154 thePlotFirst ( plotFirst_ ), theMin(-1.), theMax(-1.), mcPlots_(mc)
165 std::cout <<
"FlavourHistograms::FlavourHistograms : thePlotFirst was not correct : " <<
thePlotFirst << std::endl ;
166 std::cout <<
"FlavourHistograms::FlavourHistograms : Set it to default value (l)! " << std::endl ;
250 template <
class T>
void
254 fillVariable ( flavour , variable ) ;
257 template <
class T>
void
260 if ( theArrayDimension == 0 ) {
262 fillVariable ( flavour , *variable ) ;
265 int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
267 for (
int i = 0 ;
i != iMax ; ++
i ) {
269 if ( ( theIndexToPlot < 0 ) || (
i == theIndexToPlot ) ) {
270 fillVariable ( flavour , *(variable+
i) ) ;
275 if ( theIndexToPlot >= iMax ) {
277 const T& theZero =
static_cast<T> ( 0.0 ) ;
278 fillVariable ( flavour , theZero ) ;
286 if(theHisto_all) theHisto_all ->setAxisTitle(title) ;
289 theHisto_d ->setAxisTitle(title) ;
290 theHisto_u ->setAxisTitle(title) ;
291 theHisto_s ->setAxisTitle(title) ;
292 theHisto_c ->setAxisTitle(title) ;
293 theHisto_b ->setAxisTitle(title) ;
294 theHisto_g ->setAxisTitle(title) ;
295 theHisto_ni ->setAxisTitle(title) ;
296 theHisto_dus ->setAxisTitle(title) ;
297 theHisto_dusg->setAxisTitle(title) ;
307 bool btppColour =
true;
313 gPad->UseCurrentStyle();
321 gPad->SetLogy ( 0 ) ;
322 if ( thePlotLog ) gPad->SetLogy ( 1 ) ;
323 gPad->SetGridx ( 0 ) ;
324 gPad->SetGridy ( 0 ) ;
325 gPad->SetTitle ( 0 ) ;
328 int col[4], lineStyle[4], markerStyle[4];
331 const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
334 histo[0] = theHisto_dusg ;
336 histo[1] = theHisto_b ;
337 histo[2] = theHisto_c ;
342 max = theHisto_dusg->getTH1F()->GetMaximum();
343 if (theHisto_b->getTH1F()->GetMaximum() >
max) max = theHisto_b->getTH1F()->GetMaximum();
344 if (theHisto_c->getTH1F()->GetMaximum() >
max) max = theHisto_c->getTH1F()->GetMaximum();
348 histo[3] = theHisto_ni ;
349 if (theHisto_ni->getTH1F()->GetMaximum() >
max) max = theHisto_ni->
getTH1F()->GetMaximum();
361 markerStyle[0] = 20 ;
362 markerStyle[1] = 21 ;
363 markerStyle[2] = 22 ;
364 markerStyle[3] = 23 ;
376 markerStyle[0] = 20 ;
377 markerStyle[1] = 21 ;
378 markerStyle[2] = 22 ;
379 markerStyle[3] = 23 ;
385 if ( thePlotFirst ==
"c" ) {
386 histo[0] = theHisto_c ;
387 if ( btppColour ) col[0] = 6 ;
388 if ( !btppColour ) lineStyle[0] = 3 ;
389 histo[2] = theHisto_dusg ;
390 if ( btppColour ) col[2] = 4 ;
391 if ( !btppColour ) lineStyle[2] = 2 ;
395 if ( thePlotFirst ==
"b" ) {
396 histo[0] = theHisto_b ;
397 if ( btppColour ) col[0] = 2 ;
398 if ( !btppColour ) lineStyle[0] = 1 ;
399 histo[1] = theHisto_dusg ;
400 if ( btppColour ) col[1] = 4 ;
401 if ( !btppColour ) lineStyle[1] = 2 ;
405 histo[0] ->
getTH1F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
406 histo[0] ->
getTH1F()->GetYaxis()->SetTitle (
"Arbitrary Units" ) ;
407 histo[0] ->
getTH1F()->GetYaxis()->SetTitleOffset(1.25) ;
409 for (
int i=0;
i != 4; ++
i) {
410 if (histo[
i]== 0 )
continue;
411 histo[
i] ->
getTH1F()->SetStats (
false ) ;
412 histo[
i] ->
getTH1F()->SetLineStyle ( lineStyle[
i] ) ;
413 histo[
i] ->
getTH1F()->SetLineWidth ( lineWidth ) ;
414 histo[
i] ->
getTH1F()->SetLineColor ( col[i] ) ;
415 histo[
i] ->
getTH1F()->SetMarkerStyle ( markerStyle[i] ) ;
416 histo[
i] ->
getTH1F()->SetMarkerColor ( col[i] ) ;
417 histo[
i] ->
getTH1F()->SetMarkerSize ( markerSize ) ;
420 if ( thePlotNormalized ) {
422 if (histo[0]->
getTH1F()->GetEntries() != 0) {histo[0]->
getTH1F() ->DrawNormalized() ;}
else { histo[0]->
getTH1F() ->SetMaximum(1.0);
423 histo[0] ->
getTH1F()->Draw() ;}
424 if (histo[1]->
getTH1F()->GetEntries() != 0) histo[1] ->
getTH1F()->DrawNormalized(
"Same") ;
425 if (histo[2]->
getTH1F()->GetEntries() != 0) histo[2]->
getTH1F() ->DrawNormalized(
"Same") ;
426 if ((histo[3] != 0) && (histo[3]->
getTH1F()->GetEntries() != 0)) histo[3] ->
getTH1F()->DrawNormalized(
"Same") ;
429 histo[0]->
getTH1F()->SetMaximum(max*1.05);
430 if (theMin!=-1.) histo[0]->
getTH1F()->SetMinimum(theMin);
432 histo[1]->
getTH1F()->Draw(
"Same") ;
433 histo[2]->
getTH1F()->Draw(
"Same") ;
434 if ( histo[3] != 0 ) histo[3]->
getTH1F()->Draw(
"Same") ;
442 TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
445 tc.Print((name + theBaseNameTitle +
".eps").c_str());
458 theHisto_all ->getTH1F()->
Divide ( theHisto_all->getTH1F() , bHD.
histo_all () , 1.0 , 1.0 ,
"b" ) ;
466 theHisto_ni ->getTH1F()->
Divide ( theHisto_ni->getTH1F() , bHD.
histo_ni () , 1.0 , 1.0 ,
"b" ) ;
467 theHisto_dus ->getTH1F()->
Divide ( theHisto_dus->getTH1F() , bHD.
histo_dus () , 1.0 , 1.0 ,
"b" ) ;
468 theHisto_dusg ->getTH1F()->
Divide ( theHisto_dusg->getTH1F() , bHD.
histo_dusg() , 1.0 , 1.0 ,
"b" ) ;
476 theHisto_all ->Fill ( var ) ;
478 if (!mcPlots_)
return;
482 theHisto_d->Fill( var );
483 theHisto_dus->Fill( var );
484 theHisto_dusg->Fill( var );
487 theHisto_u->Fill( var );
488 theHisto_dus->Fill( var );
489 theHisto_dusg->Fill( var );
492 theHisto_s->Fill( var );
493 theHisto_dus->Fill( var );
494 theHisto_dusg->Fill( var );
497 theHisto_c->Fill( var );
500 theHisto_b->Fill( var );
503 theHisto_g->Fill( var );
504 theHisto_dusg->Fill( var );
507 theHisto_ni->Fill( var );
515 std::vector<TH1F*> histoVector;
516 histoVector.push_back ( theHisto_all->getTH1F() );
518 histoVector.push_back ( theHisto_d->getTH1F() );
519 histoVector.push_back ( theHisto_u->getTH1F() );
520 histoVector.push_back ( theHisto_s->getTH1F() );
521 histoVector.push_back ( theHisto_c->getTH1F() );
522 histoVector.push_back ( theHisto_b->getTH1F() );
523 histoVector.push_back ( theHisto_g ->
getTH1F() );
524 histoVector.push_back ( theHisto_ni->getTH1F() );
525 histoVector.push_back ( theHisto_dus->getTH1F() );
526 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)
void fillVariable(const int &flavour, const T &var) const
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
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