File indexing completed on 2024-04-06 12:12:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "FWCore/Framework/interface/ComponentDescription.h"
0022 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/Framework/interface/EventSetupRecord.h"
0025 #include "FWCore/Framework/interface/IOVSyncValue.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/Framework/interface/ValidityInterval.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0031
0032
0033 #include <iostream>
0034 #include <map>
0035 #include <memory>
0036
0037
0038
0039
0040
0041 namespace edm {
0042 class PrintEventSetupContent : public one::EDAnalyzer<one::WatchRuns, one::WatchLuminosityBlocks> {
0043 public:
0044 explicit PrintEventSetupContent(ParameterSet const&);
0045 ~PrintEventSetupContent() override;
0046
0047 static void fillDescriptions(ConfigurationDescriptions& descriptions);
0048
0049 private:
0050 void beginJob() override;
0051
0052 void analyze(Event const&, EventSetup const&) override;
0053 void endJob() override;
0054 void beginRun(Run const&, EventSetup const&) override;
0055 void endRun(Run const&, EventSetup const&) override;
0056 void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
0057 void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
0058
0059 void print(EventSetup const&);
0060
0061
0062 const bool printProviders_;
0063 const bool compact_;
0064 std::map<eventsetup::EventSetupRecordKey, unsigned long long> cacheIdentifiers_;
0065 };
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 PrintEventSetupContent::PrintEventSetupContent(ParameterSet const& config)
0079 : printProviders_(config.getUntrackedParameter<bool>("printProviders")),
0080 compact_(config.getUntrackedParameter<bool>("compact")) {
0081
0082
0083 }
0084
0085 PrintEventSetupContent::~PrintEventSetupContent() {
0086
0087
0088 }
0089
0090
0091
0092
0093
0094
0095 void PrintEventSetupContent::analyze(Event const&, EventSetup const& iSetup) { print(iSetup); }
0096
0097 void PrintEventSetupContent::beginRun(Run const&, EventSetup const& iSetup) { print(iSetup); }
0098
0099 void PrintEventSetupContent::endRun(Run const&, EventSetup const& iSetup) {}
0100
0101 void PrintEventSetupContent::beginLuminosityBlock(LuminosityBlock const&, EventSetup const& iSetup) { print(iSetup); }
0102
0103 void PrintEventSetupContent::endLuminosityBlock(LuminosityBlock const&, EventSetup const& iSetup) {}
0104
0105 void PrintEventSetupContent::print(EventSetup const& iSetup) {
0106 typedef std::vector<eventsetup::EventSetupRecordKey> Records;
0107 typedef std::vector<eventsetup::DataKey> Data;
0108
0109 Records records;
0110 Data data;
0111 iSetup.fillAvailableRecordKeys(records);
0112 std::unique_ptr<LogSystem> msg;
0113
0114 for (Records::iterator itrecords = records.begin(), itrecordsend = records.end(); itrecords != itrecordsend;
0115 ++itrecords) {
0116 auto rec = iSetup.find(*itrecords);
0117
0118 if (rec && cacheIdentifiers_[*itrecords] != rec->cacheIdentifier()) {
0119 cacheIdentifiers_[*itrecords] = rec->cacheIdentifier();
0120 rec->fillRegisteredDataKeys(data);
0121 if (compact_) {
0122 for (Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata) {
0123 if (not msg)
0124 msg = std::make_unique<LogSystem>("ESContent");
0125 else
0126 *msg << '\n';
0127 *msg << "ESContent> "
0128 << "record:" << itrecords->name() << " data:" << itdata->type().name() << " '"
0129 << itdata->name().value() << "'";
0130 if (printProviders_) {
0131 edm::eventsetup::ComponentDescription const* cd = rec->providerDescription(*itdata);
0132 *msg << " provider:" << cd->type_ << " '" << cd->label_ << "'";
0133 }
0134 }
0135 } else {
0136 if (not msg) {
0137 msg = std::make_unique<LogSystem>("ESContent");
0138 *msg << "Changed Record"
0139 << "\n "
0140 << "<datatype>"
0141 << " "
0142 << "'label' provider: 'provider label' <provider module type>";
0143 }
0144 *msg << "\n" << itrecords->name();
0145 *msg << "\n start: " << rec->validityInterval().first().eventID()
0146 << " time: " << rec->validityInterval().first().time().value();
0147 *msg << "\n end: " << rec->validityInterval().last().eventID()
0148 << " time: " << rec->validityInterval().last().time().value();
0149 for (Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata) {
0150 *msg << "\n " << itdata->type().name() << " '" << itdata->name().value() << "'";
0151 if (printProviders_) {
0152 edm::eventsetup::ComponentDescription const* cd = rec->providerDescription(*itdata);
0153 *msg << " provider:" << cd->type_ << " '" << cd->label_ << "'";
0154 }
0155 }
0156 }
0157 }
0158 }
0159 }
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172 void PrintEventSetupContent::beginJob() {}
0173
0174
0175 void PrintEventSetupContent::endJob() {}
0176
0177
0178 void PrintEventSetupContent::fillDescriptions(ConfigurationDescriptions& descriptions) {
0179 descriptions.setComment(
0180 "Print what data is available in each available EventSetup Record in the job.\n"
0181 "As part of the data is the C++ class type, label and which module makes that data.");
0182 ParameterSetDescription desc;
0183 desc.addUntracked<bool>("compact", false)
0184 ->setComment("If 'true' produces a more compact view, similar to the one used by PrintEventSetupDataRetrieval");
0185 desc.addUntracked<bool>("printProviders", true)
0186 ->setComment("If 'true' also print which ES module provides the data");
0187 descriptions.add("printEventSetupContent", desc);
0188 }
0189 }
0190
0191
0192 using edm::PrintEventSetupContent;
0193 DEFINE_FWK_MODULE(PrintEventSetupContent);