CMS 3D CMS Logo

TaggingVariablePlotter.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace edm;
5 using namespace reco;
6 
8  const string &name, const ParameterSet &pSet,
9  const string &category, const string& label, unsigned int mc, DQMStore::IBooker & ibook) :
11  nBins(pSet.getParameter<unsigned int>("nBins")),
12  min(pSet.getParameter<double>("min")),
13  max(pSet.getParameter<double>("max"))
14 {
16  throw cms::Exception("Configuration")
17  << "Tagging variable \"" << name
18  << "\" does not exist." << endl;
19 
20  if (pSet.exists("logScale"))
21  logScale = pSet.getParameter<bool>("logScale");
22  else
23  logScale = false;
24 
25  std::vector<unsigned int> indices;
26  if (pSet.exists("indices"))
27  indices = pSet.getParameter< vector<unsigned int> >("indices");
28  else
29  indices.push_back(0);
30 
31  for (const unsigned int iter: indices) {
32  Plot plot;
33  plot.histo = std::make_shared<FlavourHistograms<double>>(
34  name + (iter ? Form("%d", iter) : "")
35  + (category.empty() ? "_" + label
36  : ("_" + category) + "_" + label),
38  false, logScale, true, "b", label,mc,ibook);
39  plot.index = iter;
40  plots.push_back(plot);
41  }
42 }
43 
45  const EtaPtBin &etaPtBin, const ParameterSet &pSet,
46  unsigned int mc, bool willFinalize, DQMStore::IBooker & ibook,
47  const string &category): BaseTagInfoPlotter(tagName, etaPtBin), mcPlots_(mc)
48 {
49  const std::string tagVarDir(theExtensionString.substr(1));
50 
51  if (willFinalize) return;
52 
53  const vector<string>& pSets = pSet.getParameterNames();
54  for (const std::string& iter: pSets) {
55  VariableConfig var(iter,
56  pSet.getParameter<ParameterSet>(iter),
57  category,tagVarDir, mcPlots_, ibook);
58  variables.push_back(var);
59  }
60 }
61 
62 
64 
65 
66 void TaggingVariablePlotter::analyzeTag(const BaseTagInfo *baseTagInfo, double jec, int jetFlavour, float w/*=1*/)
67 {
68  analyzeTag(baseTagInfo->taggingVariables(), jetFlavour,w);
69 }
70 
71 void TaggingVariablePlotter::analyzeTag(const TaggingVariableList &vars, int jetFlavour, float w/*=1*/)
72 {
73  for (const VariableConfig& cfg: variables) {
74  const std::vector<TaggingValue> values(vars.getList(cfg.var, false));
75  if (values.empty())
76  continue;
77 
78  const unsigned int& size = values.size();
79 
80  for (const VariableConfig::Plot& plot: cfg.plots) {
81  if (plot.index == 0) {
82  for (const TaggingValue& val: values)
83  plot.histo->fill(jetFlavour, val, w);
84  } else if (plot.index - 1 < size)
85  plot.histo->fill(jetFlavour, values[plot.index - 1], w);
86  }
87  }
88 }
size
Write out results.
TaggingVariablePlotter(const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, unsigned int mc, bool willFinalize, DQMStore::IBooker &ibook, const std::string &category=std::string())
T getParameter(std::string const &) const
std::vector< VariableConfig > variables
const double w
Definition: UKUtility.cc:23
virtual TaggingVariableList taggingVariables(void) const
returns a description of the extended informations in a TaggingVariableList
Definition: BaseTagInfo.h:39
const std::string theExtensionString
const EtaPtBin & etaPtBin()
bool exists(std::string const &parameterName) const
checks if a parameter exists
void analyzeTag(const reco::BaseTagInfo *baseTagInfo, double jec, int jetFlavour, float w=1) override
char const * label
float TaggingValue
std::shared_ptr< FlavourHistograms< double > > histo
std::vector< TaggingValue > getList(TaggingVariableName tag, bool throwOnEmptyList=true) const
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< std::string > getParameterNames() const
TaggingVariableName getTaggingVariableName(const std::string &name)
fixed size matrix
HLT enums.
vars
Definition: DeepTauId.cc:77
const char *const TaggingVariableDescription[]
VariableConfig(const std::string &name, const edm::ParameterSet &pSet, const std::string &category, const std::string &label, unsigned int mc, DQMStore::IBooker &ibook)