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.reset(new 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.reset(new 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
ConfigurationDescriptions.h
edm::PrintEventSetupContent::beginLuminosityBlock
void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
Definition: PrintEventSetupContent.cc:101
electrons_cff.bool
bool
Definition: electrons_cff.py:372
EDAnalyzer.h
edm::PrintEventSetupContent::~PrintEventSetupContent
~PrintEventSetupContent() override
Definition: PrintEventSetupContent.cc:85
MessageLogger.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::PrintEventSetupContent::beginJob
void beginJob() override
Definition: PrintEventSetupContent.cc:172
ValidityInterval.h
edm::PrintEventSetupContent
Definition: PrintEventSetupContent.cc:42
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::LogSystem
Definition: MessageLogger.h:222
ComponentDescription.h
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
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::PrintEventSetupContent::endRun
void endRun(Run const &, EventSetup const &) override
Definition: PrintEventSetupContent.cc:99
EventSetupRecord.h
edm::PrintEventSetupContent::compact_
const bool compact_
Definition: PrintEventSetupContent.cc:63
config
Definition: config.py:1
MakerMacros.h
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::PrintEventSetupContent::beginRun
void beginRun(Run const &, EventSetup const &) override
Definition: PrintEventSetupContent.cc:97
ParameterSetDescription.h
edm::PrintEventSetupContent::endLuminosityBlock
void endLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
Definition: PrintEventSetupContent.cc:103
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::eventsetup::ComponentDescription
Definition: ComponentDescription.h:30
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ParameterSet
Definition: ParameterSet.h:36
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edm::EventSetup
Definition: EventSetup.h:57
edm::EventSetup::find
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:162
edm::PrintEventSetupContent::PrintEventSetupContent
PrintEventSetupContent(ParameterSet const &)
Definition: PrintEventSetupContent.cc:78
edm::PrintEventSetupContent::cacheIdentifiers_
std::map< eventsetup::EventSetupRecordKey, unsigned long long > cacheIdentifiers_
Definition: PrintEventSetupContent.cc:64
EventSetup.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::PrintEventSetupContent::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: PrintEventSetupContent.cc:178
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40
edm::PrintEventSetupContent::analyze
void analyze(Event const &, EventSetup const &) override
Definition: PrintEventSetupContent.cc:95
edm::PrintEventSetupContent::print
void print(EventSetup const &)
Definition: PrintEventSetupContent.cc:105
edm::Event
Definition: Event.h:73
IOVSyncValue.h
edm::PrintEventSetupContent::endJob
void endJob() override
Definition: PrintEventSetupContent.cc:175
edm::PrintEventSetupContent::printProviders_
const bool printProviders_
Definition: PrintEventSetupContent.cc:62