CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/DQMOffline/RecoB/interface/FlavourHistorgrams2D.h

Go to the documentation of this file.
00001 
00002 #ifndef FlavourHistograms2D_H
00003 #define FlavourHistograms2D_H
00004 
00005 #include "DQMServices/Core/interface/DQMStore.h"
00006 #include "DQMServices/Core/interface/MonitorElement.h"
00007 #include "FWCore/ServiceRegistry/interface/Service.h" 
00008 
00009 // #include "BTagPlotPrintC.h"
00010 
00011 #include "TH2F.h"
00012 #include "TProfile.h"
00013 #include "TCanvas.h"
00014 #include "TROOT.h"
00015 #include "TSystem.h"
00016 #include "TStyle.h"
00017 
00018 #include "DQMOffline/RecoB/interface/Tools.h"
00019 #include "DQMOffline/RecoB/interface/HistoProviderDQM.h"
00020 
00021 #include <iostream>
00022 #include <vector>
00023 #include <string>
00024 //class DQMStore;
00025 
00026 //
00027 // class to describe Histo
00028 //
00029 template <class T, class G>
00030 class FlavourHistograms2D {
00031 
00032 public:
00033 
00034   FlavourHistograms2D (TString baseNameTitle_ , TString baseNameDescription_ ,
00035                       int nBinsX_ , double lowerBoundX_ , double upperBoundX_ ,
00036                       int nBinsY_ , double lowerBoundY_ , double upperBoundY_ ,
00037                       bool statistics_ , bool update, std::string folder, unsigned int mc,
00038                       bool createProfile) ;
00039 
00040   virtual ~FlavourHistograms2D () ;
00041 
00042 
00043   // define arrays (if needed)
00044 //   void defineArray ( int * dimension , int max , int indexToPlot ) ;
00045   
00046   // fill entry
00047   // For single variables and arrays (for arrays only a single index can be filled)
00048   void fill ( const int & flavour,  const T & variableX, const G & variableY) const;
00049   void fill ( const int & flavour,  const T & variableX, const G & variableY, const float & w) const;
00050 
00051   // For single variables and arrays
00052   void fill ( const int & flavour,  const T * variableX, const G * variableY) const;
00053   void fill ( const int & flavour,  const T * variableX, const G * variableY, const float & w) const;
00054 
00055 
00056   void settitle(const char* titleX, const char* titleY) ;
00057   
00058   // needed for efficiency computations -> this / b
00059   // (void : alternative would be not to overwrite the histos but to return a cloned HistoDescription)
00060   void divide ( const FlavourHistograms2D<T, G> & bHD ) const ;
00061 
00062   inline void SetMaximum(const double& max) { theMax = max;}
00063   inline void SetMinimum(const double& min) { theMin = min;}
00064 
00065 
00066   // trivial access functions
00067   inline std::string  baseNameTitle       () const { return theBaseNameTitle       ; }
00068   inline std::string  baseNameDescription () const { return theBaseNameDescription ; }
00069   inline int    nBinsX              () const { return theNBinsX              ; }
00070   inline int    nBinsY              () const { return theNBinsY              ; }
00071   inline double lowerBoundX         () const { return theLowerBoundX         ; } 
00072   inline double upperBoundX         () const { return theUpperBoundX         ; }
00073   inline double lowerBoundY         () const { return theLowerBoundY         ; } 
00074   inline double upperBoundY         () const { return theUpperBoundY         ; }
00075   inline bool   statistics          () const { return theStatistics          ; }
00076 
00077   // access to the histos
00078   inline TH2F * histo_all  () const { return theHisto_all->getTH2F()  ; }    
00079   inline TH2F * histo_d    () const { return theHisto_d ->getTH2F()   ; }    
00080   inline TH2F * histo_u    () const { return theHisto_u->getTH2F()    ; }
00081   inline TH2F * histo_s    () const { return theHisto_s->getTH2F()    ; }
00082   inline TH2F * histo_c    () const { return theHisto_c->getTH2F()    ; }
00083   inline TH2F * histo_b    () const { return theHisto_b->getTH2F()    ; }
00084   inline TH2F * histo_g    () const { return theHisto_g->getTH2F()    ; }
00085   inline TH2F * histo_ni   () const { return theHisto_ni->getTH2F()   ; }
00086   inline TH2F * histo_dus  () const { return theHisto_dus->getTH2F()  ; }
00087   inline TH2F * histo_dusg () const { return theHisto_dusg->getTH2F() ; }
00088 
00089   TProfile * profile_all  () const { return theProfile_all->getTProfile()  ; }    
00090   TProfile * profile_d    () const { return theProfile_d ->getTProfile()   ; }    
00091   TProfile * profile_u    () const { return theProfile_u->getTProfile()    ; }
00092   TProfile * profile_s    () const { return theProfile_s->getTProfile()    ; }
00093   TProfile * profile_c    () const { return theProfile_c->getTProfile()    ; }
00094   TProfile * profile_b    () const { return theProfile_b->getTProfile()    ; }
00095   TProfile * profile_g    () const { return theProfile_g->getTProfile()    ; }
00096   TProfile * profile_ni   () const { return theProfile_ni->getTProfile()   ; }
00097   TProfile * profile_dus  () const { return theProfile_dus->getTProfile()  ; }
00098   TProfile * profile_dusg () const { return theProfile_dusg->getTProfile() ; }
00099 
00100   std::vector<TH2F*> getHistoVector() const;
00101 
00102   std::vector<TProfile*> getProfileVector() const;
00103 
00104   
00105 
00106 protected:
00107 
00108   void fillVariable ( const int & flavour , const T & varX , const G & varY , const float & w) const;
00109   
00110   //
00111   // the data members
00112   //
00113   
00114 //   T *   theVariable   ;
00115 
00116   // for arrays
00117   int * theArrayDimension ;
00118   int   theMaxDimension ;
00119   int   theIndexToPlot ; // in case that not the complete array has to be plotted
00120 
00121   std::string  theBaseNameTitle ;
00122   std::string  theBaseNameDescription ;
00123   int    theNBinsX ;
00124   int    theNBinsY ;
00125   double theLowerBoundX ;
00126   double theUpperBoundX ;
00127   double theLowerBoundY ;
00128   double theUpperBoundY ;
00129   bool   theStatistics ;
00130   double theMin, theMax;
00131 
00132   // the histos
00133   MonitorElement *theHisto_all  ;    
00134   MonitorElement *theHisto_d    ;    
00135   MonitorElement *theHisto_u    ;
00136   MonitorElement *theHisto_s    ;
00137   MonitorElement *theHisto_c    ;
00138   MonitorElement *theHisto_b    ;
00139   MonitorElement *theHisto_g    ;
00140   MonitorElement *theHisto_ni   ;
00141   MonitorElement *theHisto_dus  ;
00142   MonitorElement *theHisto_dusg ;
00143 
00144   // the profiles
00145   MonitorElement *theProfile_all  ;    
00146   MonitorElement *theProfile_d    ;    
00147   MonitorElement *theProfile_u    ;
00148   MonitorElement *theProfile_s    ;
00149   MonitorElement *theProfile_c    ;
00150   MonitorElement *theProfile_b    ;
00151   MonitorElement *theProfile_g    ;
00152   MonitorElement *theProfile_ni   ;
00153   MonitorElement *theProfile_dus  ;
00154   MonitorElement *theProfile_dusg ;
00155 
00156   //  DQMStore * dqmStore_; 
00157 
00158 
00159   // the canvas to plot
00160   private:
00161   FlavourHistograms2D(){}
00162 
00163   unsigned int mcPlots_;
00164   bool createProfile_;
00165 
00166 } ;
00167 
00168 
00169 
00170 template <class T, class G>
00171 FlavourHistograms2D<T, G>::FlavourHistograms2D (TString baseNameTitle_ , TString baseNameDescription_ ,
00172                                           int nBinsX_ , double lowerBoundX_ , double upperBoundX_ ,
00173                                           int nBinsY_ , double lowerBoundY_ , double upperBoundY_ ,
00174                                           bool statistics_ ,
00175                                           bool update, std::string folder, unsigned int mc, bool createProfile) :
00176   // BaseFlavourHistograms2D () ,
00177   // theVariable ( variable_ ) ,
00178   theMaxDimension(-1), theIndexToPlot(-1), theBaseNameTitle ( baseNameTitle_ ) , theBaseNameDescription ( baseNameDescription_ ) ,
00179   theNBinsX ( nBinsX_ ) , theNBinsY (nBinsY_), 
00180   theLowerBoundX ( lowerBoundX_ ) , theUpperBoundX ( upperBoundX_ ) ,
00181   theLowerBoundY ( lowerBoundY_ ) , theUpperBoundY ( upperBoundY_ ) ,
00182   theStatistics ( statistics_ ) , theMin(-1.), theMax(-1.), mcPlots_(mc), createProfile_(createProfile)
00183 {
00184   // defaults for array dimensions
00185   theArrayDimension = 0  ;
00186     
00187   if (!update) {
00188     // book histos
00189     HistoProviderDQM prov("Btag",folder);
00190     if(mcPlots_%2 == 0) theHisto_all   = (prov.book2D( theBaseNameTitle + "ALL"  , theBaseNameDescription + " all jets"  , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY )) ; 
00191     else theHisto_all = 0;
00192     if (mcPlots_) {  
00193       if (mcPlots_>2) {
00194         theHisto_d     = (prov.book2D ( theBaseNameTitle + "D"    , theBaseNameDescription + " d-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY )) ; 
00195         theHisto_u     = (prov.book2D ( theBaseNameTitle + "U"    , theBaseNameDescription + " u-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00196         theHisto_s     = (prov.book2D ( theBaseNameTitle + "S"    , theBaseNameDescription + " s-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00197         theHisto_g     = (prov.book2D ( theBaseNameTitle + "G"    , theBaseNameDescription + " g-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00198         theHisto_dus   = (prov.book2D ( theBaseNameTitle + "DUS"  , theBaseNameDescription + " dus-jets"  , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00199       }
00200       else {
00201         theHisto_d = 0;
00202         theHisto_u = 0;
00203         theHisto_s = 0;
00204         theHisto_g = 0;
00205         theHisto_dus = 0;
00206       }
00207       theHisto_c     = (prov.book2D ( theBaseNameTitle + "C"    , theBaseNameDescription + " c-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00208       theHisto_b     = (prov.book2D ( theBaseNameTitle + "B"    , theBaseNameDescription + " b-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00209       theHisto_ni    = (prov.book2D ( theBaseNameTitle + "NI"   , theBaseNameDescription + " ni-jets"   , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00210       theHisto_dusg  = (prov.book2D ( theBaseNameTitle + "DUSG" , theBaseNameDescription + " dusg-jets" , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ;
00211     }else{
00212       theHisto_d = 0;
00213       theHisto_u = 0;
00214       theHisto_s = 0;
00215       theHisto_c = 0;
00216       theHisto_b = 0;
00217       theHisto_g = 0;
00218       theHisto_ni = 0;
00219       theHisto_dus = 0;
00220       theHisto_dusg = 0;
00221     }
00222 
00223     if (createProfile_) {
00224       if(mcPlots_%2 == 0) theProfile_all = (prov.bookProfile( theBaseNameTitle + "_Profile_ALL" , theBaseNameDescription + " all jets" , theNBinsX, theLowerBoundX, theUpperBoundX, theNBinsY, theLowerBoundY, theUpperBoundY));
00225       else theProfile_all = 0;
00226       if (mcPlots_) {
00227         if (mcPlots_>2) {
00228           theProfile_d     = (prov.bookProfile ( theBaseNameTitle + "_Profile_D"    , theBaseNameDescription + " d-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY )) ; 
00229           theProfile_u     = (prov.bookProfile ( theBaseNameTitle + "_Profile_U"    , theBaseNameDescription + " u-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00230           theProfile_s     = (prov.bookProfile ( theBaseNameTitle + "_Profile_S"    , theBaseNameDescription + " s-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00231           theProfile_g     = (prov.bookProfile ( theBaseNameTitle + "_Profile_G"    , theBaseNameDescription + " g-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00232           theProfile_dus   = (prov.bookProfile ( theBaseNameTitle + "_Profile_DUS"  , theBaseNameDescription + " dus-jets"  , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00233         }
00234         else {
00235           theProfile_d = 0;
00236           theProfile_u = 0;
00237           theProfile_s = 0;
00238           theProfile_g = 0;
00239           theProfile_dus = 0;
00240         }
00241         theProfile_c     = (prov.bookProfile ( theBaseNameTitle + "_Profile_C"    , theBaseNameDescription + " c-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00242         theProfile_b     = (prov.bookProfile ( theBaseNameTitle + "_Profile_B"    , theBaseNameDescription + " b-jets"    , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00243         theProfile_ni    = (prov.bookProfile ( theBaseNameTitle + "_Profile_NI"   , theBaseNameDescription + " ni-jets"   , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ; 
00244         theProfile_dusg  = (prov.bookProfile ( theBaseNameTitle + "_Profile_DUSG" , theBaseNameDescription + " dusg-jets" , theNBinsX , theLowerBoundX , theUpperBoundX , theNBinsY, theLowerBoundY, theUpperBoundY)) ;
00245       } else{
00246           theProfile_d = 0;
00247           theProfile_u = 0;
00248           theProfile_s = 0;
00249           theProfile_c = 0;
00250           theProfile_b = 0;
00251           theProfile_g = 0;
00252           theProfile_ni = 0;
00253           theProfile_dus = 0;
00254           theProfile_dusg = 0;
00255       } 
00256     }  else {
00257           theProfile_all = 0;
00258           theProfile_d = 0;
00259           theProfile_u = 0;
00260           theProfile_s = 0;
00261           theProfile_c = 0;
00262           theProfile_b = 0;
00263           theProfile_g = 0;
00264           theProfile_ni = 0;
00265           theProfile_dus = 0;
00266           theProfile_dusg = 0;
00267     }
00268       // statistics if requested
00269     if ( theStatistics ) {
00270       if(theHisto_all) theHisto_all ->getTH2F()->Sumw2() ; 
00271       if(createProfile)
00272         if(theProfile_all) theProfile_all ->getTProfile()->Sumw2() ; 
00273       if (mcPlots_) {  
00274         if (mcPlots_>2) {
00275           theHisto_d   ->getTH2F()->Sumw2() ; 
00276           theHisto_u   ->getTH2F()->Sumw2() ; 
00277           theHisto_s   ->getTH2F()->Sumw2() ;
00278           theHisto_g   ->getTH2F()->Sumw2() ; 
00279           theHisto_dus ->getTH2F()->Sumw2() ; 
00280         } 
00281         theHisto_c   ->getTH2F()->Sumw2() ; 
00282         theHisto_b   ->getTH2F()->Sumw2() ; 
00283         theHisto_ni  ->getTH2F()->Sumw2() ; 
00284         theHisto_dusg->getTH2F()->Sumw2() ;
00285 
00286         if(createProfile) {
00287           if (mcPlots_>2) {
00288             theProfile_d   ->getTProfile()->Sumw2() ; 
00289             theProfile_u   ->getTProfile()->Sumw2() ; 
00290             theProfile_s   ->getTProfile()->Sumw2() ;
00291             theProfile_g   ->getTProfile()->Sumw2() ; 
00292             theProfile_dus ->getTProfile()->Sumw2() ; 
00293           } 
00294           theProfile_c   ->getTProfile()->Sumw2() ; 
00295           theProfile_b   ->getTProfile()->Sumw2() ; 
00296           theProfile_ni  ->getTProfile()->Sumw2() ; 
00297           theProfile_dusg->getTProfile()->Sumw2() ;
00298         }
00299       }
00300     }
00301   } else {
00302     HistoProviderDQM prov("Btag",folder);
00303     if(theHisto_all) theHisto_all   = prov.access(theBaseNameTitle + "ALL" ) ; 
00304     if (mcPlots_) {  
00305       if (mcPlots_>2) {
00306         theHisto_d     = prov.access(theBaseNameTitle + "D"   ) ; 
00307         theHisto_u     = prov.access(theBaseNameTitle + "U"   ) ; 
00308         theHisto_s     = prov.access(theBaseNameTitle + "S"   ) ;
00309         theHisto_g     = prov.access(theBaseNameTitle + "G"   ) ; 
00310         theHisto_dus   = prov.access(theBaseNameTitle + "DUS" ) ; 
00311       } 
00312       theHisto_c     = prov.access(theBaseNameTitle + "C"   ) ; 
00313       theHisto_b     = prov.access(theBaseNameTitle + "B"   ) ; 
00314       theHisto_ni    = prov.access(theBaseNameTitle + "NI"  ) ; 
00315       theHisto_dusg  = prov.access(theBaseNameTitle + "DUSG") ;
00316     }
00317 
00318     if(createProfile_) {
00319       if(theProfile_all) theProfile_all = prov.access(theBaseNameTitle + "_Profile_ALL");
00320       if(mcPlots_) {
00321         if (mcPlots_>2) {
00322           theProfile_d     = prov.access(theBaseNameTitle + "_Profile_D"   ) ; 
00323           theProfile_u     = prov.access(theBaseNameTitle + "_Profile_U"   ) ; 
00324           theProfile_s     = prov.access(theBaseNameTitle + "_Profile_S"   ) ;
00325           theProfile_g     = prov.access(theBaseNameTitle + "_Profile_G"   ) ; 
00326           theProfile_dus   = prov.access(theBaseNameTitle + "_Profile_DUS" ) ; 
00327         } 
00328         theProfile_c     = prov.access(theBaseNameTitle + "_Profile_C"   ) ; 
00329         theProfile_b     = prov.access(theBaseNameTitle + "_Profile_B"   ) ; 
00330         theProfile_ni    = prov.access(theBaseNameTitle + "_Profile_NI"  ) ; 
00331         theProfile_dusg  = prov.access(theBaseNameTitle + "_Profile_DUSG") ;
00332       }
00333     }
00334   }
00335 }
00336 
00337 
00338 template <class T, class G>
00339 FlavourHistograms2D<T, G>::~FlavourHistograms2D () {}
00340 
00341 
00342 // define arrays (if needed)
00343 // template <class T, class G>
00344 // void FlavourHistograms2D<T, G>::defineArray ( int * dimension , int max , int indexToPlot ) {
00345 //   // indexToPlot < 0 if all to be plotted
00346 //   theArrayDimension = dimension ;
00347 //   theMaxDimension   = max ;
00348 //   theIndexToPlot    = indexToPlot ;
00349 // }
00350   
00351 // fill entry
00352 template <class T, class G> void
00353   FlavourHistograms2D<T, G>::fill ( const int & flavour,  const T & variableX, const G & variableY, const float & w) const 
00354 {
00355   // For single variables and arrays (for arrays only a single index can be filled)
00356   fillVariable ( flavour , variableX , variableY , w ) ;
00357 }
00358 
00359 template <class T, class G> void
00360 FlavourHistograms2D<T, G>::fill ( const int & flavour,  const T & variableX, const G & variableY) const 
00361 {
00362   fill ( flavour , variableX , variableY , 1. ) ;
00363 }
00364 
00365 template <class T, class G> void
00366   FlavourHistograms2D<T, G>::fill ( const int & flavour,  const T * variableX, const G * variableY, const float & w) const
00367 {
00368   if ( theArrayDimension == 0 ) {       
00369     // single variable
00370     fillVariable ( flavour , *variableX, *variableY , w) ;
00371   } else {
00372     // array      
00373     int iMax = *theArrayDimension ;
00374     if ( *theArrayDimension > theMaxDimension ) iMax = theMaxDimension ;
00375     //
00376     for ( int i = 0 ; i != iMax ; ++i ) {
00377       // check if only one index to be plotted (<0: switched off -> plot all)
00378       if ( ( theIndexToPlot < 0 ) || ( i == theIndexToPlot ) ) { 
00379         fillVariable ( flavour , *(variableX+i) , *(variableY+i) , w) ;
00380       }
00381     }
00382 
00383     // if single index to be filled but not enough entries: fill 0.0 (convention!)
00384     if ( theIndexToPlot >= iMax ) { 
00385       // cout << "==>> The index to be filled is too big -> fill 0.0 : " << theBaseNameTitle << " : " << theIndexToPlot << " >= " << iMax << endl ;
00386       const T& theZeroT = static_cast<T> ( 0.0) ;
00387       const G& theZeroG = static_cast<T> ( 0.0 );
00388       fillVariable ( flavour , theZeroT , theZeroG , w ) ;
00389     }
00390   }
00391 } 
00392 
00393 template <class T, class G> void
00394   FlavourHistograms2D<T, G>::fill ( const int & flavour,  const T * variableX, const G * variableY) const
00395 {
00396   fill ( flavour,  variableX , variableY , 1. );
00397 }
00398 
00399 template <class T, class G>
00400 void FlavourHistograms2D<T, G>::settitle(const char* titleX, const char* titleY) {
00401  if(theHisto_all) theHisto_all ->setAxisTitle(titleX) ;
00402  if(theHisto_all) theHisto_all ->setAxisTitle(titleY, 2) ;
00403     if (mcPlots_) {  
00404       
00405       if(theHisto_d)  theHisto_d   ->setAxisTitle(titleX) ;
00406       if(theHisto_u)  theHisto_u   ->setAxisTitle(titleX) ;
00407       if(theHisto_s)  theHisto_s   ->setAxisTitle(titleX) ;
00408       if(theHisto_c)  theHisto_c   ->setAxisTitle(titleX) ;
00409       if(theHisto_b)  theHisto_b   ->setAxisTitle(titleX) ;
00410       if(theHisto_g)  theHisto_g   ->setAxisTitle(titleX) ;
00411       if(theHisto_ni) theHisto_ni  ->setAxisTitle(titleX) ;
00412       if(theHisto_dus) theHisto_dus ->setAxisTitle(titleX) ;
00413       if(theHisto_dusg)theHisto_dusg->setAxisTitle(titleX) ;
00414       if(theHisto_d)  theHisto_d   ->setAxisTitle(titleY, 2) ;
00415       if(theHisto_u)  theHisto_u   ->setAxisTitle(titleY, 2) ;
00416       if(theHisto_s)  theHisto_s   ->setAxisTitle(titleY, 2) ;
00417       if(theHisto_c)  theHisto_c   ->setAxisTitle(titleY, 2) ;
00418       if(theHisto_b)  theHisto_b   ->setAxisTitle(titleY, 2) ;
00419       if(theHisto_g)  theHisto_g   ->setAxisTitle(titleY, 2) ;
00420       if(theHisto_ni) theHisto_ni  ->setAxisTitle(titleY, 2) ;
00421       if(theHisto_dus) theHisto_dus ->setAxisTitle(titleY, 2) ;
00422       if(theHisto_dusg)theHisto_dusg->setAxisTitle(titleY, 2) ;
00423     }
00424 
00425   if(createProfile_) {
00426     if(theProfile_all) theProfile_all ->setAxisTitle(titleX) ;
00427     if(theProfile_all) theProfile_all ->setAxisTitle(titleY, 2) ;
00428     if (mcPlots_) {  
00429       
00430       if(theProfile_d)  theProfile_d   ->setAxisTitle(titleX) ;
00431       if(theProfile_u)  theProfile_u   ->setAxisTitle(titleX) ;
00432       if(theProfile_s)  theProfile_s   ->setAxisTitle(titleX) ;
00433       if(theProfile_c)  theProfile_c   ->setAxisTitle(titleX) ;
00434       if(theProfile_b)  theProfile_b   ->setAxisTitle(titleX) ;
00435       if(theProfile_g)  theProfile_g   ->setAxisTitle(titleX) ;
00436       if(theProfile_ni) theProfile_ni  ->setAxisTitle(titleX) ;
00437       if(theProfile_dus) theProfile_dus ->setAxisTitle(titleX) ;
00438       if(theProfile_dusg)theProfile_dusg->setAxisTitle(titleX) ;
00439       if(theProfile_d)  theProfile_d   ->setAxisTitle(titleY, 2) ;
00440       if(theProfile_u)  theProfile_u   ->setAxisTitle(titleY, 2) ;
00441       if(theProfile_s)  theProfile_s   ->setAxisTitle(titleY, 2) ;
00442       if(theProfile_c)  theProfile_c   ->setAxisTitle(titleY, 2) ;
00443       if(theProfile_b)  theProfile_b   ->setAxisTitle(titleY, 2) ;
00444       if(theProfile_g)  theProfile_g   ->setAxisTitle(titleY, 2) ;
00445       if(theProfile_ni) theProfile_ni  ->setAxisTitle(titleY, 2) ;
00446       if(theProfile_dus) theProfile_dus ->setAxisTitle(titleY, 2) ;
00447       if(theProfile_dusg)theProfile_dusg->setAxisTitle(titleY, 2) ;
00448     }
00449   }
00450 }
00451 
00452 // needed for efficiency computations -> this / b
00453 // (void : alternative would be not to overwrite the histos but to return a cloned HistoDescription)
00454 template <class T, class G>
00455 void FlavourHistograms2D<T, G>::divide ( const FlavourHistograms2D<T, G> & bHD ) const {
00456   // divide histos using binomial errors
00457   //
00458   // ATTENTION: It's the responsability of the user to make sure that the HistoDescriptions
00459   //            involved in this operation have been constructed with the statistics option switched on!!
00460   //
00461   if(theHisto_all) theHisto_all  ->getTH2F()-> Divide ( theHisto_all->getTH2F()  , bHD.histo_all () , 1.0 , 1.0 , "b" ) ;    
00462     if (mcPlots_) {  
00463       if (mcPlots_>2) {
00464         theHisto_d    ->getTH2F()-> Divide ( theHisto_d ->getTH2F()   , bHD.histo_d   () , 1.0 , 1.0 , "b" ) ;    
00465         theHisto_u    ->getTH2F()-> Divide ( theHisto_u ->getTH2F()   , bHD.histo_u   () , 1.0 , 1.0 , "b" ) ;
00466         theHisto_s    ->getTH2F()-> Divide ( theHisto_s ->getTH2F()   , bHD.histo_s   () , 1.0 , 1.0 , "b" ) ;
00467         theHisto_g    ->getTH2F()-> Divide ( theHisto_g  ->getTH2F()  , bHD.histo_g   () , 1.0 , 1.0 , "b" ) ;
00468         theHisto_dus  ->getTH2F()-> Divide ( theHisto_dus->getTH2F()  , bHD.histo_dus () , 1.0 , 1.0 , "b" ) ;
00469       }
00470       theHisto_c    ->getTH2F()-> Divide ( theHisto_c ->getTH2F()   , bHD.histo_c   () , 1.0 , 1.0 , "b" ) ;
00471       theHisto_b    ->getTH2F()-> Divide ( theHisto_b ->getTH2F()   , bHD.histo_b   () , 1.0 , 1.0 , "b" ) ;
00472       theHisto_ni   ->getTH2F()-> Divide ( theHisto_ni->getTH2F()   , bHD.histo_ni  () , 1.0 , 1.0 , "b" ) ;
00473       theHisto_dusg ->getTH2F()-> Divide ( theHisto_dusg->getTH2F() , bHD.histo_dusg() , 1.0 , 1.0 , "b" ) ;
00474     }
00475 }
00476   
00477 
00478 template <class T, class G>
00479   void FlavourHistograms2D<T, G>::fillVariable ( const int & flavour , const T & varX , const G & varY , const float & w) const {
00480   // all
00481   if(theHisto_all) theHisto_all->Fill ( varX, varY,w ) ;
00482   if(createProfile_)
00483     //if(theProfile_all) theProfile_all->Fill( varX, varY, w );
00484     if(theProfile_all) theProfile_all->Fill( varX, varY);
00485 
00486   //exit(-1);
00487   // flavour specific
00488   if (!mcPlots_) return;
00489 
00490   switch( flavour ) {
00491     case 1:
00492       if (mcPlots_>2) {
00493         theHisto_d->Fill( varX, varY,w );
00494         theHisto_dus->Fill( varX, varY,w );
00495       }
00496       theHisto_dusg->Fill( varX, varY,w );
00497       if(createProfile_) {
00498         //theProfile_d->Fill(varX, varY,w);
00499         //theProfile_dus->Fill(varX, varY,w);
00500         //theProfile_dusg->Fill(varX, varY,w);
00501         if (mcPlots_>2) {
00502           theProfile_d->Fill(varX, varY);
00503           theProfile_dus->Fill(varX, varY);
00504         }
00505         theProfile_dusg->Fill(varX, varY);
00506       }
00507       return;
00508     case 2:
00509       if (mcPlots_>2) {
00510         theHisto_u->Fill( varX, varY,w );
00511         theHisto_dus->Fill( varX, varY,w );
00512       }
00513       theHisto_dusg->Fill( varX, varY,w );
00514       if(createProfile_) {
00515         //theProfile_u->Fill(varX, varY,w);
00516         //theProfile_dus->Fill(varX, varY,w);
00517         //theProfile_dusg->Fill(varX, varY,w);
00518         if (mcPlots_>2) {
00519           theProfile_u->Fill(varX, varY);
00520           theProfile_dus->Fill(varX, varY);
00521         }
00522         theProfile_dusg->Fill(varX, varY);
00523       }
00524       return;
00525     case 3:
00526       if (mcPlots_>2) {
00527         theHisto_s->Fill( varX, varY,w );
00528         theHisto_dus->Fill( varX, varY,w );
00529       }
00530       theHisto_dusg->Fill( varX, varY,w );
00531       if(createProfile_) {
00532         //theProfile_s->Fill(varX, varY,w);
00533         //theProfile_dus->Fill(varX, varY,w);
00534         //theProfile_dusg->Fill(varX, varY,w);
00535         if (mcPlots_>2) {
00536           theProfile_s->Fill(varX, varY);
00537           theProfile_dus->Fill(varX, varY);
00538         }
00539         theProfile_dusg->Fill(varX, varY);
00540       }
00541       return;
00542     case 4:
00543       theHisto_c->Fill( varX, varY,w );
00544       //if(createProfile_) theProfile_c->Fill(varX, varY,w);
00545       if(createProfile_) theProfile_c->Fill(varX, varY);
00546       return;
00547     case 5:
00548       theHisto_b->Fill( varX, varY,w );
00549       //if(createProfile_) theProfile_b->Fill(varX, varY,w);
00550       if(createProfile_) theProfile_b->Fill(varX, varY);
00551       return;
00552     case 21:
00553       if (mcPlots_>2) theHisto_g->Fill( varX, varY,w );
00554       theHisto_dusg->Fill( varX, varY,w );
00555       if(createProfile_) {
00556         //theProfile_g->Fill(varX, varY,w);
00557         //theProfile_dusg->Fill(varX, varY,w);
00558         if (mcPlots_>2) theProfile_g->Fill(varX, varY);
00559         theProfile_dusg->Fill(varX, varY);
00560       }
00561       return;
00562     default:
00563       theHisto_ni->Fill( varX, varY,w );
00564       //if(createProfile_) theProfile_ni->Fill(varX, varY,w);
00565       if(createProfile_) theProfile_ni->Fill(varX, varY);
00566       return;
00567   }
00568 }
00569 
00570 template <class T, class G>
00571 std::vector<TH2F*> FlavourHistograms2D<T, G>::getHistoVector() const
00572 {
00573   std::vector<TH2F*> histoVector;
00574   if(theHisto_all) histoVector.push_back ( theHisto_all->getTH2F() );
00575     if (mcPlots_) {  
00576       if (mcPlots_>2) {
00577         histoVector.push_back ( theHisto_d->getTH2F()   );
00578         histoVector.push_back ( theHisto_u->getTH2F()   );
00579         histoVector.push_back ( theHisto_s->getTH2F()   );
00580         histoVector.push_back ( theHisto_g ->getTH2F()  );
00581         histoVector.push_back ( theHisto_dus->getTH2F() );
00582       }
00583       histoVector.push_back ( theHisto_c->getTH2F()   );
00584       histoVector.push_back ( theHisto_b->getTH2F()   );
00585       histoVector.push_back ( theHisto_ni->getTH2F()  );
00586       histoVector.push_back ( theHisto_dusg->getTH2F());
00587     }
00588   return histoVector;
00589 }
00590 
00591 template <class T, class G>
00592 std::vector<TProfile*> FlavourHistograms2D<T, G>::getProfileVector() const
00593 {
00594   std::vector<TProfile*> profileVector;
00595   if(createProfile_) {
00596     if(theProfile_all) profileVector.push_back ( theProfile_all->getTProfile() );
00597       if (mcPlots_) {  
00598         if (mcPlots_>2) {
00599           profileVector.push_back ( theProfile_d->getTProfile()   );
00600           profileVector.push_back ( theProfile_u->getTProfile()   );
00601           profileVector.push_back ( theProfile_s->getTProfile()   );
00602           profileVector.push_back ( theProfile_g ->getTProfile()  );
00603           profileVector.push_back ( theProfile_dus->getTProfile() );
00604         }
00605         profileVector.push_back ( theProfile_c->getTProfile()   );
00606         profileVector.push_back ( theProfile_b->getTProfile()   );
00607         profileVector.push_back ( theProfile_ni->getTProfile()  );
00608         profileVector.push_back ( theProfile_dusg->getTProfile());
00609       }
00610   }
00611   return profileVector;
00612 }
00613 
00614 #endif