CMS 3D CMS Logo

ProduceDropBoxMetadata.cc
Go to the documentation of this file.
1 
12 #include <iostream>
13 #include <vector>
14 #include <string>
15 
19 
23 
27 
30 
32 public:
35 
37  ~ProduceDropBoxMetadata() override;
38 
39 private:
40  // Operations
41  void analyze(const edm::Event&, const edm::EventSetup&) override;
42 
43  bool read;
44  bool write;
45 
46  std::vector<edm::ParameterSet> fToWrite;
47  std::vector<std::string> fToRead;
48 
50 };
51 
52 using namespace std;
53 using namespace edm;
54 
56  read = pSet.getUntrackedParameter<bool>("read");
57  write = pSet.getUntrackedParameter<bool>("write");
58 
59  fToWrite = pSet.getParameter<vector<ParameterSet> >("toWrite");
60  fToRead = pSet.getUntrackedParameter<vector<string> >("toRead");
61 }
62 
64 
66  // ---------------------------------------------------------------------------------
67  // Write the payload
68  if (write) {
70 
71  edm::LogPrint("ProduceDropBoxMetadata") << "Entering write, to loop over toWrite";
72  // loop over all the pSets for the TF1 that we want to write to DB
73  for (vector<ParameterSet>::const_iterator fSetup = fToWrite.begin(); fSetup != fToWrite.end(); ++fSetup) {
74  string record = (*fSetup).getUntrackedParameter<string>("record");
75  edm::LogPrint("ProduceDropBoxMetadata") << "\n--- record: " << record;
77  vector<string> paramKeys = (*fSetup).getParameterNames();
78  for (vector<string>::const_iterator key = paramKeys.begin(); key != paramKeys.end(); ++key) {
79  if (*key != "record") {
80  string value = (*fSetup).getUntrackedParameter<string>(*key);
81  params.addParameter(*key, value);
82  edm::LogPrint("ProduceDropBoxMetadata") << " key: " << *key << " value: " << value;
83  }
84  }
85  metadata.addRecordParameters(record, params);
86  }
87 
88  // actually write to DB
90  if (dbOut.isAvailable()) {
91  dbOut->writeOneIOV<DropBoxMetadata>(metadata, 1, "DropBoxMetadataRcd");
92  }
93  }
94 
95  if (read) {
96  // Read the objects
97  edm::LogPrint("ProduceDropBoxMetadata") << "Entering read, to loop over toRead";
98  const auto& mdPayload = iSetup.getData(dropBoxMetadataToken_);
99 
100  // loop
101  for (vector<string>::const_iterator name = fToRead.begin(); name != fToRead.end(); ++name) {
102  edm::LogPrint("ProduceDropBoxMetadata") << "\n--- record: " << *name;
103  if (mdPayload.knowsRecord(*name)) {
104  const map<string, string>& params = mdPayload.getRecordParameters(*name).getParameterMap();
105  for (map<string, string>::const_iterator par = params.begin(); par != params.end(); ++par) {
106  edm::LogPrint("ProduceDropBoxMetadata") << " key: " << par->first << " value: " << par->second;
107  }
108  } else {
109  edm::LogPrint("ProduceDropBoxMetadata") << " not in the payload!";
110  }
111  }
112  }
113 }
114 
~ProduceDropBoxMetadata() override
Destructor.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
ProduceDropBoxMetadata(const edm::ParameterSet &)
Constructor.
std::vector< edm::ParameterSet > fToWrite
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< DropBoxMetadata, DropBoxMetadataRcd > dropBoxMetadataToken_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
key
prepare the HTCondor submission files and eventually submit them
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: value.py:1
Log< level::Warning, true > LogPrint
HLT enums.
bool isAvailable() const
Definition: Service.h:40
std::vector< std::string > fToRead