CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
NanoAODOutputModule Class Reference
Inheritance diagram for NanoAODOutputModule:
edm::one::OutputModule<> edm::one::OutputModuleBase edm::core::OutputModuleCore edm::EDConsumerBase

Classes

class  CommonEventBranches
 
class  CommonLumiBranches
 
class  CommonRunBranches
 

Public Member Functions

 NanoAODOutputModule (edm::ParameterSet const &pset)
 
 ~NanoAODOutputModule () override
 
- Public Member Functions inherited from edm::one::OutputModule<>
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const OutputModuleoperator= (const OutputModule &)=delete
 
 OutputModule (edm::ParameterSet const &iPSet)
 
 OutputModule (const OutputModule &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::OutputModuleBase
OutputModuleBaseoperator= (OutputModuleBase const &)=delete
 
 OutputModuleBase (ParameterSet const &pset)
 
 OutputModuleBase (OutputModuleBase const &)=delete
 
SharedResourcesAcquirersharedResourcesAcquirer ()
 
SubProcessParentageHelper const * subProcessParentageHelper () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
- Public Member Functions inherited from edm::core::OutputModuleCore
BranchIDLists const * branchIDLists () const
 
std::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch () const
 
SelectedProductsForBranchType const & keptProducts () const
 
int maxEvents () const
 
const ModuleDescriptionmoduleDescription () const
 
OutputModuleCoreoperator= (OutputModuleCore const &)=delete
 
 OutputModuleCore (ParameterSet const &pset)
 
 OutputModuleCore (OutputModuleCore const &)=delete
 
OutputProcessBlockHelper const & outputProcessBlockHelper () const
 
std::string const & processName () const
 
int remainingEvents () const
 
bool selected (BranchDescription const &desc) const
 
void selectProducts (ProductRegistry const &preg, ThinnedAssociationsHelper const &, ProcessBlockHelperBase const &)
 
ThinnedAssociationsHelper const * thinnedAssociationsHelper () const
 
bool wantAllEvents () const
 
 ~OutputModuleCore () 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
 
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::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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::core::OutputModuleCore
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

bool isFileOpen () const override
 
void openFile (edm::FileBlock const &) override
 
void reallyCloseFile () override
 
void write (edm::EventForOutput const &e) override
 
void writeLuminosityBlock (edm::LuminosityBlockForOutput const &) override
 
void writeRun (edm::RunForOutput const &) override
 

Private Attributes

int m_autoFlush
 
class NanoAODOutputModule::CommonEventBranches m_commonBranches
 
class NanoAODOutputModule::CommonLumiBranches m_commonLumiBranches
 
class NanoAODOutputModule::CommonRunBranches m_commonRunBranches
 
std::string m_compressionAlgorithm
 
int m_compressionLevel
 
int m_eventsSinceFlush {0}
 
std::vector< EventStringOutputBranchesm_evstrings
 
bool m_fakeName
 
std::unique_ptr< TFile > m_file
 
std::string m_fileName
 
edm::JobReport::Token m_jrToken
 
std::string m_logicalFileName
 
std::vector< SummaryTableOutputBranchesm_lumiTables
 
std::vector< LumiOutputBranchesm_lumiTables2
 
std::unique_ptr< TTree > m_lumiTree
 
std::unique_ptr< TTree > m_metaDataTree
 
std::vector< std::pair< std::string, edm::EDGetToken > > m_nanoMetadata
 
std::unique_ptr< TTree > m_parameterSetsTree
 
edm::ProcessHistoryRegistry m_processHistoryRegistry
 
std::vector< TableOutputBranchesm_runFlatTables
 
std::vector< SummaryTableOutputBranchesm_runTables
 
std::unique_ptr< TTree > m_runTree
 
std::vector< TableOutputBranchesm_tables
 
std::unique_ptr< TTree > m_tree
 
std::vector< TriggerOutputBranchesm_triggers
 
bool m_triggers_areSorted = false
 
bool m_writeProvenance
 

Static Private Attributes

static constexpr int m_firstFlush {1000}
 

Additional Inherited Members

- Public Types inherited from edm::one::OutputModuleBase
typedef OutputModuleBase ModuleType
 
- Public Types inherited from edm::core::OutputModuleCore
typedef OutputModuleCore ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::one::OutputModuleBase
void configure (OutputModuleDescription const &desc)
 
void doBeginJob ()
 
bool doEvent (EventTransitionInfo const &, ActivityRegistry *, ModuleCallingContext const *)
 
void doPreallocate (PreallocationConfiguration const &)
 
- Protected Member Functions inherited from edm::core::OutputModuleCore
void configure (OutputModuleDescription const &desc)
 
ModuleDescription const & description () const
 
void doAccessInputProcessBlock (ProcessBlockPrincipal const &, ModuleCallingContext const *)
 
void doBeginJob_ ()
 
bool doBeginLuminosityBlock (LumiTransitionInfo const &, ModuleCallingContext const *)
 
void doBeginProcessBlock (ProcessBlockPrincipal const &, ModuleCallingContext const *)
 
bool doBeginRun (RunTransitionInfo const &, ModuleCallingContext const *)
 
void doEndJob ()
 
bool doEndLuminosityBlock (LumiTransitionInfo const &, ModuleCallingContext const *)
 
void doEndProcessBlock (ProcessBlockPrincipal const &, ModuleCallingContext const *)
 
bool doEndRun (RunTransitionInfo const &, ModuleCallingContext const *)
 
bool doEvent_ (EventTransitionInfo const &, ActivityRegistry *, ModuleCallingContext const *)
 
void doPreallocate_ (PreallocationConfiguration const &)
 
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID ()
 
virtual void preallocLumis (unsigned int)
 
ParameterSetID selectorConfig () const
 
void setEventSelectionInfo (std::map< std::string, std::vector< std::pair< std::string, int >>> const &outputModulePathPositions, bool anyProductProduced)
 
- 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 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<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)
 
