CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Attributes
TauDQMFileLoader Class Reference

#include <DQMFileLoader.h>

Inheritance diagram for TauDQMFileLoader:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  cfgEntryFileSet
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 TauDQMFileLoader (const edm::ParameterSet &)
 
 ~TauDQMFileLoader () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::set< std::string > sstring
 
typedef std::vector< std::string > vstring
 

Private Attributes

int cfgError_
 
std::map< std::string, cfgEntryFileSetfileSets_
 
std::map< std::string, sstringsubDirectoryMap_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Class to load DQM monitoring elements from ROOT files into DQMStore –> hanged name to avoid conflict with TauAnalysis package

Author
Christian Veelken, UC Davis

Definition at line 24 of file DQMFileLoader.h.

Member Typedef Documentation

typedef std::set<std::string> TauDQMFileLoader::sstring
private

Definition at line 27 of file DQMFileLoader.h.

typedef std::vector<std::string> TauDQMFileLoader::vstring
private

Definition at line 26 of file DQMFileLoader.h.

Constructor & Destructor Documentation

TauDQMFileLoader::TauDQMFileLoader ( const edm::ParameterSet cfg)
explicit

Definition at line 122 of file DQMFileLoader.cc.

References looper::cfg, cfgError_, gather_cfg::cout, edmPickEvents::fileSet, and fileSets_.

123 {
124  std::cout << "<TauDQMFileLoader::TauDQMFileLoader>:" << std::endl;
125 
126  cfgError_ = 0;
127 
128 //--- configure fileSets
129  //std::cout << "--> configuring fileSets..." << std::endl;
130  readCfgParameter<cfgEntryFileSet>(cfg, fileSets_);
131 
132 //--- check that dqmDirectory_store configuration parameters are specified for all fileSets,
133 // unless there is only one fileSet to be loaded
134 // (otherwise histograms of different fileSets get overwritten,
135 // once histograms of the next fileSet are loaded)
136  for ( std::map<std::string, cfgEntryFileSet>::const_iterator fileSet = fileSets_.begin();
137  fileSet != fileSets_.end(); ++fileSet ) {
138  if ( fileSet->second.dqmDirectory_store_ == "" && fileSets_.size() > 1 ) {
139  edm::LogError ("TauDQMFileLoader") << " dqmDirectory_store undefined for fileSet = " << fileSet->second.name_ << " !!";
140  cfgError_ = 1;
141  break;
142  }
143  }
144 
145  std::cout << "done." << std::endl;
146 }
std::map< std::string, cfgEntryFileSet > fileSets_
Definition: DQMFileLoader.h:47
TauDQMFileLoader::~TauDQMFileLoader ( )
override

Definition at line 148 of file DQMFileLoader.cc.

149 {
150 // nothing to be done yet...
151 }

Member Function Documentation

void TauDQMFileLoader::analyze ( const edm::Event ,
const edm::EventSetup  
)
override

Definition at line 153 of file DQMFileLoader.cc.

154 {
155 // nothing to be done yet...
156 }
void TauDQMFileLoader::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file DQMFileLoader.h.

References EnergyCorrector::c, endRun(), and alignCSCRings::r.

43 {}
void TauDQMFileLoader::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 158 of file DQMFileLoader.cc.

References cfgError_, gather_cfg::cout, DEFINE_FWK_MODULE, createBeamHaloJobs::directory, TrackerOfflineValidation_Dqm_cff::dirName, dqmCopyRecursively(), dqmDirectoryName(), dqmRootDirectory, dqmRootDirectory_inTFile, dqmSubDirectoryName_merged(), edmPickEvents::fileSet, fileSets_, DQMStore::getSubdirs(), analyzePatCleaning_cfg::inputFile, writeAntiElectronDiscrMVA_cfi::inputFileName, mapSubDirectoryStructure(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, GetRecoTauVFromDQM_MC_cff::obj, DQMStore::open(), DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), AlCaHLTBitMon_QueryRunRegistry::string, subDirectoryMap_, and verbosity.

Referenced by endJob().

