30 #include "tbb/task_arena.h"
55 class TreeHelperBase {
57 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
58 virtual ~TreeHelperBase() {}
66 bool wasFilled()
const {
return m_wasFilled; }
67 void getRangeAndReset(ULong64_t& iFirstIndex, ULong64_t& iLastIndex) {
68 iFirstIndex = m_firstIndex;
69 iLastIndex = m_lastIndex;
71 m_firstIndex = m_lastIndex + 1;
72 m_lastIndex = m_firstIndex;
78 ULong64_t m_firstIndex;
79 ULong64_t m_lastIndex;
83 class TreeHelper :
public TreeHelperBase {
85 TreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
86 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
93 assert(
nullptr != m_bufferPtr);
95 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
103 m_bufferPtr =
nullptr;
104 m_tree->Branch(
kValueBranch, &m_bufferPtr, 128 * 1024, 0);
107 uint32_t m_flagBuffer;
112 class IntTreeHelper :
public TreeHelperBase {
114 IntTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
115 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
123 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
133 uint32_t m_flagBuffer;
138 class FloatTreeHelper :
public TreeHelperBase {
140 FloatTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
141 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
148 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
159 uint32_t m_flagBuffer;
164 class StringTreeHelper :
public TreeHelperBase {
166 StringTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
167 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr), m_bufferPtr(&m_buffer) {
174 tbb::this_task_arena::isolate([&] { m_tree->Fill(); });
185 uint32_t m_flagBuffer;
194 class ModuleCallingContext;
244 switch (iTypeIndex) {
246 return new IntTreeHelper(iTree, iFullNameBufferPtr);
248 return new FloatTreeHelper(iTree, iFullNameBufferPtr);
250 return new StringTreeHelper(iTree, iFullNameBufferPtr);
252 return new TreeHelper<TH1F>(iTree, iFullNameBufferPtr);
254 return new TreeHelper<TH1S>(iTree, iFullNameBufferPtr);
256 return new TreeHelper<TH1D>(iTree, iFullNameBufferPtr);
258 return new TreeHelper<TH2F>(iTree, iFullNameBufferPtr);
260 return new TreeHelper<TH2S>(iTree, iFullNameBufferPtr);
262 return new TreeHelper<TH2D>(iTree, iFullNameBufferPtr);
264 return new TreeHelper<TH3F>(iTree, iFullNameBufferPtr);
266 return new TreeHelper<TProfile>(iTree, iFullNameBufferPtr);
268 return new TreeHelper<TProfile2D>(iTree, iFullNameBufferPtr);
284 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
285 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
287 m_treeHelpers(
kNIndicies,
std::shared_ptr<TreeHelperBase>()),
288 m_presentHistoryIndex(0),
289 m_filterOnRun(
pset.getUntrackedParameter<unsigned
int>(
"filterOnRun")),
290 m_fullNameBufferPtr(&m_fullNameBuffer),
291 m_indicesTree(nullptr) {
297 consumesMany<DQMToken, edm::InLumi>();
298 consumesMany<DQMToken, edm::InRun>();
342 "DQMRootOutputModule",
347 std::vector<std::string>());
398 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
399 assert((*it)->getScope() == MonitorElementData::Scope::LUMI);
400 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
416 bool storedLumiIndex =
false;
417 unsigned int typeIndex = 0;
421 if ((*it)->wasFilled()) {
424 storedLumiIndex =
true;
425 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
428 if (not storedLumiIndex) {
434 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
454 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
455 assert((*it)->getScope() == MonitorElementData::Scope::RUN);
456 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
472 unsigned int typeIndex = 0;
476 if ((*it)->wasFilled()) {
479 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
500 processHistoryTree->SetDirectory(metaDataDirectory);
502 unsigned int index = 0;
517 assert(
nullptr != history);
519 for (edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
523 releaseVersion = itPC->releaseVersion();
524 passID = itPC->passID();
525 parameterSetID = itPC->parameterSetID().compactForm();
526 tbb::this_task_arena::isolate([&] { processHistoryTree->Fill(); });
532 parameterSetsTree->SetDirectory(metaDataDirectory);
540 it->second.toString(blob);
541 tbb::this_task_arena::isolate([&] { parameterSetsTree->Fill(); });
565 desc.addUntracked<
unsigned int>(
"filterOnRun", 0)
566 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
567 desc.addOptionalUntracked<
int>(
"splitLevel", 99)
568 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
569 const std::vector<std::string>
keep = {
"drop *",
"keep DQMToken_*_*_*"};
575 ->setComment(
"PSet is only used by Data Operations and not by this module.");