CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  const unsigned int& mc,
10  const 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 
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 
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 
29  ("ips_3D" + theExtensionString, "3D Significance of impact parameter",
30  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
31 
32  tkcntHistosSig3D[0] = new FlavourHistograms<double>
33  ("ips1_3D" + theExtensionString, "3D Significance of impact parameter 1st trk",
34  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
35 
36  tkcntHistosSig3D[1] = new FlavourHistograms<double>
37  ("ips2_3D" + theExtensionString, "3D Significance of impact parameter 2nd trk",
38  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
39 
40  tkcntHistosSig3D[2] = new FlavourHistograms<double>
41  ("ips3_3D" + theExtensionString, "3D Significance of impact parameter 3rd trk",
42  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
43 
44  tkcntHistosSig3D[3] = new FlavourHistograms<double>
45  ("ips4_3D" + theExtensionString, "3D Significance of impact parameter 4th trk",
46  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
47 
49  ("ips_2D" + theExtensionString, "2D Significance of impact parameter",
50  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
51 
52  tkcntHistosSig2D[0] = new FlavourHistograms<double>
53  ("ips1_2D" + theExtensionString, "2D Significance of impact parameter 1st trk",
54  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
55 
56  tkcntHistosSig2D[1] = new FlavourHistograms<double>
57  ("ips2_2D" + theExtensionString, "2D Significance of impact parameter 2nd trk",
58  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
59 
60  tkcntHistosSig2D[2] = new FlavourHistograms<double>
61  ("ips3_2D" + theExtensionString, "2D Significance of impact parameter 3rd trk",
62  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
63 
64  tkcntHistosSig2D[3] = new FlavourHistograms<double>
65  ("ips4" + theExtensionString, "2D Significance of impact parameter 4th trk",
66  50, lowerIPSBound, upperIPSBound, false, true, true, "b", dir, mc, ibook) ;
67 }
68 
69 
71 {
72 
73  if (willFinalize_) {
74  for(int n=0; n != 4; ++n) {
75  if(n==1 || n==2){
76  delete tkcntHistosSig2D[n];
77  delete tkcntHistosSig3D[n];
78  }
79  delete effPurFromHistos[n];
80  }
81  return;
82  }
83 
84  delete trkNbr3D;
85  delete trkNbr2D;
86 
87  for(int n=0; n != 5; ++n) {
88  delete tkcntHistosSig2D[n];
89  delete tkcntHistosSig3D[n];
90  }
91 }
92 
93 void TrackCountingTagPlotter::analyzeTag (const reco::BaseTagInfo * baseTagInfo, const double & jec,
94  const int & jetFlavour)
95 {
96  analyzeTag(baseTagInfo,jetFlavour,1.);
97 }
98 
100  const double & jec,
101  const int & jetFlavour,
102  const float & w)
103 {
104 
106  dynamic_cast<const reco::TrackCountingTagInfo *>(baseTagInfo);
107 
108  if (!tagInfo) {
109  throw cms::Exception("Configuration")
110  << "BTagPerformanceAnalyzer: Extended TagInfo not of type TrackCountingTagInfo. " << endl;
111  }
112 
113  trkNbr3D->fill(jetFlavour, tagInfo->selectedTracks(0),w);
114  trkNbr2D->fill(jetFlavour, tagInfo->selectedTracks(1),w);
115 
116  for(int n=0; n != tagInfo->selectedTracks(1) && n != 4; ++n)
117  tkcntHistosSig2D[n]->fill(jetFlavour, tagInfo->significance(n,1),w);
118  for(int n=tagInfo->selectedTracks(1); n < 4; ++n)
119  tkcntHistosSig2D[n]->fill(jetFlavour, lowerIPSBound-1.0,w);
120 
121  for(int n=0; n != tagInfo->selectedTracks(0) && n != 4; ++n)
122  tkcntHistosSig3D[n]->fill(jetFlavour, tagInfo->significance(n,0),w);
123  for(int n=tagInfo->selectedTracks(0); n < 4; ++n)
124  tkcntHistosSig3D[n]->fill(jetFlavour, lowerIPSBound-1.0,w);
125 
126  for(int n=0; n != tagInfo->selectedTracks(1); ++n)
127  tkcntHistosSig2D[4]->fill(jetFlavour, tagInfo->significance(n,1),w);
128  for(int n=0; n != tagInfo->selectedTracks(0); ++n)
129  tkcntHistosSig3D[4]->fill(jetFlavour, tagInfo->significance(n,0),w);
130 }
131 
133 {
134  //
135  // final processing:
136  // produce the misid. vs. eff histograms
137  //
138  const std::string dir("TrackCounting"+theExtensionString);
139 
141  ("ips2_3D" + theExtensionString, "3D Significance of impact parameter 2nd trk",
142  50, lowerIPSBound, upperIPSBound, "b", dir, mcPlots_, igetter_) ;
143  effPurFromHistos[0] = new EffPurFromHistos (tkcntHistosSig3D[1],dir,mcPlots_, ibook,
145  endEffPur_);
146 
148  ("ips3_3D" + theExtensionString, "3D Significance of impact parameter 3rd trk",
149  50, lowerIPSBound, upperIPSBound, "b", dir, mcPlots_, igetter_) ;
150  effPurFromHistos[1] = new EffPurFromHistos (tkcntHistosSig3D[2],dir,mcPlots_, ibook,
152  endEffPur_);
153 
155  ("ips2_2D" + theExtensionString, "2D Significance of impact parameter 2nd trk",
156  50, lowerIPSBound, upperIPSBound, "b", dir, mcPlots_, igetter_) ;
157  effPurFromHistos[2] = new EffPurFromHistos (tkcntHistosSig2D[1],dir,mcPlots_, ibook,
159  endEffPur_);
160 
162  ("ips3_2D" + theExtensionString, "2D Significance of impact parameter 3rd trk",
163  50, lowerIPSBound, upperIPSBound, "b", dir, mcPlots_, igetter_) ;
164  effPurFromHistos[3] = new EffPurFromHistos (tkcntHistosSig2D[2],dir,mcPlots_, ibook,
166  endEffPur_);
167 
168  for(int n=0; n != 4; ++n) effPurFromHistos[n]->compute(ibook);
169 }
170 
172 {
173  const std::string cName("TrackCountingPlots"+ theExtensionString);
174  setTDRStyle()->cd();
175  TCanvas canvas(cName.c_str(), cName.c_str(), 600, 900);
176  canvas.UseCurrentStyle();
177  if (willFinalize_) {
178  for(int n=0; n != 2; ++n) {
179  canvas.Print((name + cName + ".ps").c_str());
180  canvas.Clear();
181  canvas.Divide(2,3);
182  canvas.cd(1);
184  canvas.cd(2);
186  canvas.cd(3);
187  effPurFromHistos[0+n]->plot();
188  canvas.cd(4);
190  canvas.cd(5);
192  canvas.cd(6);
193  effPurFromHistos[1+n]->plot();
194  }
195  return;
196  }
197 
198  canvas.Clear();
199  canvas.Divide(2,3);
200  canvas.Print((name + cName + ".ps[").c_str());
201 
202  canvas.cd(1);
203  trkNbr3D->plot();
204  canvas.cd(2);
205  tkcntHistosSig3D[4]->plot();
206  for(int n=0; n < 4; n++) {
207  canvas.cd(3+n);
208  tkcntHistosSig3D[n]->plot();
209  }
210 
211  canvas.Print((name + cName + ".ps").c_str());
212  canvas.Clear();
213  canvas.Divide(2,3);
214 
215  canvas.cd(1);
216  trkNbr2D->plot();
217  canvas.cd(2);
218  tkcntHistosSig2D[4]->plot();
219  for(int n=0; n != 4; ++n) {
220  canvas.cd(3+n);
221  tkcntHistosSig2D[n]->plot();
222  }
223 
224  canvas.Print((name + cName + ".ps").c_str());
225  canvas.Print((name + cName + ".ps]").c_str());
226 }
227 
228 
230 {
231  if (willFinalize_) {
232  for(int n=0; n != 4; ++n) effPurFromHistos[n]->epsPlot(name);
233  return;
234  }
235 
236  trkNbr2D->epsPlot(name);
237  trkNbr3D->epsPlot(name);
238  for(int n=0; n != 5; ++n) {
239  tkcntHistosSig2D[n]->epsPlot(name);
240  tkcntHistosSig3D[n]->epsPlot(name);
241  }
242 }
virtual void finalize(DQMStore::IBooker &ibook_, DQMStore::IGetter &igetter_)
FlavourHistograms< int > * trkNbr3D
void plot(TPad *theCanvas=0)
void epsPlot(const std::string &name)
FlavourHistograms< double > * tkcntHistosSig2D[5]
string fill
Definition: lumiContext.py:319
const double w
Definition: UKUtility.cc:23
FlavourHistograms< int > * trkNbr2D
const std::string theExtensionString
void fill(const int &flavour, const T &variable) const
void analyzeTag(const reco::BaseTagInfo *baseTagInfo, const double &jec, const int &jetFlavour)
void psPlot(const std::string &name)
def canvas
Definition: svgfig.py:481
void epsPlot(const std::string &name)
FlavourHistograms< double > * discriminatorCutEfficScan() const
void plot(TPad *theCanvas=0)
FlavourHistograms< double > * discriminatorNoCutEffic() const
FlavourHistograms< double > * tkcntHistosSig3D[5]
virtual int selectedTracks(int ipType) const
virtual float significance(size_t n, int ip) const
TrackCountingTagPlotter(const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const unsigned int &mc, const bool &willfinalize, DQMStore::IBooker &ibook)
void setTDRStyle()
Definition: plotscripts.py:87
dbl *** dir
Definition: mlp_gen.cc:35
EffPurFromHistos * effPurFromHistos[4]