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 }
edm::ParameterSetID
Hash< ParameterSetType > ParameterSetID
Definition: ParameterSetID.h:21
edm::pset::Registry::instance
static Registry * instance()
Definition: Registry.cc:12
HLTConfigProvider::matched
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
Definition: HLTConfigProvider.cc:225
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
edm::detail::ThreadSafeRegistry::insertMapped
bool insertMapped(value_type const &v)
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HLTConfigProvider::getDataFrom
void getDataFrom(const edm::ParameterSetID &iID)
Definition: HLTConfigProvider.cc:115
HLTConfigData
Definition: HLTConfigData.h:25
TriggerNamesService.h
edm::Run
Definition: Run.h:45
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProcessHistory::getConfigurationForProcess
bool getConfigurationForProcess(std::string const &name, ProcessConfiguration &config) const
Definition: ProcessHistory.cc:34
edm::detail::ThreadSafeRegistry::getMapped
bool getMapped(key_type const &k, value_type &result) const
edm::ParameterSet::id
ParameterSetID id() const
Definition: ParameterSet.cc:189
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
s_dummyHLTConfigData
static const HLTConfigData * s_dummyHLTConfigData()
Definition: HLTConfigProvider.cc:28
edm::detail::ThreadSafeRegistry
Definition: ThreadSafeRegistry.h:34
fetchall_from_DQM_v2.regexp
regexp
Definition: fetchall_from_DQM_v2.py:93
HLTConfigProvider::hltConfigData_
const HLTConfigData * hltConfigData_
Definition: HLTConfigProvider.h:219
edm::detail::ThreadSafeRegistry::instance
static ThreadSafeRegistry * instance()
HLTConfigProvider::processPSet
const edm::ParameterSet & processPSet() const
ParameterSet of process.
Definition: HLTConfigProvider.h:110
edm::Hash::isValid
bool isValid() const
Definition: Hash.h:141
ProcessHistory.h
Service.h
edm::pset::Registry::end
const_iterator end() const
Definition: Registry.h:65
edm::glob2reg
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:19
HLTConfigProvider::processName_
std::string processName_
data members
Definition: HLTConfigProvider.h:216
Run.h
edm::Hash< ParameterSetType >
HLTConfigProvider::removeVersion
static const std::string removeVersion(const std::string &trigger)
Definition: HLTConfigProvider.cc:238
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTConfigProvider::inited_
bool inited_
Definition: HLTConfigProvider.h:217
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
funct::true
true
Definition: Factorize.h:173
HLTConfigProvider::restoreVersion
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
Definition: HLTConfigProvider.cc:243
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::ProcessHistory::const_iterator
collection_type::const_iterator const_iterator
Definition: ProcessHistory.h:19
edm::Service
Definition: Service.h:30
HLTConfigDataRegistry.h
edm::ProcessHistory::end
const_iterator end() const
Definition: ProcessHistory.h:63
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
HLTConfigProvider::tableName
const std::string & tableName() const
HLT ConfDB table name.
Definition: HLTConfigProvider.h:60
HLTConfigProvider::processName
const std::string & processName() const
process name
Definition: HLTConfigProvider.h:54
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HLTConfigProvider.h
hcalSimParameters_cfi.hb
hb
Definition: hcalSimParameters_cfi.py:60
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
Registry.h
hi
Definition: EPCuts.h:4
HLTConfigProvider::clear
void clear()
Definition: HLTConfigProvider.cc:214
HLTConfigProvider::HLTConfigProvider
HLTConfigProvider()
c'tor
Definition: HLTConfigProvider.cc:33
std
Definition: JetResolutionObject.h:76
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
hcalSimParameters_cfi.he
he
Definition: hcalSimParameters_cfi.py:79
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HLTConfigProvider::changed
bool changed() const
changed?
Definition: HLTConfigProvider.h:51
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HLTConfigData::id
edm::ParameterSetID id() const
technical: id() function needed for use with ThreadSafeRegistry
Definition: HLTConfigData.cc:603
trigger
Definition: HLTPrescaleTableCond.h:8
ztail.d
d
Definition: ztail.py:151
edm::ProcessHistory::begin
const_iterator begin() const
Definition: ProcessHistory.h:62
ThreadSafeRegistry.h
edm::ProcessHistory
Definition: ProcessHistory.h:13
ParameterSet.h
edm::pset::Registry::begin
const_iterator begin() const
Definition: Registry.h:63
edm::pset::Registry::const_iterator
map_type::const_iterator const_iterator
Definition: Registry.h:61
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39
HLTConfigProvider::changed_
bool changed_
Definition: HLTConfigProvider.h:218
edm::pset::Registry::getMapped
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
RegexMatch.h
edm::ProcessConfiguration
Definition: ProcessConfiguration.h:14
edm::pset::Registry
Definition: Registry.h:26
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::Run::processHistory
ProcessHistory const & processHistory() const
Definition: Run.cc:113