CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HLTGenValPathSpecificSettingParser Class Reference

#include <HLTGenValPathSpecificSettingParser.h>

Public Member Functions

const std::vector< double > * getPathSpecificBins () const
 
const std::vector< edm::ParameterSet > * getPathSpecificCuts () const
 
const std::string * getTag () const
 
const bool havePathSpecificBins () const
 
 HLTGenValPathSpecificSettingParser (std::string pathSpecificSettings, std::vector< edm::ParameterSet > binnings, std::string vsVar)
 

Private Attributes

std::vector< double > pathSpecificBins_
 
std::vector< edm::ParameterSetpathSpecificCutsVector_
 
std::string tag_ = ""
 

Detailed Description

Definition at line 22 of file HLTGenValPathSpecificSettingParser.h.

Constructor & Destructor Documentation

◆ HLTGenValPathSpecificSettingParser()

HLTGenValPathSpecificSettingParser::HLTGenValPathSpecificSettingParser ( std::string  pathSpecificSettings,
std::vector< edm::ParameterSet binnings,
std::string  vsVar 
)

Definition at line 3 of file HLTGenValPathSpecificSettingParser.cc.

References edm::ParameterSet::addParameter(), pileupCalc::binning, edm::ParameterSet::empty(), Exception, pathSpecificBins_, pathSpecificCutsVector_, nano_mu_digi_cff::region, AlCaHLTBitMon_QueryRunRegistry::string, tag_, and B2GTnPMonitor_cfi::vsVar.

5  {
6  // splitting the cutstring
7  std::stringstream pathSpecificSettingsStream(pathSpecificSettings);
8  std::string pathSpecificSettingsSegment;
9  std::vector<std::string> pathSpecificSettingsSeglist;
10  while (std::getline(pathSpecificSettingsStream, pathSpecificSettingsSegment, ',')) {
11  pathSpecificSettingsSeglist.push_back(pathSpecificSettingsSegment);
12  }
13 
14  for (const auto& pathSpecificSetting : pathSpecificSettingsSeglist) {
15  // each of these strings is expected to contain exactly one equal sign
16  std::stringstream pathSpecificSettingStream(pathSpecificSetting);
17  std::string pathSpecificSettingSegment;
18  std::vector<std::string> pathSpecificSettingSeglist;
19  while (std::getline(pathSpecificSettingStream, pathSpecificSettingSegment, '=')) {
20  pathSpecificSettingSeglist.push_back(pathSpecificSettingSegment);
21  }
22  if (pathSpecificSettingSeglist.size() != 2)
23  throw cms::Exception("InputError") << "Path-specific cuts could not be parsed. Make sure that each parameter "
24  "contains exactly one equal sign!.\n";
25  const std::string cutVariable = pathSpecificSettingSeglist.at(0);
26  const std::string cutParameter = pathSpecificSettingSeglist.at(1);
27 
28  edm::ParameterSet rangeCutConfig;
29  if (cutVariable == "absEtaMax" || cutVariable == "absEtaCut") {
30  rangeCutConfig.addParameter<std::string>("rangeVar", "eta");
31  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {"-" + cutParameter + ":" + cutParameter});
32  } else if (cutVariable == "absEtaMin") {
33  rangeCutConfig.addParameter<std::string>("rangeVar", "eta");
34  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges",
35  {"-999:" + cutParameter, cutParameter + ":999"});
36  } else if (cutVariable == "ptMax") {
37  rangeCutConfig.addParameter<std::string>("rangeVar", "pt");
38  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {"0:" + cutParameter});
39  } else if (cutVariable == "ptMin" || cutVariable == "ptCut") {
40  rangeCutConfig.addParameter<std::string>("rangeVar", "pt");
41  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {cutParameter + ":999999"});
42  } else if (cutVariable == "etMax") {
43  rangeCutConfig.addParameter<std::string>("rangeVar", "et");
44  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {"0:" + cutParameter});
45  } else if (cutVariable == "etMin" || cutVariable == "etCut") {
46  rangeCutConfig.addParameter<std::string>("rangeVar", "et");
47  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {cutParameter + ":999999"});
48  } else if (cutVariable == "region") {
49  rangeCutConfig.addParameter<std::string>("rangeVar", "eta");
50 
51  // various predefined regions
52  // multiple regions might used, which are then split by a plus sign
53  std::stringstream cutParameterStream(cutParameter);
54  std::string cutParameterSegment;
55  std::vector<std::string> cutParameterSeglist;
56  while (std::getline(cutParameterStream, cutParameterSegment, '+')) {
57  cutParameterSeglist.push_back(cutParameterSegment);
58  }
59 
60  for (const auto& region : cutParameterSeglist) {
61  if (region == "EB") {
62  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {"-1.4442:1.4442"});
63  } else if (region == "EE") {
64  rangeCutConfig.addParameter<std::vector<std::string>>("allowedRanges", {"-999:-1.5660", "1.5660:999"});
65  } else {
66  throw cms::Exception("InputError") << "Region " + region + " not recognized.\n";
67  }
68  }
69 
70  } else if (cutVariable == "bins") {
71  // sets of binnings are read from the user-input ones passed in the "binnings" VPset
72 
73  bool binningFound = false;
74  bool binningUsed = false;
75  for (const auto& binning : binnings) {
76  if (binning.getParameter<std::string>("name") == cutParameter) {
77  if (binning.getParameter<std::string>("vsVar") == vsVar) {
78  if (binningUsed)
79  throw cms::Exception("InputError")
80  << "Multiple different binnings set for a path, this does not make sense!.\n";
81  pathSpecificBins_ = binning.getParameter<std::vector<double>>("binLowEdges");
82  binningUsed = true;
83  }
84  binningFound = true;
85  }
86  }
87  if (!binningFound)
88  throw cms::Exception("InputError")
89  << "Binning " << cutParameter << " not recognized! Please pass the definition to the module.\n";
90 
91  } else if (cutVariable == "tag") {
92  tag_ = cutParameter;
93  } else if (cutVariable == "autotag") {
94  // autotag is only used if no manual tag is set
95  if (tag_.empty())
96  tag_ = cutParameter;
97  } else {
98  throw cms::Exception("InputError")
99  << "Path-specific cut " + cutVariable +
100  " not recognized. The following options can be user: absEtaMax, absEtaCut, absEtaMin, ptMax, ptMin, "
101  "ptCut, etMax, etMin, etCut, region, bins and tag.\n";
102  }
103 
104  if (!rangeCutConfig.empty())
105  pathSpecificCutsVector_.push_back(rangeCutConfig);
106  }
107 }
std::vector< edm::ParameterSet > pathSpecificCutsVector_
bool empty() const
Definition: ParameterSet.h:201
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135

