CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
GBRForestWriter Class Reference
Inheritance diagram for GBRForestWriter:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  categoryEntryType
 
struct  jobEntryType
 

Public Member Functions

 GBRForestWriter (const edm::ParameterSet &)
 
 ~GBRForestWriter () 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
 
std::vector< ESProxyIndex > 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::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 std::vector< std::string > vstring
 

Private Member Functions

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

Private Attributes

bool hasRun_
 
std::vector< jobEntryType * > jobs_
 
std::string moduleLabel_
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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

Read GBRForest objects from ROOT file input and store it in SQL-lite output file

Authors
Christian Veelken, LLR

Definition at line 24 of file GBRForestWriter.cc.

Member Typedef Documentation

◆ vstring

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

Definition at line 36 of file GBRForestWriter.cc.

Constructor & Destructor Documentation

◆ GBRForestWriter()

GBRForestWriter::GBRForestWriter ( const edm::ParameterSet cfg)

Definition at line 116 of file GBRForestWriter.cc.

117  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
118  edm::VParameterSet cfgJobs = cfg.getParameter<edm::VParameterSet>("jobs");
119  for (edm::VParameterSet::const_iterator cfgJob = cfgJobs.begin(); cfgJob != cfgJobs.end(); ++cfgJob) {
120  jobEntryType* job = new jobEntryType(*cfgJob);
121  jobs_.push_back(job);
122  }
123 }

References looper::cfg, and jobs_.

◆ ~GBRForestWriter()

GBRForestWriter::~GBRForestWriter ( )
override

Definition at line 125 of file GBRForestWriter.cc.

125  {
126  for (std::vector<jobEntryType*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) {
127  delete (*it);
128  }
129 }

References jobs_.

Member Function Documentation

◆ analyze()

void GBRForestWriter::analyze ( const edm::Event ,
const edm::EventSetup  
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 131 of file GBRForestWriter.cc.

131  {
132  for (std::vector<jobEntryType*>::iterator job = jobs_.begin(); job != jobs_.end(); ++job) {
133  std::map<std::string, const GBRForest*> gbrForests; // key = name
134  for (std::vector<categoryEntryType*>::iterator category = (*job)->categories_.begin();
135  category != (*job)->categories_.end();
136  ++category) {
137  const GBRForest* gbrForest = nullptr;
138  if ((*category)->inputFileType_ == categoryEntryType::kXML) {
139  gbrForest = createGBRForest((*category)->inputFileName_).release();
140  } else if ((*category)->inputFileType_ == categoryEntryType::kGBRForest) {
141  TFile* inputFile = new TFile((*category)->inputFileName_.data());
142  // gbrForest = dynamic_cast<GBRForest*>(inputFile->Get((*category)->gbrForestName_.data())); // CV:
143  // dynamic_cast<GBRForest*> fails for some reason ?!
144  gbrForest = (GBRForest*)inputFile->Get((*category)->gbrForestName_.data());
145  delete inputFile;
146  }
147  if (!gbrForest)
148  throw cms::Exception("GBRForestWriter") << " Failed to load GBRForest = " << (*category)->gbrForestName_.data()
149  << " from file = " << (*category)->inputFileName_ << " !!\n";
150  gbrForests[(*category)->gbrForestName_] = gbrForest;
151  }
152  if ((*job)->outputFileType_ == jobEntryType::kGBRForest) {
153  TFile* outputFile = new TFile((*job)->outputFileName_.data(), "RECREATE");
154 
155  for (std::map<std::string, const GBRForest*>::iterator gbrForest = gbrForests.begin();
156  gbrForest != gbrForests.end();
157  ++gbrForest) {
158  outputFile->WriteObject(gbrForest->second, gbrForest->first.data());
159  }
160  delete outputFile;
161  } else if ((*job)->outputFileType_ == jobEntryType::kSQLLite) {
163  if (!dbService.isAvailable())
164  throw cms::Exception("GBRForestWriter") << " Failed to access PoolDBOutputService !!\n";
165 
166  for (std::map<std::string, const GBRForest*>::iterator gbrForest = gbrForests.begin();
167  gbrForest != gbrForests.end();
168  ++gbrForest) {
169  std::string outputRecord = (*job)->outputRecord_;
170  if (gbrForests.size() > 1)
171  outputRecord.append("_").append(gbrForest->first);
172  dbService->writeOne(gbrForest->second, dbService->beginOfTime(), outputRecord);
173  }
174  }
175 
176  // gbrforest deletion
177  for (std::map<std::string, const GBRForest*>::iterator gbrForest = gbrForests.begin();
178  gbrForest != gbrForests.end();
179  ++gbrForest) {
180  delete gbrForest->second;
181  }
182  }
183 }

References cond::service::PoolDBOutputService::beginOfTime(), taus_updatedMVAIds_cff::category, createGBRForest(), Exception, dtResolutionTest_cfi::inputFile, edm::Service< T >::isAvailable(), jobs_, GBRForestWriter::categoryEntryType::kGBRForest, GBRForestWriter::jobEntryType::kGBRForest, GBRForestWriter::jobEntryType::kSQLLite, GBRForestWriter::categoryEntryType::kXML, download_sqlite_cfg::outputFile, AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOne().

Member Data Documentation

◆ hasRun_

bool GBRForestWriter::hasRun_
private

Definition at line 34 of file GBRForestWriter.cc.

◆ jobs_

std::vector<jobEntryType*> GBRForestWriter::jobs_
private

Definition at line 113 of file GBRForestWriter.cc.

Referenced by analyze(), GBRForestWriter(), and ~GBRForestWriter().

◆ moduleLabel_

std::string GBRForestWriter::moduleLabel_
private
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
GBRForestWriter::jobEntryType::kSQLLite
Definition: GBRForestWriter.cc:108
GBRForest
Definition: GBRForest.h:25
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:244
GBRForestWriter::moduleLabel_
std::string moduleLabel_
Definition: GBRForestWriter.cc:32
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
download_sqlite_cfg.outputFile
outputFile
Definition: download_sqlite_cfg.py:5
GBRForestWriter::categoryEntryType::kXML
Definition: GBRForestWriter.cc:67
GBRForestWriter::jobEntryType::kGBRForest
Definition: GBRForestWriter.cc:108
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Service< cond::service::PoolDBOutputService >
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
GBRForestWriter::jobs_
std::vector< jobEntryType * > jobs_
Definition: GBRForestWriter.cc:113
looper.cfg
cfg
Definition: looper.py:297
GBRForestWriter::categoryEntryType::kGBRForest
Definition: GBRForestWriter.cc:67
Exception
Definition: hltDiff.cc:246
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
cms::Exception
Definition: Exception.h:70