CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Validation/RecoTau/Tools/PFTauRenderPlugin.cc

Go to the documentation of this file.
00001 
00009 #include "DQM/DQMRenderPlugin.h"
00010 #include "utils.h"
00011 
00012 #include "TProfile2D.h"
00013 #include "TStyle.h"
00014 #include "TCanvas.h"
00015 #include "TGraphPolar.h"
00016 #include "TColor.h"
00017 #include "TText.h"
00018 #include "TLine.h"
00019 #include <cassert>
00020 #include <string>
00021 
00022 using namespace std;
00023 
00024 class PFTauRenderPlugin : public DQMRenderPlugin
00025 {
00026 public:
00027   virtual bool applies( const VisDQMObject & o, const VisDQMImgInfo & )
00028     {
00029       return ((o.name.find( "RecoTauV/" ) != std::string::npos ) && (o.name.find( "Eff" ) != std::string::npos ) ); //Size and SumPt are already configured
00030     }
00031 
00032   virtual void preDraw( TCanvas * canvas, const VisDQMObject & o, const VisDQMImgInfo & , VisDQMRenderInfo & renderInfo)
00033     {
00034       canvas->cd();
00035       TH1* obj = dynamic_cast<TH1*>( o.object );
00036       if(!obj) return; //nothing to do for TH2
00037       //general setings
00038       //drawing options
00039       gStyle->SetOptStat(0);
00040       renderInfo.drawOptions = "E0";
00041       if(o.name.find( "Rejection" ) != std::string::npos ) canvas->SetLogy();
00042       if(o.name.find( "RealData"  ) != std::string::npos ) canvas->SetLogy();
00043 
00044       //titles and axis
00045       string discriminator = stripDicriminator(o.name);
00046       string variable = stripVar(o.name);
00047       obj->SetTitle((discriminator+" fake rate vs "+variable).c_str());
00048       obj->GetXaxis()->SetTitle(variable.c_str());
00049       obj->GetYaxis()->SetTitle("fake rate");
00050       double min = (canvas->GetLogy() ) ? 0.001 : 0.;
00051       double max = (canvas->GetLogy() ) ? 2.    : 1.2;
00052       obj->GetYaxis()->SetRangeUser(min,max);
00053       obj->SetMarkerStyle(20);
00054     }
00055 
00056   virtual void postDraw( TCanvas *, const VisDQMObject &, const VisDQMImgInfo & )
00057     {
00058     }
00059 
00060 private:
00061 
00062   string stripDicriminator(string name)
00063   {
00064     return name.substr(name.rfind("/")+1,name.rfind("Eff")-name.rfind("/")-1);
00065   }
00066   string stripVar(string name)
00067   {
00068     return name.substr(name.rfind("Eff")+3);
00069   }
00070 };
00071 
00072 static PFTauRenderPlugin instance;