- Protected Attributes inherited from edm::core::OutputModuleCore
std::atomic< int > remainingEvents_
 

Detailed Description

Definition at line 51 of file NanoAODOutputModule.cc.

Constructor & Destructor Documentation

◆ NanoAODOutputModule()

NanoAODOutputModule::NanoAODOutputModule ( edm::ParameterSet const &  pset)

Definition at line 149 of file NanoAODOutputModule.cc.

152  m_fileName(pset.getUntrackedParameter<std::string>("fileName")),
153  m_logicalFileName(pset.getUntrackedParameter<std::string>("logicalFileName")),
154  m_compressionLevel(pset.getUntrackedParameter<int>("compressionLevel")),
155  m_compressionAlgorithm(pset.getUntrackedParameter<std::string>("compressionAlgorithm")),
156  m_writeProvenance(pset.getUntrackedParameter<bool>("saveProvenance", true)),
157  m_fakeName(pset.getUntrackedParameter<bool>("fakeNameForCrab", false)),
158  m_autoFlush(pset.getUntrackedParameter<int>("autoFlush", -10000000)),
OutputModuleBase(ParameterSet const &pset)
edm::ProcessHistoryRegistry m_processHistoryRegistry
std::string m_compressionAlgorithm

◆ ~NanoAODOutputModule()

NanoAODOutputModule::~NanoAODOutputModule ( )
override

Definition at line 161 of file NanoAODOutputModule.cc.

161 {}

Member Function Documentation

◆ fillDescriptions()

void NanoAODOutputModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 396 of file NanoAODOutputModule.cc.

References edm::ConfigurationDescriptions::addDefault(), EgammaPostProcessor_cfi::dataSet, submitPVResolutionJobs::desc, edm::core::OutputModuleCore::fillDescription(), runTheMatrix::keep, edm::ParameterSetDescription::setAllowAnything(), and AlCaHLTBitMon_QueryRunRegistry::string.

