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 
24 
25 // an empty dummy config data used when we fail to initialize
27 { static HLTConfigData dummyHLTConfigData;
28  return &dummyHLTConfigData;
29 }
30 
32  processName_(""),
33  inited_(false),
34  changed_(true),
35  hltConfigData_(s_dummyHLTConfigData()),
36  l1GtUtils_(new L1GtUtils())
37 {
38 }
39 
41  const edm::EventSetup& iSetup,
42  const std::string& processName,
43  bool& changed) {
44 
45  using namespace std;
46  using namespace edm;
47 
48  LogInfo("HLTConfigData") << "Called (R) with processName '"
49  << processName
50  << "' for " << iRun.id() << endl;
51 
53 
56 
58  changed=changed_;
59  return inited_;
60 
61 }
62 
63 void HLTConfigProvider::init(const edm::ProcessHistory& iHistory, const std::string& processName) {
64 
65  using namespace std;
66  using namespace edm;
67 
69  const ProcessHistory::const_iterator hb(iHistory.begin());
70  const ProcessHistory::const_iterator he(iHistory.end());
71  unsigned int n(0);
72  for (ProcessHistory::const_iterator hi=hb; hi!=he; ++hi) {
73  if (hi->processName()==processName) {n++;}
74  }
75  if (n>1) {
76  clear();
77  LogError("HLTConfigProvider") << " ProcessName '"<< processName
78  << " found " << n
79  << " times in history!" << endl;
80  return;
81  }
82 
84  ProcessConfiguration processConfiguration;
85  if (iHistory.getConfigurationForProcess(processName,processConfiguration)) {
86  if ((hltConfigData_ !=s_dummyHLTConfigData()) && (processConfiguration.parameterSetID() == hltConfigData_->id())) {
87  changed_ = false;
88  inited_ = true;
89  return;
90  } else {
91  getDataFrom(processConfiguration.parameterSetID(),processName);
92  }
93  } else {
94  LogError("HLTConfigProvider") << "Falling back to processName-only init!";
95  clear();
96  init(processName);
97  if (!inited_) {
98  LogError("HLTConfigProvider") << "ProcessName not found in history!";
99  }
100  return;
101  }
102 }
103 
105 {
106  //is it in our registry?
108  const HLTConfigData* d = reg->getMapped(iID);
109  if(0 != d) {
110  changed_ = true;
111  inited_ = true;
112  hltConfigData_ = d;
113  } else {
114  const edm::ParameterSet* processPSet = 0;
115  if ( 0 != (processPSet = edm::pset::Registry::instance()->getMapped(iID))) {
116  if (not processPSet->id().isValid()) {
117  clear();
118  edm::LogError("HLTConfigProvider") << "ProcessPSet found is empty!";
119  changed_ = true;
120  inited_ = false;
122  return;
123  } else {
124  clear();
125  reg->insertMapped( HLTConfigData(processPSet));
126  changed_ = true;
127  inited_ = true;
128  hltConfigData_ = reg->getMapped(processPSet->id());
129  return;
130  }
131  } else {
132  clear();
133  edm::LogError("HLTConfigProvider") << "ProcessPSet not found in regsistry!";
134  changed_ = true;
135  inited_ = false;
137  return;
138  }
139  }
140  return;
141 }
142 
143 void HLTConfigProvider::init(const std::string& processName)
144 {
145  using namespace std;
146  using namespace edm;
147 
148  // Obtain ParameterSetID for requested process (with name
149  // processName) from pset registry
150  string pNames("");
151  string hNames("");
152  const ParameterSet* pset = 0;
153  ParameterSetID psetID;
154  unsigned int nPSets(0);
155  const edm::pset::Registry * registry_(pset::Registry::instance());
156  const edm::pset::Registry::const_iterator rb(registry_->begin());
157  const edm::pset::Registry::const_iterator re(registry_->end());
158  for (edm::pset::Registry::const_iterator i = rb; i != re; ++i) {
159  if (i->second.exists("@process_name")) {
160  const std::string pName(i->second.getParameter<string>("@process_name"));
161  pNames += pName+" ";
162  if ( pName == processName ) {
163  psetID = i->first;
164  nPSets++;
165  if ((hltConfigData_ != s_dummyHLTConfigData()) && (hltConfigData_->id()==psetID)) {
166  hNames += tableName();
167  } else if ( 0 != (pset = registry_->getMapped(psetID))) {
168  if (pset->exists("HLTConfigVersion")) {
169  const ParameterSet& HLTPSet(pset->getParameterSet("HLTConfigVersion"));
170  if (HLTPSet.exists("tableName")) {
171  hNames += HLTPSet.getParameter<string>("tableName")+" ";
172  }
173  }
174  }
175  }
176  }
177  }
178 
179  LogVerbatim("HLTConfigProvider") << "Unordered list of all process names found: "
180  << pNames << "." << endl;
181 
182  LogVerbatim("HLTConfigProvider") << "HLT TableName of each selected process: "
183  << hNames << "." << endl;
184 
185  if (nPSets==0) {
186  clear();
187  LogError("HLTConfigProvider") << " Process name '"
188  << processName
189  << "' not found in registry!" << endl;
190  return;
191  }
192  if (psetID==ParameterSetID()) {
193  clear();
194  LogError("HLTConfigProvider") << " Process name '"
195  << processName
196  << "' found but ParameterSetID invalid!"
197  << endl;
198  return;
199  }
200  if (nPSets>1) {
201  clear();
202  LogError("HLTConfigProvider") << " Process name '"
203  << processName
204  << " found " << nPSets
205  << " times in registry!" << endl;
206  return;
207  }
208 
209  getDataFrom(psetID,processName);
210 
211  return;
212 
213 }
214 
216 {
217  // clear all data members
218 
219  processName_ = "";
220  inited_ = false;
221  changed_ = true;
223  *l1GtUtils_ = L1GtUtils();
224 
225  return;
226 }
227 
228 
230  // return hltPrescaleTable_.set();
231  l1GtUtils_->retrieveL1EventSetup(iSetup);
232  int errorTech(0);
233  const int psfsiTech(l1GtUtils_->prescaleFactorSetIndex(iEvent,L1GtUtils::TechnicalTrigger,errorTech));
234  int errorPhys(0);
235  const int psfsiPhys(l1GtUtils_->prescaleFactorSetIndex(iEvent,L1GtUtils::AlgorithmTrigger,errorPhys));
236  assert(psfsiTech==psfsiPhys);
237  if ( (errorTech==0) && (errorPhys==0) &&
238  (psfsiTech>=0) && (psfsiPhys>=0) && (psfsiTech==psfsiPhys) ) {
239  return psfsiPhys;
240  } else {
242  edm::LogError("HLTConfigData")
243  << " Error in determining HLT prescale set index from L1 data using L1GtUtils: "
244  << " Tech/Phys error = " << errorTech << "/" << errorPhys
245  << " Tech/Phys psfsi = " << psfsiTech << "/" << psfsiPhys;
246  return -1;
247  }
248 }
249 
250 unsigned int HLTConfigProvider::prescaleValue(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& trigger) const {
251  const int set(prescaleSet(iEvent,iSetup));
252  if (set<0) {
253  return 1;
254  } else {
255  return prescaleValue(static_cast<unsigned int>(set),trigger);
256  }
257 }
258 
259 std::pair<int,int> HLTConfigProvider::prescaleValues(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& trigger) const {
260 
261  // start with setting both L1T and HLT prescale values to 0
262  std::pair<int,int> result(std::pair<int,int>(0,0));
263 
264  // get HLT prescale (possible if HLT prescale set index is correctly found)
265  const int set(prescaleSet(iEvent,iSetup));
266  if (set<0) {
267  result.second = -1;
268  } else {
269  result.second = static_cast<int>(prescaleValue(static_cast<unsigned int>(set),trigger));
270  }
271 
272  // get L1T prescale - works only for those hlt trigger paths with
273  // exactly one L1GT seed module which has exactly one L1T name as seed
274  const unsigned int nL1GTSeedModules(hltL1GTSeeds(trigger).size());
275  if (nL1GTSeedModules==0) {
276  // no L1 seed module on path hence no L1 seed hence formally no L1 prescale
277  result.first=1;
278  } else if (nL1GTSeedModules==1) {
279  l1GtUtils_->retrieveL1EventSetup(iSetup);
280  const std::string l1tname(hltL1GTSeeds(trigger).at(0).second);
281  int l1error(0);
282  result.first = l1GtUtils_->prescaleFactor(iEvent,l1tname,l1error);
283  if (l1error!=0) {
284  edm::LogError("HLTConfigData")
285  << " Error in determining L1T prescale for HLT path: '" << trigger
286  << "' with L1T seed: '" << l1tname
287  << "' using L1GtUtils: error code: " << l1error
288  << ". (Note: only a single L1T name, not a bit number, is allowed as seed for a proper determination of the L1T prescale!)";
289  result.first = -1;
290  }
291  } else {
293  std::string dump("'"+hltL1GTSeeds(trigger).at(0).second+"'");
294  for (unsigned int i=1; i!=nL1GTSeedModules; ++i) {
295  dump += " * '"+hltL1GTSeeds(trigger).at(i).second+"'";
296  }
297  edm::LogError("HLTConfigData")
298  << " Error in determining L1T prescale for HLT path: '" << trigger
299  << "' has multiple L1GTSeed modules, " << nL1GTSeedModules
300  << ", with L1 seeds: " << dump
301  << ". (Note: at most one L1GTSeed module is allowed for a proper determination of the L1T prescale!)";
302  result.first = -1;
303  }
304 
305  return result;
306 }
unsigned int size() const
number of trigger paths in trigger table
collection_type::const_iterator const_iterator
void dump(const std::string &what) const
Dumping config info to cout.
T getParameter(std::string const &) const
const_iterator begin() const
int i
Definition: DBlmapReader.cc:9
RunID const & id() const
Definition: RunBase.h:43
edm::detail::ThreadSafeRegistry< edm::ParameterSetID, HLTConfigData > HLTConfigDataRegistry
ParameterSetID id() const
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
bool getMapped(key_type const &k, value_type &result) const
static const HLTConfigData * s_dummyHLTConfigData()
const std::string & tableName() const
HLT ConfDB table name.
std::string processName_
data members
bool insertMapped(value_type const &v)
const HLTConfigData * hltConfigData_
U second(std::pair< T, U > const &p)
bool getConfigurationForProcess(std::string const &name, ProcessConfiguration &config) const
boost::shared_ptr< L1GtUtils > l1GtUtils_
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
int iEvent
Definition: GenABIO.cc:243
const edm::ParameterSet & processPSet() const
ParameterSet of process.
collection_type::const_iterator const_iterator
tuple result
Definition: query.py:137
ProcessHistory const & processHistory() const
Definition: Run.cc:100
tuple pset
Definition: CrabTask.py:85
Hash< ParameterSetType > ParameterSetID
HLTConfigProvider()
c&#39;tor
const std::string & processName() const
Accessors (const methods)
int prescaleSet(const edm::Event &iEvent, const edm::EventSetup &iSetup) const
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger) const
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
const_iterator end() const
bool isValid() const
Definition: Hash.h:136
static ThreadSafeRegistry * instance()
void getDataFrom(const edm::ParameterSetID &iID, const std::string &iProcessName)
edm::ParameterSetID id() const
technical: id() function needed for use with ThreadSafeRegistry
Definition: Run.h:31
list at
Definition: asciidump.py:428