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  readFromDB = pSet.getParameter<bool>("readFromDB");
27 
28  vector<ParameterSet> recordsToMap = pSet.getParameter<vector<ParameterSet>>("recordsToMap");
29  for (vector<ParameterSet>::const_iterator recordPset = recordsToMap.begin(); recordPset != recordsToMap.end();
30  ++recordPset) {
31  // record is the key which identifies one set of metadata in
32  // DropBoxMetadataRcd (not necessarily a record in the strict framework
33  // sense)
34  string record = (*recordPset).getUntrackedParameter<string>("record");
35 
36  map<string, string> jrInfo;
37  if (!readFromDB) {
38  vector<string> paramKeys = (*recordPset).getParameterNames();
39  for (vector<string>::const_iterator key = paramKeys.begin(); key != paramKeys.end(); ++key) {
40  jrInfo["Source"] = "AlcaHarvesting";
41  jrInfo["FileClass"] = "ALCA";
42  if (*key != "record") {
43  jrInfo[*key] = (*recordPset).getUntrackedParameter<string>(*key);
44  }
45  }
46  }
47  recordMap[record] = jrInfo;
48  }
49 }
50 
52 
54 
56 
58  const DropBoxMetadata *metadata = nullptr;
59 
60  if (readFromDB) {
61  // Read the objects
63  eSetup.get<DropBoxMetadataRcd>().get(mdPayload);
64 
65  metadata = mdPayload.product();
66  }
67 
68  // get the PoolDBOutputService
70  if (poolDbService.isAvailable()) {
72  if (jr.isAvailable()) {
73  // the filename is unique for all records
74  string filename = poolDbService->session().connectionString();
75 
76  // loop over all records
77  for (map<string, map<string, string>>::const_iterator recordAndMap = recordMap.begin();
78  recordAndMap != recordMap.end();
79  ++recordAndMap) {
80  string record = (*recordAndMap).first;
81 
82  // this is the map of metadata that we write in the JR
83  map<string, string> jrInfo = (*recordAndMap).second;
84  if (readFromDB) {
85  if (metadata->knowsRecord(record)) {
86  jrInfo = metadata->getRecordParameters(record).getParameterMap();
87  }
88  }
89 
90  // name of the the input tag in the metadata for the condUploader
91  // metadata needs to be the same as the tag written out by the
92  // harvesting step
93  jrInfo["inputtag"] = poolDbService->tag(record);
94 
95  // actually write in the job report
96  jr->reportAnalysisFile(filename, jrInfo);
97  }
98  }
99  }
100 }
101 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:96
PCLMetadataWriter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: PCLMetadataWriter.cc:53
ESHandle.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::JobReport::reportAnalysisFile
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
PCLMetadataWriter::PCLMetadataWriter
PCLMetadataWriter(const edm::ParameterSet &)
Constructor.
Definition: PCLMetadataWriter.cc:25
PCLMetadataWriter.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
DropBoxMetadata.h
MakerMacros.h
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cond::service::PoolDBOutputService::session
cond::persistency::Session session() const
Definition: PoolDBOutputService.cc:94
Service.h
edm::ESHandle
Definition: DTSurvey.h:22
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
TrackingMonitor_cfi.metadata
metadata
Definition: TrackingMonitor_cfi.py:71
edm::ParameterSet
Definition: ParameterSet.h:47
cond::persistency::Session::connectionString
std::string connectionString()
Definition: Session.cc:216
edm::Service< cond::service::PoolDBOutputService >
DropBoxMetadata
Definition: DropBoxMetadata.h:17
edm::EventSetup
Definition: EventSetup.h:57
PCLMetadataWriter::~PCLMetadataWriter
~PCLMetadataWriter() override
Destructor.
Definition: PCLMetadataWriter.cc:51
PCLMetadataWriter::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: PCLMetadataWriter.cc:55
get
#define get
PCLMetadataWriter::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: PCLMetadataWriter.cc:57
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
EventSetup.h
DropBoxMetadataRcd
Definition: DropBoxMetadataRcd.h:24
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PCLMetadataWriter
Definition: PCLMetadataWriter.h:18
JobReport.h
genParticles_cff.map
map
Definition: genParticles_cff.py:11
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
DropBoxMetadataRcd.h