00001 #include "DQMOffline/RecoB/interface/TrackCountingTagPlotter.h"
00002 #include "DQMOffline/RecoB/interface/Tools.h"
00003
00004 using namespace std;
00005 using namespace RecoBTag;
00006
00007 TrackCountingTagPlotter::TrackCountingTagPlotter(const std::string & tagName,
00008 const EtaPtBin & etaPtBin, const edm::ParameterSet& pSet, const bool& update, const bool& mc, const bool& wf) :
00009 BaseTagInfoPlotter(tagName, etaPtBin), mcPlots_(mc),
00010 nBinEffPur_(pSet.getParameter<int>("nBinEffPur")),
00011 startEffPur_(pSet.getParameter<double>("startEffPur")),
00012 endEffPur_(pSet.getParameter<double>("endEffPur")),
00013 willFinalize_(wf), lowerIPSBound(-35.0), upperIPSBound(35.0), finalized(false)
00014 {
00015 const std::string dir(theExtensionString.substr(1));
00016
00017 trkNbr3D = new FlavourHistograms<int>
00018 ("selTrksNbr_3D" + theExtensionString, "Number of selected tracks for 3D IPS" + theExtensionString, 31, -0.5, 30.5,
00019 false, true, true, "b", update, dir, mc);
00020
00021 trkNbr2D = new FlavourHistograms<int>
00022 ("selTrksNbr_2D" + theExtensionString, "Number of selected tracks for 2D IPS" + theExtensionString, 31, -0.5, 30.5,
00023 false, true, true, "b", update, dir, mc);
00024
00025 tkcntHistosSig3D[4] = new FlavourHistograms<double>
00026 ("ips_3D" + theExtensionString, "3D Significance of impact parameter",
00027 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00028
00029 tkcntHistosSig3D[0] = new FlavourHistograms<double>
00030 ("ips1_3D" + theExtensionString, "3D Significance of impact parameter 1st trk",
00031 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00032
00033 tkcntHistosSig3D[1] = new FlavourHistograms<double>
00034 ("ips2_3D" + theExtensionString, "3D Significance of impact parameter 2nd trk",
00035 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00036
00037 tkcntHistosSig3D[2] = new FlavourHistograms<double>
00038 ("ips3_3D" + theExtensionString, "3D Significance of impact parameter 3rd trk",
00039 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00040
00041 tkcntHistosSig3D[3] = new FlavourHistograms<double>
00042 ("ips4_3D" + theExtensionString, "3D Significance of impact parameter 4th trk",
00043 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00044
00045 tkcntHistosSig2D[4] = new FlavourHistograms<double>
00046 ("ips_2D" + theExtensionString, "2D Significance of impact parameter",
00047 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00048
00049 tkcntHistosSig2D[0] = new FlavourHistograms<double>
00050 ("ips1_2D" + theExtensionString, "2D Significance of impact parameter 1st trk",
00051 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00052
00053 tkcntHistosSig2D[1] = new FlavourHistograms<double>
00054 ("ips2_2D" + theExtensionString, "2D Significance of impact parameter 2nd trk",
00055 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00056
00057 tkcntHistosSig2D[2] = new FlavourHistograms<double>
00058 ("ips3_2D" + theExtensionString, "2D Significance of impact parameter 3rd trk",
00059 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00060
00061 tkcntHistosSig2D[3] = new FlavourHistograms<double>
00062 ("ips4" + theExtensionString, "2D Significance of impact parameter 4th trk",
00063 50, lowerIPSBound, upperIPSBound, false, true, true, "b", update, dir, mc) ;
00064
00065 if (willFinalize_) createPlotsForFinalize();
00066
00067 }
00068
00069
00070 TrackCountingTagPlotter::~TrackCountingTagPlotter ()
00071 {
00072
00073 delete trkNbr3D;
00074 delete trkNbr2D;
00075
00076 for(int n=0; n != 5; ++n) {
00077 delete tkcntHistosSig2D[n];
00078 delete tkcntHistosSig3D[n];
00079 }
00080 if (finalized) {
00081 for(int n=0; n != 4; ++n) delete effPurFromHistos[n];
00082 }
00083 }
00084
00085
00086 void TrackCountingTagPlotter::analyzeTag (const reco::BaseTagInfo * baseTagInfo,
00087 const int & jetFlavour)
00088 {
00089
00090 const reco::TrackCountingTagInfo * tagInfo =
00091 dynamic_cast<const reco::TrackCountingTagInfo *>(baseTagInfo);
00092
00093 if (!tagInfo) {
00094 throw cms::Exception("Configuration")
00095 << "BTagPerformanceAnalyzer: Extended TagInfo not of type TrackCountingTagInfo. " << endl;
00096 }
00097
00098 trkNbr3D->fill(jetFlavour, tagInfo->selectedTracks(0));
00099 trkNbr2D->fill(jetFlavour, tagInfo->selectedTracks(1));
00100
00101 for(int n=0; n != tagInfo->selectedTracks(1) && n != 4; ++n)
00102 tkcntHistosSig2D[n]->fill(jetFlavour, tagInfo->significance(n,1));
00103 for(int n=tagInfo->selectedTracks(1); n < 4; ++n)
00104 tkcntHistosSig2D[n]->fill(jetFlavour, lowerIPSBound-1.0);
00105
00106 for(int n=0; n != tagInfo->selectedTracks(0) && n != 4; ++n)
00107 tkcntHistosSig3D[n]->fill(jetFlavour, tagInfo->significance(n,0));
00108 for(int n=tagInfo->selectedTracks(0); n < 4; ++n)
00109 tkcntHistosSig3D[n]->fill(jetFlavour, lowerIPSBound-1.0);
00110
00111 for(int n=0; n != tagInfo->selectedTracks(1); ++n)
00112 tkcntHistosSig2D[4]->fill(jetFlavour, tagInfo->significance(n,1));
00113 for(int n=0; n != tagInfo->selectedTracks(0); ++n)
00114 tkcntHistosSig3D[4]->fill(jetFlavour, tagInfo->significance(n,0));
00115 }
00116
00117
00118
00119 void TrackCountingTagPlotter::createPlotsForFinalize (){
00120
00121
00122
00123
00124 const std::string dir("TrackCounting"+theExtensionString);
00125
00126 effPurFromHistos[0] = new EffPurFromHistos (tkcntHistosSig3D[1],dir,mcPlots_,
00127 nBinEffPur_, startEffPur_,
00128 endEffPur_);
00129 effPurFromHistos[1] = new EffPurFromHistos (tkcntHistosSig3D[2],dir,mcPlots_,
00130 nBinEffPur_, startEffPur_,
00131 endEffPur_);
00132 effPurFromHistos[2] = new EffPurFromHistos (tkcntHistosSig2D[1],dir,mcPlots_,
00133 nBinEffPur_, startEffPur_,
00134 endEffPur_);
00135 effPurFromHistos[3] = new EffPurFromHistos (tkcntHistosSig2D[2],dir,mcPlots_,
00136 nBinEffPur_, startEffPur_,
00137 endEffPur_);
00138 }
00139
00140 void TrackCountingTagPlotter::finalize ()
00141 {
00142 for(int n=0; n != 4; ++n) effPurFromHistos[n]->compute();
00143 finalized = true;
00144 }
00145
00146 void TrackCountingTagPlotter::psPlot(const std::string & name)
00147 {
00148 const std::string cName("TrackCountingPlots"+ theExtensionString);
00149 setTDRStyle()->cd();
00150 TCanvas canvas(cName.c_str(), cName.c_str(), 600, 900);
00151 canvas.UseCurrentStyle();
00152 canvas.Divide(2,3);
00153 canvas.Print((name + cName + ".ps[").c_str());
00154
00155 canvas.cd(1);
00156 trkNbr3D->plot();
00157 canvas.cd(2);
00158 tkcntHistosSig3D[4]->plot();
00159 for(int n=0; n < 4; n++) {
00160 canvas.cd(3+n);
00161 tkcntHistosSig3D[n]->plot();
00162 }
00163
00164 canvas.Print((name + cName + ".ps").c_str());
00165 canvas.Clear();
00166 canvas.Divide(2,3);
00167
00168 canvas.cd(1);
00169 trkNbr2D->plot();
00170 canvas.cd(2);
00171 tkcntHistosSig2D[4]->plot();
00172 for(int n=0; n != 4; ++n) {
00173 canvas.cd(3+n);
00174 tkcntHistosSig2D[n]->plot();
00175 }
00176
00177 if (finalized) {
00178 for(int n=0; n != 2; ++n) {
00179 canvas.Print((name + cName + ".ps").c_str());
00180 canvas.Clear();
00181 canvas.Divide(2,3);
00182 canvas.cd(1);
00183 effPurFromHistos[0+n]->discriminatorNoCutEffic()->plot();
00184 canvas.cd(2);
00185 effPurFromHistos[0+n]->discriminatorCutEfficScan()->plot();
00186 canvas.cd(3);
00187 effPurFromHistos[0+n]->plot();
00188 canvas.cd(4);
00189 effPurFromHistos[1+n]->discriminatorNoCutEffic()->plot();
00190 canvas.cd(5);
00191 effPurFromHistos[1+n]->discriminatorCutEfficScan()->plot();
00192 canvas.cd(6);
00193 effPurFromHistos[1+n]->plot();
00194 }
00195 }
00196
00197 canvas.Print((name + cName + ".ps").c_str());
00198 canvas.Print((name + cName + ".ps]").c_str());
00199 }
00200
00201
00202 void TrackCountingTagPlotter::epsPlot(const std::string & name)
00203 {
00204 trkNbr2D->epsPlot(name);
00205 trkNbr3D->epsPlot(name);
00206 for(int n=0; n != 5; ++n) {
00207 tkcntHistosSig2D[n]->epsPlot(name);
00208 tkcntHistosSig3D[n]->epsPlot(name);
00209 }
00210 if (finalized) {
00211 for(int n=0; n != 4; ++n) effPurFromHistos[n]->epsPlot(name);
00212 }
00213 }