CMS 3D CMS Logo

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