396  {
398 
399  desc.addUntracked<std::string>("fileName");
400  desc.addUntracked<std::string>("logicalFileName", "");
401 
402  desc.addUntracked<int>("compressionLevel", 9)->setComment("ROOT compression level of output file.");
403  desc.addUntracked<std::string>("compressionAlgorithm", "ZLIB")
404  ->setComment("Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
405  desc.addUntracked<bool>("saveProvenance", true)
406  ->setComment("Save process provenance information, e.g. for edmProvDump");
407  desc.addUntracked<bool>("fakeNameForCrab", false)
408  ->setComment(
409  "Change the OutputModule name in the fwk job report to fake PoolOutputModule. This is needed to run on cran "
410  "(and publish) till crab is fixed");
411  desc.addUntracked<int>("autoFlush", -10000000)->setComment("Autoflush parameter for ROOT file");
412 
413  //replace with whatever you want to get from the EDM by default
414  const std::vector<std::string> keep = {"drop *",
415  "keep nanoaodFlatTable_*Table_*_*",
416  "keep edmTriggerResults_*_*_*",
417  "keep String_*_genModel_*",
418  "keep nanoaodMergeableCounterTable_*Table_*_*",
419  "keep nanoaodUniqueString_nanoMetadata_*_*"};
421 
422  //Used by Workflow management for their own meta data
424  dataSet.setAllowAnything();
425  desc.addUntracked<edm::ParameterSetDescription>("dataset", dataSet)
426  ->setComment("PSet is only used by Data Operations and not by this module.");
427 
429  branchSet.setAllowAnything();
430  desc.add<edm::ParameterSetDescription>("branches", branchSet);
431 
432  descriptions.addDefault(desc);
433 }
void setAllowAnything()
allow any parameter label/value pairs
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())

◆ isFileOpen()

bool NanoAODOutputModule::isFileOpen ( ) const
overrideprivatevirtual

Reimplemented from edm::core::OutputModuleCore.

Definition at line 279 of file NanoAODOutputModule.cc.

References m_file.

279 { return nullptr != m_file.get(); }
std::unique_ptr< TFile > m_file

◆ openFile()

void NanoAODOutputModule::openFile ( edm::FileBlock const &  )
overrideprivatevirtual

Reimplemented from edm::core::OutputModuleCore.

Definition at line 281 of file NanoAODOutputModule.cc.

References NanoAODOutputModule::CommonEventBranches::branch(), NanoAODOutputModule::CommonLumiBranches::branch(), NanoAODOutputModule::CommonRunBranches::branch(), edm::createGlobalIdentifier(), edm::core::OutputModuleCore::description(), cms::Digest::digest(), Exception, edm::InEvent, edm::InLumi, edm::InRun, runTheMatrix::keep, edm::core::OutputModuleCore::keptProducts(), m_commonBranches, m_commonLumiBranches, m_commonRunBranches, m_compressionAlgorithm, m_compressionLevel, m_evstrings, m_fakeName, m_file, m_fileName, m_jrToken, m_logicalFileName, m_lumiTables, m_lumiTables2, m_lumiTree, m_metaDataTree, m_nanoMetadata, m_parameterSetsTree, m_runFlatTables, m_runTables, m_runTree, m_tables, m_tree, m_triggers, m_triggers_areSorted, m_writeProvenance, edm::poolNames::metaDataTreeName(), HerwigMaxPtPartonFilter_cfi::moduleLabel, edm::poolNames::parameterSetsTreeName(), AlCaHLTBitMon_QueryRunRegistry::string, and cms::MD5Result::toString().

