21 #include <boost/filesystem.hpp>
52 class TreeHelperBase {
54 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
55 virtual ~TreeHelperBase() {}
63 bool wasFilled()
const {
return m_wasFilled; }
64 void getRangeAndReset(ULong64_t& iFirstIndex, ULong64_t& iLastIndex) {
65 iFirstIndex = m_firstIndex;
66 iLastIndex = m_lastIndex;
68 m_firstIndex = m_lastIndex + 1;
69 m_lastIndex = m_firstIndex;
75 ULong64_t m_firstIndex;
76 ULong64_t m_lastIndex;
80 class TreeHelper :
public TreeHelperBase {
82 TreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
83 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
90 assert(
nullptr != m_bufferPtr);
100 m_bufferPtr =
nullptr;
101 m_tree->Branch(
kValueBranch, &m_bufferPtr, 128 * 1024, 0);
104 uint32_t m_flagBuffer;
109 class IntTreeHelper :
public TreeHelperBase {
111 IntTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
112 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
130 uint32_t m_flagBuffer;
135 class FloatTreeHelper :
public TreeHelperBase {
137 FloatTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
138 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr) {
156 uint32_t m_flagBuffer;
161 class StringTreeHelper :
public TreeHelperBase {
163 StringTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr)
164 : m_tree(iTree), m_flagBuffer(0), m_fullNameBufferPtr(iFullNameBufferPtr), m_bufferPtr(&m_buffer) {
182 uint32_t m_flagBuffer;
191 class ModuleCallingContext;
241 switch (iTypeIndex) {
243 return new IntTreeHelper(iTree, iFullNameBufferPtr);
245 return new FloatTreeHelper(iTree, iFullNameBufferPtr);
247 return new StringTreeHelper(iTree, iFullNameBufferPtr);
249 return new TreeHelper<TH1F>(iTree, iFullNameBufferPtr);
251 return new TreeHelper<TH1S>(iTree, iFullNameBufferPtr);
253 return new TreeHelper<TH1D>(iTree, iFullNameBufferPtr);
255 return new TreeHelper<TH2F>(iTree, iFullNameBufferPtr);
257 return new TreeHelper<TH2S>(iTree, iFullNameBufferPtr);
259 return new TreeHelper<TH2D>(iTree, iFullNameBufferPtr);
261 return new TreeHelper<TH3F>(iTree, iFullNameBufferPtr);
263 return new TreeHelper<TProfile>(iTree, iFullNameBufferPtr);
265 return new TreeHelper<TProfile2D>(iTree, iFullNameBufferPtr);
280 edm::one::OutputModule<>(
pset),
281 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
282 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
284 m_treeHelpers(
kNIndicies,
std::shared_ptr<TreeHelperBase>()),
285 m_presentHistoryIndex(0),
286 m_filterOnRun(
pset.getUntrackedParameter<unsigned
int>(
"filterOnRun")),
287 m_fullNameBufferPtr(&m_fullNameBuffer),
288 m_indicesTree(nullptr) {
294 consumesMany<DQMToken, edm::InLumi>();
295 consumesMany<DQMToken, edm::InRun>();
339 "DQMRootOutputModule",
344 std::vector<std::string>());
394 std::vector<MonitorElement*>
items(dstore->getAllContents(
"",
m_run,
m_lumi));
395 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
396 assert((*it)->getScope() == MonitorElementData::Scope::LUMI);
397 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
413 bool storedLumiIndex =
false;
414 unsigned int typeIndex = 0;
418 if ((*it)->wasFilled()) {
421 storedLumiIndex =
true;
425 if (not storedLumiIndex) {
450 std::vector<MonitorElement*>
items(dstore->getAllContents(
"",
m_run, 0));
451 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
452 assert((*it)->getScope() == MonitorElementData::Scope::RUN);
453 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
469 unsigned int typeIndex = 0;
473 if ((*it)->wasFilled()) {
497 processHistoryTree->SetDirectory(metaDataDirectory);
499 unsigned int index = 0;
514 assert(
nullptr != history);
516 for (edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
520 releaseVersion = itPC->releaseVersion();
521 passID = itPC->passID();
522 parameterSetID = itPC->parameterSetID().compactForm();
523 processHistoryTree->Fill();
529 parameterSetsTree->SetDirectory(metaDataDirectory);
537 it->second.toString(blob);
538 parameterSetsTree->Fill();
563 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
565 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
566 const std::vector<std::string>
keep = {
"drop *",
"keep DQMToken_*_*_*"};
572 ->setComment(
"PSet is only used by Data Operations and not by this module.");