159 {
160  std::cout << "<TauDQMFileLoader::endJob>:" << std::endl;
161 
162 //--- check that configuration parameters contain no errors
163  if ( cfgError_ ) {
164  edm::LogError ("endJob") << " Error in Configuration ParameterSet"
165  << " --> histograms will NOT be loaded !!";
166  return;
167  }
168 
169 //--- check that DQMStore service is available
170  if ( !edm::Service<DQMStore>().isAvailable() ) {
171  edm::LogError ("endJob") << " Failed to access dqmStore"
172  << " --> histograms will NOT be loaded !!";
173  return;
174  }
175 
176 //--- stop ROOT from keeping references to all histograms
177  //TH1::AddDirectory(false);
178 
179 //--- check that inputFiles exist;
180 // store list of directories existing in inputFile,
181 // in order to separate histogram directories existing in the inputFile from directories existing in DQMStore
182 // when calling recursive function dqmCopyRecursively
183  for ( std::map<std::string, cfgEntryFileSet>::const_iterator fileSet = fileSets_.begin();
184  fileSet != fileSets_.end(); ++fileSet ) {
185  for ( vstring::const_iterator inputFileName = fileSet->second.inputFileNames_.begin();
186  inputFileName != fileSet->second.inputFileNames_.end(); ++inputFileName ) {
187  //std::cout << " checking inputFile = " << (*inputFileName) << std::endl;
188  TFile inputFile(inputFileName->data());
189  if ( inputFile.IsZombie() ) {
190  edm::LogError ("endJob") << " Failed to open inputFile = " << (*inputFileName)
191  << "--> histograms will NOT be loaded !!";
192  return;
193  }
194 
195  TObject* obj = inputFile.Get(dqmRootDirectory_inTFile.data());
196  //std::cout << " obj = " << obj << std::endl;
197  if ( TDirectory* directory = dynamic_cast<TDirectory*>(obj) ) {
199  } else {
200  edm::LogError ("endJob") << " Failed to access " << dqmRootDirectory_inTFile << " in inputFile = " << (*inputFileName)
201  << "--> histograms will NOT be loaded !!";
202  return;
203  }
204 
205  inputFile.Close();
206  }
207  }
208 
209  //for ( std::map<std::string, sstring>::const_iterator inputFile = subDirectoryMap_.begin();
210  // inputFile != subDirectoryMap_.end(); ++inputFile ) {
211  // std::cout << "inputFile = " << inputFile->first << ":" << std::endl;
212  // for ( sstring::const_iterator directory = inputFile->second.begin();
213  // directory != inputFile->second.end(); ++directory ) {
214  // std::cout << " " << (*directory) << std::endl;
215  // }
216  //}
217 
218 //--- load histograms from file
219  //std::cout << "--> loading histograms from file..." << std::endl;
220  DQMStore& dqmStore = (*edm::Service<DQMStore>());
221  for ( std::map<std::string, cfgEntryFileSet>::const_iterator fileSet = fileSets_.begin();
222  fileSet != fileSets_.end(); ++fileSet ) {
223  for ( vstring::const_iterator inputFileName = fileSet->second.inputFileNames_.begin();
224  inputFileName != fileSet->second.inputFileNames_.end(); ++inputFileName ) {
225  if ( verbosity ) std::cout << " opening inputFile = " << (*inputFileName) << std::endl;
226  dqmStore.open(*inputFileName, true);
227 
228  //if ( verbosity ) dqmStore.showDirStructure();
229 
230 //--- if dqmDirectory_store specified in configuration parameters,
231 // move histograms from dqmRootDirectory to dqmDirectory_store
232 // (if the histograms are not moved, the histograms get overwritten,
233 // the next time DQMStore::open is called)
234  if ( fileSet->second.dqmDirectory_store_ != "" ) {
235  std::string inputDirectory = dqmRootDirectory;
236  //std::cout << "inputDirectory = " << inputDirectory << std::endl;
237  std::string outputDirectory = dqmDirectoryName(std::string(inputDirectory)).append(fileSet->second.dqmDirectory_store_);
238  //std::cout << "outputDirectory = " << outputDirectory << std::endl;
239 
240  dqmStore.setCurrentFolder(inputDirectory);
241  std::vector<std::string> dirNames = dqmStore.getSubdirs();
242  for ( std::vector<std::string>::const_iterator dirName = dirNames.begin();
243  dirName != dirNames.end(); ++dirName ) {
244  std::string subDirName = dqmSubDirectoryName_merged(inputDirectory, *dirName);
245  //std::cout << " subDirName = " << subDirName << std::endl;
246 
247  const sstring& subDirectories = subDirectoryMap_[*inputFileName];
248  if ( subDirectories.find(subDirName) != subDirectories.end() ) {
249  std::string inputDirName_full = dqmDirectoryName(inputDirectory).append(subDirName);
250  //std::cout << " inputDirName_full = " << inputDirName_full << std::endl;
251 
252  std::string outputDirName_full = dqmDirectoryName(outputDirectory).append(subDirName);
253  //std::cout << " outputDirName_full = " << outputDirName_full << std::endl;
254 
255 //--- load histograms contained in inputFile into inputDirectory;
256 // when processing first inputFile, check that histograms in outputDirectory do not yet exist;
257 // add histograms in inputFile to those in outputDirectory afterwards;
258 // clear inputDirectory once finished processing all inputFiles.
259  int mode = ( inputFileName == fileSet->second.inputFileNames_.begin() ) ? 1 : 3;
260  dqmCopyRecursively(dqmStore, inputDirName_full, outputDirName_full, fileSet->second.scaleFactor_, mode, true);
261  }
262  }
263  }
264  }
265  }
266 
267  std::cout << "done." << std::endl;
268  if ( verbosity ) dqmStore.showDirStructure();
269 }
std::set< std::string > sstring
Definition: DQMFileLoader.h:27
std::string dqmDirectoryName(const std::string &dqmRootDirectory, const std::string &dqmSubDirectory)
Definition: EwkTauDQM.cc:10
const std::string dqmRootDirectory_inTFile
std::string dqmSubDirectoryName_merged(const std::string &directory, const std::string &subdirectory)
std::map< std::string, sstring > subDirectoryMap_
Definition: DQMFileLoader.h:48
bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2861
std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:1552
const int verbosity
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:565
void showDirStructure() const
Definition: DQMStore.cc:3285
std::map< std::string, cfgEntryFileSet > fileSets_
Definition: DQMFileLoader.h:47
void dqmCopyRecursively(DQMStore &dqmStore, const std::string &inputDirectory, const std::string &outputDirectory, double scaleFactor, int mode, bool rmInputDirectory)
const std::string dqmRootDirectory
void mapSubDirectoryStructure(TDirectory *directory, std::string directoryName, std::set< std::string > &subDirectories)

Member Data Documentation

int TauDQMFileLoader::cfgError_
private

Definition at line 49 of file DQMFileLoader.h.

Referenced by endRun(), and TauDQMFileLoader().

std::map<std::string, cfgEntryFileSet> TauDQMFileLoader::fileSets_
private

Definition at line 47 of file DQMFileLoader.h.

Referenced by endRun(), and TauDQMFileLoader().

std::map<std::string, sstring> TauDQMFileLoader::subDirectoryMap_
private

Definition at line 48 of file DQMFileLoader.h.

Referenced by endRun().