281  {
282  m_file = std::make_unique<TFile>(m_fileName.c_str(), "RECREATE", "", m_compressionLevel);
284  cms::Digest branchHash;
285  m_jrToken = jr->outputFileOpened(m_fileName,
287  std::string(),
288  m_fakeName ? "PoolOutputModule" : "NanoAODOutputModule",
291  std::string(),
292  branchHash.digest().toString(),
293  std::vector<std::string>());
294 
295  if (m_compressionAlgorithm == std::string("ZLIB")) {
296  m_file->SetCompressionAlgorithm(ROOT::kZLIB);
297  } else if (m_compressionAlgorithm == std::string("LZMA")) {
298  m_file->SetCompressionAlgorithm(ROOT::kLZMA);
299  } else {
300  throw cms::Exception("Configuration")
301  << "NanoAODOutputModule configured with unknown compression algorithm '" << m_compressionAlgorithm << "'\n"
302  << "Allowed compression algorithms are ZLIB and LZMA\n";
303  }
304  /* Setup file structure here */
305  m_tables.clear();
306  m_triggers.clear();
307  m_triggers_areSorted = false;
308  m_evstrings.clear();
309  m_runTables.clear();
310  m_lumiTables.clear();
311  m_lumiTables2.clear();
312  m_runFlatTables.clear();
313  const auto& keeps = keptProducts();
314  for (const auto& keep : keeps[edm::InEvent]) {
315  if (keep.first->className() == "nanoaod::FlatTable")
316  m_tables.emplace_back(keep.first, keep.second);
317  else if (keep.first->className() == "edm::TriggerResults") {
318  m_triggers.emplace_back(keep.first, keep.second);
319  } else if (keep.first->className() == "std::basic_string<char,std::char_traits<char> >" &&
320  keep.first->productInstanceName() == "genModel") { // friendlyClassName == "String"
321  m_evstrings.emplace_back(keep.first, keep.second, true); // update only at lumiBlock transitions
322  } else
323  throw cms::Exception("Configuration", "NanoAODOutputModule cannot handle class " + keep.first->className());
324  }
325 
326  for (const auto& keep : keeps[edm::InLumi]) {
327  if (keep.first->className() == "nanoaod::MergeableCounterTable")
328  m_lumiTables.push_back(SummaryTableOutputBranches(keep.first, keep.second));
329  else if (keep.first->className() == "nanoaod::UniqueString" && keep.first->moduleLabel() == "nanoMetadata")
330  m_nanoMetadata.emplace_back(keep.first->productInstanceName(), keep.second);
331  else if (keep.first->className() == "nanoaod::FlatTable")
332  m_lumiTables2.push_back(LumiOutputBranches(keep.first, keep.second));
333  else
334  throw cms::Exception(
335  "Configuration",
336  "NanoAODOutputModule cannot handle class " + keep.first->className() + " in LuminosityBlock branch");
337  }
338 
339  for (const auto& keep : keeps[edm::InRun]) {
340  if (keep.first->className() == "nanoaod::MergeableCounterTable")
341  m_runTables.push_back(SummaryTableOutputBranches(keep.first, keep.second));
342  else if (keep.first->className() == "nanoaod::UniqueString" && keep.first->moduleLabel() == "nanoMetadata")
343  m_nanoMetadata.emplace_back(keep.first->productInstanceName(), keep.second);
344  else if (keep.first->className() == "nanoaod::FlatTable")
345  m_runFlatTables.emplace_back(keep.first, keep.second);
346  else
347  throw cms::Exception("Configuration",
348  "NanoAODOutputModule cannot handle class " + keep.first->className() + " in Run branch");
349  }
350 
351  // create the trees
352  m_tree = std::make_unique<TTree>("Events", "Events");
353  m_tree->SetAutoSave(0);
354  m_tree->SetAutoFlush(0);
356 
357  m_lumiTree = std::make_unique<TTree>("LuminosityBlocks", "LuminosityBlocks");
358  m_lumiTree->SetAutoSave(0);
360 
361  m_runTree = std::make_unique<TTree>("Runs", "Runs");
362  m_runTree->SetAutoSave(0);
364 
365  if (m_writeProvenance) {
366  m_metaDataTree = std::make_unique<TTree>(edm::poolNames::metaDataTreeName().c_str(), "Job metadata");
367  m_metaDataTree->SetAutoSave(0);
368  m_parameterSetsTree = std::make_unique<TTree>(edm::poolNames::parameterSetsTreeName().c_str(), "Parameter sets");
369  m_parameterSetsTree->SetAutoSave(0);
370  }
371 }
std::unique_ptr< TTree > m_runTree
std::vector< TableOutputBranches > m_runFlatTables
std::string const & metaDataTreeName()
Definition: BranchType.cc:159
std::unique_ptr< TTree > m_lumiTree
std::vector< SummaryTableOutputBranches > m_lumiTables
std::unique_ptr< TTree > m_tree
ModuleDescription const & description() const
std::unique_ptr< TTree > m_parameterSetsTree
class NanoAODOutputModule::CommonLumiBranches m_commonLumiBranches
std::unique_ptr< TTree > m_metaDataTree
std::unique_ptr< TFile > m_file
MD5Result digest()
Definition: Digest.cc:171
std::vector< EventStringOutputBranches > m_evstrings
std::vector< SummaryTableOutputBranches > m_runTables
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:216
std::vector< TableOutputBranches > m_tables
std::vector< TriggerOutputBranches > m_triggers
std::vector< std::pair< std::string, edm::EDGetToken > > m_nanoMetadata
std::vector< LumiOutputBranches > m_lumiTables2
std::string createGlobalIdentifier(bool binary=false)
SelectedProductsForBranchType const & keptProducts() const
class NanoAODOutputModule::CommonRunBranches m_commonRunBranches
edm::JobReport::Token m_jrToken
class NanoAODOutputModule::CommonEventBranches m_commonBranches
std::string toString() const
Definition: Digest.cc:95
std::string m_compressionAlgorithm

