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 
21 using namespace std;
22 using namespace edm;
23 
25 
26  readFromDB = pSet.getParameter<bool>("readFromDB");
27 
28 
29  vector<ParameterSet> recordsToMap = pSet.getParameter<vector<ParameterSet> >("recordsToMap");
30  for(vector<ParameterSet>::const_iterator recordPset = recordsToMap.begin();
31  recordPset != recordsToMap.end();
32  ++recordPset) {
33 
34  string record = (*recordPset).getUntrackedParameter<string>("record");
35  map<string, string> jrInfo;
36  if(!readFromDB) {
37  vector<string> paramKeys = (*recordPset).getParameterNames();
38  for(vector<string>::const_iterator key = paramKeys.begin();
39  key != paramKeys.end();
40  ++key) {
41  jrInfo["Source"] = "AlcaHarvesting";
42  jrInfo["FileClass"] = "ALCA";
43  if(*key != "record") {
44  jrInfo[*key] = (*recordPset).getUntrackedParameter<string>(*key);
45  }
46  }
47  }
48  recordMap[record] = jrInfo;
49 
50  }
51 
52 }
53 
55 
56 
58 
59 
61 
63 
64  const DropBoxMetadata *metadata = 0;
65 
66  if(readFromDB) {
67  // Read the objects
69  eSetup.get<DropBoxMetadataRcd>().get(mdPayload);
70 
71  metadata = mdPayload.product();
72  }
73 
74  // get the PoolDBOutputService
76  if(poolDbService.isAvailable() ) {
78  if (jr.isAvailable()) {
79  // the filename is unique for all records
80  string filename = poolDbService->session().connectionString();
81 
82  // loop over all records
83  for(map<string, map<string, string> >::const_iterator recordAndMap = recordMap.begin();
84  recordAndMap != recordMap.end();
85  ++recordAndMap) {
86 
87  string record = (*recordAndMap).first;
88  // this is the map of metadata that we write in the JR
89  map<string, string> jrInfo = (*recordAndMap).second;
90  if(readFromDB) {
91  if(metadata->knowsRecord(record)) {
92  jrInfo = metadata->getRecordParameters(record).getParameterMap();
93  }
94  }
95  jrInfo["inputtag"] = poolDbService->tag(record);
96 
97 
98  // actually write in the job report
99  jr->reportAnalysisFile(filename, jrInfo);
100  }
101  }
102  }
103 }
104 
105 
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
std::string tag(const std::string &recordName)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const std::map< std::string, std::string > & getParameterMap() const
virtual void endRun(const edm::Run &, const edm::EventSetup &)
bool isAvailable() const
Definition: Service.h:46
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
std::string connectionString()
Definition: Session.cc:224
virtual ~PCLMetadataWriter()
Destructor.
const T & get() const
Definition: EventSetup.h:56
HLT enums.
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:563
const Parameters & getRecordParameters(const std::string &record) const
T const * product() const
Definition: ESHandle.h:86
Definition: event.py:1
Definition: Run.h:42