CMS 3D CMS Logo

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