Member Function Documentation

◆ getPathSpecificBins()

const std::vector<double>* HLTGenValPathSpecificSettingParser::getPathSpecificBins ( ) const
inline

Definition at line 30 of file HLTGenValPathSpecificSettingParser.h.

References pathSpecificBins_.

◆ getPathSpecificCuts()

const std::vector<edm::ParameterSet>* HLTGenValPathSpecificSettingParser::getPathSpecificCuts ( ) const
inline

Definition at line 29 of file HLTGenValPathSpecificSettingParser.h.

References pathSpecificCutsVector_.

29 { return &pathSpecificCutsVector_; }
std::vector< edm::ParameterSet > pathSpecificCutsVector_

◆ getTag()

const std::string* HLTGenValPathSpecificSettingParser::getTag ( ) const
inline

Definition at line 32 of file HLTGenValPathSpecificSettingParser.h.

References tag_.

◆ havePathSpecificBins()

const bool HLTGenValPathSpecificSettingParser::havePathSpecificBins ( ) const
inline

Definition at line 31 of file HLTGenValPathSpecificSettingParser.h.

References pathSpecificBins_.

31 { return (!pathSpecificBins_.empty()); }

Member Data Documentation

◆ pathSpecificBins_

std::vector<double> HLTGenValPathSpecificSettingParser::pathSpecificBins_
private

◆ pathSpecificCutsVector_

std::vector<edm::ParameterSet> HLTGenValPathSpecificSettingParser::pathSpecificCutsVector_
private

◆ tag_

std::string HLTGenValPathSpecificSettingParser::tag_ = ""
private