CMS 3D CMS Logo

PrintEventSetupDataRetrieval.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Services
4 // Class : PrintEventSetupDataRetrieval
5 //
6 // Implementation:
7 // A service which prints which data from the EventSetup have been retrieved since the last time it checked
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Jul 9 14:30:13 CDT 2009
11 //
12 
13 // system include files
14 #include <iostream>
15 #include <map>
16 
17 // user include files
29 
30 namespace edm {
32  : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
33  public:
35 
36  void analyze(edm::Event const&, edm::EventSetup const&) override;
37 
38  void beginRun(edm::Run const&, edm::EventSetup const&) override;
39  void endRun(edm::Run const&, edm::EventSetup const&) override;
40 
41  void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
42  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  private:
47  void check(EventSetup const&);
48  // ---------- member data --------------------------------
50  std::pair<unsigned long long, std::map<eventsetup::DataKey, bool> > >
52 
54  std::vector<eventsetup::EventSetupRecordKey> m_recordKeys;
55  const bool m_printProviders;
58  const bool m_checkDuringEvent;
59  };
60  //
61  // constants, enums and typedefs
62  //
63 
64  //
65  // static data member definitions
66  //
67 
68  //
69  // constructors and destructor
70  //
72  : m_printProviders(iPS.getUntrackedParameter<bool>("printProviders")),
73  m_checkDuringBeginRun(iPS.getUntrackedParameter<bool>("checkDuringBeginRun")),
74  m_checkDuringBeginLumi(iPS.getUntrackedParameter<bool>("checkDuringBeginLumi")),
75  m_checkDuringEvent(iPS.getUntrackedParameter<bool>("checkDuringEvent")) {}
76 
77  // PrintEventSetupDataRetrieval::PrintEventSetupDataRetrieval(const PrintEventSetupDataRetrieval& rhs)
78  // {
79  // // do actual copying here;
80  // }
81 
82  //PrintEventSetupDataRetrieval::~PrintEventSetupDataRetrieval()
83  //{
84  //}
85 
88  desc.addUntracked<bool>("printProviders", false)
89  ->setComment("If 'true' also print which ES module provides the data");
90  desc.addUntracked<bool>("checkDuringBeginRun", false)
91  ->setComment("If 'true' check for retrieved data during each begin run is processed");
92  desc.addUntracked<bool>("checkDuringBeginLumi", false)
93  ->setComment("If 'true' check for retrieved data during each begin lumi is processed");
94  desc.addUntracked<bool>("checkDuringEvent", true)
95  ->setComment("If 'true' check for retrieved data during an event is processed");
96  descriptions.add("PrintEventSetupDataRetrieval", desc);
97  descriptions.setComment("This analyzer reports when EventSetup data is retrieved by a module in the job.");
98  }
99 
100  //
101  // assignment operators
102  //
103  // const PrintEventSetupDataRetrieval& PrintEventSetupDataRetrieval::operator=(const PrintEventSetupDataRetrieval& rhs)
104  // {
105  // //An exception safe implementation is
106  // PrintEventSetupDataRetrieval temp(rhs);
107  // swap(rhs);
108  //
109  // return *this;
110  // }
111 
112  //
113  // member functions
114  //
116  if (m_checkDuringEvent) {
117  check(iES);
118  }
119  }
120 
122  if (m_checkDuringBeginRun) {
123  check(iES);
124  }
125  }
126 
128 
131  check(iES);
132  }
133  }
134 
136 
138  //std::cout <<"postProcessEvent"<<std::endl;
139  m_recordKeys.clear();
141 
142  std::unique_ptr<LogSystem> msg;
143  for (std::vector<eventsetup::EventSetupRecordKey>::const_iterator it = m_recordKeys.begin(),
144  itEnd = m_recordKeys.end();
145  it != itEnd;
146  ++it) {
147  //std::cout <<" "<<it->name()<<std::endl;
148  auto r = iES.find(*it);
149  assert(r);
150 
151  RetrievedDataMap::iterator itRetrievedData = m_retrievedDataMap.find(*it);
152  if (itRetrievedData == m_retrievedDataMap.end()) {
153  itRetrievedData =
155  .insert(std::make_pair(*it, std::pair<unsigned long long, std::map<eventsetup::DataKey, bool> >()))
156  .first;
157  itRetrievedData->second.first = r->cacheIdentifier();
158  std::vector<eventsetup::DataKey> keys;
159  r->fillRegisteredDataKeys(keys);
160  for (std::vector<eventsetup::DataKey>::const_iterator itData = keys.begin(), itDataEnd = keys.end();
161  itData != itDataEnd;
162  ++itData) {
163  itRetrievedData->second.second.insert(std::make_pair(*itData, false));
164  }
165  }
166  RetrievedDataMap::value_type& retrievedData = *itRetrievedData;
167  if (itRetrievedData->second.first != r->cacheIdentifier()) {
168  itRetrievedData->second.first = r->cacheIdentifier();
169  for (std::map<eventsetup::DataKey, bool>::iterator itDatum = retrievedData.second.second.begin(),
170  itDatumEnd = retrievedData.second.second.end();
171  itDatum != itDatumEnd;
172  ++itDatum) {
173  itDatum->second = false;
174  }
175  }
176 
177  for (std::map<eventsetup::DataKey, bool>::iterator itDatum = retrievedData.second.second.begin(),
178  itDatumEnd = retrievedData.second.second.end();
179  itDatum != itDatumEnd;
180  ++itDatum) {
181  bool wasGotten = r->wasGotten(itDatum->first);
182  if (wasGotten != itDatum->second) {
183  if (not msg)
184  msg.reset(new LogSystem("ESContent"));
185  else
186  *msg << "\n";
187  itDatum->second = wasGotten;
188  *msg << "Retrieved> record:" << it->name() << " data:" << itDatum->first.type().name() << " '"
189  << itDatum->first.name().value() << "'";
190  if (m_printProviders) {
191  const edm::eventsetup::ComponentDescription* d = r->providerDescription(itDatum->first);
192  assert(nullptr != d);
193  *msg << " provider:" << d->type_ << " '" << d->label_ << "'";
194  }
195  }
196  }
197  }
198  }
199 
200  //
201  // const member functions
202  //
203 
204  //
205  // static member functions
206  //
207 } // namespace edm
208 
209 //define this as a plug-in
ConfigurationDescriptions.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
EDAnalyzer.h
MessageLogger.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::PrintEventSetupDataRetrieval::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:127
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::LogSystem
Definition: MessageLogger.h:222
ComponentDescription.h
cms::cuda::assert
assert(be >=bs)
edm::EventSetup::fillAvailableRecordKeys
void fillAvailableRecordKeys(std::vector< eventsetup::EventSetupRecordKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all available records
Definition: EventSetup.h:167
mps_check.msg
tuple msg
Definition: mps_check.py:285
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::PrintEventSetupDataRetrieval::m_recordKeys
std::vector< eventsetup::EventSetupRecordKey > m_recordKeys
Definition: PrintEventSetupDataRetrieval.cc:54
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::PrintEventSetupDataRetrieval::m_checkDuringBeginRun
const bool m_checkDuringBeginRun
Definition: PrintEventSetupDataRetrieval.cc:56
EventSetupRecord.h
MakerMacros.h
edm::PrintEventSetupDataRetrieval::m_checkDuringEvent
const bool m_checkDuringEvent
Definition: PrintEventSetupDataRetrieval.cc:58
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::PrintEventSetupDataRetrieval::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:115
edm::PrintEventSetupDataRetrieval::m_printProviders
const bool m_printProviders
Definition: PrintEventSetupDataRetrieval.cc:55
edm::PrintEventSetupDataRetrieval::RetrievedDataMap
std::map< eventsetup::EventSetupRecordKey, std::pair< unsigned long long, std::map< eventsetup::DataKey, bool > > > RetrievedDataMap
Definition: PrintEventSetupDataRetrieval.cc:51
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::eventsetup::ComponentDescription
Definition: ComponentDescription.h:30
edm::PrintEventSetupDataRetrieval::m_checkDuringBeginLumi
const bool m_checkDuringBeginLumi
Definition: PrintEventSetupDataRetrieval.cc:57
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ParameterSet
Definition: ParameterSet.h:36
edm::PrintEventSetupDataRetrieval::m_retrievedDataMap
RetrievedDataMap m_retrievedDataMap
Definition: PrintEventSetupDataRetrieval.cc:53
DataKey.h
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edm::PrintEventSetupDataRetrieval::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:135
edm::EventSetup
Definition: EventSetup.h:57
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
edm::EventSetup::find
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:162
edm::PrintEventSetupDataRetrieval
Definition: PrintEventSetupDataRetrieval.cc:31
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::PrintEventSetupDataRetrieval::PrintEventSetupDataRetrieval
PrintEventSetupDataRetrieval(edm::ParameterSet const &)
Definition: PrintEventSetupDataRetrieval.cc:71
edm::PrintEventSetupDataRetrieval::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PrintEventSetupDataRetrieval.cc:86
edm::PrintEventSetupDataRetrieval::check
void check(EventSetup const &)
Definition: PrintEventSetupDataRetrieval.cc:137
EventSetup.h
edm::PrintEventSetupDataRetrieval::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:129
edm::PrintEventSetupDataRetrieval::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:121
ztail.d
d
Definition: ztail.py:151
genParticles_cff.map
map
Definition: genParticles_cff.py:11
ParameterSet.h
EventSetupRecordKey.h
edm::Event
Definition: Event.h:73