CMS 3D CMS Logo

PrintEventSetupContent.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: PrintEventSetupContent
5 // Class: PrintEventSetupContent
6 //
14 //
15 // Original Author: Weng Yao
16 // Created: Tue Oct 2 13:49:56 EDT 2007
17 //
18 //
19 
20 // user include files
31 
32 // system include files
33 #include <iostream>
34 #include <map>
35 #include <memory>
36 
37 //
38 // class decleration
39 //
40 
41 namespace edm {
42  class PrintEventSetupContent : public one::EDAnalyzer<one::WatchRuns, one::WatchLuminosityBlocks> {
43  public:
44  explicit PrintEventSetupContent(ParameterSet const&);
45  ~PrintEventSetupContent() override;
46 
47  static void fillDescriptions(ConfigurationDescriptions& descriptions);
48 
49  private:
50  void beginJob() override;
51 
52  void analyze(Event const&, EventSetup const&) override;
53  void endJob() override;
54  void beginRun(Run const&, EventSetup const&) override;
55  void endRun(Run const&, EventSetup const&) override;
56  void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
57  void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
58 
59  void print(EventSetup const&);
60 
61  // ----------member data ---------------------------
62  const bool printProviders_;
63  const bool compact_;
64  std::map<eventsetup::EventSetupRecordKey, unsigned long long> cacheIdentifiers_;
65  };
66 
67  //
68  // constants, enums and typedefs
69  //
70 
71  //
72  // static data member definitions
73  //
74 
75  //
76  // constructors and destructor
77  //
79  : printProviders_(config.getUntrackedParameter<bool>("printProviders")),
80  compact_(config.getUntrackedParameter<bool>("compact")) {
81  //now do what ever initialization is neededEventSetupRecordDataGetter::EventSetupRecordDataGetter(ParameterSet const& iConfig):
82  // getter = new EventSetupRecordDataGetter::EventSetupRecordDataGetter(iConfig);
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 to for each event ------------
95  void PrintEventSetupContent::analyze(Event const&, EventSetup const& iSetup) { print(iSetup); }
96 
97  void PrintEventSetupContent::beginRun(Run const&, EventSetup const& iSetup) { print(iSetup); }
98 
99  void PrintEventSetupContent::endRun(Run const&, EventSetup const& iSetup) {}
100 
102 
104 
106  typedef std::vector<eventsetup::EventSetupRecordKey> Records;
107  typedef std::vector<eventsetup::DataKey> Data;
108 
109  Records records;
110  Data data;
111  iSetup.fillAvailableRecordKeys(records);
112  std::unique_ptr<LogSystem> msg;
113 
114  for (Records::iterator itrecords = records.begin(), itrecordsend = records.end(); itrecords != itrecordsend;
115  ++itrecords) {
116  auto rec = iSetup.find(*itrecords);
117 
118  if (rec && cacheIdentifiers_[*itrecords] != rec->cacheIdentifier()) {
119  cacheIdentifiers_[*itrecords] = rec->cacheIdentifier();
120  rec->fillRegisteredDataKeys(data);
121  if (compact_) {
122  for (Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata) {
123  if (not msg)
124  msg = std::make_unique<LogSystem>("ESContent");
125  else
126  *msg << '\n';
127  *msg << "ESContent> "
128  << "record:" << itrecords->name() << " data:" << itdata->type().name() << " '"
129  << itdata->name().value() << "'";
130  if (printProviders_) {
131  edm::eventsetup::ComponentDescription const* cd = rec->providerDescription(*itdata);
132  *msg << " provider:" << cd->type_ << " '" << cd->label_ << "'";
133  }
134  }
135  } else {
136  if (not msg) {
137  msg = std::make_unique<LogSystem>("ESContent");
138  *msg << "Changed Record"
139  << "\n "
140  << "<datatype>"
141  << " "
142  << "'label' provider: 'provider label' <provider module type>";
143  }
144  *msg << "\n" << itrecords->name();
145  *msg << "\n start: " << rec->validityInterval().first().eventID()
146  << " time: " << rec->validityInterval().first().time().value();
147  *msg << "\n end: " << rec->validityInterval().last().eventID()
148  << " time: " << rec->validityInterval().last().time().value();
149  for (Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata) {
150  *msg << "\n " << itdata->type().name() << " '" << itdata->name().value() << "'";
151  if (printProviders_) {
152  edm::eventsetup::ComponentDescription const* cd = rec->providerDescription(*itdata);
153  *msg << " provider:" << cd->type_ << " '" << cd->label_ << "'";
154  }
155  }
156  }
157  }
158  }
159  }
160 
161  //#ifdef THIS_IS_AN_EVENT_EXAMPLE
162  // Handle<ExampleData> pIn;
163  // iEvent.getByLabel("example", pIn);
164  //#endif
165 
166  //#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
167  // ESHandle<SetupData> pSetup;
168  // iSetup.get<SetupRecord>().get(pSetup);
169  //#endif
170 
171  // ------------ method called once each job just before starting event loop ------------
173 
174  // ------------ method called once each job just after ending the event loop ------------
176 
177  // ------------ method called once each job for validation ------------
179  descriptions.setComment(
180  "Print what data is available in each available EventSetup Record in the job.\n"
181  "As part of the data is the C++ class type, label and which module makes that data.");
183  desc.addUntracked<bool>("compact", false)
184  ->setComment("If 'true' produces a more compact view, similar to the one used by PrintEventSetupDataRetrieval");
185  desc.addUntracked<bool>("printProviders", true)
186  ->setComment("If 'true' also print which ES module provides the data");
187  descriptions.add("printEventSetupContent", desc);
188  }
189 } // namespace edm
190 
191 //define this as a plug-in
void endLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
void beginRun(Run const &, EventSetup const &) override
void endRun(Run const &, EventSetup const &) override
Definition: config.py:1
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:156
std::map< eventsetup::EventSetupRecordKey, unsigned long long > cacheIdentifiers_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setComment(std::string const &value)
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:151
void add(std::string const &label, ParameterSetDescription const &psetDescription)
tuple msg
Definition: mps_check.py:286
void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void analyze(Event const &, EventSetup const &) override
void print(EventSetup const &)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: Run.h:45
PrintEventSetupContent(ParameterSet const &)