#include <DQMFileLoader.h>
Classes | |
struct | cfgEntryFileSet |
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
DQMFileLoader (const edm::ParameterSet &) | |
virtual void | endJob () |
virtual void | endRun (const edm::Run &r, const edm::EventSetup &c) |
virtual | ~DQMFileLoader () |
Private Types | |
typedef std::set< std::string > | sstring |
typedef std::vector< std::string > | vstring |
Private Attributes | |
int | cfgError_ |
std::map< std::string, cfgEntryFileSet > | fileSets_ |
std::map< std::string, sstring > | subDirectoryMap_ |
Class to load DQM monitoring elements from ROOT files into DQMStore
Definition at line 26 of file DQMFileLoader.h.
typedef std::set<std::string> DQMFileLoader::sstring [private] |
Definition at line 29 of file DQMFileLoader.h.
typedef std::vector<std::string> DQMFileLoader::vstring [private] |
Definition at line 28 of file DQMFileLoader.h.
DQMFileLoader::DQMFileLoader | ( | const edm::ParameterSet & | cfg | ) | [explicit] |
Definition at line 122 of file DQMFileLoader.cc.
References cfgError_, gather_cfg::cout, edmPickEvents::fileSet, and fileSets_.
{ std::cout << "<DQMFileLoader::DQMFileLoader>:" << std::endl; cfgError_ = 0; //--- configure fileSets //std::cout << "--> configuring fileSets..." << std::endl; readCfgParameter<cfgEntryFileSet>(cfg, fileSets_); //--- check that dqmDirectory_store configuration parameters are specified for all fileSets, // unless there is only one fileSet to be loaded // (otherwise histograms of different fileSets get overwritten, // once histograms of the next fileSet are loaded) for ( std::map<std::string, cfgEntryFileSet>::const_iterator fileSet = fileSets_.begin(); fileSet != fileSets_.end(); ++fileSet ) { if ( fileSet->second.dqmDirectory_store_ == "" && fileSets_.size() > 1 ) { edm::LogError ("DQMFileLoader") << " dqmDirectory_store undefined for fileSet = " << fileSet->second.name_ << " !!"; cfgError_ = 1; break; } } std::cout << "done." << std::endl; }
DQMFileLoader::~DQMFileLoader | ( | ) | [virtual] |
Definition at line 148 of file DQMFileLoader.cc.
{
// nothing to be done yet...
}
void DQMFileLoader::analyze | ( | const edm::Event & | , |
const edm::EventSetup & | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 153 of file DQMFileLoader.cc.
{
// nothing to be done yet...
}
virtual void DQMFileLoader::endJob | ( | void | ) | [inline, virtual] |
void DQMFileLoader::endRun | ( | const edm::Run & | r, |
const edm::EventSetup & | c | ||
) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 158 of file DQMFileLoader.cc.
References cfgError_, gather_cfg::cout, createBeamHaloJobs::directory, TrackerOfflineValidation_Dqm_cff::dirName, dqmCopyRecursively(), dqmDirectoryName(), dqmRootDirectory, dqmRootDirectory_inTFile, dqmSubDirectoryName_merged(), edmPickEvents::fileSet, fileSets_, DQMStore::getSubdirs(), analyzePatCleaning_cfg::inputFile, mapSubDirectoryStructure(), mode, VarParsing::obj, DQMStore::open(), DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), subDirectoryMap_, and verbosity.
{ std::cout << "<DQMFileLoader::endJob>:" << std::endl; //--- check that configuration parameters contain no errors if ( cfgError_ ) { edm::LogError ("endJob") << " Error in Configuration ParameterSet" << " --> histograms will NOT be loaded !!"; return; } //--- check that DQMStore service is available if ( !edm::Service<DQMStore>().isAvailable() ) { edm::LogError ("endJob") << " Failed to access dqmStore" << " --> histograms will NOT be loaded !!"; return; } //--- stop ROOT from keeping references to all histograms //TH1::AddDirectory(false); //--- check that inputFiles exist; // store list of directories existing in inputFile, // in order to separate histogram directories existing in the inputFile from directories existing in DQMStore // when calling recursive function dqmCopyRecursively for ( std::map<std::string, cfgEntryFileSet>::const_iterator fileSet = fileSets_.begin(); fileSet != fileSets_.end(); ++fileSet ) { for ( vstring::const_iterator inputFileName = fileSet->second.inputFileNames_.begin(); inputFileName != fileSet->second.inputFileNames_.end(); ++inputFileName ) { //std::cout << " checking inputFile = " << (*inputFileName) << std::endl; TFile inputFile(inputFileName->data()); if ( inputFile.IsZombie() ) { edm::LogError ("endJob") << " Failed to open inputFile = " << (*inputFileName) << "--> histograms will NOT be loaded !!"; return; } TObject* obj = inputFile.Get(dqmRootDirectory_inTFile.data()); //std::cout << " obj = " << obj << std::endl; if ( TDirectory* directory = dynamic_cast<TDirectory*>(obj) ) { mapSubDirectoryStructure(directory, dqmRootDirectory, subDirectoryMap_[*inputFileName]); } else { edm::LogError ("endJob") << " Failed to access " << dqmRootDirectory_inTFile << " in inputFile = " << (*inputFileName) << "--> histograms will NOT be loaded !!"; return; } inputFile.Close(); } } //for ( std::map<std::string, sstring>::const_iterator inputFile = subDirectoryMap_.begin(); // inputFile != subDirectoryMap_.end(); ++inputFile ) { // std::cout << "inputFile = " << inputFile->first << ":" << std::endl; // for ( sstring::const_iterator directory = inputFile->second.begin(); // directory != inputFile->second.end(); ++directory ) { // std::cout << " " << (*directory) << std::endl; // } //} //--- load histograms from file //std::cout << "--> loading histograms from file..." << std::endl; DQMStore& dqmStore = (*edm::Service<DQMStore>()); for ( std::map<std::string, cfgEntryFileSet>::const_iterator fileSet = fileSets_.begin(); fileSet != fileSets_.end(); ++fileSet ) { for ( vstring::const_iterator inputFileName = fileSet->second.inputFileNames_.begin(); inputFileName != fileSet->second.inputFileNames_.end(); ++inputFileName ) { if ( verbosity ) std::cout << " opening inputFile = " << (*inputFileName) << std::endl; dqmStore.open(*inputFileName, true); //if ( verbosity ) dqmStore.showDirStructure(); //--- if dqmDirectory_store specified in configuration parameters, // move histograms from dqmRootDirectory to dqmDirectory_store // (if the histograms are not moved, the histograms get overwritten, // the next time DQMStore::open is called) if ( fileSet->second.dqmDirectory_store_ != "" ) { std::string inputDirectory = dqmRootDirectory; //std::cout << "inputDirectory = " << inputDirectory << std::endl; std::string outputDirectory = dqmDirectoryName(std::string(inputDirectory)).append(fileSet->second.dqmDirectory_store_); //std::cout << "outputDirectory = " << outputDirectory << std::endl; dqmStore.setCurrentFolder(inputDirectory); std::vector<std::string> dirNames = dqmStore.getSubdirs(); for ( std::vector<std::string>::const_iterator dirName = dirNames.begin(); dirName != dirNames.end(); ++dirName ) { std::string subDirName = dqmSubDirectoryName_merged(inputDirectory, *dirName); //std::cout << " subDirName = " << subDirName << std::endl; const sstring& subDirectories = subDirectoryMap_[*inputFileName]; if ( subDirectories.find(subDirName) != subDirectories.end() ) { std::string inputDirName_full = dqmDirectoryName(inputDirectory).append(subDirName); //std::cout << " inputDirName_full = " << inputDirName_full << std::endl; std::string outputDirName_full = dqmDirectoryName(outputDirectory).append(subDirName); //std::cout << " outputDirName_full = " << outputDirName_full << std::endl; //--- load histograms contained in inputFile into inputDirectory; // when processing first inputFile, check that histograms in outputDirectory do not yet exist; // add histograms in inputFile to those in outputDirectory afterwards; // clear inputDirectory once finished processing all inputFiles. int mode = ( inputFileName == fileSet->second.inputFileNames_.begin() ) ? 1 : 3; dqmCopyRecursively(dqmStore, inputDirName_full, outputDirName_full, fileSet->second.scaleFactor_, mode, true); } } } } } std::cout << "done." << std::endl; if ( verbosity ) dqmStore.showDirStructure(); }
int DQMFileLoader::cfgError_ [private] |
Definition at line 51 of file DQMFileLoader.h.
Referenced by DQMFileLoader(), and endRun().
std::map<std::string, cfgEntryFileSet> DQMFileLoader::fileSets_ [private] |
Definition at line 49 of file DQMFileLoader.h.
Referenced by DQMFileLoader(), and endRun().
std::map<std::string, sstring> DQMFileLoader::subDirectoryMap_ [private] |
Definition at line 50 of file DQMFileLoader.h.
Referenced by endRun().