CMS 3D CMS Logo

Public Member Functions | Private Attributes

PCLMetadataWriter Class Reference

#include <PCLMetadataWriter.h>

Inheritance diagram for PCLMetadataWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 PCLMetadataWriter (const edm::ParameterSet &)
 Constructor.
virtual ~PCLMetadataWriter ()
 Destructor.

Private Attributes

bool readFromDB
std::map< std::string,
std::map< std::string,
std::string > > 
recordMap

Detailed Description

No description available.

Date:
2011/03/03 09:32:46
Revision:
1.2
Author:
G. Cerminara - CERN

Definition at line 21 of file PCLMetadataWriter.h.


Constructor & Destructor Documentation

PCLMetadataWriter::PCLMetadataWriter ( const edm::ParameterSet pSet)

Constructor.

Definition at line 26 of file PCLMetadataWriter.cc.

References edm::ParameterSet::getParameter(), combine::key, and record.

                                                               {
  
  readFromDB = pSet.getParameter<bool>("readFromDB");
  

  vector<ParameterSet> recordsToMap = pSet.getParameter<vector<ParameterSet> >("recordsToMap");
  for(vector<ParameterSet>::const_iterator recordPset = recordsToMap.begin();
      recordPset != recordsToMap.end();
      ++recordPset) {
    
    string record = (*recordPset).getUntrackedParameter<string>("record");
    map<string, string> jrInfo;
    if(!readFromDB) {
      vector<string> paramKeys = (*recordPset).getParameterNames();
      for(vector<string>::const_iterator key = paramKeys.begin();
          key != paramKeys.end();
          ++key) {
        jrInfo["Source"] = "AlcaHarvesting";
        jrInfo["FileClass"] = "ALCA";
        if(*key != "record") {
          jrInfo[*key] = (*recordPset).getUntrackedParameter<string>(*key);
        }
      }
    }
    recordMap[record] = jrInfo;

  }

}
PCLMetadataWriter::~PCLMetadataWriter ( ) [virtual]

Destructor.

Definition at line 56 of file PCLMetadataWriter.cc.

{}

Member Function Documentation

void PCLMetadataWriter::analyze ( const edm::Event event,
const edm::EventSetup eSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 59 of file PCLMetadataWriter.cc.

{}
void PCLMetadataWriter::beginRun ( const edm::Run run,
const edm::EventSetup eSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 62 of file PCLMetadataWriter.cc.

{} 
void PCLMetadataWriter::endRun ( const edm::Run run,
const edm::EventSetup eSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 64 of file PCLMetadataWriter.cc.

References lut2db_cfg::filename, edm::EventSetup::get(), DropBoxMetadata::getRecordParameters(), edm::Service< T >::isAvailable(), DropBoxMetadata::knowsRecord(), edm::ESHandle< T >::product(), and record.

                                                                             {

  const DropBoxMetadata *metadata = 0;

  if(readFromDB) {
    // Read the objects
    edm::ESHandle<DropBoxMetadata> mdPayload;
    eSetup.get<DropBoxMetadataRcd>().get(mdPayload);
    
    metadata = mdPayload.product();
  }

  // get the PoolDBOutputService
  Service<cond::service::PoolDBOutputService> poolDbService;
  if(poolDbService.isAvailable() ) {
    edm::Service<edm::JobReport> jr;
    if (jr.isAvailable()) {
      // the filename is unique for all records
      string filename = poolDbService->session().connectionString();

      // loop over all records
      for(map<string,  map<string, string> >::const_iterator recordAndMap = recordMap.begin();
          recordAndMap != recordMap.end();
          ++recordAndMap) {

        string record = (*recordAndMap).first;
        // this is the map of metadata that we write in the JR
        map<string, string> jrInfo = (*recordAndMap).second;
        if(readFromDB) {
          if(metadata->knowsRecord(record)) {
            jrInfo = metadata->getRecordParameters(record).getParameterMap();
          }
        }
        jrInfo["inputtag"] = poolDbService->tag(record);
        
        
        // actually write in the job report
        jr->reportAnalysisFile(filename, jrInfo);
      }
    }
  }
}

Member Data Documentation

Definition at line 41 of file PCLMetadataWriter.h.

std::map<std::string, std::map<std::string, std::string> > PCLMetadataWriter::recordMap [private]

Definition at line 42 of file PCLMetadataWriter.h.