30 #include "oneapi/tbb/task_arena.h" 59 class TreeHelperBase {
61 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
62 virtual ~TreeHelperBase() {}
70 bool wasFilled()
const {
return m_wasFilled; }
71 void getRangeAndReset(ULong64_t& iFirstIndex, ULong64_t& iLastIndex) {
72 iFirstIndex = m_firstIndex;
73 iLastIndex = m_lastIndex;
75 m_firstIndex = m_lastIndex + 1;
76 m_lastIndex = m_firstIndex;
82 ULong64_t m_firstIndex;
83 ULong64_t m_lastIndex;
87 class TreeHelper :
public TreeHelperBase {
89 TreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
90 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
97 assert(
nullptr != m_bufferPtr);
99 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
107 m_bufferPtr =
nullptr;
108 m_tree->Branch(
kValueBranch, &m_bufferPtr, 128 * 1024, 0);
111 uint32_t m_flagBuffer;
116 class IntTreeHelper :
public TreeHelperBase {
118 IntTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
119 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
127 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
137 uint32_t m_flagBuffer;
142 class FloatTreeHelper :
public TreeHelperBase {
144 FloatTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
145 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
152 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
163 uint32_t m_flagBuffer;
168 class StringTreeHelper :
public TreeHelperBase {
170 StringTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
171 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr), m_bufferPtr(&m_buffer) {
178 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
189 uint32_t m_flagBuffer;
198 class ModuleCallingContext;
251 switch (iTypeIndex) {
253 return new IntTreeHelper(iTree, iFullNameBufferPtr);
255 return new FloatTreeHelper(iTree, iFullNameBufferPtr);
257 return new StringTreeHelper(iTree, iFullNameBufferPtr);
259 return new TreeHelper<TH1F>(iTree, iFullNameBufferPtr);
261 return new TreeHelper<TH1S>(iTree, iFullNameBufferPtr);
263 return new TreeHelper<TH1D>(iTree, iFullNameBufferPtr);
265 return new TreeHelper<TH1I>(iTree, iFullNameBufferPtr);
267 return new TreeHelper<TH2F>(iTree, iFullNameBufferPtr);
269 return new TreeHelper<TH2S>(iTree, iFullNameBufferPtr);
271 return new TreeHelper<TH2D>(iTree, iFullNameBufferPtr);
273 return new TreeHelper<TH2I>(iTree, iFullNameBufferPtr);
275 return new TreeHelper<TH3F>(iTree, iFullNameBufferPtr);
277 return new TreeHelper<TProfile>(iTree, iFullNameBufferPtr);
279 return new TreeHelper<TProfile2D>(iTree, iFullNameBufferPtr);
295 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
296 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
298 m_treeHelpers(
kNIndicies,
std::shared_ptr<TreeHelperBase>()),
299 m_presentHistoryIndex(0),
300 m_filterOnRun(
pset.getUntrackedParameter<unsigned
int>(
"filterOnRun")),
301 m_fullNameBufferPtr(&m_fullNameBuffer),
302 m_indicesTree(nullptr),
303 m_getterOfProductsLumi(
edm::TypeMatch(), this,
edm::
InLumi),
304 m_getterOfProductsRun(
edm::TypeMatch(), this,
edm::
InRun) {
361 "DQMRootOutputModule",
366 std::vector<std::string>());
419 for (std::vector<MonitorElement*>::iterator
it =
items.begin(), itEnd =
items.end();
it != itEnd; ++
it) {
420 assert((*it)->getScope() == MonitorElementData::Scope::LUMI);
421 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
437 bool storedLumiIndex =
false;
438 unsigned int typeIndex = 0;
442 if ((*it)->wasFilled()) {
445 storedLumiIndex =
true;
446 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
449 if (not storedLumiIndex) {
455 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
475 for (std::vector<MonitorElement*>::iterator
it =
items.begin(), itEnd =
items.end();
it != itEnd; ++
it) {
476 assert((*it)->getScope() == MonitorElementData::Scope::RUN);
477 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
493 unsigned int typeIndex = 0;
497 if ((*it)->wasFilled()) {
500 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
521 processHistoryTree->SetDirectory(metaDataDirectory);
523 unsigned int index = 0;
538 assert(
nullptr != history);
540 for (edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
544 releaseVersion = itPC->releaseVersion();
545 passID = itPC->passID();
546 parameterSetID = itPC->parameterSetID().compactForm();
547 tbb::this_task_arena::isolate([&] { processHistoryTree->Fill(); });
553 parameterSetsTree->SetDirectory(metaDataDirectory);
561 it->second.toString(blob);
562 tbb::this_task_arena::isolate([&] { parameterSetsTree->Fill(); });
586 desc.addUntracked<
unsigned int>(
"filterOnRun", 0)
587 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
588 desc.addOptionalUntracked<
int>(
"splitLevel", 99)
589 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
590 const std::vector<std::string>
keep = {
"drop *",
"keep DQMToken_*_*_*"};
596 ->setComment(
"PSet is only used by Data Operations and not by this module.");
void reallyCloseFile() override
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
map_type::const_iterator const_iterator
edm::GetterOfProducts< DQMToken > m_getterOfProductsRun
void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override
void write(edm::EventForOutput const &e) override
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
#define DEFINE_FWK_MODULE(type)
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)
edm::GetterOfProducts< DQMToken > m_getterOfProductsLumi
const_iterator begin() const
std::vector< edm::ProcessHistoryID > m_seenHistories
virtual int64_t getIntValue() const