test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTConfigProvider.cc
Go to the documentation of this file.
1 
21 
22 #include <boost/regex.hpp>
23 
24 // an empty dummy config data used when we fail to initialize
26 { static const HLTConfigData dummyHLTConfigData;
27  return &dummyHLTConfigData;
28 }
29 
31  processName_(""),
32  inited_(false),
33  changed_(true),
34  hltConfigData_(s_dummyHLTConfigData())
35 {
36 }
37 
39  const edm::EventSetup& iSetup,
40  const std::string& processName,
41  bool& changed) {
42 
43  using namespace std;
44  using namespace edm;
45 
46  LogInfo("HLTConfigProvider")
47  << "Called (R) with processName '" << processName << "' for " << iRun.id() << endl;
48 
50 
52  changed=changed_;
53  return inited_;
54 
55 }
56 
58 
59  using namespace std;
60  using namespace edm;
61 
62  const ProcessHistory::const_iterator hb(iHistory.begin());
63  const ProcessHistory::const_iterator he(iHistory.end());
64 
67 
69  if (processName_=="*") {
70  // auto-discovery of process name
71  for (ProcessHistory::const_iterator hi=hb; hi!=he; ++hi) {
72  if (iHistory.getConfigurationForProcess(hi->processName(),processConfiguration)) {
73  processPSet = edm::pset::Registry::instance()->getMapped(processConfiguration.parameterSetID());
74  if ((processPSet!=0) && (processPSet->exists("hltTriggerSummaryAOD"))) {
75  processName_=hi->processName();
76  }
77  }
78  }
79  LogInfo("HLTConfigProvider")
80  << "Auto-discovered processName: '" << processName_ << "'" << endl;
81  }
82  if (processName_=="*") {
83  LogError("HLTConfigProvider")
84  << "Auto-discovery of processName failed!" << endl;
85  clear();
86  return;
87  }
88 
90  unsigned int n(0);
91  for (ProcessHistory::const_iterator hi=hb; hi!=he; ++hi) {
92  if (hi->processName()==processName_) {n++;}
93  }
94  if (n>1) {
95  LogError("HLTConfigProvider")
96  << " ProcessName '"<< processName_ << " found " << n << " times in history!" << endl;
97  clear();
98  return;
99  }
100 
103  if ((hltConfigData_ !=s_dummyHLTConfigData()) && (processConfiguration.parameterSetID() == hltConfigData_->id())) {
104  changed_ = false;
105  inited_ = true;
106  return;
107  } else {
108  getDataFrom(processConfiguration.parameterSetID());
109  }
110  } else {
111  LogError("HLTConfigProvider")
112  << "Falling back to ProcessName-only init using ProcessName '"<<processName_<<"' !";
114  return;
115  }
116 }
117 
119 {
120  //is it in our registry?
122  const HLTConfigData* d = reg->getMapped(iID);
123  if(0 != d) {
124  changed_ = true;
125  inited_ = true;
126  hltConfigData_ = d;
127  } else {
128  const edm::ParameterSet* processPSet = 0;
129  if ( 0 != (processPSet = edm::pset::Registry::instance()->getMapped(iID))) {
130  if (not processPSet->id().isValid()) {
131  clear();
132  edm::LogError("HLTConfigProvider") << "ProcessPSet found is empty!";
133  changed_ = true;
134  inited_ = false;
136  return;
137  } else {
138  clear();
139  reg->insertMapped( HLTConfigData(processPSet));
140  changed_ = true;
141  inited_ = true;
142  hltConfigData_ = reg->getMapped(processPSet->id());
143  return;
144  }
145  } else {
146  clear();
147  edm::LogError("HLTConfigProvider") << "ProcessPSet not found in regsistry!";
148  changed_ = true;
149  inited_ = false;
151  return;
152  }
153  }
154  return;
155 }
156 
158 {
159  using namespace std;
160  using namespace edm;
161 
162  // Obtain ParameterSetID for requested process (with name
163  // processName) from pset registry
164  string pNames("");
165  string hNames("");
166  const ParameterSet* pset = 0;
167  ParameterSetID psetID;
168  unsigned int nPSets(0);
169  const edm::pset::Registry * registry_(pset::Registry::instance());
170  const edm::pset::Registry::const_iterator rb(registry_->begin());
171  const edm::pset::Registry::const_iterator re(registry_->end());
172  for (edm::pset::Registry::const_iterator i = rb; i != re; ++i) {
173  if (i->second.exists("@process_name")) {
174  const std::string pName(i->second.getParameter<string>("@process_name"));
175  pNames += pName+" ";
176  if ( pName == processName ) {
177  psetID = i->first;
178  nPSets++;
179  if ((hltConfigData_ != s_dummyHLTConfigData()) && (hltConfigData_->id()==psetID)) {
180  hNames += tableName();
181  } else if ( 0 != (pset = registry_->getMapped(psetID))) {
182  if (pset->exists("HLTConfigVersion")) {
183  const ParameterSet& HLTPSet(pset->getParameterSet("HLTConfigVersion"));
184  if (HLTPSet.exists("tableName")) {
185  hNames += HLTPSet.getParameter<string>("tableName")+" ";
186  }
187  }
188  }
189  }
190  }
191  }
192 
193  LogVerbatim("HLTConfigProvider")
194  << "Unordered list of all process names found: " << pNames << "." << endl;
195 
196  LogVerbatim("HLTConfigProvider")
197  << "HLT TableName of each selected process: " << hNames << "." << endl;
198 
199  if (nPSets==0) {
200  LogError("HLTConfigProvider")
201  << " Process name '" << processName << "' not found in registry!" << endl;
202  clear();
203  return;
204  }
205  if (psetID==ParameterSetID()) {
206  LogError("HLTConfigProvider")
207  << " Process name '" << processName << "' found but ParameterSetID invalid!" << endl;
208  clear();
209  return;
210  }
211  if (nPSets>1) {
212  LogError("HLTConfigProvider")
213  << " Process name '" << processName << " found " << nPSets << " times in registry!" << endl;
214  clear();
215  return;
216  }
217 
218  getDataFrom(psetID);
219 
220  return;
221 
222 }
223 
225 {
226  // clear all data members
227 
228  processName_ = "";
229  inited_ = false;
230  changed_ = true;
232 
233  return;
234 }
235 
236 
237 
238 const std::vector<std::string> HLTConfigProvider::matched(const std::vector<std::string>& inputs, const std::string& pattern) {
239  std::vector<std::string> matched;
240  const boost::regex regexp(edm::glob2reg(pattern));
241  const unsigned int n(inputs.size());
242  for (unsigned int i=0; i<n; ++i) {
243  const std::string& input(inputs[i]);
244  if (boost::regex_match(input,regexp)) matched.push_back(input);
245  }
246  return matched;
247 }
248 
250  const boost::regex regexp("_v[0-9]+$");
251  return boost::regex_replace(trigger,regexp,"");
252 }
253 
254 const std::vector<std::string> HLTConfigProvider::restoreVersion(const std::vector<std::string>& inputs, const std::string& trigger) {
255  return matched(inputs,trigger+"_v[0-9]+$");
256 }
collection_type::const_iterator const_iterator
T getParameter(std::string const &) const
const_iterator begin() const
int i
Definition: DBlmapReader.cc:9
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
processConfiguration
Definition: Schedule.cc:374
static const HLTConfigData * s_dummyHLTConfigData()
const std::string & tableName() const
HLT ConfDB table name.
std::string processName_
data members
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
tuple d
Definition: ztail.py:151
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:99
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:18
Hash< ParameterSetType > ParameterSetID
HLTConfigProvider()
c&#39;tor
const std::string & processName() const
process name
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const_iterator end() const
bool isValid() const
Definition: Hash.h:150
volatile std::atomic< bool > shutdown_flag false
edm::ParameterSetID id() const
technical: id() function needed for use with ThreadSafeRegistry
static Registry * instance()
Definition: Registry.cc:12
Definition: Run.h:43