◆ reallyCloseFile()

void NanoAODOutputModule::reallyCloseFile ( )
overrideprivatevirtual

Reimplemented from edm::core::OutputModuleCore.

Definition at line 372 of file NanoAODOutputModule.cc.

References edm::fillParameterSetBranch(), edm::fillProcessHistoryBranch(), m_file, m_jrToken, m_lumiTree, m_metaDataTree, m_parameterSetsTree, m_processHistoryRegistry, m_runTree, m_tree, m_writeProvenance, and edm::JobReport::outputFileClosed().

372  {
373  if (m_writeProvenance) {
374  int basketSize = 16384; // fixme configurable?
377  if (m_metaDataTree->GetNbranches() != 0) {
378  m_metaDataTree->SetEntries(-1);
379  }
380  if (m_parameterSetsTree->GetNbranches() != 0) {
381  m_parameterSetsTree->SetEntries(-1);
382  }
383  }
384  m_file->Write();
385  m_file->Close();
386  m_file.reset();
387  m_tree.release(); // apparently root has ownership
388  m_lumiTree.release(); //
389  m_runTree.release(); //
390  m_metaDataTree.release(); //
391  m_parameterSetsTree.release(); //
394 }
std::unique_ptr< TTree > m_runTree
std::unique_ptr< TTree > m_lumiTree
std::unique_ptr< TTree > m_tree
void fillParameterSetBranch(TTree *parameterSetsTree, int basketSize)
void fillProcessHistoryBranch(TTree *metaDataTree, int basketSize, ProcessHistoryRegistry const &processHistoryRegistry)
std::unique_ptr< TTree > m_parameterSetsTree
std::unique_ptr< TTree > m_metaDataTree
std::unique_ptr< TFile > m_file
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:432
edm::JobReport::Token m_jrToken
edm::ProcessHistoryRegistry m_processHistoryRegistry

◆ write()

void NanoAODOutputModule::write ( edm::EventForOutput const &  e)
overrideprivatevirtual

Implements edm::core::OutputModuleCore.

Definition at line 163 of file NanoAODOutputModule.cc.

References a, b, events, edm::JobReport::eventWrittenToFile(), NanoAODOutputModule::CommonEventBranches::fill(), spr::find(), iEvent, m_autoFlush, m_commonBranches, m_eventsSinceFlush, m_evstrings, m_firstFlush, m_jrToken, m_processHistoryRegistry, m_tables, m_tree, m_triggers, m_triggers_areSorted, AlCaHLTBitMon_ParallelJobs::p, edm::ProcessHistoryRegistry::registerProcessHistory(), jetUpdater_cfi::sort, and submitPVValidationJobs::t.

