CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
TauDQMFileLoader Class Reference

#include <DQMFileLoader.h>

Inheritance diagram for TauDQMFileLoader:
edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  cfgEntryFileSet
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 TauDQMFileLoader (const edm::ParameterSet &)
 
 ~TauDQMFileLoader () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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

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

◆ ~TauDQMFileLoader()

TauDQMFileLoader::~TauDQMFileLoader ( )
override

Definition at line 147 of file DQMFileLoader.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 151 of file DQMFileLoader.cc.

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

◆ beginRun()

void TauDQMFileLoader::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
inlineoverride

Definition at line 44 of file DQMFileLoader.h.

44 {}

◆ endRun()

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

Definition at line 155 of file DQMFileLoader.cc.

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

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

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