CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LuminosityBlockBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Common
4 // Class : LuminosityBlockBase
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Eric Vaandering
10 // Created: Tue Jan 12 15:31:00 CDT 2010
11 //
12 
13 // system include files
14 #include <vector>
15 #include <map>
16 
17 // user include files
19 //#include "FWCore/Common/interface/TriggerNames.h"
20 //#include "DataFormats/Provenance/interface/ParameterSetID.h"
21 //#include "DataFormats/Common/interface/TriggerResults.h"
22 //#include "FWCore/Utilities/interface/Exception.h"
23 //#include "FWCore/Utilities/interface/ThreadSafeRegistry.h"
24 //#include "FWCore/ParameterSet/interface/ParameterSet.h"
25 //#include "FWCore/ParameterSet/interface/Registry.h"
26 
27 namespace edm
28 {
29 // typedef std::map<edm::ParameterSetID, edm::TriggerNames> TriggerNamesMap;
30 // static TriggerNamesMap triggerNamesMap;
31 // static TriggerNamesMap::const_iterator previousTriggerName;
32 
34  {
35  }
36 
38  {
39  }
40 
41 /* TriggerNames const*
42  EventBase::triggerNames_(edm::TriggerResults const& triggerResults) {
43 
44  // If the current and previous requests are for the same TriggerNames
45  // then just return it.
46  if (!triggerNamesMap.empty() &&
47  previousTriggerName->first == triggerResults.parameterSetID()) {
48  return &previousTriggerName->second;
49  }
50 
51  // If TriggerNames was already created and cached here in the map,
52  // then look it up and return that one
53  TriggerNamesMap::const_iterator iter =
54  triggerNamesMap.find(triggerResults.parameterSetID());
55  if (iter != triggerNamesMap.end()) {
56  previousTriggerName = iter;
57  return &iter->second;
58  }
59 
60  // Look for the parameter set containing the trigger names in the parameter
61  // set registry using the ID from TriggerResults as the key used to find it.
62  edm::ParameterSet pset;
63  edm::pset::Registry* psetRegistry = edm::pset::Registry::instance();
64  if (psetRegistry->getMapped(triggerResults.parameterSetID(),
65  pset)) {
66 
67  if (pset.existsAs<std::vector<std::string> >("@trigger_paths", true)) {
68  TriggerNames triggerNames(pset);
69 
70  // This should never happen
71  if (triggerNames.size() != triggerResults.size()) {
72  throw cms::Exception("LogicError")
73  << "edm::EventBase::triggerNames_ Encountered vector\n"
74  "of trigger names and a TriggerResults object with\n"
75  "different sizes. This should be impossible.\n"
76  "Please send information to reproduce this problem to\n"
77  "the edm developers.\n";
78  }
79 
80  std::pair<TriggerNamesMap::iterator, bool> ret =
81  triggerNamesMap.insert(std::pair<edm::ParameterSetID, edm::TriggerNames>(triggerResults.parameterSetID(), triggerNames));
82  previousTriggerName = ret.first;
83  return &(ret.first->second);
84  }
85  }
86  // For backward compatibility to very old data
87  if (triggerResults.getTriggerNames().size() > 0U) {
88  edm::ParameterSet fakePset;
89  fakePset.addParameter<std::vector<std::string> >("@trigger_paths", triggerResults.getTriggerNames());
90  fakePset.registerIt();
91  TriggerNames triggerNames(fakePset);
92 
93  // This should never happen
94  if (triggerNames.size() != triggerResults.size()) {
95  throw cms::Exception("LogicError")
96  << "edm::EventBase::triggerNames_ Encountered vector\n"
97  "of trigger names and a TriggerResults object with\n"
98  "different sizes. This should be impossible.\n"
99  "Please send information to reproduce this problem to\n"
100  "the edm developers (2).\n";
101  }
102 
103  std::pair<TriggerNamesMap::iterator, bool> ret =
104  triggerNamesMap.insert(std::pair<edm::ParameterSetID, edm::TriggerNames>(fakePset.id(), triggerNames));
105  previousTriggerName = ret.first;
106  return &(ret.first->second);
107  }
108  return 0;
109  }*/
110 }