163  {
164  //Get data from 'e' and write it to the file
166  jr->eventWrittenToFile(m_jrToken, iEvent.id().run(), iEvent.id().event());
167 
168  if (m_autoFlush) {
169  int64_t events = m_tree->GetEntriesFast();
170  if (events == m_firstFlush) {
171  m_tree->FlushBaskets();
172  float maxMemory;
173  if (m_autoFlush > 0) {
174  // Estimate the memory we'll be using at the first full flush by
175  // linearly scaling the number of events.
176  float percentClusterDone = m_firstFlush / static_cast<float>(m_autoFlush);
177  maxMemory = static_cast<float>(m_tree->GetTotBytes()) / percentClusterDone;
178  } else if (m_tree->GetZipBytes() == 0) {
179  maxMemory = 100 * 1024 * 1024; // Degenerate case of no information in the tree; arbitrary value
180  } else {
181  // Estimate the memory we'll be using by scaling the current compression ratio.
182  float cxnRatio = m_tree->GetTotBytes() / static_cast<float>(m_tree->GetZipBytes());
183  maxMemory = -m_autoFlush * cxnRatio;
184  float percentBytesDone = -m_tree->GetZipBytes() / static_cast<float>(m_autoFlush);
185  m_autoFlush = m_firstFlush / percentBytesDone;
186  }
187  //std::cout << "OptimizeBaskets: total bytes " << m_tree->GetTotBytes() << std::endl;
188  //std::cout << "OptimizeBaskets: zip bytes " << m_tree->GetZipBytes() << std::endl;
189  //std::cout << "OptimizeBaskets: autoFlush " << m_autoFlush << std::endl;
190  //std::cout << "OptimizeBaskets: maxMemory " << static_cast<uint32_t>(maxMemory) << std::endl;
191  //m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1, "d");
192  m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1, "");
193  }
195  m_tree->FlushBaskets();
196  m_eventsSinceFlush = 0;
197  }
199  }
200 
202  // fill all tables, starting from main tables and then doing extension tables
203  for (unsigned int extensions = 0; extensions <= 1; ++extensions) {
204  for (auto& t : m_tables)
205  t.fill(iEvent, *m_tree, extensions);
206  }
207  if (!m_triggers_areSorted) { // sort triggers/flags in inverse processHistory order, to save without any special label the most recent ones
208  std::vector<std::string> pnames;
209  for (auto& p : iEvent.processHistory())
210  pnames.push_back(p.processName());
212  return ((std::find(pnames.begin(), pnames.end(), a.processName()) - pnames.begin()) >
213  (std::find(pnames.begin(), pnames.end(), b.processName()) - pnames.begin()));
214  });
215  m_triggers_areSorted = true;
216  }
217  // fill triggers
218  for (auto& t : m_triggers)
219  t.fill(iEvent, *m_tree);
220  // fill event branches
221  for (auto& t : m_evstrings)
222  t.fill(iEvent, *m_tree);
223  tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
224 
226 }
std::unique_ptr< TTree > m_tree
bool registerProcessHistory(ProcessHistory const &processHistory)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int iEvent
Definition: GenABIO.cc:224
std::vector< EventStringOutputBranches > m_evstrings
std::vector< TableOutputBranches > m_tables
static constexpr int m_firstFlush
std::vector< TriggerOutputBranches > m_triggers
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:427
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
edm::JobReport::Token m_jrToken
class NanoAODOutputModule::CommonEventBranches m_commonBranches
edm::ProcessHistoryRegistry m_processHistoryRegistry
int events

◆ writeLuminosityBlock()

void NanoAODOutputModule::writeLuminosityBlock ( edm::LuminosityBlockForOutput const &  iLumi)
overrideprivatevirtual

Implements edm::core::OutputModuleCore.

Definition at line 228 of file NanoAODOutputModule.cc.

References NanoAODOutputModule::CommonLumiBranches::fill(), edm::LuminosityBlockForOutput::id(), m_commonLumiBranches, m_jrToken, m_lumiTables, m_lumiTables2, m_lumiTree, m_processHistoryRegistry, edm::OccurrenceForOutput::processHistory(), edm::ProcessHistoryRegistry::registerProcessHistory(), edm::JobReport::reportLumiSection(), edm::LuminosityBlockID::run(), submitPVValidationJobs::t, and edm::LuminosityBlockID::value().

228  {
230  jr->reportLumiSection(m_jrToken, iLumi.id().run(), iLumi.id().value());
231 
232  m_commonLumiBranches.fill(iLumi.id());
233 
234  for (auto& t : m_lumiTables)
235  t.fill(iLumi, *m_lumiTree);
236 
237  for (unsigned int extensions = 0; extensions <= 1; ++extensions) {
238  for (auto& t : m_lumiTables2)
239  t.fill(iLumi, *m_lumiTree, extensions);
240  }
241 
242  tbb::this_task_arena::isolate([&] { m_lumiTree->Fill(); });
243 
244  m_processHistoryRegistry.registerProcessHistory(iLumi.processHistory());
245 }
std::unique_ptr< TTree > m_lumiTree
std::vector< SummaryTableOutputBranches > m_lumiTables
bool registerProcessHistory(ProcessHistory const &processHistory)
void fill(const edm::LuminosityBlockID &id)
class NanoAODOutputModule::CommonLumiBranches m_commonLumiBranches
std::vector< LumiOutputBranches > m_lumiTables2
edm::JobReport::Token m_jrToken
edm::ProcessHistoryRegistry m_processHistoryRegistry
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
Definition: JobReport.cc:458

◆ writeRun()

void NanoAODOutputModule::writeRun ( edm::RunForOutput const &  iRun)
overrideprivatevirtual

Implements edm::core::OutputModuleCore.

Definition at line 247 of file NanoAODOutputModule.cc.

References NanoAODOutputModule::CommonRunBranches::fill(), edm::OccurrenceForOutput::getByToken(), edm::RunForOutput::id(), m_commonRunBranches, m_file, m_jrToken, m_nanoMetadata, m_processHistoryRegistry, m_runFlatTables, m_runTables, m_runTree, AlCaHLTBitMon_ParallelJobs::p, edm::OccurrenceForOutput::processHistory(), edm::ProcessHistoryRegistry::registerProcessHistory(), edm::JobReport::reportRunNumber(), edm::RunID::run(), nanoaod::UniqueString::str(), and submitPVValidationJobs::t.

247  {
249  jr->reportRunNumber(m_jrToken, iRun.id().run());
250 
251  m_commonRunBranches.fill(iRun.id());
252 
253  for (auto& t : m_runTables)
254  t.fill(iRun, *m_runTree);
255 
256  for (unsigned int extensions = 0; extensions <= 1; ++extensions) {
257  for (auto& t : m_runFlatTables)
258  t.fill(iRun, *m_runTree, extensions);
259  }
260 
262  for (const auto& p : m_nanoMetadata) {
263  iRun.getByToken(p.second, hstring);
264  TObjString* tos = dynamic_cast<TObjString*>(m_file->Get(p.first.c_str()));
265  if (tos) {
266  if (hstring->str() != tos->GetString())
267  throw cms::Exception("LogicError", "Inconsistent nanoMetadata " + p.first + " (" + hstring->str() + ")");
268  } else {
269  auto ostr = std::make_unique<TObjString>(hstring->str().c_str());
270  m_file->WriteTObject(ostr.release(), p.first.c_str());
271  }
272  }
273 
274  tbb::this_task_arena::isolate([&] { m_runTree->Fill(); });
275 
276  m_processHistoryRegistry.registerProcessHistory(iRun.processHistory());
277 }
std::unique_ptr< TTree > m_runTree
std::vector< TableOutputBranches > m_runFlatTables
bool registerProcessHistory(ProcessHistory const &processHistory)
void reportRunNumber(JobReport::Token token, unsigned int run)
Definition: JobReport.cc:469
std::unique_ptr< TFile > m_file
std::vector< SummaryTableOutputBranches > m_runTables
std::vector< std::pair< std::string, edm::EDGetToken > > m_nanoMetadata
const std::string & str() const
Definition: UniqueString.h:12
class NanoAODOutputModule::CommonRunBranches m_commonRunBranches
edm::JobReport::Token m_jrToken
edm::ProcessHistoryRegistry m_processHistoryRegistry

Member Data Documentation

◆ m_autoFlush

int NanoAODOutputModule::m_autoFlush
private

Definition at line 73 of file NanoAODOutputModule.cc.

Referenced by write().

◆ m_commonBranches

class NanoAODOutputModule::CommonEventBranches NanoAODOutputModule::m_commonBranches
private

Referenced by openFile(), and write().

◆ m_commonLumiBranches

class NanoAODOutputModule::CommonLumiBranches NanoAODOutputModule::m_commonLumiBranches
private

Referenced by openFile(), and writeLuminosityBlock().

◆ m_commonRunBranches

class NanoAODOutputModule::CommonRunBranches NanoAODOutputModule::m_commonRunBranches
private

Referenced by openFile(), and writeRun().

◆ m_compressionAlgorithm

std::string NanoAODOutputModule::m_compressionAlgorithm
private

Definition at line 70 of file NanoAODOutputModule.cc.

Referenced by openFile().

◆ m_compressionLevel

int NanoAODOutputModule::m_compressionLevel
private

Definition at line 68 of file NanoAODOutputModule.cc.

Referenced by openFile().

◆ m_eventsSinceFlush

int NanoAODOutputModule::m_eventsSinceFlush {0}
private

Definition at line 69 of file NanoAODOutputModule.cc.

Referenced by write().

◆ m_evstrings

std::vector<EventStringOutputBranches> NanoAODOutputModule::m_evstrings
private

Definition at line 128 of file NanoAODOutputModule.cc.

Referenced by openFile(), and write().

◆ m_fakeName

bool NanoAODOutputModule::m_fakeName
private

Definition at line 72 of file NanoAODOutputModule.cc.

Referenced by openFile().

◆ m_file

std::unique_ptr<TFile> NanoAODOutputModule::m_file
private

