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("HLTConfigData") << "Called (R) with processName '"
47  << processName
48  << "' for " << iRun.id() << endl;
49 
51 
53  changed=changed_;
54  return inited_;
55 
56 }
57 
59 
60  using namespace std;
61  using namespace edm;
62 
63  const ProcessHistory::const_iterator hb(iHistory.begin());
64  const ProcessHistory::const_iterator he(iHistory.end());
65 
68 
70  if (processName_=="*") {
71  // auto-discovery of process name
72  for (ProcessHistory::const_iterator hi=hb; hi!=he; ++hi) {
73  if (iHistory.getConfigurationForProcess(hi->processName(),processConfiguration)) {
74  processPSet = edm::pset::Registry::instance()->getMapped(processConfiguration.parameterSetID());
75  if ((processPSet!=0) && (processPSet->exists("hltTriggerSummaryAOD"))) {
76  processName_=hi->processName();
77  }
78  }
79  }
80  LogInfo("HLTConfigData") << "Auto-discovered processName: '"
81  << processName_ << "'"
82  << endl;
83  }
84  if (processName_=="*") {
85  LogError("HLTConfigData") << "Auto-discovery of processName failed!"
86  << endl;
87  clear();
88  return;
89  }
90 
92  unsigned int n(0);
93  for (ProcessHistory::const_iterator hi=hb; hi!=he; ++hi) {
94  if (hi->processName()==processName_) {n++;}
95  }
96  if (n>1) {
97  LogError("HLTConfigProvider") << " ProcessName '"<< processName_
98  << " found " << n
99  << " times in history!" << endl;
100  clear();
101  return;
102  }
103 
106  if ((hltConfigData_ !=s_dummyHLTConfigData()) && (processConfiguration.parameterSetID() == hltConfigData_->id())) {
107  changed_ = false;
108  inited_ = true;
109  return;
110  } else {
111  getDataFrom(processConfiguration.parameterSetID());
112  }
113  } else {
114  LogError("HLTConfigProvider") << "Falling back to ProcessName-only init using ProcessName '"<<processName_<<"' !";
116  return;
117  }
118 }
119 
121 {
122  //is it in our registry?
124  const HLTConfigData* d = reg->getMapped(iID);
125  if(0 != d) {
126  changed_ = true;
127  inited_ = true;
128  hltConfigData_ = d;
129  } else {
130  const edm::ParameterSet* processPSet = 0;
131  if ( 0 != (processPSet = edm::pset::Registry::instance()->getMapped(iID))) {
132  if (not processPSet->id().isValid()) {
133  clear();
134  edm::LogError("HLTConfigProvider") << "ProcessPSet found is empty!";
135  changed_ = true;
136  inited_ = false;
138  return;
139  } else {
140  clear();
141  reg->insertMapped( HLTConfigData(processPSet));
142  changed_ = true;
143  inited_ = true;
144  hltConfigData_ = reg->getMapped(processPSet->id());
145  return;
146  }
147  } else {
148  clear();
149  edm::LogError("HLTConfigProvider") << "ProcessPSet not found in regsistry!";
150  changed_ = true;
151  inited_ = false;
153  return;
154  }
155  }
156  return;
157 }
158 
160 {
161  using namespace std;
162  using namespace edm;
163 
164  // Obtain ParameterSetID for requested process (with name
165  // processName) from pset registry
166  string pNames("");
167  string hNames("");
168  const ParameterSet* pset = 0;
169  ParameterSetID psetID;
170  unsigned int nPSets(0);
171  const edm::pset::Registry * registry_(pset::Registry::instance());
172  const edm::pset::Registry::const_iterator rb(registry_->begin());
173  const edm::pset::Registry::const_iterator re(registry_->end());
174  for (edm::pset::Registry::const_iterator i = rb; i != re; ++i) {
175  if (i->second.exists("@process_name")) {
176  const std::string pName(i->second.getParameter<string>("@process_name"));
177  pNames += pName+" ";
178  if ( pName == processName ) {
179  psetID = i->first;
180  nPSets++;
181  if ((hltConfigData_ != s_dummyHLTConfigData()) && (hltConfigData_->id()==psetID)) {
182  hNames += tableName();
183  } else if ( 0 != (pset = registry_->getMapped(psetID))) {
184  if (pset->exists("HLTConfigVersion")) {
185  const ParameterSet& HLTPSet(pset->getParameterSet("HLTConfigVersion"));
186  if (HLTPSet.exists("tableName")) {
187  hNames += HLTPSet.getParameter<string>("tableName")+" ";
188  }
189  }
190  }
191  }
192  }
193  }
194 
195  LogVerbatim("HLTConfigProvider") << "Unordered list of all process names found: "
196  << pNames << "." << endl;
197 
198  LogVerbatim("HLTConfigProvider") << "HLT TableName of each selected process: "
199  << hNames << "." << endl;
200 
201  if (nPSets==0) {
202  LogError("HLTConfigProvider") << " Process name '"
203  << processName
204  << "' not found in registry!" << endl;
205  clear();
206  return;
207  }
208  if (psetID==ParameterSetID()) {
209  LogError("HLTConfigProvider") << " Process name '"
210  << processName
211  << "' found but ParameterSetID invalid!"
212  << endl;
213  clear();
214  return;
215  }
216  if (nPSets>1) {
217  LogError("HLTConfigProvider") << " Process name '"
218  << processName
219  << " found " << nPSets
220  << " times in registry!" << endl;
221  clear();
222  return;
223  }
224 
225  getDataFrom(psetID);
226 
227  return;
228 
229 }
230 
232 {
233  // clear all data members
234 
235  processName_ = "";
236  inited_ = false;
237  changed_ = true;
239 
240  return;
241 }
242 
243 
244 
245 const std::vector<std::string> HLTConfigProvider::matched(const std::vector<std::string>& inputs, const std::string& pattern) {
246  std::vector<std::string> matched;
247  const boost::regex regexp(edm::glob2reg(pattern));
248  const unsigned int n(inputs.size());
249  for (unsigned int i=0; i<n; ++i) {
250  const std::string& input(inputs[i]);
251  if (boost::regex_match(input,regexp)) matched.push_back(input);
252  }
253  return matched;
254 }
255 
257  const boost::regex regexp("_v[0-9]+$");
258  return boost::regex_replace(trigger,regexp,"");
259 }
260 
261 const std::vector<std::string> HLTConfigProvider::restoreVersion(const std::vector<std::string>& inputs, const std::string& trigger) {
262  return matched(inputs,trigger+"_v[0-9]+$");
263 }
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:41
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:369
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:43
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:103
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