21 #include <boost/filesystem.hpp> 52 class TreeHelperBase {
54 TreeHelperBase() : m_wasFilled(
false), m_firstIndex(0), m_lastIndex(0) {}
55 virtual ~TreeHelperBase() {}
56 void fill(MonitorElement* iElement) {
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;
73 virtual void doFill(MonitorElement*) = 0;
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) {
86 void doFill(MonitorElement* iElement)
override {
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) {
116 void doFill(MonitorElement* iElement)
override {
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) {
141 void doFill(MonitorElement* iElement)
override {
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) {
167 void doFill(MonitorElement* iElement)
override {
182 uint32_t m_flagBuffer;
191 class ModuleCallingContext;
207 void reallyCloseFile()
override;
210 void finishEndFile();
242 switch (iTypeIndex) {
244 return new IntTreeHelper(iTree, iFullNameBufferPtr);
246 return new FloatTreeHelper(iTree, iFullNameBufferPtr);
248 return new StringTreeHelper(iTree, iFullNameBufferPtr);
250 return new TreeHelper<TH1F>(iTree, iFullNameBufferPtr);
252 return new TreeHelper<TH1S>(iTree, iFullNameBufferPtr);
254 return new TreeHelper<TH1D>(iTree, iFullNameBufferPtr);
256 return new TreeHelper<TH2F>(iTree, iFullNameBufferPtr);
258 return new TreeHelper<TH2S>(iTree, iFullNameBufferPtr);
260 return new TreeHelper<TH2D>(iTree, iFullNameBufferPtr);
262 return new TreeHelper<TH3F>(iTree, iFullNameBufferPtr);
264 return new TreeHelper<TProfile>(iTree, iFullNameBufferPtr);
266 return new TreeHelper<TProfile2D>(iTree, iFullNameBufferPtr);
281 edm::
one::OutputModule<>(pset),
282 m_fileName(pset.getUntrackedParameter<
std::
string>(
"fileName")),
283 m_logicalFileName(pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
285 m_treeHelpers(
kNIndicies,
std::shared_ptr<TreeHelperBase>()),
286 m_presentHistoryIndex(0),
287 m_filterOnRun(pset.getUntrackedParameter<unsigned
int>(
"filterOnRun")),
288 m_enableMultiThread(
false),
289 m_fullNameBufferPtr(&m_fullNameBuffer),
335 "DQMRootOutputModule",
340 std::vector<std::string>());
360 tree->SetDirectory(
m_file.get());
390 std::vector<MonitorElement*>
items(
392 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
393 if ((*it)->getLumiFlag()) {
394 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
411 bool storedLumiIndex =
false;
412 unsigned int typeIndex = 0;
416 if ((*it)->wasFilled()) {
419 storedLumiIndex =
true;
423 if (not storedLumiIndex) {
449 for (std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd =
items.end(); it != itEnd; ++it) {
450 if (not(*it)->getLumiFlag()) {
451 std::map<unsigned int, unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((
int)(*it)->kind());
468 unsigned int typeIndex = 0;
472 if ((*it)->wasFilled()) {
496 processHistoryTree->SetDirectory(metaDataDirectory);
498 unsigned int index = 0;
513 assert(
nullptr != history);
515 for (edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
518 processName = itPC->processName();
519 releaseVersion = itPC->releaseVersion();
520 passID = itPC->passID();
521 parameterSetID = itPC->parameterSetID().compactForm();
522 processHistoryTree->Fill();
528 parameterSetsTree->SetDirectory(metaDataDirectory);
533 assert(
nullptr != psr);
536 it->second.toString(blob);
537 parameterSetsTree->Fill();
562 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
564 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
565 const std::vector<std::string>
keep = {
"drop *",
"keep DQMToken_*_*_*"};
571 ->setComment(
"PSet is only used by Data Operations and not by this module.");
const_iterator begin() const
void reallyCloseFile() override
Timestamp const & endTime() const
virtual ProcessHistory const & processHistory() const
map_type::const_iterator const_iterator
ModuleDescription const & description() const
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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
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)
const std::string getFullname() const
get full name of ME including Pathname
~DQMRootOutputModule() override
dqm::dqmstoreimpl::DQMStore DQMStore
Timestamp const & beginTime() const
std::string m_fullNameBuffer
#define DEFINE_FWK_MODULE(type)
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
const_iterator begin() const
std::vector< std::shared_ptr< TreeHelperBase > > m_treeHelpers
Token outputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &outputModuleClassName, std::string const &moduleLabel, std::string const &guid, std::string const &dataType, std::string const &branchHash, std::vector< std::string > const &branchNames)
Timestamp const & endTime() const
std::unique_ptr< TFile > m_file
DQMRootOutputModule(edm::ParameterSet const &pset)
std::string * m_fullNameBufferPtr
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void writeRun(edm::RunForOutput const &) override
dqm::legacy::MonitorElement MonitorElement
std::string toString() const
bool isFileOpen() const override
std::string const & processName() const
unsigned int m_filterOnRun
Timestamp const & beginTime() const
const_iterator end() const
virtual double getFloatValue() const
ProcessHistoryID const & processHistoryID() const
virtual const std::string & getStringValue() const
void outputFileClosed(Token fileToken)
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
std::string m_logicalFileName
TimeValue_t value() const
static Registry * instance()
std::string createGlobalIdentifier()
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
std::vector< edm::ProcessHistoryID > m_seenHistories