CMS 3D CMS Logo

EventSetupCacheIdentifierChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EventSetupCacheIdentifierChecker
4 // Class: EventSetupCacheIdentifierChecker
5 //
13 //
14 // Original Author: Chris Jones
15 // Created: Wed May 30 14:42:16 CDT 2012
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <map>
22 #include <vector>
23 
24 // user include files
27 
30 
32 
36 
38 //
39 // class declaration
40 //
41 
42 namespace edm {
44  public:
47 
48  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
49 
50  private:
51  //virtual void beginJob() ;
52  void analyze(const edm::Event&, const edm::EventSetup&) override;
53  //virtual void endJob() ;
54 
55  void beginRun(edm::Run const&, edm::EventSetup const&) override;
56  //virtual void endRun(edm::Run const&, edm::EventSetup const&);
57  void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
58  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
59 
60  void check(edm::EventSetup const&);
61  void initialize();
62  // ----------member data ---------------------------
64  std::map<eventsetup::EventSetupRecordKey, std::vector<unsigned int> > m_recordKeysToExpectedCacheIdentifiers;
65  unsigned int m_index;
66  };
67 } // namespace edm
68 //
69 // constants, enums and typedefs
70 //
71 using namespace edm;
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81  : m_pset(iConfig), m_index(0) {
82  //now do what ever initialization is needed
83 }
84 
86  // do anything here that needs to be done at desctruction time
87  // (e.g. close files, deallocate resources etc.)
88 }
89 
90 //
91 // member functions
92 //
93 
94 // ------------ method called for each event ------------
96  check(iSetup);
97 }
98 
99 // ------------ method called once each job just before starting event loop ------------
100 //void
101 //EventSetupCacheIdentifierChecker::beginJob()
102 //{
103 //}
104 
105 // ------------ method called once each job just after ending the event loop ------------
106 //void
107 //EventSetupCacheIdentifierChecker::endJob()
108 //{
109 //}
110 
111 // ------------ method called when starting to processes a run ------------
113 
114 // ------------ method called when ending the processing of a run ------------
115 //void
116 //EventSetupCacheIdentifierChecker::endRun(edm::Run const&, edm::EventSetup const&)
117 //{
118 //}
119 
120 // ------------ method called when starting to processes a luminosity block ------------
122  edm::EventSetup const& iSetup) {
123  check(iSetup);
124 }
125 
126 // ------------ method called when ending the processing of a luminosity block ------------
127 //void
128 //EventSetupCacheIdentifierChecker::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
129 //{
130 //}
131 
134  initialize();
135  }
136  using namespace edm::eventsetup;
137 
139  it != itEnd;
140  ++it) {
141  auto pRecord = iSetup.find(it->first);
142  if (not pRecord) {
143  edm::LogWarning("RecordNotInIOV") << "The EventSetup Record '" << it->first.name()
144  << "' is not available for this IOV.";
145  }
146  if (it->second.size() <= m_index) {
147  throw cms::Exception("TooFewCacheIDs")
148  << "The vector of cacheIdentifiers for the record " << it->first.name() << " is too short";
149  }
150  if (pRecord && pRecord->cacheIdentifier() != it->second[m_index]) {
151  throw cms::Exception("IncorrectCacheID")
152  << "The Record " << it->first.name() << " was supposed to have cacheIdentifier: " << it->second[m_index]
153  << " but instead has " << pRecord->cacheIdentifier();
154  }
155  }
156  ++m_index;
157 }
158 
160  std::vector<std::string> recordNames{m_pset.getParameterNamesForType<std::vector<unsigned int> >(false)};
161 
162  for (auto const& name : recordNames) {
164  if (recordKey.type() == eventsetup::EventSetupRecordKey::TypeTag()) {
165  //record not found
166  edm::LogWarning("DataGetter") << "Record \"" << name << "\" does not exist " << std::endl;
167 
168  continue;
169  }
170 
172  std::make_pair(recordKey, m_pset.getUntrackedParameter<std::vector<unsigned int> >(name)));
173  }
174 }
175 
176 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
178  //The following says we do not know what parameters are allowed so do no validation
179  // Please change this to state exactly what you do use, even if it is no parameters
181  desc.addWildcardUntracked<std::vector<unsigned int> >("*")->setComment(
182  "The label is the name of an EventSetup Record while the vector contains the expected cacheIdentifier values for "
183  "each beginRun, beginLuminosityBlock and event transition");
184  descriptions.addDefault(desc);
185 }
186 
187 //define this as a plug-in
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:162
T getUntrackedParameter(std::string const &, T const &) const
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:168
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
std::map< eventsetup::EventSetupRecordKey, std::vector< unsigned int > > m_recordKeysToExpectedCacheIdentifiers
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
heterocontainer::HCTypeTag TypeTag
HLT enums.
void analyze(const edm::Event &, const edm::EventSetup &) override
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: Run.h:45