#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <vector>
#include <set>
#include <string>
#include <iostream>
#include <memory>
#include <thread>
#include <mutex>
#include <list>
#include "DQMServices/Core/interface/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 <TProfile.h>
#include <TKey.h>
#include <TClass.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <csignal>
Go to the source code of this file.
Classes | |
struct | MicroME |
Macros | |
#define | DEBUG(x, msg) |
Typedefs | |
using | MEStore = std::set< MicroME > |
Enumerations | |
enum | ErrType { ERR_BADCFG = 1, ERR_NOFILE } |
enum | TaskType { TASK_ADD, TASK_DUMP, TASK_CONVERT, TASK_ENCODE } |
Functions | |
int | addFile (MEStore µmes, int fd) |
int | addFiles (const std::string &output_filename, const std::vector< std::string > &filenames, int nthreads) |
void | addFilesWithFork (int parent_fd, const int fork_id, const int fork_total, 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 MEStore µmes) |
static void | get_info (const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj) |
int | main (int argc, char *argv[]) |
void | processDirectory (TFile *file, const std::string &curdir, MEStore µmes) |
static int | showusage () |
void | tryRootPreload () |
void | writeMessage (const dqmstorepb::ROOTFilePB &dqmstore_output_msg, const std::string &output_filename) |
void | writeMessageFD (const dqmstorepb::ROOTFilePB &dqmstore_output_msg, int out_fd) |
Variables | |
int | debug = 0 |
#define DEBUG | ( | x, | |
msg | |||
) |
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 109 of file fastHadd.cc.
Referenced by MicroME::add(), addFile(), addFiles(), addFilesWithFork(), convertFile(), dumpFiles(), encodeFile(), fillMessage(), processDirectory(), and writeMessage().
Definition at line 146 of file fastHadd.cc.
enum ErrType |
Enumerator | |
---|---|
ERR_BADCFG | |
ERR_NOFILE |
Definition at line 150 of file fastHadd.cc.
enum TaskType |
Enumerator | |
---|---|
TASK_ADD | |
TASK_DUMP | |
TASK_CONVERT | |
TASK_ENCODE |
Definition at line 148 of file fastHadd.cc.
int addFile | ( | MEStore & | micromes, |
int | fd | ||
) |
Definition at line 352 of file fastHadd.cc.
References MicroME::add(), gather_cfg::cout, DEBUG, ERR_NOFILE, ztee::fd, groupFilesInBlocks::fin, get_info(), h, dqmstorepb::ROOTFilePB::histo(), dqmstorepb::ROOTFilePB::histo_size(), mps_fire::i, input, getGTfromDQMFile::obj, castor_dqm_sourceclient_file_cfg::path, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by addFilesWithFork(), DAQSource::readSupervisor(), and DAQSource::readWorker().
int addFiles | ( | const std::string & | output_filename, |
const std::vector< std::string > & | filenames, | ||
int | nthreads | ||
) |
Definition at line 490 of file fastHadd.cc.
References addFilesWithFork(), DEBUG, cms::cuda::nthreads, and tryRootPreload().
Referenced by main().
void addFilesWithFork | ( | int | parent_fd, |
const int | fork_id, | ||
const int | fork_total, | ||
const std::vector< std::string > & | filenames | ||
) |
Definition at line 421 of file fastHadd.cc.
References addFile(), class-composition::children, gather_cfg::cout, DEBUG, ERR_NOFILE, beamvalidation::exit(), ztee::fd, geometryDiff::file, fillMessage(), mps_fire::i, pipe::pipe(), mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, and writeMessageFD().
Referenced by addFiles().
int convertFile | ( | const std::string & | output_filename, |
const std::vector< std::string > & | filenames | ||
) |
Definition at line 267 of file fastHadd.cc.
References cms::cuda::assert(), visDQMUpload::buf, gather_cfg::cout, DEBUG, mps_fire::end, ERR_NOFILE, extractNextObject(), groupFilesInBlocks::fin, get_info(), h, dqmstorepb::ROOTFilePB::histo(), dqmstorepb::ROOTFilePB::histo_size(), mps_fire::i, input, getGTfromDQMFile::obj, convertSQLitetoXML_cfg::output, castor_dqm_sourceclient_file_cfg::path, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by main().
int dumpFiles | ( | const std::vector< std::string > & | filenames | ) |
Definition at line 320 of file fastHadd.cc.
References cms::cuda::assert(), visDQMUpload::buf, gather_cfg::cout, DEBUG, MillePedeFileConverter_cfg::e, ERR_NOFILE, extractNextObject(), groupFilesInBlocks::fin, h, dqmstorepb::ROOTFilePB::histo(), dqmstorepb::ROOTFilePB::histo_size(), mps_fire::i, input, and getGTfromDQMFile::obj.
Referenced by main().
int encodeFile | ( | const std::string & | output_filename, |
const std::vector< std::string > & | filenames | ||
) |
Definition at line 253 of file fastHadd.cc.
References cms::cuda::assert(), DEBUG, fillMessage(), input, processDirectory(), and writeMessage().
Referenced by main().
|
inline |
Extract the next serialised ROOT object from buf. Returns null if there are no more objects in the buffer, or a null pointer was serialised at this location.
Definition at line 162 of file fastHadd.cc.
References visDQMUpload::buf.
Referenced by convertFile(), dumpFiles(), and get_info().
void fillMessage | ( | dqmstorepb::ROOTFilePB & | dqmstore_output_msg, |
const MEStore & | micromes | ||
) |
Definition at line 207 of file fastHadd.cc.
References dqmstorepb::ROOTFilePB::add_histo(), edmScanValgrind::buffer, DEBUG, h, and hlt_dqm_clientPB-live_cfg::me.
Referenced by addFilesWithFork(), and encodeFile().
|
static |
Definition at line 170 of file fastHadd.cc.
References visDQMUpload::buf, DMR_cfg::cerr, BTVHLTOfflineSource_cfi::dirname, extractNextObject(), h, getGTfromDQMFile::obj, and pickleFileParser::slash.
Referenced by addFile(), convertFile(), and tryRootPreload().
int main | ( | int | argc, |
char * | argv[] | ||
) |
===============================================================================================================================================================================================
variant2: for each run define phi-averaged A for normalization channel (Dref,16) and then, divide Rijk on it, i.e. get RRijk
eta=27
eta=25
eta=23
eta=22
eta=21
eta=26
eta=24
eta=19
eta=17
eta=25
eta=23
eta=22
eta=21
eta=26
eta=24
eta=20
eta=19
eta=18
eta=27 L1=1
eta=25 L1=1
eta=23 L1=1
eta=22 L1=1
eta=21 L1=1
eta=29 L1=1
eta=26 L1=1
eta=24 L1=1
eta=20 L1=1
eta=19 L1=1
eta=18 L1=1
eta=17 L1=1
eta=28 L7=1
eta=27 L7=1
eta=25 L7=1
eta=23 L7=1
eta=22 L7=1
eta=21 L7=1
eta=26 L7=1
eta=24 L7=1
eta=20 L7=1
eta=19 L7=1
eta=18 L7=1
eta=17 L7=1
eta=27
eta=25
eta=23
eta=22
eta=21
eta=26
eta=24
eta=19
eta=17
eta=25
eta=23
eta=22
eta=21
eta=26
eta=24
eta=20
eta=19
eta=18
eta=27 L1=1
eta=25 L1=1
eta=23 L1=1
eta=22 L1=1
eta=21 L1=1
eta=26 L1=1
eta=24 L1=1
eta=20 L1=1
eta=19 L1=1
eta=18 L1=1
eta=17 L1=1
eta=28 L7=1
eta=27 L7=1
eta=25 L7=1
eta=23 L7=1
eta=22 L7=1
eta=21 L7=1
eta=26 L7=1
eta=24 L7=1
eta=20 L7=1
eta=19 L7=1
eta=18 L7=1
eta=17 L7=1
eta=27
eta=28
errA with average Amplitudes
errA with average Amplitudes
errA with average Amplitudes
errA with average Amplitudes
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Sticking ADC counts in neughbouring TS for HB:
Sticking ADC counts in neughbouring TS for HE:
RBX:
errA with average Amplitudes
errA with average Amplitudes
errA with average Amplitudes
errA with average Amplitudes
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
RBX:
errA with average Amplitudes
errA with average Amplitudes
errA with average Amplitudes
errA with average Amplitudes
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
Summed Amplitude Plots:
RBX:
Prepare maps of good/bad channels:
Prepare maps of good/bad channels:
Prepare maps of good/bad channels:
Prepare maps of good/bad channels:
Definition at line 513 of file fastHadd.cc.
References addFiles(), dir2webdir::argc, GCPpyPlots::argv, DMR_cfg::cerr, convertFile(), debug, dumpFiles(), encodeFile(), mps_setup::jobs, electronStore::output_file, runTheMatrix::ret, showusage(), AlCaHLTBitMon_QueryRunRegistry::string, TrackValidation_cff::task, TASK_ADD, TASK_CONVERT, TASK_DUMP, and TASK_ENCODE.
void processDirectory | ( | TFile * | file, |
const std::string & | curdir, | ||
MEStore & | micromes | ||
) |
Definition at line 225 of file fastHadd.cc.
References DEBUG, geometryDiff::file, submitPVResolutionJobs::key, GetRecoTauVFromDQM_MC_cff::next, getGTfromDQMFile::obj, AlCaHLTBitMon_QueryRunRegistry::string, and mkLumiAveragedPlots::subdir.
Referenced by encodeFile().
|
static |
Definition at line 503 of file fastHadd.cc.
References DMR_cfg::cerr, ERR_BADCFG, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by main().
void tryRootPreload | ( | ) |
Definition at line 396 of file fastHadd.cc.
References dqmstorepb::ROOTFilePB::add_histo(), get_info(), dqmstorepb::ROOTFilePB::histo(), getGTfromDQMFile::obj, castor_dqm_sourceclient_file_cfg::path, dqmstorepb::ROOTFilePB_Histo::set_flags(), dqmstorepb::ROOTFilePB_Histo::set_size(), dqmstorepb::ROOTFilePB_Histo::set_streamed_histo(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by addFiles().
void writeMessage | ( | const dqmstorepb::ROOTFilePB & | dqmstore_output_msg, |
const std::string & | output_filename | ||
) |
Definition at line 197 of file fastHadd.cc.
References DEBUG, and writeMessageFD().
Referenced by encodeFile().
void writeMessageFD | ( | const dqmstorepb::ROOTFilePB & | dqmstore_output_msg, |
int | out_fd | ||
) |
Definition at line 184 of file fastHadd.cc.
References AlcaSiPixelAliHarvester0T_cff::options.
Referenced by addFilesWithFork(), and writeMessage().
int debug = 0 |
Definition at line 113 of file fastHadd.cc.
Referenced by main().