CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void endJob ()
 
virtual void endRun (const edm::Run &r, const edm::EventSetup &c)
 
 TauDQMFileLoader (const edm::ParameterSet &)
 
virtual ~TauDQMFileLoader ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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, sstringsubDirectoryMap_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 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 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
tuple cout
Definition: gather_cfg.py:121
TauDQMFileLoader::~TauDQMFileLoader ( )
virtual

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  
)
virtual

Implements edm::EDAnalyzer.

Definition at line 153 of file DQMFileLoader.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file DQMFileLoader.h.

43 {}
void TauDQMFileLoader::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, PFRecoTauDiscriminationAgainstMuonMVA_cfi::inputFileName, mapSubDirectoryStructure(), alignBH_cfg::mode, getGTfromDQMFile::obj, DQMStore::open(), DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), AlCaHLTBitMon_QueryRunRegistry::string, subDirectoryMap_, and PFRecoTauDiscriminationAgainstMuon2_cfi::verbosity.

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::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1630
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
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)
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2761
tuple cout
Definition: gather_cfg.py:121
const std::string dqmRootDirectory
void showDirStructure(void) const
Definition: DQMStore.cc:3175
void mapSubDirectoryStructure(TDirectory *directory, std::string directoryName, std::set< std::string > &subDirectories)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:639

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().