CMS 3D CMS Logo

Classes | Macros | Typedefs | Enumerations | Functions | Variables
fastHadd.cc File Reference
#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 &micromes, 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 &micromes)
 
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 &micromes)
 
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
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG (   x,
  msg 
)
Value:
if (debug >= x) \
std::cout << "DEBUG: " << msg << std::flush
int debug
Definition: fastHadd.cc:113
tuple msg
Definition: mps_check.py:285
float x

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().

Typedef Documentation

◆ MEStore

using MEStore = std::set<MicroME>

Definition at line 146 of file fastHadd.cc.

Enumeration Type Documentation

◆ ErrType

enum ErrType
Enumerator
ERR_BADCFG 
ERR_NOFILE 

Definition at line 150 of file fastHadd.cc.

◆ TaskType

enum TaskType
Enumerator
TASK_ADD 
TASK_DUMP 
TASK_CONVERT 
TASK_ENCODE 

Definition at line 148 of file fastHadd.cc.

Function Documentation

◆ addFile()

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, mps_fire::i, input, getGTfromDQMFile::obj, castor_dqm_sourceclient_file_cfg::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by addFilesWithFork().

352  {
353  dqmstorepb::ROOTFilePB dqmstore_msg;
354 
355  FileInputStream fin(fd);
356  GzipInputStream input(&fin);
357  CodedInputStream input_coded(&input);
358  input_coded.SetTotalBytesLimit(1024 * 1024 * 1024);
359  if (!dqmstore_msg.ParseFromCodedStream(&input_coded)) {
360  std::cout << "Fatal decoding stream: " << fd << std::endl;
361  return ERR_NOFILE;
362  }
363 
364  auto hint = micromes.begin();
365  for (int i = 0; i < dqmstore_msg.histo_size(); i++) {
367  std::string objname;
368  TObject *obj = nullptr;
369  const dqmstorepb::ROOTFilePB::Histo &h = dqmstore_msg.histo(i);
370  get_info(h, path, objname, &obj);
371 
372  MicroME mme(nullptr, path, objname, h.flags());
373  auto ir = micromes.insert(hint, mme);
374  if (ir->obj != nullptr) {
375  // new element was not added
376  // so we merge
377 
378  ir->add(obj);
379  delete obj;
380  DEBUG(2, "Merged MicroME " << mme.fullname() << std::endl);
381  } else {
382  ir->obj = obj;
383  DEBUG(2, "Inserted MicroME " << mme.fullname() << std::endl);
384  }
385 
386  hint = ir;
387  ++hint;
388  }
389 
390  return 0;
391 }
static void get_info(const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj)
Definition: fastHadd.cc:170
static std::string const input
Definition: EdmProvDump.cc:47
void add(TObject *obj_to_add) const
Definition: fastHadd.cc:132
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
fd
Definition: ztee.py:136
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ addFiles()

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().

