CMS 3D CMS Logo

TrackCountingTagPlotter.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 using namespace RecoBTag;
6 
8  const EtaPtBin & etaPtBin, const edm::ParameterSet& pSet,
9  unsigned int mc,
10  bool wf, DQMStore::IBooker & ibook):
11  BaseTagInfoPlotter(tagName, etaPtBin), mcPlots_(mc),
12  nBinEffPur_(pSet.getParameter<int>("nBinEffPur")),
13  startEffPur_(pSet.getParameter<double>("startEffPur")),
14  endEffPur_(pSet.getParameter<double>("endEffPur")),
15  willFinalize_(wf), lowerIPSBound(-35.0), upperIPSBound(35.0)
16 {
17  const std::string dir(theExtensionString.substr(1));
18  if (willFinalize_) return;
19 
20  trkNbr3D = std::make_unique<FlavourHistograms<int>>
21  ("selTrksNbr_3D" + theExtensionString, "Number of selected tracks for 3D IPS" + theExtensionString, 31, -0.5, 30.5,
22  false, true, true, "b", dir, mc, ibook);
23 
24  trkNbr2D = std::make_unique<FlavourHistograms<int>>
25  ("selTrksNbr_2D" + theExtensionString, "Number of selected tracks for 2D IPS" + theExtensionString, 31, -0.5, 30.5,
26  false, true, true, "b", dir, mc, ibook);
27 
28  for (unsigned int i = 1; i <= 4; i++) {
29  tkcntHistosSig3D.push_back(std::make_unique<FlavourHistograms<double>>
30  ("ips" + std::to_string(i) + "_3D" + theExtensionString, "3D Significance of impact parameter " + std::to_string(i) + ". trk",
31  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook));
32  }
33  tkcntHistosSig3D.push_back(std::make_unique<FlavourHistograms<double>>
34  ("ips_3D" + theExtensionString, "3D Significance of impact parameter",
35  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook));
36 
37  for (unsigned int i = 1; i <= 4; i++) {
38  tkcntHistosSig2D.push_back(std::make_unique<FlavourHistograms<double>>
39  ("ips" + std::to_string(i) + "_2D" + theExtensionString, "2D Significance of impact parameter " + std::to_string(i) + ". trk",
40  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook));
41  }
42 
43  tkcntHistosSig2D.push_back(std::make_unique<FlavourHistograms<double>>
44  ("ips_2D" + theExtensionString, "2D Significance of impact parameter",
45  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook));
46 }
47 
48 
50 
51 void TrackCountingTagPlotter::analyzeTag(const reco::BaseTagInfo * baseTagInfo, double jec, int jetFlavour, float w)
52 {
53 
54  const reco::TrackCountingTagInfo * tagInfo =
55  dynamic_cast<const reco::TrackCountingTagInfo *>(baseTagInfo);
56 
57  if (!tagInfo) {
58  throw cms::Exception("Configuration")
59  << "BTagPerformanceAnalyzer: Extended TagInfo not of type TrackCountingTagInfo. " << endl;
60  }
61 
62  trkNbr3D->fill(jetFlavour, tagInfo->selectedTracks(0), w);
63  trkNbr2D->fill(jetFlavour, tagInfo->selectedTracks(1), w);
64 
65  for (int n = 0; n != tagInfo->selectedTracks(1) && n != 4; ++n)
66  tkcntHistosSig2D[n]->fill(jetFlavour, tagInfo->significance(n, 1), w);
67  for (int n = tagInfo->selectedTracks(1); n < 4; ++n)
68  tkcntHistosSig2D[n]->fill(jetFlavour, lowerIPSBound - 1.0, w);
69 
70  for (int n = 0; n != tagInfo->selectedTracks(0) && n != 4; ++n)
71  tkcntHistosSig3D[n]->fill(jetFlavour, tagInfo->significance(n, 0), w);
72  for (int n = tagInfo->selectedTracks(0); n < 4; ++n)
73  tkcntHistosSig3D[n]->fill(jetFlavour, lowerIPSBound - 1.0, w);
74 
75  for (int n = 0; n != tagInfo->selectedTracks(1); ++n)
76  tkcntHistosSig2D[4]->fill(jetFlavour, tagInfo->significance(n, 1), w);
77  for (int n = 0; n != tagInfo->selectedTracks(0); ++n)
78  tkcntHistosSig3D[4]->fill(jetFlavour, tagInfo->significance(n, 0), w);
79 }
80 
82 {
83  //
84  // final processing:
85  // produce the misid. vs. eff histograms
86  //
87  const std::string dir("TrackCounting" + theExtensionString);
88 
89  tkcntHistosSig3D.clear();
90  tkcntHistosSig2D.clear();
91  effPurFromHistos.clear();
92 
93  for (unsigned int i = 2; i <= 3; i++) {
94  tkcntHistosSig3D.push_back(
95  std::make_unique<FlavourHistograms<double>>
96  ("ips" + std::to_string(i) + "_3D" + theExtensionString, "3D Significance of impact parameter " + std::to_string(i) + ". trk",
97  50, lowerIPSBound, upperIPSBound, "b", dir, mcPlots_, igetter_));
98  effPurFromHistos.push_back(
99  std::make_unique<EffPurFromHistos>(*tkcntHistosSig3D.back(), dir, mcPlots_, ibook,
101  }
102 
103  for (unsigned int i = 2; i <= 3; i++) {
104  tkcntHistosSig2D.push_back(
105  std::make_unique<FlavourHistograms<double>>
106  ("ips" + std::to_string(i) + "_2D" + theExtensionString, "2D Significance of impact parameter " + std::to_string(i) + ". trk",
107  50, lowerIPSBound, upperIPSBound, "b", dir, mcPlots_, igetter_));
108  effPurFromHistos.push_back(
109  std::make_unique<EffPurFromHistos>(*tkcntHistosSig2D.back(), dir, mcPlots_, ibook,
111  }
112 
113  for (int n = 0; n != 4; ++n) effPurFromHistos[n]->compute(ibook);
114 }
115 
117 {
118  const std::string cName("TrackCountingPlots"+ theExtensionString);
119  setTDRStyle()->cd();
120  TCanvas canvas(cName.c_str(), cName.c_str(), 600, 900);
121  canvas.UseCurrentStyle();
122  if (willFinalize_) {
123  for (int n = 0; n != 2; ++n) {
124  canvas.Print((name + cName + ".ps").c_str());
125  canvas.Clear();
126  canvas.Divide(2,3);
127  canvas.cd(1);
128  effPurFromHistos[0+n]->discriminatorNoCutEffic().plot();
129  canvas.cd(2);
130  effPurFromHistos[0+n]->discriminatorCutEfficScan().plot();
131  canvas.cd(3);
132  effPurFromHistos[0+n]->plot();
133  canvas.cd(4);
134  effPurFromHistos[1+n]->discriminatorNoCutEffic().plot();
135  canvas.cd(5);
136  effPurFromHistos[1+n]->discriminatorCutEfficScan().plot();
137  canvas.cd(6);
138  effPurFromHistos[1+n]->plot();
139  }
140  return;
141  }
142 
143  canvas.Clear();
144  canvas.Divide(2,3);
145  canvas.Print((name + cName + ".ps[").c_str());
146 
147  canvas.cd(1);
148  trkNbr3D->plot();
149  canvas.cd(2);
150  tkcntHistosSig3D[4]->plot();
151  for (int n = 0; n < 4; n++) {
152  canvas.cd(3+n);
153  tkcntHistosSig3D[n]->plot();
154  }
155 
156  canvas.Print((name + cName + ".ps").c_str());
157  canvas.Clear();
158  canvas.Divide(2,3);
159 
160  canvas.cd(1);
161  trkNbr2D->plot();
162  canvas.cd(2);
163  tkcntHistosSig2D[4]->plot();
164  for (int n = 0; n != 4; ++n) {
165  canvas.cd(3+n);
166  tkcntHistosSig2D[n]->plot();
167  }
168 
169  canvas.Print((name + cName + ".ps").c_str());
170  canvas.Print((name + cName + ".ps]").c_str());
171 }
172 
173 
175 {
176  if (willFinalize_) {
177  for (int n = 0; n != 4; ++n)
178  effPurFromHistos[n]->epsPlot(name);
179  return;
180  }
181 
182  trkNbr2D->epsPlot(name);
183  trkNbr3D->epsPlot(name);
184  for (int n = 0; n != 5; ++n) {
185  tkcntHistosSig2D[n]->epsPlot(name);
186  tkcntHistosSig3D[n]->epsPlot(name);
187  }
188 }
std::unique_ptr< FlavourHistograms< int > > trkNbr3D
std::unique_ptr< FlavourHistograms< int > > trkNbr2D
std::vector< std::unique_ptr< FlavourHistograms< double > > > tkcntHistosSig2D
const double w
Definition: UKUtility.cc:23
const std::string theExtensionString
TrackCountingTagPlotter(const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, unsigned int mc, bool willfinalize, DQMStore::IBooker &ibook)
void epsPlot(const std::string &name) override
std::vector< std::unique_ptr< EffPurFromHistos > > effPurFromHistos
def setTDRStyle()
Definition: plotscripts.py:89
void psPlot(const std::string &name) override
virtual int selectedTracks(int ipType) const
virtual float significance(size_t n, int ip) const
std::vector< std::unique_ptr< FlavourHistograms< double > > > tkcntHistosSig3D
void finalize(DQMStore::IBooker &ibook_, DQMStore::IGetter &igetter_) override
Definition: Tools.h:23
def compute(min, max)
void analyzeTag(const reco::BaseTagInfo *baseTagInfo, double jec, int jetFlavour, float w) override
def canvas(sub, attr)
Definition: svgfig.py:482
dbl *** dir
Definition: mlp_gen.cc:35