Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:01

0001 /*!
0002   \file PFTauRenderPlugin
0003   \brief Display Plugin for Pixel DQM Histograms
0004   \author P.Merkel
0005 */
0006 
0007 #include "DQM/DQMRenderPlugin.h"
0008 #include "utils.h"
0009 
0010 #include "TProfile2D.h"
0011 #include "TStyle.h"
0012 #include "TCanvas.h"
0013 #include "TGraphPolar.h"
0014 #include "TColor.h"
0015 #include "TText.h"
0016 #include "TLine.h"
0017 #include <cassert>
0018 #include <string>
0019 
0020 using namespace std;
0021 
0022 class PFTauRenderPlugin : public DQMRenderPlugin
0023 {
0024 public:
0025   virtual bool applies( const VisDQMObject & o, const VisDQMImgInfo & )
0026     {
0027       return ((o.name.find( "RecoTauV/" ) != std::string::npos ) && (o.name.find( "Eff" ) != std::string::npos ) ); //Size and SumPt are already configured
0028     }
0029 
0030   virtual void preDraw( TCanvas * canvas, const VisDQMObject & o, const VisDQMImgInfo & , VisDQMRenderInfo & renderInfo)
0031     {
0032       canvas->cd();
0033       TH1* obj = dynamic_cast<TH1*>( o.object );
0034       if(!obj) return; //nothing to do for TH2
0035       //general setings
0036       //drawing options
0037       gStyle->SetOptStat(0);
0038       renderInfo.drawOptions = "E0";
0039       if(o.name.find( "Rejection" ) != std::string::npos ) canvas->SetLogy();
0040       if(o.name.find( "RealData"  ) != std::string::npos ) canvas->SetLogy();
0041 
0042       //titles and axis
0043       string discriminator = stripDicriminator(o.name);
0044       string variable = stripVar(o.name);
0045       obj->SetTitle((discriminator+" fake rate vs "+variable).c_str());
0046       obj->GetXaxis()->SetTitle(variable.c_str());
0047       obj->GetYaxis()->SetTitle("fake rate");
0048       double min = (canvas->GetLogy() ) ? 0.001 : 0.;
0049       double max = (canvas->GetLogy() ) ? 2.    : 1.2;
0050       obj->GetYaxis()->SetRangeUser(min,max);
0051       obj->SetMarkerStyle(20);
0052     }
0053 
0054   virtual void postDraw( TCanvas *, const VisDQMObject &, const VisDQMImgInfo & )
0055     {
0056     }
0057 
0058 private:
0059 
0060   string stripDicriminator(string name)
0061   {
0062     return name.substr(name.rfind("/")+1,name.rfind("Eff")-name.rfind("/")-1);
0063   }
0064   string stripVar(string name)
0065   {
0066     return name.substr(name.rfind("Eff")+3);
0067   }
0068 };
0069 
0070 static PFTauRenderPlugin instance;