CMS 3D CMS Logo

PCLMetadataWriter.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Cerminara - CERN
6  */
7 
9 
11 
19 
20 #include <iostream>
21 
22 using namespace std;
23 using namespace edm;
24 
26 
27  readFromDB = pSet.getParameter<bool>("readFromDB");
28 
29 
30  vector<ParameterSet> recordsToMap = pSet.getParameter<vector<ParameterSet> >("recordsToMap");
31  for(vector<ParameterSet>::const_iterator recordPset = recordsToMap.begin();
32  recordPset != recordsToMap.end();
33  ++recordPset) {
34 
35  // record is the key which identifies one set of metadata in DropBoxMetadataRcd
36  // (not necessarily a record in the strict framework sense)
37  string record = (*recordPset).getUntrackedParameter<string>("record");
38 
39  map<string, string> jrInfo;
40  if(!readFromDB) {
41  vector<string> paramKeys = (*recordPset).getParameterNames();
42  for(vector<string>::const_iterator key = paramKeys.begin();
43  key != paramKeys.end();
44  ++key) {
45  jrInfo["Source"] = "AlcaHarvesting";
46  jrInfo["FileClass"] = "ALCA";
47  if(*key != "record") {
48  jrInfo[*key] = (*recordPset).getUntrackedParameter<string>(*key);
49  }
50  }
51  }
52  recordMap[record] = jrInfo;
53 
54  }
55 
56 }
57 
59 
60 
62 
63 
65 
67 
68  const DropBoxMetadata *metadata = nullptr;
69 
70  if(readFromDB) {
71  // Read the objects
73  eSetup.get<DropBoxMetadataRcd>().get(mdPayload);
74 
75  metadata = mdPayload.product();
76  }
77 
78  // get the PoolDBOutputService
80  if(poolDbService.isAvailable() ) {
82  if (jr.isAvailable()) {
83  // the filename is unique for all records
84  string filename = poolDbService->session().connectionString();
85 
86  // loop over all records
87  for(map<string, map<string, string> >::const_iterator recordAndMap = recordMap.begin();
88  recordAndMap != recordMap.end();
89  ++recordAndMap) {
90 
91  string record = (*recordAndMap).first;
92 
93  // this is the map of metadata that we write in the JR
94  map<string, string> jrInfo = (*recordAndMap).second;
95  if(readFromDB) {
96  if(metadata->knowsRecord(record)) {
97  jrInfo = metadata->getRecordParameters(record).getParameterMap();
98  }
99  }
100 
101  // name of the the input tag in the metadata for the condUploader metadata
102  // needs to be the same as the tag written out by the harvesting step
103  jrInfo["inputtag"] = poolDbService->tag(record);
104 
105  // actually write in the job report
106  jr->reportAnalysisFile(filename, jrInfo);
107 
108  }
109  }
110  }
111 }
112 
113 
T getParameter(std::string const &) const
PCLMetadataWriter(const edm::ParameterSet &)
Constructor.
JetCorrectorParameters::Record record
Definition: classes.h:7
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool knowsRecord(const std::string &record) const
cond::persistency::Session session() const
void analyze(const edm::Event &, const edm::EventSetup &) override
std::string tag(const std::string &recordName)
const std::map< std::string, std::string > & getParameterMap() const
bool isAvailable() const
Definition: Service.h:46
std::string connectionString()
Definition: Session.cc:224
void endRun(const edm::Run &, const edm::EventSetup &) override
HLT enums.
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:507
~PCLMetadataWriter() override
Destructor.
T get() const
Definition: EventSetup.h:63
void beginRun(const edm::Run &, const edm::EventSetup &) override
const Parameters & getRecordParameters(const std::string &record) const
T const * product() const
Definition: ESHandle.h:86
Definition: event.py:1
Definition: Run.h:44