20 #include <boost/shared_ptr.hpp> 21 #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;
179 class ModuleCallingContext;
195 virtual void reallyCloseFile()
override;
196 virtual void postForkReacquireResources(
unsigned int childIndex,
unsigned int numberOfChildren)
override;
199 void finishEndFile();
230 static TreeHelperBase*
236 return new IntTreeHelper(iTree,iFullNameBufferPtr);
238 return new FloatTreeHelper(iTree,iFullNameBufferPtr);
240 return new StringTreeHelper(iTree,iFullNameBufferPtr);
242 return new TreeHelper<TH1F>(iTree,iFullNameBufferPtr);
244 return new TreeHelper<TH1S>(iTree,iFullNameBufferPtr);
246 return new TreeHelper<TH1D>(iTree,iFullNameBufferPtr);
248 return new TreeHelper<TH2F>(iTree,iFullNameBufferPtr);
250 return new TreeHelper<TH2S>(iTree,iFullNameBufferPtr);
252 return new TreeHelper<TH2D>(iTree,iFullNameBufferPtr);
254 return new TreeHelper<TH3F>(iTree,iFullNameBufferPtr);
256 return new TreeHelper<TProfile>(iTree,iFullNameBufferPtr);
258 return new TreeHelper<TProfile2D>(iTree,iFullNameBufferPtr);
273 edm::
one::OutputModule<>(pset),
274 m_fileName(pset.getUntrackedParameter<
std::
string>(
"fileName")),
275 m_logicalFileName(pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
278 m_presentHistoryIndex(0),
279 m_filterOnRun(pset.getUntrackedParameter<unsigned
int>(
"filterOnRun")),
280 m_enableMultiThread(
false),
281 m_fullNameBufferPtr(&m_fullNameBuffer),
321 return nullptr!=
m_file.get();
338 "DQMRootOutputModule",
343 std::vector<std::string>()
365 tree->SetDirectory(
m_file.get());
386 unsigned int digits = 0;
387 while (numberOfChildren != 0) {
389 numberOfChildren /= 10;
396 char buffer[digits + 2];
397 snprintf(buffer, digits + 2,
"_%0*d", digits, childIndex);
400 m_fileName = (filename.parent_path() / (filename.stem().string() + buffer + filename.extension().string())).string();
425 for(std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd=
items.end();
428 if((*it)->getLumiFlag()) {
429 std::map<unsigned int,unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((*it)->kind());
446 bool storedLumiIndex =
false;
447 unsigned int typeIndex = 0;
451 if((*it)->wasFilled()) {
454 storedLumiIndex =
true;
458 if(not storedLumiIndex) {
486 for(std::vector<MonitorElement*>::iterator it =
items.begin(), itEnd=
items.end();
489 if(not (*it)->getLumiFlag()) {
490 std::map<unsigned int,unsigned int>::iterator itFound =
m_dqmKindToTypeIndex.find((*it)->kind());
507 unsigned int typeIndex = 0;
511 if((*it)->wasFilled()) {
538 processHistoryTree->SetDirectory(metaDataDirectory);
540 unsigned int index = 0;
557 for(edm::ProcessHistory::collection_type::const_iterator itPC = history->
begin(), itPCEnd = history->
end();
560 processName = itPC->processName();
561 releaseVersion = itPC->releaseVersion();
562 passID = itPC->passID();
563 parameterSetID = itPC->parameterSetID().compactForm();
564 processHistoryTree->Fill();
570 parameterSetsTree->SetDirectory(metaDataDirectory);
580 it->second.toString(blob);
581 parameterSetsTree->Fill();
608 ->setComment(
"Only write the run with this run number. 0 means write all runs.");
610 ->setComment(
"UNUSED Only here to allow older configurations written for PoolOutputModule to work.");
616 ->setComment(
"PSet is only used by Data Operations and not by this module.");
virtual void beginJob() override
const_iterator begin() const
virtual void reallyCloseFile() override
Timestamp const & endTime() const
virtual ProcessHistory const & processHistory() const
boost::uint64_t value() 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
virtual void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override
virtual 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)
edm::ProcessHistoryRegistry m_processHistoryRegistry
def setup(process, global_tag, zero_tesla=False)
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 uint32_t getTag(void) const
Timestamp const & beginTime() const
std::string m_fullNameBuffer
virtual ~DQMRootOutputModule()
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
void addDefault(ParameterSetDescription const &psetDescription)
std::auto_ptr< TFile > m_file
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
double getFloatValue(void) 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)
Timestamp const & endTime() const
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
virtual void writeRun(edm::RunForOutput const &) override
int64_t getIntValue(void) const
std::string toString() const
virtual bool isFileOpen() const override
std::string const & processName() const
unsigned int m_filterOnRun
Timestamp const & beginTime() const
const_iterator end() const
virtual void postForkReacquireResources(unsigned int childIndex, unsigned int numberOfChildren) override
ProcessHistoryID const & processHistoryID() const
void outputFileClosed(Token fileToken)
edm::JobReport::Token m_jrToken
virtual void openFile(edm::FileBlock const &) override
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
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