490  {
491  tryRootPreload();
492 
493  DEBUG(1, "Writing file" << std::endl);
494  int out_fd =
495  ::open(output_filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
496 
497  addFilesWithFork(out_fd, 1, nthreads, filenames);
498  ::close(out_fd);
499 
500  return 0;
501 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int nthreads
void tryRootPreload()
Definition: fastHadd.cc:396
void addFilesWithFork(int parent_fd, const int fork_id, const int fork_total, const std::vector< std::string > &filenames)
Definition: fastHadd.cc:421
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ addFilesWithFork()

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().

424  {
425  DEBUG(1, "Start process: " << fork_id << " parent: " << (fork_id / 2) << std::endl);
426 
427  std::list<std::pair<int, int> > children;
428 
429  // if this node has a subtree, start it
430  for (int i = 0; i < 2; ++i) {
431  int child_id = fork_id * 2 + i;
432  if (child_id > fork_total)
433  continue;
434 
435  int fd[2];
436  ::pipe(fd);
437 
438  int child_pid = ::fork();
439  if (child_pid == 0) {
440  ::prctl(PR_SET_PDEATHSIG, SIGKILL);
441  ::close(fd[0]); // close read end
442 
443  addFilesWithFork(fd[1], child_id, fork_total, filenames);
444  ::close(fd[1]);
445 
446  ::_exit(0);
447  } else {
448  ::close(fd[1]); // close write end
449  children.push_back(std::make_pair(fd[0], child_pid));
450  }
451  }
452 
453  // merge all my files
454  MEStore microme;
455 
456  // select the filenames to process
457  // with threads=1, this just selects all the files
458  for (unsigned int fi = fork_id - 1; fi < filenames.size(); fi += fork_total) {
459  const std::string &file = filenames[fi];
460  DEBUG(1, "Adding file " << file << std::endl);
461 
462  int filedescriptor;
463  if ((filedescriptor = ::open(file.c_str(), O_RDONLY)) == -1) {
464  std::cout << "Fatal Error opening file " << file << std::endl;
465 
466  exit(ERR_NOFILE);
467  }
468 
469  addFile(microme, filedescriptor);
470  ::close(filedescriptor);
471  }
472 
473  // merge all children
474  for (auto &chpair : children) {
475  int fd = chpair.first;
476  addFile(microme, fd);
477  ::close(fd);
478 
479  // collect the child, not necessary, but avoids <defunct>
480  int status;
481  ::waitpid(chpair.second, &status, 0);
482  }
483 
484  // output everything to fd
485  dqmstorepb::ROOTFilePB dqmstore_output_msg;
486  fillMessage(dqmstore_output_msg, microme);
487  writeMessageFD(dqmstore_output_msg, parent_fd);
488 };
def pipe(cmdline, input=None)
Definition: pipe.py:5
void writeMessageFD(const dqmstorepb::ROOTFilePB &dqmstore_output_msg, int out_fd)
Definition: fastHadd.cc:184
void fillMessage(dqmstorepb::ROOTFilePB &dqmstore_output_msg, const MEStore &micromes)
Definition: fastHadd.cc:207
std::set< MicroME > MEStore
Definition: fastHadd.cc:146
int addFile(MEStore &micromes, int fd)
Definition: fastHadd.cc:352
void addFilesWithFork(int parent_fd, const int fork_id, const int fork_total, const std::vector< std::string > &filenames)
Definition: fastHadd.cc:421
fd
Definition: ztee.py:136
#define DEBUG(x, msg)
Definition: fastHadd.cc:109
def exit(msg="")

◆ convertFile()

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, mps_fire::i, input, getGTfromDQMFile::obj, convertSQLitetoXML_cfg::output, castor_dqm_sourceclient_file_cfg::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by main().

267  {
268  assert(filenames.size() == 1);
269  TFile output(output_filename.c_str(), "RECREATE");
270  DEBUG(0, "Converting file " << filenames[0] << std::endl);
271  dqmstorepb::ROOTFilePB dqmstore_message;
272 
273  int filedescriptor = ::open(filenames[0].c_str(), O_RDONLY);
274  FileInputStream fin(filedescriptor);
275  GzipInputStream input(&fin);
276  CodedInputStream input_coded(&input);
277  input_coded.SetTotalBytesLimit(1024 * 1024 * 1024);
278  if (!dqmstore_message.ParseFromCodedStream(&input_coded)) {
279  std::cout << "Fatal Error opening file " << filenames[0] << std::endl;
280  return ERR_NOFILE;
281  }
282  ::close(filedescriptor);
283 
284  for (int i = 0; i < dqmstore_message.histo_size(); i++) {
285  const dqmstorepb::ROOTFilePB::Histo &h = dqmstore_message.histo(i);
286  DEBUG(1, h.full_pathname() << std::endl);
287  DEBUG(1, h.size() << std::endl);
288  TBufferFile buf(TBufferFile::kRead, h.size(), (void *)h.streamed_histo().data(), kFALSE);
289  buf.Reset();
290  TObject *obj = extractNextObject(buf);
291  std::string path, objname;
292  get_info(h, path, objname, &obj);
293  gDirectory->cd("/");
294  // Find the first path component.
295  size_t start = 0;
296  size_t end = path.find('/', start);
297  if (end == std::string::npos)
298  end = path.size();
299  while (true) {
301  if (!gDirectory->Get(part.c_str()))
302  gDirectory->mkdir(part.c_str());
303  gDirectory->cd(part.c_str());
304  // Stop if we reached the end, ignoring any trailing '/'.
305  if (end + 1 >= path.size())
306  break;
307  // Find the next path component.
308  start = end + 1;
309  end = path.find('/', start);
310  if (end == std::string::npos)
311  end = path.size();
312  }
313  obj->Write();
314  DEBUG(1, obj->GetName() << std::endl);
315  }
316  output.Close();
317  return 0;
318 }
Definition: start.py:1
static void get_info(const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj)
Definition: fastHadd.cc:170
TObject * extractNextObject(TBufferFile &buf)
Definition: fastHadd.cc:162
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
part
Definition: HCALResponse.h:20
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ dumpFiles()

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, mps_fire::i, input, and getGTfromDQMFile::obj.

Referenced by main().

320  {
321  assert(!filenames.empty());
322  for (int i = 0, e = filenames.size(); i != e; ++i) {
323  DEBUG(0, "Dumping file " << filenames[i] << std::endl);
324  dqmstorepb::ROOTFilePB dqmstore_message;
325 
326  int filedescriptor = ::open(filenames[0].c_str(), O_RDONLY);
327  FileInputStream fin(filedescriptor);
328  GzipInputStream input(&fin);
329  CodedInputStream input_coded(&input);
330  input_coded.SetTotalBytesLimit(1024 * 1024 * 1024);
331  if (!dqmstore_message.ParseFromCodedStream(&input_coded)) {
332  std::cout << "Fatal Error opening file " << filenames[0] << std::endl;
333  return ERR_NOFILE;
334  }
335  ::close(filedescriptor);
336 
337  for (int i = 0; i < dqmstore_message.histo_size(); i++) {
338  const dqmstorepb::ROOTFilePB::Histo &h = dqmstore_message.histo(i);
339  DEBUG(1, h.full_pathname() << std::endl);
340  DEBUG(1, h.size() << std::endl);
341  TBufferFile buf(TBufferFile::kRead, h.size(), (void *)h.streamed_histo().data(), kFALSE);
342  buf.Reset();
343  TObject *obj = extractNextObject(buf);
344  DEBUG(1, obj->GetName() << std::endl);
345  DEBUG(1, "Flags: " << h.flags() << std::endl);
346  }
347  }
348 
349  return 0;
350 }
TObject * extractNextObject(TBufferFile &buf)
Definition: fastHadd.cc:162
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ encodeFile()

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().

253  {
254  assert(filenames.size() == 1);
255  TFile input(filenames[0].c_str());
256  DEBUG(0, "Encoding file " << filenames[0] << std::endl);
257  MEStore micromes;
258  dqmstorepb::ROOTFilePB dqmstore_message;
259 
260  processDirectory(&input, "", micromes);
261  fillMessage(dqmstore_message, micromes);
262  writeMessage(dqmstore_message, output_filename);
263 
264  return 0;
265 }
void processDirectory(TFile *file, const std::string &curdir, MEStore &micromes)
Definition: fastHadd.cc:225
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
void fillMessage(dqmstorepb::ROOTFilePB &dqmstore_output_msg, const MEStore &micromes)
Definition: fastHadd.cc:207
void writeMessage(const dqmstorepb::ROOTFilePB &dqmstore_output_msg, const std::string &output_filename)
Definition: fastHadd.cc:197
std::set< MicroME > MEStore
Definition: fastHadd.cc:146
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ extractNextObject()

TObject* extractNextObject ( TBufferFile &  buf)
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().

162  {
163  if (buf.Length() == buf.BufferSize())
164  return nullptr;
165 
166  buf.InitMap();
167  return reinterpret_cast<TObject *>(buf.ReadObjectAny(nullptr));
168 }

◆ fillMessage()

void fillMessage ( dqmstorepb::ROOTFilePB &  dqmstore_output_msg,
const MEStore micromes 
)

Definition at line 207 of file fastHadd.cc.

References edmScanValgrind::buffer, DEBUG, h, and hlt_dqm_clientPB-live_cfg::me.

Referenced by addFilesWithFork(), and encodeFile().

207  {
208  auto mi = micromes.begin();
209  auto me = micromes.end();
210 
211  DEBUG(1, "Streaming ROOT objects" << std::endl);
212  for (; mi != me; ++mi) {
213  dqmstorepb::ROOTFilePB::Histo *h = dqmstore_output_msg.add_histo();
214  DEBUG(2, "Streaming ROOT object " << mi->fullname() << "\n");
215  h->set_full_pathname(mi->fullname());
216  TBufferFile buffer(TBufferFile::kWrite);
217  buffer.WriteObject(mi->obj);
218  h->set_size(buffer.Length());
219  h->set_flags(mi->flags);
220  h->set_streamed_histo((const void *)buffer.Buffer(), buffer.Length());
221  delete mi->obj;
222  }
223 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ get_info()

static void get_info ( const dqmstorepb::ROOTFilePB::Histo &  h,
std::string &  dirname,
std::string &  objname,
TObject **  obj 
)
static

Definition at line 170 of file fastHadd.cc.

References visDQMUpload::buf, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, BTVHLTOfflineSource_cfi::dirname, extractNextObject(), h, getGTfromDQMFile::obj, and pickleFileParser::slash.

Referenced by addFile(), convertFile(), and tryRootPreload().

170  {
171  size_t slash = h.full_pathname().rfind('/');
172  size_t dirpos = (slash == std::string::npos ? 0 : slash);
173  size_t namepos = (slash == std::string::npos ? 0 : slash + 1);
174  dirname.assign(h.full_pathname(), 0, dirpos);
175  objname.assign(h.full_pathname(), namepos, std::string::npos);
176  TBufferFile buf(TBufferFile::kRead, h.size(), (void *)h.streamed_histo().data(), kFALSE);
177  buf.Reset();
179  if (!*obj) {
180  std::cerr << "Error reading element: " << h.full_pathname() << std::endl;
181  }
182 }
TObject * extractNextObject(TBufferFile &buf)
Definition: fastHadd.cc:162
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ main()

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:

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, cmsBatch::argv, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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.

513  {
514  int arg;
515  int ret = 0;
516  int jobs = 1;
518  std::vector<std::string> filenames;
519  TaskType task;
520 
521  filenames.reserve(argc);
522 
523  for (arg = 1; arg < argc; ++arg) {
524  if (!strcmp(argv[arg], "--no-debug"))
525  debug = 0;
526  else if (!strcmp(argv[arg], "--debug") || !strcmp(argv[arg], "-d"))
527  debug++;
528  else
529  break;
530  }
531 
532  if (arg < argc) {
533  if (!strcmp(argv[arg], "add")) {
534  ++arg;
535  task = TASK_ADD;
536  } else if (!strcmp(argv[arg], "dump")) {
537  ++arg;
538  task = TASK_DUMP;
539  } else if (!strcmp(argv[arg], "convert")) {
540  ++arg;
541  task = TASK_CONVERT;
542  } else if (!strcmp(argv[arg], "encode")) {
543  ++arg;
544  task = TASK_ENCODE;
545  } else {
546  std::cerr << "Unknown action: " << argv[arg] << std::endl;
547  return showusage();
548  }
549  } else {
550  std::cerr << "Not enough arguments\n";
551  return showusage();
552  }
553 
554  if (task == TASK_ADD) {
555  if ((arg != argc) && (strcmp(argv[arg], "-j") == 0)) {
556  jobs = atoi(argv[arg + 1]);
557 
558  if ((jobs < 1) || (jobs > 128)) {
559  std::cerr << "Invalid argument for -j\n";
560  return showusage();
561  };
562 
563  arg += 2;
564  }
565  }
566 
567  if (task == TASK_ADD || task == TASK_CONVERT || task == TASK_ENCODE) {
568  if (arg == argc) {
569  std::cerr << "add|convert|encode actions requires a -o option to be set\n";
570  return showusage();
571  }
572  if (!strcmp(argv[arg], "-o")) {
573  if (arg < argc - 1) {
574  output_file = argv[++arg];
575  } else {
576  std::cerr << " -o option requires a value\n";
577  return showusage();
578  }
579  }
580  } else if (task == TASK_DUMP) {
581  if (arg == argc) {
582  std::cerr << "Missing input file(s)\n";
583  return showusage();
584  }
585  for (; arg < argc; ++arg) {
586  filenames.emplace_back(argv[arg]);
587  }
588  }
589 
590  if (task == TASK_ADD || task == TASK_CONVERT || task == TASK_ENCODE) {
591  if (++arg == argc) {
592  std::cerr << "Missing input file(s)\n";
593  return showusage();
594  }
595  for (; arg < argc; ++arg) {
596  filenames.emplace_back(argv[arg]);
597  }
598  }
599 
600  if (task == TASK_ADD)
601  ret = addFiles(output_file, filenames, jobs);
602  else if (task == TASK_DUMP)
603  ret = dumpFiles(filenames);
604  else if (task == TASK_CONVERT)
605  ret = convertFile(output_file, filenames);
606  else if (task == TASK_ENCODE)
607  ret = encodeFile(output_file, filenames);
608 
609  google::protobuf::ShutdownProtobufLibrary();
610  return ret;
611 }
ret
prodAgent to be discontinued
A arg
Definition: Factorize.h:31
int debug
Definition: fastHadd.cc:113
TaskType
Definition: fastHadd.cc:148
int encodeFile(const std::string &output_filename, const std::vector< std::string > &filenames)
Definition: fastHadd.cc:253
int convertFile(const std::string &output_filename, const std::vector< std::string > &filenames)
Definition: fastHadd.cc:267
int addFiles(const std::string &output_filename, const std::vector< std::string > &filenames, int nthreads)
Definition: fastHadd.cc:490
static int showusage()
Definition: fastHadd.cc:503
int dumpFiles(const std::vector< std::string > &filenames)
Definition: fastHadd.cc:320

◆ processDirectory()

void processDirectory ( TFile *  file,
const std::string &  curdir,
MEStore micromes 
)

Definition at line 225 of file fastHadd.cc.

References DEBUG, geometryDiff::file, crabWrapper::key, GetRecoTauVFromDQM_MC_cff::next, getGTfromDQMFile::obj, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by encodeFile().

225  {
226  DEBUG(1, "Processing directory " << curdir << "\n");
227  file->cd(curdir.c_str());
228  TKey *key;
229  TIter next(gDirectory->GetListOfKeys());
230  while ((key = (TKey *)next())) {
231  TObject *obj = key->ReadObj();
232  if (dynamic_cast<TDirectory *>(obj)) {
233  std::string subdir;
234  subdir.reserve(curdir.size() + strlen(obj->GetName()) + 2);
235  subdir += curdir;
236  if (!curdir.empty())
237  subdir += '/';
238  subdir += obj->GetName();
239  processDirectory(file, subdir, micromes);
240  } else if ((dynamic_cast<TH1 *>(obj)) || (dynamic_cast<TObjString *>(obj))) {
241  if (dynamic_cast<TH1 *>(obj)) {
242  dynamic_cast<TH1 *>(obj)->SetDirectory(nullptr);
243  }
244 
245  DEBUG(2, curdir << "/" << obj->GetName() << "\n");
246  MicroME mme(obj, curdir, obj->GetName());
247 
248  micromes.insert(mme);
249  }
250  }
251 }
void processDirectory(TFile *file, const std::string &curdir, MEStore &micromes)
Definition: fastHadd.cc:225
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ showusage()

static int showusage ( )
static

Definition at line 503 of file fastHadd.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, ERR_BADCFG, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by main().

503  {
504  static const std::string app_name("fasthadd");
505 
506  std::cerr << "Usage: " << app_name << " [--[no-]debug] TASK OPTIONS\n\n " << app_name
507  << " [OPTIONS] add [-j NUM_THREADS] -o OUTPUT_FILE [DAT FILE...]\n " << app_name
508  << " [OPTIONS] convert -o ROOT_FILE DAT_FILE\n " << app_name
509  << " [OPTIONS] encode -o DAT_FILE ROOT_FILE\n " << app_name << " [OPTIONS] dump [DAT FILE...]\n ";
510  return ERR_BADCFG;
511 }

◆ tryRootPreload()

void tryRootPreload ( )

Definition at line 396 of file fastHadd.cc.

References get_info(), getGTfromDQMFile::obj, castor_dqm_sourceclient_file_cfg::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by addFiles().

396  {
397  // write a single histogram
398  TH1F obj_th1f("preload_th1f", "preload_th1f", 2, 0, 1);
399 
400  TBufferFile write_buffer(TBufferFile::kWrite);
401  write_buffer.WriteObject(&obj_th1f);
402 
403  dqmstorepb::ROOTFilePB preload_file;
404  dqmstorepb::ROOTFilePB::Histo *hw = preload_file.add_histo();
405  hw->set_size(write_buffer.Length());
406  hw->set_flags(0);
407  hw->set_streamed_histo((const void *)write_buffer.Buffer(), write_buffer.Length());
408 
409  // now load this th1f
410  const dqmstorepb::ROOTFilePB::Histo &hr = preload_file.histo(0);
412  std::string objname;
413  TObject *obj = nullptr;
414  get_info(hr, path, objname, &obj);
415  delete obj;
416 
417  // all done
418 }
static void get_info(const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj)
Definition: fastHadd.cc:170

◆ writeMessage()

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().

197  {
198  DEBUG(1, "Writing file" << std::endl);
199 
200  int out_fd =
201  ::open(output_filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
202 
203  writeMessageFD(dqmstore_output_msg, out_fd);
204  ::close(out_fd);
205 }
void writeMessageFD(const dqmstorepb::ROOTFilePB &dqmstore_output_msg, int out_fd)
Definition: fastHadd.cc:184
#define DEBUG(x, msg)
Definition: fastHadd.cc:109

◆ writeMessageFD()

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().

184  {
185  FileOutputStream out_stream(out_fd);
187  options.format = GzipOutputStream::GZIP;
188  options.compression_level = 2;
189  GzipOutputStream gzip_stream(&out_stream, options);
190  dqmstore_output_msg.SerializeToZeroCopyStream(&gzip_stream);
191 
192  // make sure we flush before close
193  gzip_stream.Close();
194  out_stream.Close();
195 }
std::vector< std::shared_ptr< fireworks::OptionNode > > Options

Variable Documentation

◆ debug

int debug = 0

Definition at line 113 of file fastHadd.cc.

Referenced by main().