#include "CxxUtils/checker_macros.h"
#include "TSystem.h"
#include "TH1.h"
#include "TH2.h"
#include "TFile.h"
#include "TKey.h"
#include "TTree.h"
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include "DataQualityUtils/MonitoringFile.h"
Go to the source code of this file.
◆ MAXSKIPPEDFILES
#define MAXSKIPPEDFILES 5 |
◆ MAXSKIPPEDFILESFRACTION
#define MAXSKIPPEDFILESFRACTION 0.1 |
◆ ATLAS_NOT_THREAD_SAFE()
void lowerLB ATLAS_NOT_THREAD_SAFE |
( |
TObject * |
a, |
|
|
const TObject * |
b |
|
) |
| |
Definition at line 144 of file LArQuickHistMerge.cxx.
145 TH1* a1=(
dynamic_cast<TH1*
>(
a));
146 const TH1* b1=
dynamic_cast<const TH1*
>(
b);
148 std::cout <<
"ERROR in weightedAverageTH1: Object not of type TH1" << std::endl;
◆ defaultMerge()
template<class HIST >
void defaultMerge |
( |
TObject * |
a, |
|
|
const TObject * |
b |
|
) |
| |
◆ identical()
void identical |
( |
TObject * |
a, |
|
|
const TObject * |
b |
|
) |
| |
Definition at line 214 of file LArQuickHistMerge.cxx.
215 TH1* a1=(
dynamic_cast<TH1*
>(
a));
216 const TH1* b1=
dynamic_cast<const TH1*
>(
b);
218 const TH2*
d1=
dynamic_cast<const TH2*
>(
b);
221 }
else if (
c1 and
d1){
224 std::cout <<
"ERROR in identical: Object not of type THist" << std::endl;
225 std::cout << a1 <<
" " << b1 <<
" " <<
c1 <<
" " <<
d1 <<std::endl;
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 472 of file LArQuickHistMerge.cxx.
474 if (
argc<2 || (
argc>1 && (!strcmp(
argv[1],
"-h") || !strcmp(
argv[1],
"--help")))) {
475 std::cout <<
"Syntax:\n" <<
argv[0] <<
" [-v ] [-i inputTextFile] [-d directroy] <outfile> <infile1> <infile2> .... " << std::endl;
476 std::cout <<
" -v verbose " << std::endl;
483 std::vector<std::string> baseDirs;
485 for(
int iArg=1;iArg<
argc;++iArg) {
486 if (!strcmp(
argv[iArg],
"-v")) {
491 if (!strcmp(
argv[iArg],
"-d")) {
494 std::cout <<
"ERROR: Expected a parameter (directory name) after '-d'" << std::endl;
497 baseDirs.push_back(std::string(
argv[iArg]));
502 if (!strcmp(
argv[iArg],
"-i")) {
505 std::cout <<
"ERROR: Expected text file name after '-i'" << std::endl;
519 std::cout <<
"ERROR: No output file name given!" << std::endl;
523 if (!gSystem->AccessPathName(
outFileName.c_str())) {
524 std::cout <<
"ERROR: Output file " <<
outFileName <<
" exists already!" << std::endl;
529 std::cout <<
"WARNING: No input files given! Will produce empty output file" << std::endl;
533 std::cout <<
"Number of input files: " <<
inFileNames.size() << std::endl;
534 std::cout <<
"Output file: " <<
outFileName << std::endl;
536 if (baseDirs.empty()) {
537 baseDirs.push_back(
"LAr");
538 baseDirs.push_back(
"CaloMonitoring/LArCellMon_NoTrigSel");
539 baseDirs.push_back(
"CaloTopoClusters/CalBAR");
540 baseDirs.push_back(
"CaloTopoClusters/CalECA");
541 baseDirs.push_back(
"CaloTopoClusters/CalECC");
542 baseDirs.push_back(
"CaloTopoClusters/CalEMBAR");
543 baseDirs.push_back(
"CaloTopoClusters/CalEMECA");
544 baseDirs.push_back(
"CaloTopoClusters/CalEMECC");
549 for (
size_t i=0;
i<baseDirs.size();++
i) {
550 std::vector<std::string> dirtok=
splitString(baseDirs[
i],std::string(
"/"));
551 if (dirtok.empty()) {
555 baseDirs[
i]=dirtok[0];
556 for (
size_t j=1;j<dirtok.size();++j) {
557 baseDirs[
i]+=
"/"+dirtok[j];
564 listOfHists.addExclusion(
"/CaloMonitoring/LArCellMon_NoTrigSel/Sporadic");
567 std::string runDir(
"/");
569 unsigned nSkippedFiles=0;
574 for (;fileIndex<
nFiles && runDir.size()==1;++fileIndex) {
578 std::cout <<
"ERROR: Could not open first file " <<
inFileNames[fileIndex] <<
"after all attempts" << std::endl;
580 std::cout <<
"Failed to read " << nSkippedFiles <<
" input files. Abort job ..." << std::endl;
584 std::cout <<
"Failed to read " << 100.0*nSkippedFiles/
nFiles <<
"% of input files. Abort job ..." << std::endl;
588 std::cout <<
"Continue without this file. Skipped " << nSkippedFiles <<
" input files so far." << std::endl;
592 std::cout <<
"Working on file " <<
inFileNames[fileIndex] << std::endl;
594 TIter
next(in1->GetListOfKeys() );
597 const char*
name=
key->GetName();
598 if (!strncmp(
name,
"run_",4)) {
599 if (runDir.size()>1) {
600 std::cout <<
"ERROR More than one run_XXX directory found! Ignoring " <<
name << std::endl;
607 if (runDir.size()==1) {
608 std::cout <<
"WARNING: No run_XXXX directory found. Empty File? Ignored." << std::endl;
614 std::vector<std::string>::const_iterator dIt=baseDirs.begin();
615 std::vector<std::string>::const_iterator dIt_e=baseDirs.end();
616 for (;dIt!=dIt_e;++dIt) {
617 std::string dirName=runDir+
"/"+(*dIt);
618 TDirectory*
dir=
dynamic_cast<TDirectory*
>(in1->Get(dirName.c_str()));
620 std::cout <<
"Did not find directory " << dirName <<
"!" << std::endl;
623 listOfHists.addDirectory(
dir,dirName);
626 std::cout <<
"Number of directories: " << listOfHists.size() << std::endl;
628 if (
debug) listOfHists.print();
635 for (;fileIndex<
nFiles;++fileIndex) {
640 std::cout <<
"ERROR: Could not open file " <<
filename <<
"after all attempts" << std::endl;
642 std::cout <<
"Failed to read " << nSkippedFiles <<
" input files. Abort job ..." << std::endl;
646 std::cout <<
"Failed to read " << 100.0*nSkippedFiles/
nFiles <<
"% of input files. Abort job ..." << std::endl;
650 std::cout <<
"Continue without this file. Skipped " << nSkippedFiles <<
" input files so far." << std::endl;
653 std::cout <<
"Working on file " <<
filename << std::endl;
654 TObject* dirObj=in->Get(runDir.c_str()+1);
656 std::cout <<
"Directory " << runDir <<
" not found. Ignoring apprently empty file" << std::endl;
659 listOfHists.addFile(in);
665 if (!
out || !
out->IsOpen()) {
666 std::cout <<
"ERROR: Failed to open output file " <<
outFileName <<
" for writing" << std::endl;
669 listOfHists.write(
out);
673 if (in1 && in1->IsOpen()) {
678 if (nSkippedFiles>0) {
679 std::cout <<
"WARNING: Skipped " << nSkippedFiles <<
" input file(s)." << std::endl;
◆ openWithRetry()
TFile* openWithRetry |
( |
const char * |
path, |
|
|
const unsigned |
nTrys = 3 |
|
) |
| |
Definition at line 33 of file LArQuickHistMerge.cxx.
36 unsigned sleepSeconds=30;
37 while (!
f && iTry<nTrys) {
38 f=TFile::Open(
path,
"READ");
39 if (!
f || !(
f->IsOpen())) {
41 std::cout <<
"WARNING: Failed to open file " <<
path <<
" on " << iTry <<
". attempt." << std::endl;
43 std::cout <<
"Will re-try after " << sleepSeconds <<
" seconds..." << std::endl;
49 std::cout <<
"No more retrys" << std::endl;
◆ readFromTextFile()
bool readFromTextFile |
( |
const char * |
filename, |
|
|
std::vector< std::string > & |
out |
|
) |
| |
Definition at line 441 of file LArQuickHistMerge.cxx.
443 std::ifstream ifs (
filename, std::ifstream::in );
445 std::cout <<
"Failed to open file " <<
filename <<
" for reading." << std::endl;
454 std::vector<std::string>::const_iterator
it=linetok.begin();
455 std::vector<std::string>::const_iterator it_e=linetok.end();
456 for(;
it!=it_e;++
it) {
457 if ((*
it)[0]==
'#')
break;
◆ splitString()
std::vector<std::string> splitString |
( |
const std::string & |
in, |
|
|
const std::string & |
delim |
|
) |
| |
Definition at line 426 of file LArQuickHistMerge.cxx.
427 std::vector<std::string> retvec;
428 size_t pos1=0,pos2=0;
429 while (pos2!=std::string::npos) {
430 pos2=in.find_first_of(delim,pos1);
431 const std::string sub=in.substr(pos1,pos2-pos1);
433 retvec.push_back(sub);
◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY |