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
edm::EventSetupCacheIdentifierChecker::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EventSetupCacheIdentifierChecker.cc:95
edm::eventsetup::heterocontainer::HCTypeTag::findType
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121
edm::EventSetupCacheIdentifierChecker::initialize
void initialize()
Definition: EventSetupCacheIdentifierChecker.cc:159
MessageLogger.h
edm::EventSetupCacheIdentifierChecker::m_pset
ParameterSet m_pset
Definition: EventSetupCacheIdentifierChecker.cc:63
edm::EventSetupCacheIdentifierChecker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EventSetupCacheIdentifierChecker.cc:112
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
EventSetupRecord.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EventSetupCacheIdentifierChecker::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EventSetupCacheIdentifierChecker.cc:121
edm::EventSetupCacheIdentifierChecker
Definition: EventSetupCacheIdentifierChecker.cc:43
edm::EventSetupCacheIdentifierChecker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EventSetupCacheIdentifierChecker.cc:177
edm::eventsetup::EventSetupRecordKey::TypeTag
heterocontainer::HCTypeTag TypeTag
Definition: EventSetupRecordKey.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::EventSetupCacheIdentifierChecker::check
void check(edm::EventSetup const &)
Definition: EventSetupCacheIdentifierChecker.cc:132
edm::eventsetup::EventSetupRecordKey::type
const TypeTag & type() const
Definition: EventSetupRecordKey.h:40
edm::ParameterSet::getParameterNamesForType
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
edm::EventSetup::find
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:169
edm::EventSetupCacheIdentifierChecker::m_recordKeysToExpectedCacheIdentifiers
std::map< eventsetup::EventSetupRecordKey, std::vector< unsigned int > > m_recordKeysToExpectedCacheIdentifiers
Definition: EventSetupCacheIdentifierChecker.cc:64
edm::EventSetupCacheIdentifierChecker::EventSetupCacheIdentifierChecker
EventSetupCacheIdentifierChecker(const edm::ParameterSet &)
Definition: EventSetupCacheIdentifierChecker.cc:80
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::EventSetupCacheIdentifierChecker::~EventSetupCacheIdentifierChecker
~EventSetupCacheIdentifierChecker() override
Definition: EventSetupCacheIdentifierChecker.cc:85
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
Exception.h
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::eventsetup
Definition: ES_DDDetector.cc:16
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::EventSetupCacheIdentifierChecker::m_index
unsigned int m_index
Definition: EventSetupCacheIdentifierChecker.cc:65