Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQMOffline/RecoB/interface/TaggingVariablePlotter.h"
0002 
0003 using namespace std;
0004 using namespace edm;
0005 using namespace reco;
0006 
0007 TaggingVariablePlotter::VariableConfig::VariableConfig(const string &name,
0008                                                        const ParameterSet &pSet,
0009                                                        const string &category,
0010                                                        const string &label,
0011                                                        unsigned int mc,
0012                                                        DQMStore::IBooker &ibook)
0013     : var(getTaggingVariableName(name)),
0014       nBins(pSet.getParameter<unsigned int>("nBins")),
0015       min(pSet.getParameter<double>("min")),
0016       max(pSet.getParameter<double>("max")) {
0017   if (var == btau::lastTaggingVariable)
0018     throw cms::Exception("Configuration") << "Tagging variable \"" << name << "\" does not exist." << endl;
0019 
0020   if (pSet.exists("logScale"))
0021     logScale = pSet.getParameter<bool>("logScale");
0022   else
0023     logScale = false;
0024 
0025   std::vector<unsigned int> indices;
0026   if (pSet.exists("indices"))
0027     indices = pSet.getParameter<vector<unsigned int>>("indices");
0028   else
0029     indices.push_back(0);
0030 
0031   for (const unsigned int iter : indices) {
0032     Plot plot;
0033     plot.histo = std::make_shared<FlavourHistograms<double>>(
0034         name + (iter ? Form("%d", iter) : "") + (category.empty() ? "_" + label : ("_" + category) + "_" + label),
0035         TaggingVariableDescription[var],
0036         nBins,
0037         min,
0038         max,
0039         false,
0040         logScale,
0041         true,
0042         "b",
0043         label,
0044         mc,
0045         ibook);
0046     plot.index = iter;
0047     plots.push_back(plot);
0048   }
0049 }
0050 
0051 TaggingVariablePlotter::TaggingVariablePlotter(const std::string &tagName,
0052                                                const EtaPtBin &etaPtBin,
0053                                                const ParameterSet &pSet,
0054                                                unsigned int mc,
0055                                                bool willFinalize,
0056                                                DQMStore::IBooker &ibook,
0057                                                const string &category)
0058     : BaseTagInfoPlotter(tagName, etaPtBin), mcPlots_(mc) {
0059   const std::string tagVarDir(theExtensionString.substr(1));
0060 
0061   if (willFinalize)
0062     return;
0063 
0064   const vector<string> &pSets = pSet.getParameterNames();
0065   for (const std::string &iter : pSets) {
0066     VariableConfig var(iter, pSet.getParameter<ParameterSet>(iter), category, tagVarDir, mcPlots_, ibook);
0067     variables.push_back(var);
0068   }
0069 }
0070 
0071 TaggingVariablePlotter::~TaggingVariablePlotter() {}
0072 
0073 void TaggingVariablePlotter::analyzeTag(const BaseTagInfo *baseTagInfo, double jec, int jetFlavour, float w /*=1*/) {
0074   analyzeTag(baseTagInfo->taggingVariables(), jetFlavour, w);
0075 }
0076 
0077 void TaggingVariablePlotter::analyzeTag(const TaggingVariableList &vars, int jetFlavour, float w /*=1*/) {
0078   for (const VariableConfig &cfg : variables) {
0079     const std::vector<TaggingValue> values(vars.getList(cfg.var, false));
0080     if (values.empty())
0081       continue;
0082 
0083     const unsigned int &size = values.size();
0084 
0085     for (const VariableConfig::Plot &plot : cfg.plots) {
0086       if (plot.index == 0) {
0087         for (const TaggingValue &val : values)
0088           plot.histo->fill(jetFlavour, val, w);
0089       } else if (plot.index - 1 < size)
0090         plot.histo->fill(jetFlavour, values[plot.index - 1], w);
0091     }
0092   }
0093 }