Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:16

0001 #include "DQMOffline/RecoB/interface/TrackCountingTagPlotter.h"
0002 #include "DQMOffline/RecoB/interface/Tools.h"
0003 
0004 using namespace std;
0005 using namespace RecoBTag;
0006 
0007 TrackCountingTagPlotter::TrackCountingTagPlotter(const std::string& tagName,
0008                                                  const EtaPtBin& etaPtBin,
0009                                                  const edm::ParameterSet& pSet,
0010                                                  unsigned int mc,
0011                                                  bool wf,
0012                                                  DQMStore::IBooker& ibook)
0013     : BaseTagInfoPlotter(tagName, etaPtBin),
0014       mcPlots_(mc),
0015       nBinEffPur_(pSet.getParameter<int>("nBinEffPur")),
0016       startEffPur_(pSet.getParameter<double>("startEffPur")),
0017       endEffPur_(pSet.getParameter<double>("endEffPur")),
0018       willFinalize_(wf),
0019       lowerIPSBound(-35.0),
0020       upperIPSBound(35.0) {
0021   const std::string dir(theExtensionString.substr(1));
0022   if (willFinalize_)
0023     return;
0024 
0025   trkNbr3D = std::make_unique<FlavourHistograms<int>>("selTrksNbr_3D" + theExtensionString,
0026                                                       "Number of selected tracks for 3D IPS" + theExtensionString,
0027                                                       31,
0028                                                       -0.5,
0029                                                       30.5,
0030                                                       false,
0031                                                       true,
0032                                                       true,
0033                                                       "b",
0034                                                       dir,
0035                                                       mc,
0036                                                       ibook);
0037 
0038   trkNbr2D = std::make_unique<FlavourHistograms<int>>("selTrksNbr_2D" + theExtensionString,
0039                                                       "Number of selected tracks for 2D IPS" + theExtensionString,
0040                                                       31,
0041                                                       -0.5,
0042                                                       30.5,
0043                                                       false,
0044                                                       true,
0045                                                       true,
0046                                                       "b",
0047                                                       dir,
0048                                                       mc,
0049                                                       ibook);
0050 
0051   for (unsigned int i = 1; i <= 4; i++) {
0052     tkcntHistosSig3D.push_back(std::make_unique<FlavourHistograms<double>>(
0053         "ips" + std::to_string(i) + "_3D" + theExtensionString,
0054         "3D Significance of impact parameter " + std::to_string(i) + ". trk",
0055         50,
0056         lowerIPSBound,
0057         upperIPSBound,
0058         false,
0059         true,
0060         true,
0061         "b",
0062         dir,
0063         mc,
0064         ibook));
0065   }
0066   tkcntHistosSig3D.push_back(std::make_unique<FlavourHistograms<double>>("ips_3D" + theExtensionString,
0067                                                                          "3D Significance of impact parameter",
0068                                                                          50,
0069                                                                          lowerIPSBound,
0070                                                                          upperIPSBound,
0071                                                                          false,
0072                                                                          true,
0073                                                                          true,
0074                                                                          "b",
0075                                                                          dir,
0076                                                                          mc,
0077                                                                          ibook));
0078 
0079   for (unsigned int i = 1; i <= 4; i++) {
0080     tkcntHistosSig2D.push_back(std::make_unique<FlavourHistograms<double>>(
0081         "ips" + std::to_string(i) + "_2D" + theExtensionString,
0082         "2D Significance of impact parameter " + std::to_string(i) + ". trk",
0083         50,
0084         lowerIPSBound,
0085         upperIPSBound,
0086         false,
0087         true,
0088         true,
0089         "b",
0090         dir,
0091         mc,
0092         ibook));
0093   }
0094 
0095   tkcntHistosSig2D.push_back(std::make_unique<FlavourHistograms<double>>("ips_2D" + theExtensionString,
0096                                                                          "2D Significance of impact parameter",
0097                                                                          50,
0098                                                                          lowerIPSBound,
0099                                                                          upperIPSBound,
0100                                                                          false,
0101                                                                          true,
0102                                                                          true,
0103                                                                          "b",
0104                                                                          dir,
0105                                                                          mc,
0106                                                                          ibook));
0107 }
0108 
0109 TrackCountingTagPlotter::~TrackCountingTagPlotter() {}
0110 
0111 void TrackCountingTagPlotter::analyzeTag(const reco::BaseTagInfo* baseTagInfo, double jec, int jetFlavour, float w) {
0112   const reco::TrackCountingTagInfo* tagInfo = dynamic_cast<const reco::TrackCountingTagInfo*>(baseTagInfo);
0113 
0114   if (!tagInfo) {
0115     throw cms::Exception("Configuration")
0116         << "BTagPerformanceAnalyzer: Extended TagInfo not of type TrackCountingTagInfo. " << endl;
0117   }
0118 
0119   trkNbr3D->fill(jetFlavour, tagInfo->selectedTracks(0), w);
0120   trkNbr2D->fill(jetFlavour, tagInfo->selectedTracks(1), w);
0121 
0122   for (int n = 0; n != tagInfo->selectedTracks(1) && n != 4; ++n)
0123     tkcntHistosSig2D[n]->fill(jetFlavour, tagInfo->significance(n, 1), w);
0124   for (int n = tagInfo->selectedTracks(1); n < 4; ++n)
0125     tkcntHistosSig2D[n]->fill(jetFlavour, lowerIPSBound - 1.0, w);
0126 
0127   for (int n = 0; n != tagInfo->selectedTracks(0) && n != 4; ++n)
0128     tkcntHistosSig3D[n]->fill(jetFlavour, tagInfo->significance(n, 0), w);
0129   for (int n = tagInfo->selectedTracks(0); n < 4; ++n)
0130     tkcntHistosSig3D[n]->fill(jetFlavour, lowerIPSBound - 1.0, w);
0131 
0132   for (int n = 0; n != tagInfo->selectedTracks(1); ++n)
0133     tkcntHistosSig2D[4]->fill(jetFlavour, tagInfo->significance(n, 1), w);
0134   for (int n = 0; n != tagInfo->selectedTracks(0); ++n)
0135     tkcntHistosSig3D[4]->fill(jetFlavour, tagInfo->significance(n, 0), w);
0136 }
0137 
0138 void TrackCountingTagPlotter::finalize(DQMStore::IBooker& ibook, DQMStore::IGetter& igetter_) {
0139   //
0140   // final processing:
0141   // produce the misid. vs. eff histograms
0142   //
0143   const std::string dir("TrackCounting" + theExtensionString);
0144 
0145   tkcntHistosSig3D.clear();
0146   tkcntHistosSig2D.clear();
0147   effPurFromHistos.clear();
0148 
0149   for (unsigned int i = 2; i <= 3; i++) {
0150     tkcntHistosSig3D.push_back(std::make_unique<FlavourHistograms<double>>(
0151         "ips" + std::to_string(i) + "_3D" + theExtensionString,
0152         "3D Significance of impact parameter " + std::to_string(i) + ". trk",
0153         50,
0154         lowerIPSBound,
0155         upperIPSBound,
0156         "b",
0157         dir,
0158         mcPlots_,
0159         igetter_));
0160     effPurFromHistos.push_back(std::make_unique<EffPurFromHistos>(
0161         *tkcntHistosSig3D.back(), dir, mcPlots_, ibook, nBinEffPur_, startEffPur_, endEffPur_));
0162   }
0163 
0164   for (unsigned int i = 2; i <= 3; i++) {
0165     tkcntHistosSig2D.push_back(std::make_unique<FlavourHistograms<double>>(
0166         "ips" + std::to_string(i) + "_2D" + theExtensionString,
0167         "2D Significance of impact parameter " + std::to_string(i) + ". trk",
0168         50,
0169         lowerIPSBound,
0170         upperIPSBound,
0171         "b",
0172         dir,
0173         mcPlots_,
0174         igetter_));
0175     effPurFromHistos.push_back(std::make_unique<EffPurFromHistos>(
0176         *tkcntHistosSig2D.back(), dir, mcPlots_, ibook, nBinEffPur_, startEffPur_, endEffPur_));
0177   }
0178 
0179   for (int n = 0; n != 4; ++n)
0180     effPurFromHistos[n]->compute(ibook);
0181 }
0182 
0183 void TrackCountingTagPlotter::psPlot(const std::string& name) {
0184   const std::string cName("TrackCountingPlots" + theExtensionString);
0185   setTDRStyle()->cd();
0186   TCanvas canvas(cName.c_str(), cName.c_str(), 600, 900);
0187   canvas.UseCurrentStyle();
0188   if (willFinalize_) {
0189     for (int n = 0; n != 2; ++n) {
0190       canvas.Print((name + cName + ".ps").c_str());
0191       canvas.Clear();
0192       canvas.Divide(2, 3);
0193       canvas.cd(1);
0194       effPurFromHistos[0 + n]->discriminatorNoCutEffic().plot();
0195       canvas.cd(2);
0196       effPurFromHistos[0 + n]->discriminatorCutEfficScan().plot();
0197       canvas.cd(3);
0198       effPurFromHistos[0 + n]->plot();
0199       canvas.cd(4);
0200       effPurFromHistos[1 + n]->discriminatorNoCutEffic().plot();
0201       canvas.cd(5);
0202       effPurFromHistos[1 + n]->discriminatorCutEfficScan().plot();
0203       canvas.cd(6);
0204       effPurFromHistos[1 + n]->plot();
0205     }
0206     return;
0207   }
0208 
0209   canvas.Clear();
0210   canvas.Divide(2, 3);
0211   canvas.Print((name + cName + ".ps[").c_str());
0212 
0213   canvas.cd(1);
0214   trkNbr3D->plot();
0215   canvas.cd(2);
0216   tkcntHistosSig3D[4]->plot();
0217   for (int n = 0; n < 4; n++) {
0218     canvas.cd(3 + n);
0219     tkcntHistosSig3D[n]->plot();
0220   }
0221 
0222   canvas.Print((name + cName + ".ps").c_str());
0223   canvas.Clear();
0224   canvas.Divide(2, 3);
0225 
0226   canvas.cd(1);
0227   trkNbr2D->plot();
0228   canvas.cd(2);
0229   tkcntHistosSig2D[4]->plot();
0230   for (int n = 0; n != 4; ++n) {
0231     canvas.cd(3 + n);
0232     tkcntHistosSig2D[n]->plot();
0233   }
0234 
0235   canvas.Print((name + cName + ".ps").c_str());
0236   canvas.Print((name + cName + ".ps]").c_str());
0237 }
0238 
0239 void TrackCountingTagPlotter::epsPlot(const std::string& name) {
0240   if (willFinalize_) {
0241     for (int n = 0; n != 4; ++n)
0242       effPurFromHistos[n]->epsPlot(name);
0243     return;
0244   }
0245 
0246   trkNbr2D->epsPlot(name);
0247   trkNbr3D->epsPlot(name);
0248   for (int n = 0; n != 5; ++n) {
0249     tkcntHistosSig2D[n]->epsPlot(name);
0250     tkcntHistosSig3D[n]->epsPlot(name);
0251   }
0252 }