CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/DQMOffline/RecoB/interface/TrackIPHistograms.h

Go to the documentation of this file.
00001 #ifndef DQMOffline_RecoB_TrackIPHistograms_h
00002 #define DQMOffline_RecoB_TrackIPHistograms_h
00003 
00004 #include <string>
00005 
00006 #include "DataFormats/TrackReco/interface/Track.h"
00007 #include "DQMOffline/RecoB/interface/FlavourHistorgrams.h"
00008 
00009 template<class T>
00010 class TrackIPHistograms : public FlavourHistograms<T>
00011 {
00012   public:
00013 
00014   TrackIPHistograms(const std::string& baseNameTitle_ , const std::string& baseNameDescription_,
00015                     const int& nBins_, const double& lowerBound_, const double& upperBound_,
00016                     const bool& statistics, const bool& plotLog_, const bool& plotNormalized_,
00017                     const std::string& plotFirst_, const bool& update, const std::string& folder, const bool& mc, const bool& quality);
00018 
00019   virtual ~TrackIPHistograms(){};
00020 
00021   void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack) const;
00022  
00023   void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack) const;
00024 
00025   void settitle(const char* title);
00026 
00027   protected:
00028 
00029   void fillVariable ( const reco::TrackBase::TrackQuality& qual, const T & var, const bool& hasTrack) const;
00030 
00031   bool quality_;
00032 
00033   MonitorElement *theQual_undefined;
00034   MonitorElement *theQual_loose;
00035   MonitorElement *theQual_tight;
00036   MonitorElement *theQual_highpur;
00037 
00038   private:
00039   TrackIPHistograms(){}
00040 };
00041 
00042 template <class T>
00043 TrackIPHistograms<T>::TrackIPHistograms (const std::string& baseNameTitle_, const std::string& baseNameDescription_,
00044                                          const int& nBins_, const double& lowerBound_, const double& upperBound_,
00045                                          const bool& statistics_, const bool& plotLog_, const bool& plotNormalized_,
00046                                          const std::string& plotFirst_, const bool& update, const std::string& folder, const bool& mc, const bool& quality) :
00047   FlavourHistograms<T>(baseNameTitle_, baseNameDescription_, nBins_, lowerBound_, upperBound_, statistics_, plotLog_, plotNormalized_,
00048                        plotFirst_, update, folder, mc), quality_(quality)
00049 {
00050   if(quality_) {
00051     if(!update) {
00052       HistoProviderDQM prov("Btag",folder);
00053       theQual_undefined = prov.book1D( baseNameTitle_ + "QualUnDef" , baseNameDescription_ + " Undefined Quality", nBins_, lowerBound_, upperBound_);
00054       theQual_loose = prov.book1D( baseNameTitle_ + "QualLoose" , baseNameDescription_ + " Loose Quality", nBins_, lowerBound_, upperBound_);
00055       theQual_tight = prov.book1D( baseNameTitle_ + "QualTight" , baseNameDescription_ + " Tight Quality", nBins_, lowerBound_, upperBound_);
00056       theQual_highpur = prov.book1D( baseNameTitle_ + "QualHighPur" , baseNameDescription_ + " High Purity Quality", nBins_, lowerBound_, upperBound_);
00057 
00058       if( statistics_ ) {
00059         theQual_undefined->getTH1F()->Sumw2();
00060         theQual_loose->getTH1F()->Sumw2();
00061         theQual_tight->getTH1F()->Sumw2();
00062         theQual_highpur->getTH1F()->Sumw2();
00063       }
00064     } else {
00065       HistoProviderDQM prov("Btag",folder);
00066       theQual_undefined = prov.access(baseNameTitle_ + "QualUnDef");
00067       theQual_loose = prov.access(baseNameTitle_ + "QualLoose");
00068       theQual_tight = prov.access(baseNameTitle_ + "QualTight");
00069       theQual_highpur = prov.access(baseNameTitle_ + "QualHighPur");
00070     }
00071   }
00072 }
00073 
00074 template <class T>
00075 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack) const
00076 {
00077   FlavourHistograms<T>::fill(flavour, variable);
00078   if(quality_)
00079     fillVariable(quality, variable, hasTrack);
00080 }
00081 
00082 template <class T>
00083 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack) const
00084 {
00085   const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
00086   const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
00087   const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
00088 
00089   FlavourHistograms<T>::fill(flavour, variable);
00090   if( theArrayDimension == 0 && quality_) {
00091     fillVariable( quality, *variable);
00092   } else {
00093       int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
00094       for(int i = 0; i != iMax; ++i) {
00095         if( quality_ && (( theIndexToPlot < 0) || ( i == theIndexToPlot)) ) {
00096           fillVariable ( flavour , *(variable + i), hasTrack);
00097         }
00098       }
00099 
00100       if(theIndexToPlot >= iMax && quality_) {
00101         const T& theZero = static_cast<T> (0.0);
00102         fillVariable ( quality, theZero, hasTrack);
00103       }
00104   }
00105 }
00106 
00107 template <class T>
00108 void TrackIPHistograms<T>::settitle(const char* title)
00109 {
00110   FlavourHistograms<T>::settitle(title);
00111   theQual_undefined->setAxisTitle(title);
00112   theQual_loose->setAxisTitle(title);
00113   theQual_tight->setAxisTitle(title);
00114   theQual_highpur->setAxisTitle(title);
00115 }
00116 
00117 template<class T>
00118 void TrackIPHistograms<T>::fillVariable( const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack) const
00119 {
00120   if(!hasTrack || !quality_) return;
00121 
00122   switch(qual) {
00123     case reco::TrackBase::loose:
00124       theQual_loose->Fill(var);
00125       break;
00126     case reco::TrackBase::tight:
00127       theQual_tight->Fill(var);
00128       break;
00129     case reco::TrackBase::highPurity:
00130       theQual_highpur->Fill(var);
00131       break;
00132     default:
00133       theQual_undefined->Fill(var);
00134       break;
00135   }
00136 }
00137 
00138 #endif