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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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

◆ DQMStore

Definition at line 25 of file DQMFileLoader.h.

◆ MonitorElement

Definition at line 26 of file DQMFileLoader.h.

◆ sstring

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

Definition at line 29 of file DQMFileLoader.h.

◆ vstring

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

Definition at line 28 of file DQMFileLoader.h.

Constructor & Destructor Documentation

◆ TauDQMFileLoader()

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

Definition at line 120 of file DQMFileLoader.cc.

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

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

◆ ~TauDQMFileLoader()

TauDQMFileLoader::~TauDQMFileLoader ( )
override

Definition at line 146 of file DQMFileLoader.cc.

146  {
147  // nothing to be done yet...
148 }

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 150 of file DQMFileLoader.cc.

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

◆ endJob()

void TauDQMFileLoader::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 44 of file DQMFileLoader.h.

44 {}

◆ endRun()

void TauDQMFileLoader::endRun ( const edm::Run r,
const edm::EventSetup c 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 154 of file DQMFileLoader.cc.

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

References cfgError_, gather_cfg::cout, createBeamHaloJobs::directory, TrackerOfflineValidation_Dqm_cff::dirName, dqmCopyRecursively(), dqmDirectoryName(), dqmRootDirectory, dqmRootDirectory_inTFile, L1TBPTX_cfi::dqmStore, dqmSubDirectoryName_merged(), edmPickEvents::fileSet, fileSets_, dtResolutionTest_cfi::inputFile, InefficientDoubleROC::inputFileName, mapSubDirectoryStructure(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, getGTfromDQMFile::obj, AlCaHLTBitMon_QueryRunRegistry::string, subDirectoryMap_, and verbosity.

Member Data Documentation

◆ cfgError_

int TauDQMFileLoader::cfgError_
private

Definition at line 50 of file DQMFileLoader.h.

Referenced by endRun(), and TauDQMFileLoader().

◆ fileSets_

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

Definition at line 48 of file DQMFileLoader.h.

Referenced by endRun(), and TauDQMFileLoader().

◆ subDirectoryMap_

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

Definition at line 49 of file DQMFileLoader.h.

Referenced by endRun().

dqmRootDirectory_inTFile
const std::string dqmRootDirectory_inTFile
Definition: DQMFileLoader.cc:20
TauDQMFileLoader::subDirectoryMap_
std::map< std::string, sstring > subDirectoryMap_
Definition: DQMFileLoader.h:49
TauDQMFileLoader::fileSets_
std::map< std::string, cfgEntryFileSet > fileSets_
Definition: DQMFileLoader.h:48
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
TauDQMFileLoader::cfgError_
int cfgError_
Definition: DQMFileLoader.h:50
InefficientDoubleROC.inputFileName
inputFileName
Definition: InefficientDoubleROC.py:437
dqmSubDirectoryName_merged
std::string dqmSubDirectoryName_merged(const std::string &directory, const std::string &subdirectory)
Definition: dqmAuxFunctions.cc:66
dqmDirectoryName
std::string dqmDirectoryName(const std::string &dqmRootDirectory, const std::string &dqmSubDirectory)
Definition: EwkTauDQM.cc:10
dqmRootDirectory
const std::string dqmRootDirectory
Definition: dqmAuxFunctions.h:38
edmPickEvents.fileSet
fileSet
Definition: edmPickEvents.py:341
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
L1TBPTX_cfi.dqmStore
dqmStore
Definition: L1TBPTX_cfi.py:6
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
mapSubDirectoryStructure
void mapSubDirectoryStructure(TDirectory *directory, std::string directoryName, std::set< std::string > &subDirectories)
Definition: DQMFileLoader.cc:26
edm::LogError
Definition: MessageLogger.h:183
dqmCopyRecursively
void dqmCopyRecursively(dqm::legacy::DQMStore &dqmStore, const std::string &inputDirectory, const std::string &outputDirectory, double scaleFactor, int mode, bool rmInputDirectory)
Definition: dqmAuxFunctions.cc:109
edm::Service
Definition: Service.h:30
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
TauDQMFileLoader::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: DQMFileLoader.h:25
TauDQMFileLoader::sstring
std::set< std::string > sstring
Definition: DQMFileLoader.h:29
looper.cfg
cfg
Definition: looper.py:297
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
TrackerOfflineValidation_Dqm_cff.dirName
dirName
Definition: TrackerOfflineValidation_Dqm_cff.py:55
verbosity
const int verbosity
Definition: DQMFileLoader.cc:24