30 #include "tbb/task_arena.h"
56 class TreeHelperBase {
58 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
59 virtual ~TreeHelperBase() {}
60 void fill(MonitorElement* iElement) {
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;
77 virtual void doFill(MonitorElement*) = 0;
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) {
90 void doFill(MonitorElement* iElement)
override {
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) {
120 void doFill(MonitorElement* iElement)
override {
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) {
145 void doFill(MonitorElement* iElement)
override {
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) {
171 void doFill(MonitorElement* iElement)
override {
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<TH2F>(iTree, iFullNameBufferPtr);
261 return new TreeHelper<TH2S>(iTree, iFullNameBufferPtr);
263 return new TreeHelper<TH2D>(iTree, iFullNameBufferPtr);
265 return new TreeHelper<TH3F>(iTree, iFullNameBufferPtr);
267 return new TreeHelper<TProfile>(iTree, iFullNameBufferPtr);
269 return new TreeHelper<TProfile2D>(iTree, iFullNameBufferPtr);
284 edm::
one::OutputModule<>(pset),
285 m_fileName(pset.getUntrackedParameter<std::
string>(
"fileName")),
286 m_logicalFileName(pset.getUntrackedParameter<std::
string>(
"logicalFileName")),
288 m_treeHelpers(
kNIndicies, std::shared_ptr<TreeHelperBase>()),
289 m_presentHistoryIndex(0),
290 m_filterOnRun(pset.getUntrackedParameter<unsigned int>(
"filterOnRun")),
291 m_fullNameBufferPtr(&m_fullNameBuffer),
292 m_indicesTree(nullptr) {
298 consumesMany<DQMToken, edm::InLumi>();
299 consumesMany<DQMToken, edm::InRun>();
339 std::transform(guid.begin(), guid.end(), guid.begin(), (int (*)(int))std::toupper);
345 "DQMRootOutputModule",
350 std::vector<std::string>());
370 tree->SetDirectory(
m_file.get());
401 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
402 assert((*it)->getScope() == MonitorElementData::Scope::LUMI);
403 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
419 bool storedLumiIndex =
false;
420 unsigned int typeIndex = 0;
424 if ((*it)->wasFilled()) {
427 storedLumiIndex =
true;
428 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
431 if (not storedLumiIndex) {
437 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
457 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
458 assert((*it)->getScope() == MonitorElementData::Scope::RUN);
459 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
475 unsigned int typeIndex = 0;
479 if ((*it)->wasFilled()) {
482 tbb::this_task_arena::isolate([&] {
m_indicesTree->Fill(); });
503 processHistoryTree->SetDirectory(metaDataDirectory);
505 unsigned int index = 0;
520 assert(
nullptr != history);
522 for (edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
525 processName = itPC->processName();
526 releaseVersion = itPC->releaseVersion();
527 passID = itPC->passID();
528 parameterSetID = itPC->parameterSetID().compactForm();
529 tbb::this_task_arena::isolate([&] { processHistoryTree->Fill(); });
535 parameterSetsTree->SetDirectory(metaDataDirectory);
543 it->second.toString(blob);
544 tbb::this_task_arena::isolate([&] { parameterSetsTree->Fill(); });
569 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
571 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
572 const std::vector<std::string>
keep = {
"drop *",
"keep DQMToken_*_*_*"};
578 ->setComment(
"PSet is only used by Data Operations and not by this module.");
const_iterator begin() const
void reallyCloseFile() override
Timestamp const & endTime() const
map_type::const_iterator const_iterator
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
uint16_t *__restrict__ id
const_iterator end() const
void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override
void write(edm::EventForOutput const &e) override
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
unsigned int m_presentHistoryIndex
bool registerProcessHistory(ProcessHistory const &processHistory)
static TreeHelperBase * makeHelper(unsigned int iTypeIndex, TTree *iTree, std::string *iFullNameBufferPtr)
virtual int64_t getIntValue() const
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)
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
~DQMRootOutputModule() override
Timestamp const & beginTime() 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 ProcessHistory const & processHistory() const
ModuleDescription const & description() const
const_iterator begin() const
std::vector< std::shared_ptr< TreeHelperBase > > m_treeHelpers
Timestamp const & endTime() const
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
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
void writeRun(edm::RunForOutput const &) override
std::string const & processName() const
dqm::legacy::MonitorElement MonitorElement
std::string toString() const
unsigned int m_filterOnRun
Timestamp const & beginTime() const
const_iterator end() const
virtual double getFloatValue() const
virtual const std::string & getStringValue() const
void outputFileClosed(Token fileToken)
std::string getFullname() const
get full name of ME including Pathname
edm::JobReport::Token m_jrToken
void openFile(edm::FileBlock const &) override
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
TObject * getRootObject() const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
LuminosityBlockID const & id() const
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
std::string m_logicalFileName
TimeValue_t value() const
static Registry * instance()
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
std::vector< edm::ProcessHistoryID > m_seenHistories