20 #include <boost/shared_ptr.hpp>
21 #include <boost/filesystem.hpp>
49 class TreeHelperBase {
51 TreeHelperBase(): m_wasFilled(
false), m_firstIndex(0),m_lastIndex(0) {}
52 virtual ~TreeHelperBase(){}
55 if(m_wasFilled) {++m_lastIndex;}
57 bool wasFilled()
const {
return m_wasFilled;}
58 void getRangeAndReset(ULong64_t& iFirstIndex, ULong64_t& iLastIndex) {
59 iFirstIndex = m_firstIndex;
60 iLastIndex = m_lastIndex;
62 m_firstIndex = m_lastIndex +1;
63 m_lastIndex = m_firstIndex;
68 ULong64_t m_firstIndex;
69 ULong64_t m_lastIndex;
73 class TreeHelper :
public TreeHelperBase {
75 TreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr ):
76 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr){
setup();}
79 m_flagBuffer = iElement->
getTag();
81 assert(0!=m_bufferPtr);
96 uint32_t m_flagBuffer;
101 class IntTreeHelper:
public TreeHelperBase {
103 IntTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr):
104 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr)
109 m_flagBuffer = iElement->
getTag();
121 uint32_t m_flagBuffer;
126 class FloatTreeHelper:
public TreeHelperBase {
128 FloatTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr):
129 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr)
133 m_flagBuffer = iElement->
getTag();
145 uint32_t m_flagBuffer;
150 class StringTreeHelper:
public TreeHelperBase {
152 StringTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr):
153 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr), m_bufferPtr(&m_buffer)
157 m_flagBuffer = iElement->
getTag();
169 uint32_t m_flagBuffer;
178 class ModuleCallingContext;
228 static TreeHelperBase*
234 return new IntTreeHelper(iTree,iFullNameBufferPtr);
236 return new FloatTreeHelper(iTree,iFullNameBufferPtr);
238 return new StringTreeHelper(iTree,iFullNameBufferPtr);
240 return new TreeHelper<TH1F>(iTree,iFullNameBufferPtr);
242 return new TreeHelper<TH1S>(iTree,iFullNameBufferPtr);
244 return new TreeHelper<TH1D>(iTree,iFullNameBufferPtr);
246 return new TreeHelper<TH2F>(iTree,iFullNameBufferPtr);
248 return new TreeHelper<TH2S>(iTree,iFullNameBufferPtr);
250 return new TreeHelper<TH2D>(iTree,iFullNameBufferPtr);
252 return new TreeHelper<TH3F>(iTree,iFullNameBufferPtr);
254 return new TreeHelper<TProfile>(iTree,iFullNameBufferPtr);
256 return new TreeHelper<TProfile2D>(iTree,iFullNameBufferPtr);
270 edm::OutputModule(pset),
271 m_fileName(pset.getUntrackedParameter<std::
string>(
"fileName")),
272 m_logicalFileName(pset.getUntrackedParameter<std::
string>(
"logicalFileName",
"")),
274 m_treeHelpers(
kNIndicies,boost::shared_ptr<TreeHelperBase>()),
275 m_presentHistoryIndex(0),
276 m_filterOnRun(pset.getUntrackedParameter<unsigned int>(
"filterOnRun",0)),
277 m_enableMultiThread(pset.getUntrackedParameter<bool>(
"enableMultiThread",
false)),
278 m_fullNameBufferPtr(&m_fullNameBuffer),
310 return nullptr!=
m_file.get();
327 "DQMRootOutputModule",
332 std::vector<std::string>()
354 tree->SetDirectory(
m_file.get());
375 unsigned int digits = 0;
376 while (numberOfChildren != 0) {
378 numberOfChildren /= 10;
385 char buffer[digits + 2];
386 snprintf(buffer, digits + 2,
"_%0*d", digits, childIndex);
389 m_fileName = (filename.parent_path() / (filename.stem().string() + buffer + filename.extension().string())).string();
416 for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
419 if((*it)->getLumiFlag()) {
420 std::map<unsigned int,unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((*it)->kind());
437 bool storedLumiIndex =
false;
438 unsigned int typeIndex = 0;
442 if((*it)->wasFilled()) {
445 storedLumiIndex =
true;
449 if(not storedLumiIndex) {
478 for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
481 if(not (*it)->getLumiFlag()) {
482 std::map<unsigned int,unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((*it)->kind());
499 unsigned int typeIndex = 0;
503 if((*it)->wasFilled()) {
530 processHistoryTree->SetDirectory(metaDataDirectory);
532 unsigned int index = 0;
549 for(edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
552 processName = itPC->processName();
553 releaseVersion = itPC->releaseVersion();
554 passID = itPC->passID();
555 parameterSetID = itPC->parameterSetID().compactForm();
556 processHistoryTree->Fill();
562 parameterSetsTree->SetDirectory(metaDataDirectory);
572 it->second.toString(blob);
573 parameterSetsTree->Fill();
const_iterator begin() const
virtual void reallyCloseFile() override
map_type::const_iterator const_iterator
Timestamp const & beginTime() const
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
const_iterator end() const
#define DEFINE_FWK_MODULE(type)
Timestamp const & endTime() const
unsigned int m_presentHistoryIndex
boost::uint64_t value() const
bool registerProcessHistory(ProcessHistory const &processHistory)
static TreeHelperBase * makeHelper(unsigned int iTypeIndex, TTree *iTree, std::string *iFullNameBufferPtr)
edm::ProcessHistoryRegistry m_processHistoryRegistry
std::string const & processName() const
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)
ProcessHistory const & processHistory() const
virtual void write(edm::EventPrincipal const &e, edm::ModuleCallingContext const *) override
const uint32_t getTag(void) const
std::string m_fullNameBuffer
virtual ~DQMRootOutputModule()
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
virtual bool isFileOpen() const override
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
void addDefault(ParameterSetDescription const &psetDescription)
ProcessHistoryID const & processHistoryID() const
Timestamp const & beginTime() const
std::auto_ptr< TFile > m_file
double getFloatValue(void) const
const_iterator begin() const
Timestamp const & endTime() const
virtual void writeRun(edm::RunPrincipal const &, edm::ModuleCallingContext const *) override
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)
const std::string getFullname(void) const
get full name of ME including Pathname
const std::string & getStringValue(void) const
DQMRootOutputModule(edm::ParameterSet const &pset)
std::vector< boost::shared_ptr< TreeHelperBase > > m_treeHelpers
std::string * m_fullNameBufferPtr
TObject * getRootObject(void) const
int64_t getIntValue(void) const
std::string toString() const
unsigned int m_filterOnRun
const_iterator end() const
virtual void postForkReacquireResources(unsigned int childIndex, unsigned int numberOfChildren) override
void outputFileClosed(Token fileToken)
edm::JobReport::Token m_jrToken
virtual void openFile(edm::FileBlock const &) override
virtual void writeLuminosityBlock(edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *) override
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
volatile std::atomic< bool > shutdown_flag false
std::string m_logicalFileName
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
ModuleDescription const & description() const
TimeValue_t value() const
static Registry * instance()
std::string createGlobalIdentifier()
LuminosityBlockID id() const
std::vector< edm::ProcessHistoryID > m_seenHistories