#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 10 |
◆ MAXSKIPPEDFILESFRACTION
#define MAXSKIPPEDFILESFRACTION 0.1 |
◆ ATLAS_NOT_THREAD_SAFE()
void lowerLB ATLAS_NOT_THREAD_SAFE |
( |
TObject * |
a, |
|
|
const TObject * |
b |
|
) |
| |
Definition at line 145 of file LArQuickHistMerge.cxx.
146 TH1* a1=(
dynamic_cast<TH1*
>(
a));
147 const TH1* b1=
dynamic_cast<const TH1*
>(
b);
149 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 215 of file LArQuickHistMerge.cxx.
216 TH1* a1=(
dynamic_cast<TH1*
>(
a));
217 const TH1* b1=
dynamic_cast<const TH1*
>(
b);
218 TH2*
c1=(
dynamic_cast<TH2*
>(
a));
219 const TH2*
d1=
dynamic_cast<const TH2*
>(
b);
222 }
else if (
c1 and
d1){
225 std::cout <<
"ERROR in identical: Object not of type THist" << std::endl;
226 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];
563 std::vector<std::string> foundDirs;
566 listOfHists.addExclusion(
"/CaloMonitoring/LArCellMon_NoTrigSel/Sporadic");
569 std::string runDir(
"/");
571 unsigned nSkippedFiles=0;
577 for (;fileIndex<
nFiles && foundDirs.size()!=baseDirs.size() ;++fileIndex) {
581 std::cout <<
"ERROR: Could not open first file " <<
inFileNames[fileIndex] <<
"after all attempts" << std::endl;
583 std::cout <<
"Failed to read " << nSkippedFiles <<
" input files. Abort job ..." << std::endl;
587 std::cout <<
"Failed to read " << 100.0*nSkippedFiles/
nFiles <<
"% of input files. Abort job ..." << std::endl;
591 std::cout <<
"Continue without this file. Skipped " << nSkippedFiles <<
" input files so far." << std::endl;
595 std::cout <<
"First loop: Working on file " <<
inFileNames[fileIndex] <<std::endl;
597 TIter
next(in1->GetListOfKeys() );
600 const char*
name=
key->GetName();
601 if (!strncmp(
name,
"run_",4)) {
602 if (runDir.size()>1) {
603 std::cout <<
"ERROR More than one run_XXX directory found! Ignoring " <<
name << std::endl;
610 if (runDir.size()==1) {
611 std::cout <<
"WARNING: No run_XXXX directory found. Empty File? Ignored." << std::endl;
617 std::vector<std::string>::const_iterator dIt=baseDirs.begin();
618 std::vector<std::string>::const_iterator dIt_e=baseDirs.end();
620 for (;dIt!=dIt_e;++dIt) {
621 std::string dirName=runDir+
"/"+(*dIt);
624 TDirectory*
dir=
dynamic_cast<TDirectory*
>(in1->Get(dirName.c_str()));
626 std::cout <<
"Did not find directory " << dirName <<
" in file "<<
inFileNames[fileIndex].c_str()<<
" !" << std::endl;
629 if (
std::find(foundDirs.begin(), foundDirs.end(), dirName) != foundDirs.end())
631 std::cout<<
"Already found "<<dirName<<
" before"<<std::endl;
634 foundDirs.push_back(dirName);
636 if (
debug) std::cout <<
"Found directory " << dirName <<
" in file "<<
inFileNames[fileIndex].c_str()<<
" !" << std::endl;
637 listOfHists.addDirectory(
dir,dirName);
640 std::cout <<
"Number of directories: " << listOfHists.size() << std::endl;
641 std::cout<<
"SIZE "<< listOfHists.size() <<std::endl;
643 if (
debug) listOfHists.print();
650 for (;fileIndex<
nFiles;++fileIndex) {
655 std::cout <<
"ERROR: Could not open file " <<
filename <<
"after all attempts" << std::endl;
657 std::cout <<
"Failed to read " << nSkippedFiles <<
" input files. Abort job ..." << std::endl;
661 std::cout <<
"Failed to read " << 100.0*nSkippedFiles/
nFiles <<
"% of input files. Abort job ..." << std::endl;
665 std::cout <<
"Continue without this file. Skipped " << nSkippedFiles <<
" input files so far." << std::endl;
668 std::cout <<
"Working on file " <<
filename << std::endl;
669 TObject* dirObj=in->Get(runDir.c_str()+1);
671 std::cout <<
"Directory " << runDir <<
" not found. Ignoring apprently empty file" << std::endl;
674 listOfHists.addFile(in);
680 if (!
out || !
out->IsOpen()) {
681 std::cout <<
"ERROR: Failed to open output file " <<
outFileName <<
" for writing" << std::endl;
684 listOfHists.write(
out);
688 if (in1 && in1->IsOpen()) {
693 if (nSkippedFiles>0) {
694 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 447 of file LArQuickHistMerge.cxx.
448 std::ifstream ifs (
filename, std::ifstream::in );
450 std::cout <<
"Failed to open file " <<
filename <<
" for reading." << std::endl;
458 std::vector<std::string>::const_iterator
it=linetok.begin();
459 std::vector<std::string>::const_iterator it_e=linetok.end();
460 for(;
it!=it_e;++
it) {
461 if ((*
it)[0]==
'#')
break;
◆ splitString()
std::vector<std::string> splitString |
( |
const std::string & |
in, |
|
|
const std::string & |
delim |
|
) |
| |
Definition at line 434 of file LArQuickHistMerge.cxx.
435 std::vector<std::string> retvec;
436 size_t pos1=0,pos2=0;
437 while (pos2!=std::string::npos) {
438 pos2=in.find_first_of(delim,pos1);
439 const std::string sub=in.substr(pos1,pos2-pos1);
441 retvec.push_back(sub);
◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY |