30 #include "oneapi/tbb/task_arena.h" 56 class TreeHelperBase {
58 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
59 virtual ~TreeHelperBase() {}
67 bool wasFilled()
const {
return m_wasFilled; }
68 void getRangeAndReset(ULong64_t& iFirstIndex, ULong64_t& iLastIndex) {
69 iFirstIndex = m_firstIndex;
70 iLastIndex = m_lastIndex;
72 m_firstIndex = m_lastIndex + 1;
73 m_lastIndex = m_firstIndex;
79 ULong64_t m_firstIndex;
80 ULong64_t m_lastIndex;
84 class TreeHelper :
public TreeHelperBase {
86 TreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
87 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
94 assert(
nullptr != m_bufferPtr);
96 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
104 m_bufferPtr =
nullptr;
105 m_tree->Branch(
kValueBranch, &m_bufferPtr, 128 * 1024, 0);
108 uint32_t m_flagBuffer;
113 class IntTreeHelper :
public TreeHelperBase {
115 IntTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
116 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
124 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
134 uint32_t m_flagBuffer;
139 class FloatTreeHelper :
public TreeHelperBase {
141 FloatTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
142 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
149 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
160 uint32_t m_flagBuffer;
165 class StringTreeHelper :
public TreeHelperBase {
167 StringTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
168 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr), m_bufferPtr(&m_buffer) {
175 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
186 uint32_t m_flagBuffer;
195 class ModuleCallingContext;
245 switch (iTypeIndex) {
247 return new IntTreeHelper(iTree, iFullNameBufferPtr);
249 return new FloatTreeHelper(iTree, iFullNameBufferPtr);
251 return new StringTreeHelper(iTree, iFullNameBufferPtr);
253 return new TreeHelper<TH1F>(iTree, iFullNameBufferPtr);
255 return new TreeHelper<TH1S>(iTree, iFullNameBufferPtr);
257 return new TreeHelper<TH1D>(iTree, iFullNameBufferPtr);
259 return new TreeHelper<TH1I>(iTree, iFullNameBufferPtr);
261 return new TreeHelper<TH2F>(iTree, iFullNameBufferPtr);
263 return new TreeHelper<TH2S>(iTree, iFullNameBufferPtr);
265 return new TreeHelper<TH2D>(iTree, iFullNameBufferPtr);
267 return new TreeHelper<TH2I>(iTree, iFullNameBufferPtr);
269 return new TreeHelper<TH3F>(iTree, iFullNameBufferPtr);
271 return new TreeHelper<TProfile>(iTree, iFullNameBufferPtr);
273 return new TreeHelper<TProfile2D>(iTree, iFullNameBufferPtr);
289 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
290 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
292 m_treeHelpers(
kNIndicies,
std::shared_ptr<TreeHelperBase>()),
293 m_presentHistoryIndex(0),
294 m_filterOnRun(
pset.getUntrackedParameter<unsigned
int>(
"filterOnRun")),
295 m_fullNameBufferPtr(&m_fullNameBuffer),
296 m_indicesTree(nullptr) {
302 consumesMany<DQMToken, edm::InLumi>();
303 consumesMany<DQMToken, edm::InRun>();
349 "DQMRootOutputModule",
354 std::vector<std::string>());
407 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
408 assert((*it)->getScope() == MonitorElementData::Scope::LUMI);
409 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
425 bool storedLumiIndex =
false;
426 unsigned int typeIndex = 0;
430 if ((*it)->wasFilled()) {
433 storedLumiIndex =
true;
434 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
437 if (not storedLumiIndex) {
443 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
463 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
464 assert((*it)->getScope() == MonitorElementData::Scope::RUN);
465 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
481 unsigned int typeIndex = 0;
485 if ((*it)->wasFilled()) {
488 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
509 processHistoryTree->SetDirectory(metaDataDirectory);
511 unsigned int index = 0;
526 assert(
nullptr != history);
528 for (edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
532 releaseVersion = itPC->releaseVersion();
533 passID = itPC->passID();
534 parameterSetID = itPC->parameterSetID().compactForm();
535 tbb::this_task_arena::isolate([&] { processHistoryTree->Fill(); });
541 parameterSetsTree->SetDirectory(metaDataDirectory);
549 it->second.toString(blob);
550 tbb::this_task_arena::isolate([&] { parameterSetsTree->Fill(); });
574 desc.addUntracked<
unsigned int>(
"filterOnRun", 0)
575 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
576 desc.addOptionalUntracked<
int>(
"splitLevel", 99)
577 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
578 const std::vector<std::string>
keep = {
"drop *",
"keep DQMToken_*_*_*"};
584 ->setComment(
"PSet is only used by Data Operations and not by this module.");
void reallyCloseFile() override
map_type::const_iterator const_iterator
void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override
void write(edm::EventForOutput const &e) override
#define DEFINE_FWK_MODULE(type)
Timestamp const & beginTime() const
unsigned int m_presentHistoryIndex
bool registerProcessHistory(ProcessHistory const &processHistory)
static TreeHelperBase * makeHelper(unsigned int iTypeIndex, TTree *iTree, std::string *iFullNameBufferPtr)
edm::ProcessHistoryRegistry m_processHistoryRegistry
void reportRunNumber(JobReport::Token token, unsigned int run)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const_iterator end() const
ModuleDescription const & description() const
~DQMRootOutputModule() override
const_iterator end() const
std::string m_fullNameBuffer
dqm::reco::DQMStore DQMStore
bool isFileOpen() const override
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
void addDefault(ParameterSetDescription const &psetDescription)
virtual double getFloatValue() const
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
std::vector< std::shared_ptr< TreeHelperBase > > m_treeHelpers
std::unique_ptr< TFile > m_file
ProcessHistoryID const & processHistoryID() const
DQMRootOutputModule(edm::ParameterSet const &pset)
std::string createGlobalIdentifier(bool binary=false)
std::string * m_fullNameBufferPtr
std::string getFullname() const
get full name of ME including Pathname
void writeRun(edm::RunForOutput const &) override
TimeValue_t value() const
dqm::legacy::MonitorElement MonitorElement
LuminosityBlockID const & id() const
Timestamp const & endTime() const
unsigned int m_filterOnRun
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
virtual ProcessHistory const & processHistory() const
std::string const & processName() const
virtual const std::string & getStringValue() const
Timestamp const & endTime() const
Timestamp const & beginTime() const
void outputFileClosed(Token fileToken)
edm::JobReport::Token m_jrToken
void openFile(edm::FileBlock const &) override
TObject * getRootObject() const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
std::string toString() const
std::string m_logicalFileName
const_iterator begin() const
static Registry * instance()
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
const_iterator begin() const
std::vector< edm::ProcessHistoryID > m_seenHistories
virtual int64_t getIntValue() const