#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <vector>
#include <set>
#include <string>
#include <iostream>
#include <memory>
#include "DQMServices/Core/src/ROOTFilePB.pb.h"
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/gzip_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <TROOT.h>
#include <TFile.h>
#include <TBufferFile.h>
#include <TObject.h>
#include <TObjString.h>
#include <TH1.h>
#include <TKey.h>
Go to the source code of this file.
Classes | |
struct | MicroME |
Macros | |
#define | DEBUG(x, msg) if (debug >= x) std::cout << "DEBUG: " << msg << std::flush |
Enumerations | |
enum | ErrType { ERR_BADCFG =1, ERR_NOFILE } |
enum | TaskType { TASK_ADD, TASK_DUMP, TASK_CONVERT, TASK_ENCODE } |
Functions | |
int | addFiles (const std::string &output_filename, const std::vector< std::string > &filenames) |
int | convertFile (const std::string &output_filename, const std::vector< std::string > &filenames) |
int | dumpFiles (const std::vector< std::string > &filenames) |
int | encodeFile (const std::string &output_filename, const std::vector< std::string > &filenames) |
TObject * | extractNextObject (TBufferFile &buf) |
void | fillMessage (dqmstorepb::ROOTFilePB &dqmstore_output_msg, const std::set< MicroME > µmes) |
static void | get_info (const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj) |
static bool | lessThanMME (const std::string &lhs_dirname, const std::string &lhs_objname, const std::string &rhs_dirname, const std::string &rhs_objname) |
int | main (int argc, char *argv[]) |
void | processDirectory (TFile *file, const std::string &curdir, std::set< std::string > &dirs, std::set< std::string > &objs, std::set< std::string > &fullnames, std::set< MicroME > µmes) |
static int | showusage (void) |
void | writeMessage (const dqmstorepb::ROOTFilePB &dqmstore_output_msg, const std::string &output_filename) |
Variables | |
int | debug = 0 |
Copyright (c) 2013 "Marco Rovere"
This code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
This code is simple: its sole purpose is to either dump or add ProtocolBuffer-gzipped files that are meant to replace ordinary ROOT files containing only hierarchies of histograms, arranged in arbitrarily complex levels of directories. The merging logic is such that plots present in all files are added, while plots present in some of the files are anyway tracked and added, if similar ones are found in other files.
The logic of the merging algorithm is trivial and fully rely on the ordered nature of the ProtocolBuffer files read in input. An internal set container of MicroME is used to host the final results. The relational ordering of the set must be guaranteed to match the one used to order the ProtocolBuffer files for optimal performance and correctness.
A dependency on protocolbuffer is needed and should be alrady included out of the box into any recent CMSSW release.
In case the protoclBuffer package is not avaialble, you need to install it as an external toolfile. Therefore, in order to be able to compile and run the code, you need to locally install protocol buffer 2.4.1 and add it as a scram tool to your preferred CMSSW development area.
The toolfile I used is:
<tool name="protocolbuf" version="2.4.1"> <client> <environment name="PROTOCOLBUF_CLIENT_BASE" default="/afs/cern.ch/work/r/rovere/protocolbuf"> <environment name="LIBDIR" value="$PROTOCOLBUF_CLIENT_BASE/lib"> <environment name="INCLUDE" value="$PROTOCOLBUF_CLIENT_BASE/include"> <environment name="PATH" value="$PROTOCOLBUF_CLIENT_BASE/bin"> <lib name="protobuf"> <use name="zlib"> </client> <runtime name="PATH" value="$PROTOCOLBUF_CLIENT_BASE/bin"> </tool>
To register it into your development area you can simply do:
scram setup protocolbuf.xml
To verify the correctness of the information, do:
scram tool info protocolbuf. You should see an output similar to the following:
Tool info as configured in location /afs/cern.ch/work/r/rovere/fastHistoMergingPB/CMSSW_7_0_X_2013-07-08-0200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Name : protocolbuf Version : 2.4.1 ++++++++++++++++++++ SCRAM_PROJECT=no PROTOCOLBUF_CLIENT_BASE=/afs/cern.ch/work/r/rovere/protocolbuf LIB=protobuf LIBDIR=/afs/cern.ch/work/r/rovere/protocolbuf/lib INCLUDE=/afs/cern.ch/work/r/rovere/protocolbuf/include USE=zlib PATH=/afs/cern.ch/work/r/rovere/protocolbuf/bin
Definition at line 100 of file fastHadd.cc.
Referenced by MicroME::add(), addFiles(), convertFile(), dumpFiles(), encodeFile(), fillMessage(), processDirectory(), and writeMessage().
enum ErrType |
Enumerator | |
---|---|
ERR_BADCFG | |
ERR_NOFILE |
Definition at line 156 of file fastHadd.cc.
enum TaskType |
Enumerator | |
---|---|
TASK_ADD | |
TASK_DUMP | |
TASK_CONVERT | |
TASK_ENCODE |
Definition at line 149 of file fastHadd.cc.
int addFiles | ( | const std::string & | output_filename, |
const std::vector< std::string > & | filenames | ||
) |
Definition at line 391 of file fastHadd.cc.
References gather_cfg::cout, DEBUG, diffTreeTool::diff, alignCSCRings::e, HTMLExport::elem(), ERR_NOFILE, fillMessage(), groupFilesInBlocks::fin, first, dqmstorepb::ROOTFilePB_Histo::flags(), dqmstorepb::ROOTFilePB_Histo::full_pathname(), MicroME::fullname, get_info(), h, dqmstorepb::ROOTFilePB::histo(), dqmstorepb::ROOTFilePB::histo_size(), i, input, lessThanMME(), cmsHarvester::loop, NULL, getGTfromDQMFile::obj, MicroME::obj, cmsHarvester::path, AlCaHLTBitMon_QueryRunRegistry::string, and writeMessage().
Referenced by main().
int convertFile | ( | const std::string & | output_filename, |
const std::vector< std::string > & | filenames | ||
) |
Definition at line 299 of file fastHadd.cc.
References gather_cfg::cout, DEBUG, end, ERR_NOFILE, extractNextObject(), groupFilesInBlocks::fin, dqmstorepb::ROOTFilePB_Histo::full_pathname(), get_info(), h, dqmstorepb::ROOTFilePB::histo(), dqmstorepb::ROOTFilePB::histo_size(), i, input, getGTfromDQMFile::obj, convertSQLitetoXML_cfg::output, cmsHarvester::path, dqmstorepb::ROOTFilePB_Histo::size(), dqm_diff::start, dqmstorepb::ROOTFilePB_Histo::streamed_histo(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by main().
int dumpFiles | ( | const std::vector< std::string > & | filenames | ) |
Definition at line 357 of file fastHadd.cc.
References gather_cfg::cout, DEBUG, alignCSCRings::e, ERR_NOFILE, extractNextObject(), groupFilesInBlocks::fin, dqmstorepb::ROOTFilePB_Histo::flags(), dqmstorepb::ROOTFilePB_Histo::full_pathname(), h, dqmstorepb::ROOTFilePB::histo(), dqmstorepb::ROOTFilePB::histo_size(), i, input, getGTfromDQMFile::obj, dqmstorepb::ROOTFilePB_Histo::size(), and dqmstorepb::ROOTFilePB_Histo::streamed_histo().
Referenced by main().
int encodeFile | ( | const std::string & | output_filename, |
const std::vector< std::string > & | filenames | ||
) |
Definition at line 281 of file fastHadd.cc.
References DEBUG, fillMessage(), input, processDirectory(), and writeMessage().
Referenced by main().
|
inline |
Extract the next serialised ROOT object from @a buf. Returns null
if there are no more objects in the buffer, or a null pointer was serialised at this location.
Definition at line 171 of file fastHadd.cc.
Referenced by convertFile(), dumpFiles(), and get_info().
void fillMessage | ( | dqmstorepb::ROOTFilePB & | dqmstore_output_msg, |
const std::set< MicroME > & | micromes | ||
) |
Definition at line 220 of file fastHadd.cc.
References dqmstorepb::ROOTFilePB::add_histo(), DEBUG, h, dqmstorepb::ROOTFilePB_Histo::set_flags(), dqmstorepb::ROOTFilePB_Histo::set_full_pathname(), dqmstorepb::ROOTFilePB_Histo::set_size(), and dqmstorepb::ROOTFilePB_Histo::set_streamed_histo().
Referenced by addFiles(), and encodeFile().
|
static |
Definition at line 178 of file fastHadd.cc.
References dtNoiseDBValidation_cfg::cerr, extractNextObject(), dqmstorepb::ROOTFilePB_Histo::full_pathname(), dqmstorepb::ROOTFilePB_Histo::size(), pickleFileParser::slash, and dqmstorepb::ROOTFilePB_Histo::streamed_histo().
Referenced by addFiles(), and convertFile().
|
static |
Definition at line 104 of file fastHadd.cc.
References diffTreeTool::diff.
Referenced by addFiles(), and MicroME::operator<().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 552 of file fastHadd.cc.
References addFiles(), dir2webdir::argc, dtNoiseDBValidation_cfg::cerr, convertFile(), debug, dumpFiles(), encodeFile(), cmsPerfCommons::filenames, electronStore::output_file, run_regression::ret, showusage(), AlCaHLTBitMon_QueryRunRegistry::string, TASK_ADD, TASK_CONVERT, TASK_DUMP, and TASK_ENCODE.
void processDirectory | ( | TFile * | file, |
const std::string & | curdir, | ||
std::set< std::string > & | dirs, | ||
std::set< std::string > & | objs, | ||
std::set< std::string > & | fullnames, | ||
std::set< MicroME > & | micromes | ||
) |
Definition at line 241 of file fastHadd.cc.
References DEBUG, first, combine::key, GetRecoTauVFromDQM_MC_cff::next, getGTfromDQMFile::obj, MicroME::obj, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by encodeFile().
|
static |
Definition at line 539 of file fastHadd.cc.
References dtNoiseDBValidation_cfg::cerr, ERR_BADCFG, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by main().
void writeMessage | ( | const dqmstorepb::ROOTFilePB & | dqmstore_output_msg, |
const std::string & | output_filename | ||
) |
Definition at line 198 of file fastHadd.cc.
References DEBUG, and AlCaHLTBitMon_ParallelJobs::options.
Referenced by addFiles(), and encodeFile().
int debug = 0 |
Definition at line 102 of file fastHadd.cc.