CMS 3D CMS Logo

HLTConfigProvider.cc
Go to the documentation of this file.
1 
21 
24 
25 #include <regex>
26 
27 // an empty dummy config data used when we fail to initialize
29  static const HLTConfigData dummyHLTConfigData;
30  return &dummyHLTConfigData;
31 }
32 
34  : processName_(""), inited_(false), changed_(true), hltConfigData_(s_dummyHLTConfigData()) {}
35 
37  const edm::EventSetup& iSetup,
38  const std::string& processName,
39  bool& changed) {
40  using namespace std;
41  using namespace edm;
42 
43  LogInfo("HLTConfigProvider") << "Called (R) with processName '" << processName << "' for " << iRun.id() << endl;
44 
46 
48  changed = changed_;
49  return inited_;
50 }
51 
53  using namespace std;
54  using namespace edm;
55 
56  const ProcessHistory::const_iterator hb(iHistory.begin());
57  const ProcessHistory::const_iterator he(iHistory.end());
58 
59  ProcessConfiguration processConfiguration;
60  const edm::ParameterSet* processPSet(nullptr);
61 
63  if (processName_ == "*") {
64  // auto-discovery of process name
65  for (ProcessHistory::const_iterator hi = hb; hi != he; ++hi) {
66  if (iHistory.getConfigurationForProcess(hi->processName(), processConfiguration)) {
67  processPSet = edm::pset::Registry::instance()->getMapped(processConfiguration.parameterSetID());
68  if ((processPSet != nullptr) && (processPSet->exists("hltTriggerSummaryAOD"))) {
69  processName_ = hi->processName();
70  }
71  }
72  }
73  if (processName_ == "*") {
74  LogError("HLTConfigProvider") << "Auto-discovery of processName failed!" << endl;
75  clear();
76  return;
77  } else {
78  LogInfo("HLTConfigProvider") << "Auto-discovered processName: '" << processName_ << "'" << endl;
79  }
80  }
81  if (processName_ == "@currentProcess") {
83  }
84 
86  unsigned int n(0);
87  for (ProcessHistory::const_iterator hi = hb; hi != he; ++hi) {
88  if (hi->processName() == processName_) {
89  n++;
90  }
91  }
92  if (n > 1) {
93  LogError("HLTConfigProvider") << " ProcessName '" << processName_ << " found " << n << " times in history!" << endl;
94  clear();
95  return;
96  }
97 
99  if (iHistory.getConfigurationForProcess(processName_, processConfiguration)) {
100  if ((hltConfigData_ != s_dummyHLTConfigData()) && (processConfiguration.parameterSetID() == hltConfigData_->id())) {
101  changed_ = false;
102  inited_ = true;
103  return;
104  } else {
105  getDataFrom(processConfiguration.parameterSetID());
106  }
107  } else {
108  LogError("HLTConfigProvider") << "Falling back to ProcessName-only init using ProcessName '" << processName_
109  << "' !";
111  return;
112  }
113 }
114 
116  //is it in our registry?
118  const HLTConfigData* d = reg->getMapped(iID);
119  if (nullptr != d) {
120  changed_ = true;
121  inited_ = true;
122  hltConfigData_ = d;
123  } else {
124  const edm::ParameterSet* processPSet = nullptr;
125  if (nullptr != (processPSet = edm::pset::Registry::instance()->getMapped(iID))) {
126  if (not processPSet->id().isValid()) {
127  clear();
128  edm::LogError("HLTConfigProvider") << "ProcessPSet found is empty!";
129  changed_ = true;
130  inited_ = false;
132  return;
133  } else {
134  clear();
136  changed_ = true;
137  inited_ = true;
139  return;
140  }
141  } else {
142  clear();
143  edm::LogError("HLTConfigProvider") << "ProcessPSet not found in regsistry!";
144  changed_ = true;
145  inited_ = false;
147  return;
148  }
149  }
150  return;
151 }
152 
154  using namespace std;
155  using namespace edm;
156 
157  // Obtain ParameterSetID for requested process (with name
158  // processName) from pset registry
159  string pNames("");
160  string hNames("");
161  const ParameterSet* pset = nullptr;
162  ParameterSetID psetID;
163  unsigned int nPSets(0);
164  const edm::pset::Registry* registry_(pset::Registry::instance());
165  const edm::pset::Registry::const_iterator rb(registry_->begin());
166  const edm::pset::Registry::const_iterator re(registry_->end());
167  for (edm::pset::Registry::const_iterator i = rb; i != re; ++i) {
168  if (i->second.existsAs<string>("@process_name", true) and i->second.existsAs<vector<string>>("@paths", true)) {
169  const std::string pName(i->second.getParameter<string>("@process_name"));
170  pNames += pName + " ";
171  if (pName == processName) {
172  psetID = i->first;
173  nPSets++;
174  if ((hltConfigData_ != s_dummyHLTConfigData()) && (hltConfigData_->id() == psetID)) {
175  hNames += tableName();
176  } else if (nullptr != (pset = registry_->getMapped(psetID))) {
177  if (pset->exists("HLTConfigVersion")) {
178  const ParameterSet& HLTPSet(pset->getParameterSet("HLTConfigVersion"));
179  if (HLTPSet.exists("tableName")) {
180  hNames += HLTPSet.getParameter<string>("tableName") + " ";
181  }
182  }
183  }
184  }
185  }
186  }
187 
188  LogVerbatim("HLTConfigProvider") << "Unordered list of all process names found: " << pNames << "." << endl;
189 
190  LogVerbatim("HLTConfigProvider") << "HLT TableName of each selected process: " << hNames << "." << endl;
191 
192  if (nPSets == 0) {
193  LogError("HLTConfigProvider") << " Process name '" << processName << "' not found in registry!" << endl;
194  clear();
195  return;
196  }
197  if (psetID == ParameterSetID()) {
198  LogError("HLTConfigProvider") << " Process name '" << processName << "' found but ParameterSetID invalid!" << endl;
199  clear();
200  return;
201  }
202  if (nPSets > 1) {
203  LogError("HLTConfigProvider") << " Process name '" << processName << " found " << nPSets << " times in registry!"
204  << endl;
205  clear();
206  return;
207  }
208 
209  getDataFrom(psetID);
210 
211  return;
212 }
213 
215  // clear all data members
216 
217  processName_ = "";
218  inited_ = false;
219  changed_ = true;
221 
222  return;
223 }
224 
225 const std::vector<std::string> HLTConfigProvider::matched(const std::vector<std::string>& inputs,
226  const std::string& pattern) {
227  std::vector<std::string> matched;
228  const std::regex regexp(edm::glob2reg(pattern));
229  const unsigned int n(inputs.size());
230  for (unsigned int i = 0; i < n; ++i) {
231  const std::string& input(inputs[i]);
232  if (std::regex_match(input, regexp))
233  matched.push_back(input);
234  }
235  return matched;
236 }
237 
239  const std::regex regexp("_v[0-9]+$");
240  return std::regex_replace(trigger, regexp, "");
241 }
242 
243 const std::vector<std::string> HLTConfigProvider::restoreVersion(const std::vector<std::string>& inputs,
244  const std::string& trigger) {
245  return matched(inputs, trigger + "_v[0-9]+$");
246 }
collection_type::const_iterator const_iterator
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
map_type::const_iterator const_iterator
Definition: Registry.h:61
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
bool insertMapped(value_type const &v)
static PFTauRenderPlugin instance
void getDataFrom(const edm::ParameterSetID &iID)
bool getMapped(key_type const &k, value_type &result) const
edm::ParameterSetID id() const
technical: id() function needed for use with ThreadSafeRegistry
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:19
static const HLTConfigData * s_dummyHLTConfigData()
std::string processName_
data members
Log< level::Error, false > LogError
const_iterator end() const
bool isValid() const
Definition: Hash.h:141
bool getConfigurationForProcess(std::string const &name, ProcessConfiguration &config) const
static const std::string removeVersion(const std::string &trigger)
static std::string const input
Definition: EdmProvDump.cc:50
const_iterator end() const
Definition: Registry.h:65
static ThreadSafeRegistry * instance()
const HLTConfigData * hltConfigData_
ParameterSetID id() const
const edm::ParameterSet & processPSet() const
ParameterSet of process.
Definition: EPCuts.h:4
ProcessHistory const & processHistory() const
Definition: Run.cc:115
Hash< ParameterSetType > ParameterSetID
HLTConfigProvider()
c&#39;tor
d
Definition: ztail.py:151
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
RunID const & id() const
Definition: RunBase.h:39
Log< level::Info, false > LogInfo
bool changed() const
changed?
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
const std::string & processName() const
process name
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const std::string & tableName() const
HLT ConfDB table name.
HLT enums.
const_iterator begin() const
Definition: Registry.h:63
static Registry * instance()
Definition: Registry.cc:12
Definition: Run.h:45
const_iterator begin() const