CMS 3D CMS Logo

HLTConfigProvider.cc
Go to the documentation of this file.
1 
22 
25 
26 #include <regex>
27 
28 // an empty dummy config data used when we fail to initialize
30  static const HLTConfigData dummyHLTConfigData;
31  return &dummyHLTConfigData;
32 }
33 
35  : processName_(""), inited_(false), changed_(true), hltConfigData_(s_dummyHLTConfigData()) {}
36 
38  const edm::EventSetup& iSetup,
39  const std::string& processName,
40  bool& changed) {
41  edm::LogInfo("HLTConfigProvider") << "Called (R) with processName '" << processName << "' for " << iRun.id();
42 
44 
46  changed = changed_;
47  return inited_;
48 }
49 
51  using namespace edm;
52 
53  const ProcessHistory::const_iterator hb(iHistory.begin());
54  const ProcessHistory::const_iterator he(iHistory.end());
55 
56  ProcessConfiguration processConfiguration;
57  const edm::ParameterSet* processPSet(nullptr);
58 
60 
61  if (processName_ == "*") {
62  // auto-discovery of process name
63  for (ProcessHistory::const_iterator hi = hb; hi != he; ++hi) {
64  if (iHistory.getConfigurationForProcess(hi->processName(), processConfiguration)) {
65  processPSet = edm::pset::Registry::instance()->getMapped(processConfiguration.parameterSetID());
66  CMS_SA_ALLOW if ((processPSet != nullptr) && (processPSet->exists("hltTriggerSummaryAOD"))) {
67  processName_ = hi->processName();
68  }
69  }
70  }
71  if (processName_ == "*") {
72  LogError("HLTConfigProvider") << "Auto-discovery of processName failed!";
73  clear();
74  return;
75  } else {
76  LogInfo("HLTConfigProvider") << "Auto-discovered processName: '" << processName_ << "'";
77  }
78  }
79  if (processName_ == "@currentProcess") {
81  }
82 
84  unsigned int n(0);
85  for (ProcessHistory::const_iterator hi = hb; hi != he; ++hi) {
86  if (hi->processName() == processName_) {
87  n++;
88  }
89  }
90  if (n > 1) {
91  LogError("HLTConfigProvider") << " ProcessName '" << processName_ << " found " << n << " times in history!";
92  clear();
93  return;
94  }
95 
97  if (iHistory.getConfigurationForProcess(processName_, processConfiguration)) {
98  if ((hltConfigData_ != s_dummyHLTConfigData()) && (processConfiguration.parameterSetID() == hltConfigData_->id())) {
99  changed_ = false;
100  inited_ = true;
101  return;
102  } else {
103  getDataFrom(processConfiguration.parameterSetID());
104  }
105  } else {
106  LogError("HLTConfigProvider") << "Falling back to ProcessName-only init using ProcessName '" << processName_
107  << "' !";
109  return;
110  }
111 }
112 
114  //is it in our registry?
116  const HLTConfigData* d = reg->getMapped(iID);
117  if (nullptr != d) {
118  changed_ = true;
119  inited_ = true;
120  hltConfigData_ = d;
121  } else {
122  const edm::ParameterSet* processPSet = nullptr;
123  if (nullptr != (processPSet = edm::pset::Registry::instance()->getMapped(iID))) {
124  if (not processPSet->id().isValid()) {
125  clear();
126  edm::LogError("HLTConfigProvider") << "ProcessPSet found is empty!";
127  changed_ = true;
128  inited_ = false;
130  return;
131  } else {
132  clear();
134  changed_ = true;
135  inited_ = true;
137  return;
138  }
139  } else {
140  clear();
141  edm::LogError("HLTConfigProvider") << "ProcessPSet not found in regsistry!";
142  changed_ = true;
143  inited_ = false;
145  return;
146  }
147  }
148  return;
149 }
150 
152  using namespace edm;
153 
154  // Obtain ParameterSetID for requested process (with name
155  // processName) from pset registry
156  std::string pNames("");
157  std::string hNames("");
158  const ParameterSet* pset = nullptr;
159  ParameterSetID psetID;
160  unsigned int nPSets(0);
161  const edm::pset::Registry* registry_(pset::Registry::instance());
162  const edm::pset::Registry::const_iterator rb(registry_->begin());
163  const edm::pset::Registry::const_iterator re(registry_->end());
164  for (edm::pset::Registry::const_iterator i = rb; i != re; ++i) {
165  CMS_SA_ALLOW if (i->second.existsAs<std::string>("@process_name", true) and
166  i->second.existsAs<std::vector<std::string>>("@paths", true)) {
167  const std::string pName(i->second.getParameter<std::string>("@process_name"));
168  pNames += pName + " ";
169  if (pName == processName) {
170  psetID = i->first;
171  nPSets++;
172  if ((hltConfigData_ != s_dummyHLTConfigData()) && (hltConfigData_->id() == psetID)) {
173  hNames += tableName();
174  } else if (nullptr != (pset = registry_->getMapped(psetID))) {
175  CMS_SA_ALLOW if (pset->exists("HLTConfigVersion")) {
176  const ParameterSet& HLTPSet(pset->getParameterSet("HLTConfigVersion"));
177  CMS_SA_ALLOW if (HLTPSet.exists("tableName")) {
178  hNames += HLTPSet.getParameter<std::string>("tableName") + " ";
179  }
180  }
181  }
182  }
183  }
184  }
185 
186  LogVerbatim("HLTConfigProvider") << "Unordered list of all process names found: " << pNames << ".";
187 
188  LogVerbatim("HLTConfigProvider") << "HLT TableName of each selected process: " << hNames << ".";
189 
190  if (nPSets == 0) {
191  LogError("HLTConfigProvider") << " Process name '" << processName << "' not found in registry!";
192  clear();
193  return;
194  }
195  if (psetID == ParameterSetID()) {
196  LogError("HLTConfigProvider") << " Process name '" << processName << "' found but ParameterSetID invalid!";
197  clear();
198  return;
199  }
200  if (nPSets > 1) {
201  LogError("HLTConfigProvider") << " Process name '" << processName << " found " << nPSets << " times in registry!";
202  clear();
203  return;
204  }
205 
206  getDataFrom(psetID);
207 
208  return;
209 }
210 
212  // clear all data members
213 
214  processName_ = "";
215  inited_ = false;
216  changed_ = true;
218 
219  return;
220 }
221 
222 const std::vector<std::string> HLTConfigProvider::matched(const std::vector<std::string>& inputs,
223  const std::string& pattern) {
224  std::vector<std::string> matched;
225  const std::regex regexp(edm::glob2reg(pattern));
226  const unsigned int n(inputs.size());
227  for (unsigned int i = 0; i < n; ++i) {
228  const std::string& input(inputs[i]);
229  if (std::regex_match(input, regexp))
230  matched.push_back(input);
231  }
232  return matched;
233 }
234 
236  const std::regex regexp("_v[0-9]+$");
237  return std::regex_replace(trigger, regexp, "");
238 }
239 
240 const std::vector<std::string> HLTConfigProvider::restoreVersion(const std::vector<std::string>& inputs,
241  const std::string& trigger) {
242  return matched(inputs, trigger + "_v[0-9]+$");
243 }
collection_type::const_iterator const_iterator
Log< level::Info, true > LogVerbatim
#define CMS_SA_ALLOW
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