test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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&);
46 
47  static void fillDescriptions(ConfigurationDescriptions& descriptions);
48 
49  private:
50  virtual void beginJob() override;
51 
52  virtual void analyze(Event const&, EventSetup const&) override;
53  virtual void endJob() override ;
54  virtual void beginRun(Run const&, EventSetup const&) override;
55  virtual void endRun(Run const&, EventSetup const&) override;
56  virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
57  virtual 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  {
82  //now do what ever initialization is neededEventSetupRecordDataGetter::EventSetupRecordDataGetter(ParameterSet const& iConfig):
83  // getter = new EventSetupRecordDataGetter::EventSetupRecordDataGetter(iConfig);
84  }
85 
87  // do anything here that needs to be done at desctruction time
88  // (e.g. close files, deallocate resources etc.)
89  }
90 
91  //
92  // member functions
93  //
94 
95  // ------------ method called to for each event ------------
96  void
98  print(iSetup);
99  }
100 
101  void
103  print(iSetup);
104  }
105 
106  void
108  }
109 
110  void
112  print(iSetup);
113  }
114 
115  void
117  }
118 
119  void
121  typedef std::vector<eventsetup::EventSetupRecordKey> Records;
122  typedef std::vector<eventsetup::DataKey> Data;
123 
124  Records records;
125  Data data;
126  iSetup.fillAvailableRecordKeys(records);
127  std::unique_ptr<LogSystem> msg;
128 
129  for(Records::iterator itrecords = records.begin(), itrecordsend = records.end();
130  itrecords != itrecordsend; ++itrecords ) {
131 
132  eventsetup::EventSetupRecord const* rec = iSetup.find(*itrecords);
133 
134  if (0 != rec && cacheIdentifiers_[*itrecords] != rec->cacheIdentifier()) {
135  cacheIdentifiers_[*itrecords] = rec->cacheIdentifier();
136  rec->fillRegisteredDataKeys(data);
137  if (compact_) {
138  for (Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata) {
139  if (not msg)
140  msg.reset(new LogSystem("ESContent"));
141  else
142  *msg << '\n';
143  *msg << "ESContent> " << "record:" << itrecords->name() << " data:" << itdata->type().name() << " '" << itdata->name().value() << "'";
144  if (printProviders_) {
146  *msg << " provider:" << cd->type_ << " '" << cd->label_ << "'";
147  }
148  }
149  } else {
150  if (not msg) {
151  msg.reset(new LogSystem("ESContent"));
152  *msg << "Changed Record" << "\n " << "<datatype>" << " " << "'label' provider: 'provider label' <provider module type>";
153  }
154  *msg << "\n" << itrecords->name();
155  *msg << "\n start: " << rec->validityInterval().first().eventID() << " time: " << rec->validityInterval().first().time().value();
156  *msg << "\n end: " << rec->validityInterval().last().eventID() << " time: " << rec->validityInterval().last().time().value();
157  for (Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata) {
158  *msg << "\n " << itdata->type().name() << " '" << itdata->name().value() << "'";
159  if (printProviders_) {
161  *msg << " provider:" << cd->type_ << " '" << cd->label_ << "'";
162  }
163  }
164  }
165  }
166  }
167  }
168 
169  //#ifdef THIS_IS_AN_EVENT_EXAMPLE
170  // Handle<ExampleData> pIn;
171  // iEvent.getByLabel("example", pIn);
172  //#endif
173 
174  //#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
175  // ESHandle<SetupData> pSetup;
176  // iSetup.get<SetupRecord>().get(pSetup);
177  //#endif
178 
179  // ------------ method called once each job just before starting event loop ------------
180  void
182  }
183 
184  // ------------ method called once each job just after ending the event loop ------------
185  void
187  }
188 
189  // ------------ method called once each job for validation ------------
190  void
192  descriptions.setComment("Print what data is available in each available EventSetup Record in the job.\n"
193  "As part of the data is the C++ class type, label and which module makes that data.");
195  desc.addUntracked<bool>( "compact", false )->setComment(
196  "If 'true' produces a more compact view, similar to the one used by PrintEventSetupDataRetrieval");
197  desc.addUntracked<bool>("printProviders", true)->setComment(
198  "If 'true' also print which ES module provides the data");
199  descriptions.add("printEventSetupContent", desc);
200  }
201 }
202 
203 //define this as a plug-in
virtual void endLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
unsigned long long cacheIdentifier() const
void fillRegisteredDataKeys(std::vector< DataKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all registered data keys ...
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const EventID & eventID() const
Definition: IOVSyncValue.h:42
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(Run const &, EventSetup const &) override
virtual void endRun(Run const &, EventSetup const &) override
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:91
const IOVSyncValue & last() const
ComponentDescription const * providerDescription(DataKey const &aKey) const
virtual void beginJob() override
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.cc:102
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
std::map< eventsetup::EventSetupRecordKey, unsigned long long > cacheIdentifiers_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const Timestamp & time() const
Definition: IOVSyncValue.h:44
volatile std::atomic< bool > shutdown_flag false
const IOVSyncValue & first() const
virtual void analyze(Event const &, EventSetup const &) override
ValidityInterval const & validityInterval() const
TimeValue_t value() const
Definition: Timestamp.h:56
void print(EventSetup const &)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: Run.h:43
PrintEventSetupContent(ParameterSet const &)