Definition at line 76 of file NanoAODOutputModule.cc.

Referenced by isFileOpen(), openFile(), reallyCloseFile(), and writeRun().

◆ m_fileName

std::string NanoAODOutputModule::m_fileName
private

Definition at line 66 of file NanoAODOutputModule.cc.

Referenced by openFile().

◆ m_firstFlush

constexpr int NanoAODOutputModule::m_firstFlush {1000}
staticprivate

Definition at line 79 of file NanoAODOutputModule.cc.

Referenced by write().

◆ m_jrToken

edm::JobReport::Token NanoAODOutputModule::m_jrToken
private

◆ m_logicalFileName

std::string NanoAODOutputModule::m_logicalFileName
private

Definition at line 67 of file NanoAODOutputModule.cc.

Referenced by openFile().

◆ m_lumiTables

std::vector<SummaryTableOutputBranches> NanoAODOutputModule::m_lumiTables
private

Definition at line 131 of file NanoAODOutputModule.cc.

Referenced by openFile(), and writeLuminosityBlock().

◆ m_lumiTables2

std::vector<LumiOutputBranches> NanoAODOutputModule::m_lumiTables2
private

Definition at line 132 of file NanoAODOutputModule.cc.

Referenced by openFile(), and writeLuminosityBlock().

◆ m_lumiTree

std::unique_ptr<TTree> NanoAODOutputModule::m_lumiTree
private

Definition at line 77 of file NanoAODOutputModule.cc.

Referenced by openFile(), reallyCloseFile(), and writeLuminosityBlock().

◆ m_metaDataTree

std::unique_ptr<TTree> NanoAODOutputModule::m_metaDataTree
private

Definition at line 77 of file NanoAODOutputModule.cc.

Referenced by openFile(), and reallyCloseFile().

◆ m_nanoMetadata

std::vector<std::pair<std::string, edm::EDGetToken> > NanoAODOutputModule::m_nanoMetadata
private

Definition at line 135 of file NanoAODOutputModule.cc.

Referenced by openFile(), and writeRun().

◆ m_parameterSetsTree

std::unique_ptr<TTree> NanoAODOutputModule::m_parameterSetsTree
private

Definition at line 77 of file NanoAODOutputModule.cc.

Referenced by openFile(), and reallyCloseFile().

◆ m_processHistoryRegistry

edm::ProcessHistoryRegistry NanoAODOutputModule::m_processHistoryRegistry
private

Definition at line 74 of file NanoAODOutputModule.cc.

Referenced by reallyCloseFile(), write(), writeLuminosityBlock(), and writeRun().

◆ m_runFlatTables

std::vector<TableOutputBranches> NanoAODOutputModule::m_runFlatTables
private

Definition at line 133 of file NanoAODOutputModule.cc.

Referenced by openFile(), and writeRun().

◆ m_runTables

std::vector<SummaryTableOutputBranches> NanoAODOutputModule::m_runTables
private

Definition at line 130 of file NanoAODOutputModule.cc.

Referenced by openFile(), and writeRun().

◆ m_runTree

std::unique_ptr<TTree> NanoAODOutputModule::m_runTree
private

Definition at line 77 of file NanoAODOutputModule.cc.

Referenced by openFile(), reallyCloseFile(), and writeRun().

◆ m_tables

std::vector<TableOutputBranches> NanoAODOutputModule::m_tables
private

Definition at line 125 of file NanoAODOutputModule.cc.

Referenced by openFile(), and write().

◆ m_tree

std::unique_ptr<TTree> NanoAODOutputModule::m_tree
private

Definition at line 77 of file NanoAODOutputModule.cc.

Referenced by openFile(), reallyCloseFile(), and write().

◆ m_triggers

std::vector<TriggerOutputBranches> NanoAODOutputModule::m_triggers
private

Definition at line 126 of file NanoAODOutputModule.cc.

Referenced by openFile(), and write().

◆ m_triggers_areSorted

bool NanoAODOutputModule::m_triggers_areSorted = false
private

Definition at line 127 of file NanoAODOutputModule.cc.

Referenced by openFile(), and write().

◆ m_writeProvenance

bool NanoAODOutputModule::m_writeProvenance
private

Definition at line 71 of file NanoAODOutputModule.cc.

Referenced by openFile(), and reallyCloseFile().