21 #include <boost/shared_ptr.hpp>
22 #include <boost/filesystem.hpp>
50 class TreeHelperBase {
52 TreeHelperBase(): m_wasFilled(
false), m_firstIndex(0),m_lastIndex(0) {}
53 virtual ~TreeHelperBase(){}
56 if(m_wasFilled) {++m_lastIndex;}
58 bool wasFilled()
const {
return m_wasFilled;}
59 void getRangeAndReset(ULong64_t& iFirstIndex, ULong64_t& iLastIndex) {
60 iFirstIndex = m_firstIndex;
61 iLastIndex = m_lastIndex;
63 m_firstIndex = m_lastIndex +1;
64 m_lastIndex = m_firstIndex;
69 ULong64_t m_firstIndex;
70 ULong64_t m_lastIndex;
74 class TreeHelper :
public TreeHelperBase {
76 TreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr ):
77 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr){
setup();}
80 m_flagBuffer = iElement->
getTag();
82 assert(0!=m_bufferPtr);
97 uint32_t m_flagBuffer;
102 class IntTreeHelper:
public TreeHelperBase {
104 IntTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr):
105 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr)
110 m_flagBuffer = iElement->
getTag();
122 uint32_t m_flagBuffer;
127 class FloatTreeHelper:
public TreeHelperBase {
129 FloatTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr):
130 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr)
134 m_flagBuffer = iElement->
getTag();
146 uint32_t m_flagBuffer;
151 class StringTreeHelper:
public TreeHelperBase {
153 StringTreeHelper(TTree* iTree,
std::string* iFullNameBufferPtr):
154 m_tree(iTree), m_flagBuffer(0),m_fullNameBufferPtr(iFullNameBufferPtr), m_bufferPtr(&m_buffer)
158 m_flagBuffer = iElement->
getTag();
170 uint32_t m_flagBuffer;
224 static TreeHelperBase*
230 return new IntTreeHelper(iTree,iFullNameBufferPtr);
232 return new FloatTreeHelper(iTree,iFullNameBufferPtr);
234 return new StringTreeHelper(iTree,iFullNameBufferPtr);
236 return new TreeHelper<TH1F>(iTree,iFullNameBufferPtr);
238 return new TreeHelper<TH1S>(iTree,iFullNameBufferPtr);
240 return new TreeHelper<TH1D>(iTree,iFullNameBufferPtr);
242 return new TreeHelper<TH2F>(iTree,iFullNameBufferPtr);
244 return new TreeHelper<TH2S>(iTree,iFullNameBufferPtr);
246 return new TreeHelper<TH2D>(iTree,iFullNameBufferPtr);
248 return new TreeHelper<TH3F>(iTree,iFullNameBufferPtr);
250 return new TreeHelper<TProfile>(iTree,iFullNameBufferPtr);
252 return new TreeHelper<TProfile2D>(iTree,iFullNameBufferPtr);
266 edm::OutputModule(pset),
267 m_fileName(pset.getUntrackedParameter<std::
string>(
"fileName")),
268 m_logicalFileName(pset.getUntrackedParameter<std::
string>(
"logicalFileName",
"")),
270 m_treeHelpers(
kNIndicies,boost::shared_ptr<TreeHelperBase>()),
271 m_presentHistoryIndex(0),
272 m_filterOnRun(pset.getUntrackedParameter<unsigned int>(
"filterOnRun",0)),
273 m_fullNameBufferPtr(&m_fullNameBuffer),
305 return nullptr!=
m_file.get();
322 "DQMRootOutputModule",
327 std::vector<std::string>()
349 tree->SetDirectory(
m_file.get());
370 unsigned int digits = 0;
371 while (numberOfChildren != 0) {
373 numberOfChildren /= 10;
380 char buffer[digits + 2];
381 snprintf(buffer, digits + 2,
"_%0*d", digits, childIndex);
384 m_fileName = (filename.parent_path() / (filename.stem().string() + buffer + filename.extension().string())).string();
406 for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
409 if((*it)->getLumiFlag()) {
410 std::map<unsigned int,unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((*it)->kind());
426 bool storedLumiIndex =
false;
427 unsigned int typeIndex = 0;
431 if((*it)->wasFilled()) {
434 storedLumiIndex =
true;
438 if(not storedLumiIndex) {
466 for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
469 if(not (*it)->getLumiFlag()) {
470 std::map<unsigned int,unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((*it)->kind());
486 unsigned int typeIndex = 0;
490 if((*it)->wasFilled()) {
510 processHistoryTree->SetDirectory(metaDataDirectory);
512 unsigned int index = 0;
531 for(edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
534 processName = itPC->processName();
535 releaseVersion = itPC->releaseVersion();
536 passID = itPC->passID();
537 parameterSetID = itPC->parameterSetID().compactForm();
538 processHistoryTree->Fill();
544 parameterSetsTree->SetDirectory(metaDataDirectory);
554 it->second.toString(blob);
555 parameterSetsTree->Fill();
virtual bool isFileOpen() const
const_iterator begin() const
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)
virtual void write(edm::EventPrincipal const &e)
Timestamp const & beginTime() const
virtual void writeRun(edm::RunPrincipal const &)
virtual void openFile(edm::FileBlock const &)
static ThreadSafeRegistry * instance()
#define DEFINE_FWK_MODULE(type)
Timestamp const & endTime() const
unsigned int m_presentHistoryIndex
boost::uint64_t value() const
static TreeHelperBase * makeHelper(unsigned int iTypeIndex, TTree *iTree, std::string *iFullNameBufferPtr)
std::string const & processName() const
bool getMapped(key_type const &k, value_type &result) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void outputFileClosed(Token fileToken)
const uint32_t getTag(void) const
std::vector< MonitorElement * > getAllContents(const std::string &path) const
std::string m_fullNameBuffer
virtual ~DQMRootOutputModule()
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
void addDefault(ParameterSetDescription const &psetDescription)
const_iterator begin() const
virtual void finishEndFile()
ProcessHistoryID const & processHistoryID() const
Timestamp const & beginTime() const
std::auto_ptr< TFile > m_file
collection_type::const_iterator const_iterator
double getFloatValue(void) const
Timestamp const & endTime() const
virtual void postForkReacquireResources(unsigned int childIndex, unsigned int numberOfChildren) overridefinal
const std::string getFullname(void) const
get full name of ME including Pathname
const std::string & getStringValue(void) const
DQMRootOutputModule(edm::ParameterSet const &pset)
TimeValue_t value() const
std::vector< boost::shared_ptr< TreeHelperBase > > m_treeHelpers
std::string * m_fullNameBufferPtr
virtual void startEndFile()
TObject * getRootObject(void) const
void reportLumiSection(unsigned int run, unsigned int lumiSectId)
int64_t getIntValue(void) const
std::string toString() const
unsigned int m_filterOnRun
const_iterator end() const
virtual void writeLuminosityBlock(edm::LuminosityBlockPrincipal const &)
edm::JobReport::Token m_jrToken
const_iterator end() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string m_logicalFileName
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
ModuleDescription const & description() const
std::string createGlobalIdentifier()
LuminosityBlockID id() const
void reportRunNumber(unsigned int run)
std::vector< edm::ProcessHistoryID > m_seenHistories