CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FlavourHistorgrams2D.h
Go to the documentation of this file.
1 
2 #ifndef FlavourHistograms2D_H
3 #define FlavourHistograms2D_H
4 
8 
9 // #include "BTagPlotPrintC.h"
10 
11 #include "TH2F.h"
12 #include "TProfile.h"
13 #include "TCanvas.h"
14 #include "TROOT.h"
15 #include "TSystem.h"
16 #include "TStyle.h"
17 
20 
21 #include <iostream>
22 #include <vector>
23 #include <string>
24 //class DQMStore;
25 
26 //
27 // class to describe Histo
28 //
29 template <class T, class G>
31 
32 public:
33 
34  FlavourHistograms2D (TString baseNameTitle_ , TString baseNameDescription_ ,
35  int nBinsX_ , double lowerBoundX_ , double upperBoundX_ ,
36  int nBinsY_ , double lowerBoundY_ , double upperBoundY_ ,
37  std::string folder, unsigned int mc,
38  bool createProfile, DQMStore::IGetter & iget) ;
39 
40  FlavourHistograms2D (TString baseNameTitle_ , TString baseNameDescription_ ,
41  int nBinsX_ , double lowerBoundX_ , double upperBoundX_ ,
42  int nBinsY_ , double lowerBoundY_ , double upperBoundY_ ,
43  bool statistics_ , std::string folder, unsigned int mc,
44  bool createProfile, DQMStore::IBooker & ibook) ;
45 
46  virtual ~FlavourHistograms2D () ;
47 
48 
49  // define arrays (if needed)
50 // void defineArray ( int * dimension , int max , int indexToPlot ) ;
51 
52  // fill entry
53  // For single variables and arrays (for arrays only a single index can be filled)
54  void fill ( const int & flavour, const T & variableX, const G & variableY) const;
55  void fill ( const int & flavour, const T & variableX, const G & variableY, const float & w) const;
56 
57  // For single variables and arrays
58  void fill ( const int & flavour, const T * variableX, const G * variableY) const;
59  void fill ( const int & flavour, const T * variableX, const G * variableY, const float & w) const;
60 
61 
62  void settitle(const char* titleX, const char* titleY) ;
63 
64  void plot (TPad * theCanvas = 0) ;
65  void epsPlot(const std::string& name);
66 
67  // needed for efficiency computations -> this / b
68  // (void : alternative would be not to overwrite the histos but to return a cloned HistoDescription)
69  void divide ( const FlavourHistograms2D<T, G> & bHD ) const ;
70  void setEfficiencyFlag();
71 
72  inline void SetMaximum(const double& max) { theMax = max;}
73  inline void SetMinimum(const double& min) { theMin = min;}
74 
75 
76  // trivial access functions
77  inline std::string baseNameTitle () const { return theBaseNameTitle ; }
79  inline int nBinsX () const { return theNBinsX ; }
80  inline int nBinsY () const { return theNBinsY ; }
81  inline double lowerBoundX () const { return theLowerBoundX ; }
82  inline double upperBoundX () const { return theUpperBoundX ; }
83  inline double lowerBoundY () const { return theLowerBoundY ; }
84  inline double upperBoundY () const { return theUpperBoundY ; }
85  inline bool statistics () const { return theStatistics ; }
86 
87  // access to the histos
88  inline TH2F * histo_all () const { return theHisto_all->getTH2F() ; }
89  inline TH2F * histo_d () const { return theHisto_d ->getTH2F() ; }
90  inline TH2F * histo_u () const { return theHisto_u->getTH2F() ; }
91  inline TH2F * histo_s () const { return theHisto_s->getTH2F() ; }
92  inline TH2F * histo_c () const { return theHisto_c->getTH2F() ; }
93  inline TH2F * histo_b () const { return theHisto_b->getTH2F() ; }
94  inline TH2F * histo_g () const { return theHisto_g->getTH2F() ; }
95  inline TH2F * histo_ni () const { return theHisto_ni->getTH2F() ; }
96  inline TH2F * histo_dus () const { return theHisto_dus->getTH2F() ; }
97  inline TH2F * histo_dusg () const { return theHisto_dusg->getTH2F() ; }
98  inline TH2F * histo_pu () const { return theHisto_pu->getTH2F() ; }
99 
100  TProfile * profile_all () const { return theProfile_all->getTProfile() ; }
101  TProfile * profile_d () const { return theProfile_d ->getTProfile() ; }
102  TProfile * profile_u () const { return theProfile_u->getTProfile() ; }
103  TProfile * profile_s () const { return theProfile_s->getTProfile() ; }
104  TProfile * profile_c () const { return theProfile_c->getTProfile() ; }
105  TProfile * profile_b () const { return theProfile_b->getTProfile() ; }
106  TProfile * profile_g () const { return theProfile_g->getTProfile() ; }
107  TProfile * profile_ni () const { return theProfile_ni->getTProfile() ; }
108  TProfile * profile_dus () const { return theProfile_dus->getTProfile() ; }
109  TProfile * profile_dusg () const { return theProfile_dusg->getTProfile() ; }
110  TProfile * profile_pu () const { return theProfile_pu->getTProfile() ; }
111 
112  std::vector<TH2F*> getHistoVector() const;
113 
114  std::vector<TProfile*> getProfileVector() const;
115 
116 
117 
118 protected:
119 
120  void fillVariable ( const int & flavour , const T & varX , const G & varY , const float & w) const;
121 
122  //
123  // the data members
124  //
125 
126 // T * theVariable ;
127 
128  // for arrays
131  int theIndexToPlot ; // in case that not the complete array has to be plotted
132 
135  int theNBinsX ;
136  int theNBinsY ;
137  double theLowerBoundX ;
138  double theUpperBoundX ;
139  double theLowerBoundY ;
140  double theUpperBoundY ;
142  double theMin, theMax;
143 
144  // the histos
156 
157  // the profiles
169 
170  // DQMStore * dqmStore_;
171 
172 
173  // the canvas to plot
174  private:
176 
177  unsigned int mcPlots_;
179 
180 } ;
181 
182 
183 
184 template <class T, class G>
185 FlavourHistograms2D<T, G>::FlavourHistograms2D (TString baseNameTitle_ , TString baseNameDescription_ ,
186  int nBinsX_ , double lowerBoundX_ , double upperBoundX_ ,
187  int nBinsY_ , double lowerBoundY_ , double upperBoundY_ , std::string folder,
188  unsigned int mc, bool createProfile, DQMStore::IGetter & iget) :
189  // BaseFlavourHistograms2D () ,
190  // theVariable ( variable_ ) ,
191  theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
192  theNBinsX ( nBinsX_ ) , theNBinsY (nBinsY_),
193  theLowerBoundX ( lowerBoundX_ ) , theUpperBoundX ( upperBoundX_ ) ,
194  theLowerBoundY ( lowerBoundY_ ) , theUpperBoundY ( upperBoundY_ ) ,
195  theMin(-1.), theMax(-1.), mcPlots_(mc), createProfile_(createProfile)
196 {
197  // defaults for array dimensions
198  theArrayDimension = 0 ;
199 
200  if(mcPlots_%2 == 0) theHisto_all = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "ALL" ) ;
201  else theHisto_all = 0;
202  if (mcPlots_) {
203  if (mcPlots_>2) {
204  theHisto_d = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "D" ) ;
205  theHisto_u = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "U" ) ;
206  theHisto_s = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "S" ) ;
207  theHisto_g = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "G" ) ;
208  theHisto_dus = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "DUS" ) ;
209  }
210  else {
211  theHisto_d = 0;
212  theHisto_u = 0;
213  theHisto_s = 0;
214  theHisto_g = 0;
215  theHisto_dus = 0;
216  }
217  theHisto_c = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "C" ) ;
218  theHisto_b = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "B" ) ;
219  theHisto_ni = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "NI" ) ;
220  theHisto_dusg = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "DUSG") ;
221  theHisto_pu = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "PU" ) ;
222  }
223  else{
224  theHisto_d = 0;
225  theHisto_u = 0;
226  theHisto_s = 0;
227  theHisto_c = 0;
228  theHisto_b = 0;
229  theHisto_g = 0;
230  theHisto_ni = 0;
231  theHisto_dus = 0;
232  theHisto_dusg = 0;
233  theHisto_pu = 0;
234  }
235 
236  if(createProfile_) {
237  if(mcPlots_%2 == 0) theProfile_all = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_ALL");
238  else theProfile_all = 0;
239  if(mcPlots_) {
240  if (mcPlots_>2) {
241  theProfile_d = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_D" ) ;
242  theProfile_u = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_U" ) ;
243  theProfile_s = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_S" ) ;
244  theProfile_g = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_G" ) ;
245  theProfile_dus = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_DUS" ) ;
246  }
247  else {
248  theProfile_d = 0;
249  theProfile_u = 0;
250  theProfile_s = 0;
251  theProfile_g = 0;
252  theProfile_dus = 0;
253  }
254  theProfile_c = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_C" ) ;
255  theProfile_b = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_B" ) ;
256  theProfile_ni = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_NI" ) ;
257  theProfile_dusg = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_DUSG") ;
258  theProfile_pu = iget.get("Btag/" + folder + "/" + theBaseNameTitle + "_Profile_PU" ) ;
259  }
260  else{
261  theProfile_d = 0;
262  theProfile_u = 0;
263  theProfile_s = 0;
264  theProfile_c = 0;
265  theProfile_b = 0;
266  theProfile_g = 0;
267  theProfile_ni = 0;
268  theProfile_dus = 0;
269  theProfile_dusg = 0;
270  theProfile_pu = 0;
271  }
272  }
273  else {
274  theProfile_all = 0;
275  theProfile_d = 0;
276  theProfile_u = 0;
277  theProfile_s = 0;
278  theProfile_c = 0;
279  theProfile_b = 0;
280  theProfile_g = 0;
281  theProfile_ni = 0;
282  theProfile_dus = 0;
283  theProfile_dusg = 0;
284  theProfile_pu = 0;
285  }
286 }
287 
288 template <class T, class G>
289 FlavourHistograms2D<T, G>::FlavourHistograms2D (TString baseNameTitle_ , TString baseNameDescription_ ,
290  int nBinsX_ , double lowerBoundX_ , double upperBoundX_ ,
291  int nBinsY_ , double lowerBoundY_ , double upperBoundY_ ,
292  bool statistics_ , std::string folder,
293  unsigned int mc, bool createProfile, DQMStore::IBooker & ibook) :
294  theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
295  theNBinsX ( nBinsX_ ) , theNBinsY (nBinsY_),
296  theLowerBoundX ( lowerBoundX_ ) , theUpperBoundX ( upperBoundX_ ) ,
297  theLowerBoundY ( lowerBoundY_ ) , theUpperBoundY ( upperBoundY_ ) ,
298  theStatistics ( statistics_ ) , theMin(-1.), theMax(-1.), mcPlots_(mc), createProfile_(createProfile)
299 {
300  // defaults for array dimensions
301  theArrayDimension = 0 ;
302 
303  // book histos
304  HistoProviderDQM prov("Btag",folder,ibook);
306  else theHisto_all = 0;
307  if (mcPlots_) {
308  if (mcPlots_>2) {
314  }
315  else {
316  theHisto_d = 0;
317  theHisto_u = 0;
318  theHisto_s = 0;
319  theHisto_g = 0;
320  theHisto_dus = 0;
321  }
327  }else{
328  theHisto_d = 0;
329  theHisto_u = 0;
330  theHisto_s = 0;
331  theHisto_c = 0;
332  theHisto_b = 0;
333  theHisto_g = 0;
334  theHisto_ni = 0;
335  theHisto_dus = 0;
336  theHisto_dusg = 0;
337  theHisto_pu = 0;
338  }
339 
340  if (createProfile_) {
342  else theProfile_all = 0;
343  if (mcPlots_) {
344  if (mcPlots_>2) {
350  }
351  else {
352  theProfile_d = 0;
353  theProfile_u = 0;
354  theProfile_s = 0;
355  theProfile_g = 0;
356  theProfile_dus = 0;
357  }
363  } else{
364  theProfile_d = 0;
365  theProfile_u = 0;
366  theProfile_s = 0;
367  theProfile_c = 0;
368  theProfile_b = 0;
369  theProfile_g = 0;
370  theProfile_ni = 0;
371  theProfile_dus = 0;
372  theProfile_dusg = 0;
373  theProfile_pu = 0;
374  }
375  } else {
376  theProfile_all = 0;
377  theProfile_d = 0;
378  theProfile_u = 0;
379  theProfile_s = 0;
380  theProfile_c = 0;
381  theProfile_b = 0;
382  theProfile_g = 0;
383  theProfile_ni = 0;
384  theProfile_dus = 0;
385  theProfile_dusg = 0;
386  theProfile_pu = 0;
387  }
388  // statistics if requested
389  if ( theStatistics ) {
390  if(theHisto_all) theHisto_all ->getTH2F()->Sumw2() ;
391  if(createProfile)
392  if(theProfile_all) theProfile_all ->getTProfile()->Sumw2() ;
393  if (mcPlots_) {
394  if (mcPlots_>2) {
395  theHisto_d ->getTH2F()->Sumw2() ;
396  theHisto_u ->getTH2F()->Sumw2() ;
397  theHisto_s ->getTH2F()->Sumw2() ;
398  theHisto_g ->getTH2F()->Sumw2() ;
399  theHisto_dus ->getTH2F()->Sumw2() ;
400  }
401  theHisto_c ->getTH2F()->Sumw2() ;
402  theHisto_b ->getTH2F()->Sumw2() ;
403  theHisto_ni ->getTH2F()->Sumw2() ;
404  theHisto_dusg->getTH2F()->Sumw2() ;
405  theHisto_pu ->getTH2F()->Sumw2() ;
406 
407  if(createProfile) {
408  if (mcPlots_>2) {
409  theProfile_d ->getTProfile()->Sumw2() ;
410  theProfile_u ->getTProfile()->Sumw2() ;
411  theProfile_s ->getTProfile()->Sumw2() ;
412  theProfile_g ->getTProfile()->Sumw2() ;
413  theProfile_dus ->getTProfile()->Sumw2() ;
414  }
415  theProfile_c ->getTProfile()->Sumw2() ;
416  theProfile_b ->getTProfile()->Sumw2() ;
417  theProfile_ni ->getTProfile()->Sumw2() ;
418  theProfile_dusg->getTProfile()->Sumw2() ;
419  theProfile_pu ->getTProfile()->Sumw2() ;
420  }
421  }
422  }
423 }
424 
425 template <class T, class G>
427 
428 // fill entry
429 template <class T, class G> void
430  FlavourHistograms2D<T, G>::fill ( const int & flavour, const T & variableX, const G & variableY, const float & w) const
431 {
432  // For single variables and arrays (for arrays only a single index can be filled)
433  fillVariable ( flavour , variableX , variableY , w ) ;
434 }
435 
436 template <class T, class G> void
437 FlavourHistograms2D<T, G>::fill ( const int & flavour, const T & variableX, const G & variableY) const
438 {
439  fill ( flavour , variableX , variableY , 1. ) ;
440 }
441 
442 template <class T, class G> void
443  FlavourHistograms2D<T, G>::fill ( const int & flavour, const T * variableX, const G * variableY, const float & w) const
444 {
445  if ( theArrayDimension == 0 ) {
446  // single variable
447  fillVariable ( flavour , *variableX, *variableY , w) ;
448  } else {
449  // array
450  int iMax = *theArrayDimension ;
451  if ( *theArrayDimension > theMaxDimension ) iMax = theMaxDimension ;
452  //
453  for ( int i = 0 ; i != iMax ; ++i ) {
454  // check if only one index to be plotted (<0: switched off -> plot all)
455  if ( ( theIndexToPlot < 0 ) || ( i == theIndexToPlot ) ) {
456  fillVariable ( flavour , *(variableX+i) , *(variableY+i) , w) ;
457  }
458  }
459 
460  // if single index to be filled but not enough entries: fill 0.0 (convention!)
461  if ( theIndexToPlot >= iMax ) {
462  // cout << "==>> The index to be filled is too big -> fill 0.0 : " << theBaseNameTitle << " : " << theIndexToPlot << " >= " << iMax << endl ;
463  const T& theZeroT = static_cast<T> ( 0.0) ;
464  const G& theZeroG = static_cast<T> ( 0.0 );
465  fillVariable ( flavour , theZeroT , theZeroG , w ) ;
466  }
467  }
468 }
469 
470 template <class T, class G> void
471  FlavourHistograms2D<T, G>::fill ( const int & flavour, const T * variableX, const G * variableY) const
472 {
473  fill ( flavour, variableX , variableY , 1. );
474 }
475 
476 template <class T, class G>
477 void FlavourHistograms2D<T, G>::settitle(const char* titleX, const char* titleY) {
478  if(theHisto_all) theHisto_all ->setAxisTitle(titleX) ;
479  if(theHisto_all) theHisto_all ->setAxisTitle(titleY, 2) ;
480  if (mcPlots_) {
481 
482  if(theHisto_d) theHisto_d ->setAxisTitle(titleX) ;
483  if(theHisto_u) theHisto_u ->setAxisTitle(titleX) ;
484  if(theHisto_s) theHisto_s ->setAxisTitle(titleX) ;
485  if(theHisto_c) theHisto_c ->setAxisTitle(titleX) ;
486  if(theHisto_b) theHisto_b ->setAxisTitle(titleX) ;
487  if(theHisto_g) theHisto_g ->setAxisTitle(titleX) ;
488  if(theHisto_ni) theHisto_ni ->setAxisTitle(titleX) ;
489  if(theHisto_dus) theHisto_dus ->setAxisTitle(titleX) ;
490  if(theHisto_dusg)theHisto_dusg->setAxisTitle(titleX) ;
491  if(theHisto_d) theHisto_d ->setAxisTitle(titleY, 2) ;
492  if(theHisto_u) theHisto_u ->setAxisTitle(titleY, 2) ;
493  if(theHisto_s) theHisto_s ->setAxisTitle(titleY, 2) ;
494  if(theHisto_c) theHisto_c ->setAxisTitle(titleY, 2) ;
495  if(theHisto_b) theHisto_b ->setAxisTitle(titleY, 2) ;
496  if(theHisto_g) theHisto_g ->setAxisTitle(titleY, 2) ;
497  if(theHisto_ni) theHisto_ni ->setAxisTitle(titleY, 2) ;
498  if(theHisto_dus) theHisto_dus ->setAxisTitle(titleY, 2) ;
499  if(theHisto_dusg)theHisto_dusg->setAxisTitle(titleY, 2) ;
500  if(theHisto_pu) theHisto_pu ->setAxisTitle(titleY, 2) ;
501  }
502 
503  if(createProfile_) {
504  if(theProfile_all) theProfile_all ->setAxisTitle(titleX) ;
505  if(theProfile_all) theProfile_all ->setAxisTitle(titleY, 2) ;
506  if (mcPlots_) {
507 
508  if(theProfile_d) theProfile_d ->setAxisTitle(titleX) ;
509  if(theProfile_u) theProfile_u ->setAxisTitle(titleX) ;
510  if(theProfile_s) theProfile_s ->setAxisTitle(titleX) ;
511  if(theProfile_c) theProfile_c ->setAxisTitle(titleX) ;
512  if(theProfile_b) theProfile_b ->setAxisTitle(titleX) ;
513  if(theProfile_g) theProfile_g ->setAxisTitle(titleX) ;
514  if(theProfile_ni) theProfile_ni ->setAxisTitle(titleX) ;
515  if(theProfile_dus) theProfile_dus ->setAxisTitle(titleX) ;
516  if(theProfile_dusg)theProfile_dusg->setAxisTitle(titleX) ;
517  if(theProfile_d) theProfile_d ->setAxisTitle(titleY, 2) ;
518  if(theProfile_u) theProfile_u ->setAxisTitle(titleY, 2) ;
519  if(theProfile_s) theProfile_s ->setAxisTitle(titleY, 2) ;
520  if(theProfile_c) theProfile_c ->setAxisTitle(titleY, 2) ;
521  if(theProfile_b) theProfile_b ->setAxisTitle(titleY, 2) ;
522  if(theProfile_g) theProfile_g ->setAxisTitle(titleY, 2) ;
523  if(theProfile_ni) theProfile_ni ->setAxisTitle(titleY, 2) ;
524  if(theProfile_dus) theProfile_dus ->setAxisTitle(titleY, 2) ;
525  if(theProfile_dusg)theProfile_dusg->setAxisTitle(titleY, 2) ;
526  if(theProfile_pu) theProfile_pu ->setAxisTitle(titleY, 2) ;
527  }
528  }
529 }
530 
531 template <class T, class G>
532 void FlavourHistograms2D<T, G>::plot (TPad * theCanvas /* = 0 */) {
533 
534 //fixme:
535  bool btppNI = false;
536  bool btppColour = true;
537 
538  if (theCanvas)
539  theCanvas->cd();
540 
541  RecoBTag::setTDRStyle()->cd();
542  gPad->UseCurrentStyle();
543  gPad->SetLogy ( 0 ) ;
544  gPad->SetGridx ( 0 ) ;
545  gPad->SetGridy ( 0 ) ;
546  gPad->SetTitle ( 0 ) ;
547 
548  MonitorElement * histo[4];
549  int col[4], lineStyle[4], markerStyle[4];
550  int lineWidth = 1 ;
551 
552  const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
553  histo[0] = theHisto_dusg ;
554  histo[1] = theHisto_b ;
555  histo[2] = theHisto_c ;
556  histo[3]= 0 ;
557 
558  double max = theMax;
559  if (theMax<=0.) {
560  max = theHisto_dusg->getTH2F()->GetMaximum();
561  if (theHisto_b->getTH2F()->GetMaximum() > max) max = theHisto_b->getTH2F()->GetMaximum();
562  if (theHisto_c->getTH2F()->GetMaximum() > max) max = theHisto_c->getTH2F()->GetMaximum();
563  }
564 
565  if (btppNI) {
566  histo[3] = theHisto_ni ;
567  if (theHisto_ni->getTH2F()->GetMaximum() > max) max = theHisto_ni->getTH2F()->GetMaximum();
568  }
569 
570  if ( btppColour ) { // print colours
571  col[0] = 4 ;
572  col[1] = 2 ;
573  col[2] = 6 ;
574  col[3] = 3 ;
575  lineStyle[0] = 1 ;
576  lineStyle[1] = 1 ;
577  lineStyle[2] = 1 ;
578  lineStyle[3] = 1 ;
579  markerStyle[0] = 20 ;
580  markerStyle[1] = 21 ;
581  markerStyle[2] = 22 ;
582  markerStyle[3] = 23 ;
583  lineWidth = 1 ;
584  }
585  else { // different marker/line styles
586  col[1] = 1 ;
587  col[2] = 1 ;
588  col[3] = 1 ;
589  col[0] = 1 ;
590  lineStyle[0] = 2 ;
591  lineStyle[1] = 1 ;
592  lineStyle[2] = 3 ;
593  lineStyle[3] = 4 ;
594  markerStyle[0] = 20 ;
595  markerStyle[1] = 21 ;
596  markerStyle[2] = 22 ;
597  markerStyle[3] = 23 ;
598  }
599 
600  histo[0] ->getTH2F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
601  histo[0] ->getTH2F()->GetYaxis()->SetTitle ( "Arbitrary Units" ) ;
602  histo[0] ->getTH2F()->GetYaxis()->SetTitleOffset(1.25) ;
603 
604  for (int i=0; i != 4; ++i) {
605  if (histo[i]== 0 ) continue;
606  histo[i] ->getTH2F()->SetStats ( false ) ;
607  histo[i] ->getTH2F()->SetLineStyle ( lineStyle[i] ) ;
608  histo[i] ->getTH2F()->SetLineWidth ( lineWidth ) ;
609  histo[i] ->getTH2F()->SetLineColor ( col[i] ) ;
610  histo[i] ->getTH2F()->SetMarkerStyle ( markerStyle[i] ) ;
611  histo[i] ->getTH2F()->SetMarkerColor ( col[i] ) ;
612  histo[i] ->getTH2F()->SetMarkerSize ( markerSize ) ;
613  }
614 
615  histo[0]->getTH2F()->SetMaximum(max*1.05);
616  if (theMin!=-1.) histo[0]->getTH2F()->SetMinimum(theMin);
617  histo[0]->getTH2F()->Draw() ;
618  histo[1]->getTH2F()->Draw("Same") ;
619  histo[2]->getTH2F()->Draw("Same") ;
620  if ( histo[3] != 0 ) histo[3]->getTH2F()->Draw("Same") ;
621 
622 }
623 
624 template <class T, class G>
626 {
627  TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());
628 
629  plot(&tc);
630  tc.Print((name + theBaseNameTitle + ".eps").c_str());
631 }
632 
633 // needed for efficiency computations -> this / b
634 // (void : alternative would be not to overwrite the histos but to return a cloned HistoDescription)
635 template <class T, class G>
637  // divide histos using binomial errors
638  //
639  // ATTENTION: It's the responsability of the user to make sure that the HistoDescriptions
640  // involved in this operation have been constructed with the statistics option switched on!!
641  //
642  if(theHisto_all) theHisto_all ->getTH2F()-> Divide ( theHisto_all->getTH2F() , bHD.histo_all () , 1.0 , 1.0 , "b" ) ;
643  if (mcPlots_) {
644  if (mcPlots_>2) {
645  theHisto_d ->getTH2F()-> Divide ( theHisto_d ->getTH2F() , bHD.histo_d () , 1.0 , 1.0 , "b" ) ;
646  theHisto_u ->getTH2F()-> Divide ( theHisto_u ->getTH2F() , bHD.histo_u () , 1.0 , 1.0 , "b" ) ;
647  theHisto_s ->getTH2F()-> Divide ( theHisto_s ->getTH2F() , bHD.histo_s () , 1.0 , 1.0 , "b" ) ;
648  theHisto_g ->getTH2F()-> Divide ( theHisto_g ->getTH2F() , bHD.histo_g () , 1.0 , 1.0 , "b" ) ;
649  theHisto_dus ->getTH2F()-> Divide ( theHisto_dus->getTH2F() , bHD.histo_dus () , 1.0 , 1.0 , "b" ) ;
650  }
651  theHisto_c ->getTH2F()-> Divide ( theHisto_c ->getTH2F() , bHD.histo_c () , 1.0 , 1.0 , "b" ) ;
652  theHisto_b ->getTH2F()-> Divide ( theHisto_b ->getTH2F() , bHD.histo_b () , 1.0 , 1.0 , "b" ) ;
653  theHisto_ni ->getTH2F()-> Divide ( theHisto_ni->getTH2F() , bHD.histo_ni () , 1.0 , 1.0 , "b" ) ;
654  theHisto_dusg ->getTH2F()-> Divide ( theHisto_dusg->getTH2F() , bHD.histo_dusg() , 1.0 , 1.0 , "b" ) ;
655  theHisto_pu ->getTH2F()-> Divide ( theHisto_pu->getTH2F() , bHD.histo_pu () , 1.0 , 1.0 , "b" ) ;
656  }
657 }
658 
659 template <class T, class G>
661  if(theHisto_all) theHisto_all ->setEfficiencyFlag();
662  if (mcPlots_) {
663  if (mcPlots_>2 ) {
664  theHisto_d ->setEfficiencyFlag();
665  theHisto_u ->setEfficiencyFlag();
666  theHisto_s ->setEfficiencyFlag();
667  theHisto_g ->setEfficiencyFlag();
668  theHisto_dus ->setEfficiencyFlag();
669  }
670  theHisto_c ->setEfficiencyFlag();
671  theHisto_b ->setEfficiencyFlag();
672  theHisto_ni ->setEfficiencyFlag();
673  theHisto_dusg ->setEfficiencyFlag();
674  theHisto_pu ->setEfficiencyFlag();
675  }
676 }
677 
678 template <class T, class G>
679  void FlavourHistograms2D<T, G>::fillVariable ( const int & flavour , const T & varX , const G & varY , const float & w) const {
680  // all
681  if(theHisto_all) theHisto_all->Fill ( varX, varY,w ) ;
682  if(createProfile_)
683  //if(theProfile_all) theProfile_all->Fill( varX, varY, w );
684  if(theProfile_all) theProfile_all->Fill( varX, varY);
685 
686  //exit(-1);
687  // flavour specific
688  if (!mcPlots_) return;
689 
690  switch( flavour ) {
691  case 1:
692  if (mcPlots_>2) {
693  theHisto_d->Fill( varX, varY,w );
694  theHisto_dus->Fill( varX, varY,w );
695  }
696  theHisto_dusg->Fill( varX, varY,w );
697  if(createProfile_) {
698  //theProfile_d->Fill(varX, varY,w);
699  //theProfile_dus->Fill(varX, varY,w);
700  //theProfile_dusg->Fill(varX, varY,w);
701  if (mcPlots_>2) {
702  theProfile_d->Fill(varX, varY);
703  theProfile_dus->Fill(varX, varY);
704  }
705  theProfile_dusg->Fill(varX, varY);
706  }
707  return;
708  case 2:
709  if (mcPlots_>2) {
710  theHisto_u->Fill( varX, varY,w );
711  theHisto_dus->Fill( varX, varY,w );
712  }
713  theHisto_dusg->Fill( varX, varY,w );
714  if(createProfile_) {
715  //theProfile_u->Fill(varX, varY,w);
716  //theProfile_dus->Fill(varX, varY,w);
717  //theProfile_dusg->Fill(varX, varY,w);
718  if (mcPlots_>2) {
719  theProfile_u->Fill(varX, varY);
720  theProfile_dus->Fill(varX, varY);
721  }
722  theProfile_dusg->Fill(varX, varY);
723  }
724  return;
725  case 3:
726  if (mcPlots_>2) {
727  theHisto_s->Fill( varX, varY,w );
728  theHisto_dus->Fill( varX, varY,w );
729  }
730  theHisto_dusg->Fill( varX, varY,w );
731  if(createProfile_) {
732  //theProfile_s->Fill(varX, varY,w);
733  //theProfile_dus->Fill(varX, varY,w);
734  //theProfile_dusg->Fill(varX, varY,w);
735  if (mcPlots_>2) {
736  theProfile_s->Fill(varX, varY);
737  theProfile_dus->Fill(varX, varY);
738  }
739  theProfile_dusg->Fill(varX, varY);
740  }
741  return;
742  case 4:
743  theHisto_c->Fill( varX, varY,w );
744  //if(createProfile_) theProfile_c->Fill(varX, varY,w);
745  if(createProfile_) theProfile_c->Fill(varX, varY);
746  return;
747  case 5:
748  theHisto_b->Fill( varX, varY,w );
749  //if(createProfile_) theProfile_b->Fill(varX, varY,w);
750  if(createProfile_) theProfile_b->Fill(varX, varY);
751  return;
752  case 21:
753  if (mcPlots_>2) theHisto_g->Fill( varX, varY,w );
754  theHisto_dusg->Fill( varX, varY,w );
755  if(createProfile_) {
756  //theProfile_g->Fill(varX, varY,w);
757  //theProfile_dusg->Fill(varX, varY,w);
758  if (mcPlots_>2) theProfile_g->Fill(varX, varY);
759  theProfile_dusg->Fill(varX, varY);
760  }
761  return;
762  case 20:
763  theHisto_pu->Fill( varX, varY,w );
764  //if(createProfile_) theProfile_pu->Fill(varX, varY,w);
765  if(createProfile_) theProfile_pu->Fill(varX, varY);
766  return;
767  default:
768  theHisto_ni->Fill( varX, varY,w );
769  //if(createProfile_) theProfile_ni->Fill(varX, varY,w);
770  if(createProfile_) theProfile_ni->Fill(varX, varY);
771  return;
772  }
773 }
774 
775 template <class T, class G>
777 {
778  std::vector<TH2F*> histoVector;
779  if(theHisto_all) histoVector.push_back ( theHisto_all->getTH2F() );
780  if (mcPlots_) {
781  if (mcPlots_>2) {
782  histoVector.push_back ( theHisto_d->getTH2F() );
783  histoVector.push_back ( theHisto_u->getTH2F() );
784  histoVector.push_back ( theHisto_s->getTH2F() );
785  histoVector.push_back ( theHisto_g ->getTH2F() );
786  histoVector.push_back ( theHisto_dus->getTH2F() );
787  }
788  histoVector.push_back ( theHisto_c->getTH2F() );
789  histoVector.push_back ( theHisto_b->getTH2F() );
790  histoVector.push_back ( theHisto_ni->getTH2F() );
791  histoVector.push_back ( theHisto_dusg->getTH2F());
792  histoVector.push_back ( theHisto_pu->getTH2F() );
793  }
794  return histoVector;
795 }
796 
797 template <class T, class G>
798 std::vector<TProfile*> FlavourHistograms2D<T, G>::getProfileVector() const
799 {
800  std::vector<TProfile*> profileVector;
801  if(createProfile_) {
802  if(theProfile_all) profileVector.push_back ( theProfile_all->getTProfile() );
803  if (mcPlots_) {
804  if (mcPlots_>2) {
805  profileVector.push_back ( theProfile_d->getTProfile() );
806  profileVector.push_back ( theProfile_u->getTProfile() );
807  profileVector.push_back ( theProfile_s->getTProfile() );
808  profileVector.push_back ( theProfile_g ->getTProfile() );
809  profileVector.push_back ( theProfile_dus->getTProfile() );
810  }
811  profileVector.push_back ( theProfile_c->getTProfile() );
812  profileVector.push_back ( theProfile_b->getTProfile() );
813  profileVector.push_back ( theProfile_ni->getTProfile() );
814  profileVector.push_back ( theProfile_dusg->getTProfile());
815  profileVector.push_back ( theProfile_pu->getTProfile() );
816  }
817  }
818  return profileVector;
819 }
820 
821 #endif
TProfile * profile_c() const
std::string theBaseNameDescription
MonitorElement * theProfile_s
int i
Definition: DBlmapReader.cc:9
MonitorElement * theProfile_pu
double lowerBoundX() const
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
string fill
Definition: lumiContext.py:319
double lowerBoundY() const
const double w
Definition: UKUtility.cc:23
MonitorElement * theHisto_g
void SetMaximum(const double &max)
TH2F * histo_all() const
MonitorElement * theProfile_dusg
void settitle(const char *titleX, const char *titleY)
MonitorElement * theHisto_dusg
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:301
MonitorElement * theHisto_u
virtual MonitorElement * bookProfile(const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
TStyle * setTDRStyle()
Definition: Tools.cc:346
TProfile * profile_pu() const
virtual MonitorElement * book2D(const std::string &name, const std::string &title, const int &nchX, const double &lowX, const double &highX, const int &nchY, const double &lowY, const double &highY)
void plot(TPad *theCanvas=0)
std::string baseNameTitle() const
TProfile * profile_b() const
void divide(const FlavourHistograms2D< T, G > &bHD) const
MonitorElement * theHisto_c
MonitorElement * theHisto_pu
void fill(const int &flavour, const T &variableX, const G &variableY) const
MonitorElement * theProfile_all
MonitorElement * theProfile_ni
MonitorElement * theHisto_dus
TH2F * histo_dusg() const
MonitorElement * theProfile_u
MonitorElement * theHisto_s
TH2F * histo_dus() const
std::vector< TProfile * > getProfileVector() const
TProfile * profile_u() const
TProfile * profile_all() const
MonitorElement * theProfile_b
void SetMinimum(const double &min)
MonitorElement * theProfile_c
double upperBoundX() const
T min(T a, T b)
Definition: MathUtil.h:58
tuple G
Definition: callgraph.py:12
std::vector< TH2F * > getHistoVector() const
MonitorElement * theProfile_d
std::string baseNameDescription() const
TProfile * profile_d() const
MonitorElement * theProfile_dus
TH2F * histo_pu() const
TH2F * histo_ni() const
MonitorElement * theHisto_all
TProfile * profile_ni() const
void epsPlot(const std::string &name)
TProfile * getTProfile(void) const
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
TProfile * profile_s() const
TH2F * getTH2F(void) const
MonitorElement * theProfile_g
int col
Definition: cuy.py:1008
TProfile * profile_dusg() const
double upperBoundY() const
long double T
MonitorElement * theHisto_b
int flavour(const Candidate &part)
Definition: pdgIdUtils.h:31
TProfile * profile_dus() const
void fillVariable(const int &flavour, const T &varX, const G &varY, const float &w) const
TProfile * profile_g() const
MonitorElement * theHisto_ni
MonitorElement * theHisto_d