30 #include "tbb/task_arena.h"
55 class TreeHelperBase {
57 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
58 virtual ~TreeHelperBase() {}
59 void fill(MonitorElement* iElement) {
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;
76 virtual void doFill(MonitorElement*) = 0;
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) {
89 void doFill(MonitorElement* iElement)
override {
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) {
119 void doFill(MonitorElement* iElement)
override {
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) {
144 void doFill(MonitorElement* iElement)
override {
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) {
170 void doFill(MonitorElement* iElement)
override {
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);
283 edm::
one::OutputModule<>(pset),
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>();
338 std::transform(guid.begin(), guid.end(), guid.begin(), (int (*)(int))std::toupper);
342 "DQMRootOutputModule",
347 std::vector<std::string>());
367 tree->SetDirectory(
m_file.get());
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();
522 processName = itPC->processName();
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(); });
566 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
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.");
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 * 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