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 #include <memory>
17 
18 // user include files
30 
31 namespace edm {
33  : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
34  public:
36 
37  void analyze(edm::Event const&, edm::EventSetup const&) override;
38 
39  void beginRun(edm::Run const&, edm::EventSetup const&) override;
40  void endRun(edm::Run const&, edm::EventSetup const&) override;
41 
42  void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
43  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47  private:
48  void check(EventSetup const&);
49  // ---------- member data --------------------------------
51  std::pair<unsigned long long, std::map<eventsetup::DataKey, bool> > >
53 
55  std::vector<eventsetup::EventSetupRecordKey> m_recordKeys;
56  const bool m_printProviders;
59  const bool m_checkDuringEvent;
60  };
61  //
62  // constants, enums and typedefs
63  //
64 
65  //
66  // static data member definitions
67  //
68 
69  //
70  // constructors and destructor
71  //
73  : m_printProviders(iPS.getUntrackedParameter<bool>("printProviders")),
74  m_checkDuringBeginRun(iPS.getUntrackedParameter<bool>("checkDuringBeginRun")),
75  m_checkDuringBeginLumi(iPS.getUntrackedParameter<bool>("checkDuringBeginLumi")),
76  m_checkDuringEvent(iPS.getUntrackedParameter<bool>("checkDuringEvent")) {}
77 
78  // PrintEventSetupDataRetrieval::PrintEventSetupDataRetrieval(const PrintEventSetupDataRetrieval& rhs)
79  // {
80  // // do actual copying here;
81  // }
82 
83  //PrintEventSetupDataRetrieval::~PrintEventSetupDataRetrieval()
84  //{
85  //}
86 
89  desc.addUntracked<bool>("printProviders", false)
90  ->setComment("If 'true' also print which ES module provides the data");
91  desc.addUntracked<bool>("checkDuringBeginRun", false)
92  ->setComment("If 'true' check for retrieved data during each begin run is processed");
93  desc.addUntracked<bool>("checkDuringBeginLumi", false)
94  ->setComment("If 'true' check for retrieved data during each begin lumi is processed");
95  desc.addUntracked<bool>("checkDuringEvent", true)
96  ->setComment("If 'true' check for retrieved data during an event is processed");
97  descriptions.add("PrintEventSetupDataRetrieval", desc);
98  descriptions.setComment("This analyzer reports when EventSetup data is retrieved by a module in the job.");
99  }
100 
101  //
102  // assignment operators
103  //
104  // const PrintEventSetupDataRetrieval& PrintEventSetupDataRetrieval::operator=(const PrintEventSetupDataRetrieval& rhs)
105  // {
106  // //An exception safe implementation is
107  // PrintEventSetupDataRetrieval temp(rhs);
108  // swap(rhs);
109  //
110  // return *this;
111  // }
112 
113  //
114  // member functions
115  //
117  if (m_checkDuringEvent) {
118  check(iES);
119  }
120  }
121 
123  if (m_checkDuringBeginRun) {
124  check(iES);
125  }
126  }
127 
129 
132  check(iES);
133  }
134  }
135 
137 
139  //std::cout <<"postProcessEvent"<<std::endl;
140  m_recordKeys.clear();
142 
143  std::unique_ptr<LogSystem> msg;
144  for (std::vector<eventsetup::EventSetupRecordKey>::const_iterator it = m_recordKeys.begin(),
145  itEnd = m_recordKeys.end();
146  it != itEnd;
147  ++it) {
148  //std::cout <<" "<<it->name()<<std::endl;
149  auto r = iES.find(*it);
150  assert(r);
151 
152  RetrievedDataMap::iterator itRetrievedData = m_retrievedDataMap.find(*it);
153  if (itRetrievedData == m_retrievedDataMap.end()) {
154  itRetrievedData =
156  .insert(std::make_pair(*it, std::pair<unsigned long long, std::map<eventsetup::DataKey, bool> >()))
157  .first;
158  itRetrievedData->second.first = r->cacheIdentifier();
159  std::vector<eventsetup::DataKey> keys;
160  r->fillRegisteredDataKeys(keys);
161  for (std::vector<eventsetup::DataKey>::const_iterator itData = keys.begin(), itDataEnd = keys.end();
162  itData != itDataEnd;
163  ++itData) {
164  itRetrievedData->second.second.insert(std::make_pair(*itData, false));
165  }
166  }
167  RetrievedDataMap::value_type& retrievedData = *itRetrievedData;
168  if (itRetrievedData->second.first != r->cacheIdentifier()) {
169  itRetrievedData->second.first = r->cacheIdentifier();
170  for (std::map<eventsetup::DataKey, bool>::iterator itDatum = retrievedData.second.second.begin(),
171  itDatumEnd = retrievedData.second.second.end();
172  itDatum != itDatumEnd;
173  ++itDatum) {
174  itDatum->second = false;
175  }
176  }
177 
178  for (std::map<eventsetup::DataKey, bool>::iterator itDatum = retrievedData.second.second.begin(),
179  itDatumEnd = retrievedData.second.second.end();
180  itDatum != itDatumEnd;
181  ++itDatum) {
182  bool wasGotten = r->wasGotten(itDatum->first);
183  if (wasGotten != itDatum->second) {
184  if (not msg)
185  msg = std::make_unique<LogSystem>("ESContent");
186  else
187  *msg << "\n";
188  itDatum->second = wasGotten;
189  *msg << "Retrieved> record:" << it->name() << " data:" << itDatum->first.type().name() << " '"
190  << itDatum->first.name().value() << "'";
191  if (m_printProviders) {
192  const edm::eventsetup::ComponentDescription* d = r->providerDescription(itDatum->first);
193  assert(nullptr != d);
194  *msg << " provider:" << d->type_ << " '" << d->label_ << "'";
195  }
196  }
197  }
198  }
199  }
200 
201  //
202  // const member functions
203  //
204 
205  //
206  // static member functions
207  //
208 } // namespace edm
209 
210 //define this as a plug-in
ConfigurationDescriptions.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
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:128
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
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:181
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:55
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::PrintEventSetupDataRetrieval::m_checkDuringBeginRun
const bool m_checkDuringBeginRun
Definition: PrintEventSetupDataRetrieval.cc:57
EventSetupRecord.h
MakerMacros.h
edm::PrintEventSetupDataRetrieval::m_checkDuringEvent
const bool m_checkDuringEvent
Definition: PrintEventSetupDataRetrieval.cc:59
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:116
edm::PrintEventSetupDataRetrieval::m_printProviders
const bool m_printProviders
Definition: PrintEventSetupDataRetrieval.cc:56
edm::PrintEventSetupDataRetrieval::RetrievedDataMap
std::map< eventsetup::EventSetupRecordKey, std::pair< unsigned long long, std::map< eventsetup::DataKey, bool > > > RetrievedDataMap
Definition: PrintEventSetupDataRetrieval.cc:52
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:58
edm::ParameterSet
Definition: ParameterSet.h:47
edm::PrintEventSetupDataRetrieval::m_retrievedDataMap
RetrievedDataMap m_retrievedDataMap
Definition: PrintEventSetupDataRetrieval.cc:54
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:136
edm::EventSetup
Definition: EventSetup.h:58
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:176
edm::PrintEventSetupDataRetrieval
Definition: PrintEventSetupDataRetrieval.cc:32
alignCSCRings.r
r
Definition: alignCSCRings.py:93
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::PrintEventSetupDataRetrieval::PrintEventSetupDataRetrieval
PrintEventSetupDataRetrieval(edm::ParameterSet const &)
Definition: PrintEventSetupDataRetrieval.cc:72
edm::PrintEventSetupDataRetrieval::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PrintEventSetupDataRetrieval.cc:87
edm::PrintEventSetupDataRetrieval::check
void check(EventSetup const &)
Definition: PrintEventSetupDataRetrieval.cc:138
EventSetup.h
edm::PrintEventSetupDataRetrieval::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:130
edm::PrintEventSetupDataRetrieval::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: PrintEventSetupDataRetrieval.cc:122
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