CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauRenderPlugin.cc
Go to the documentation of this file.
1 
9 #include "DQM/DQMRenderPlugin.h"
10 #include "utils.h"
11 
12 #include "TProfile2D.h"
13 #include "TStyle.h"
14 #include "TCanvas.h"
15 #include "TGraphPolar.h"
16 #include "TColor.h"
17 #include "TText.h"
18 #include "TLine.h"
19 #include <cassert>
20 #include <string>
21 
22 using namespace std;
23 
24 class PFTauRenderPlugin : public DQMRenderPlugin
25 {
26 public:
27  virtual bool applies( const VisDQMObject & o, const VisDQMImgInfo & )
28  {
29  return ((o.name.find( "RecoTauV/" ) != std::string::npos ) && (o.name.find( "Eff" ) != std::string::npos ) ); //Size and SumPt are already configured
30  }
31 
32  virtual void preDraw( TCanvas * canvas, const VisDQMObject & o, const VisDQMImgInfo & , VisDQMRenderInfo & renderInfo)
33  {
34  canvas->cd();
35  TH1* obj = dynamic_cast<TH1*>( o.object );
36  if(!obj) return; //nothing to do for TH2
37  //general setings
38  //drawing options
39  gStyle->SetOptStat(0);
40  renderInfo.drawOptions = "E0";
41  if(o.name.find( "Rejection" ) != std::string::npos ) canvas->SetLogy();
42  if(o.name.find( "RealData" ) != std::string::npos ) canvas->SetLogy();
43 
44  //titles and axis
45  string discriminator = stripDicriminator(o.name);
46  string variable = stripVar(o.name);
47  obj->SetTitle((discriminator+" fake rate vs "+variable).c_str());
48  obj->GetXaxis()->SetTitle(variable.c_str());
49  obj->GetYaxis()->SetTitle("fake rate");
50  double min = (canvas->GetLogy() ) ? 0.001 : 0.;
51  double max = (canvas->GetLogy() ) ? 2. : 1.2;
52  obj->GetYaxis()->SetRangeUser(min,max);
53  obj->SetMarkerStyle(20);
54  }
55 
56  virtual void postDraw( TCanvas *, const VisDQMObject &, const VisDQMImgInfo & )
57  {
58  }
59 
60 private:
61 
62  string stripDicriminator(string name)
63  {
64  return name.substr(name.rfind("/")+1,name.rfind("Eff")-name.rfind("/")-1);
65  }
66  string stripVar(string name)
67  {
68  return name.substr(name.rfind("Eff")+3);
69  }
70 };
71 
virtual void postDraw(TCanvas *, const VisDQMObject &, const VisDQMImgInfo &)
static PFTauRenderPlugin instance
#define min(a, b)
Definition: mlp_lapack.h:161
virtual void preDraw(TCanvas *canvas, const VisDQMObject &o, const VisDQMImgInfo &, VisDQMRenderInfo &renderInfo)
def canvas
Definition: svgfig.py:481
const T & max(const T &a, const T &b)
virtual bool applies(const VisDQMObject &o, const VisDQMImgInfo &)
string stripVar(string name)
string stripDicriminator(string name)