ATLAS Offline Software
Loading...
Searching...
No Matches
TFileLooper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGVALTOOLS_TFILELOOPER_H
6#define TRIGVALTOOLS_TFILELOOPER_H
7
14
15#include <fstream>
16#include <vector>
17
18#include "TDirectory.h"
19#include "TFile.h"
20#include "TString.h"
21#include "TH1.h"
22#include "TPRegexp.h"
23
24
34
36 public:
37 TFileLooper() = default;
38 virtual ~TFileLooper() = default;
39
40 TFileLooper (const TFileLooper& other) = delete;
41 TFileLooper& operator= (const TFileLooper& other) = delete;
42
44 virtual Int_t run(const char* filename, const char* rootDir = 0);
45
50 virtual void processKey(TDirectory& dir, TKey& key);
51
53
54 virtual void beginJob() {}
55 virtual void endJob() {}
56 virtual void beforeFile() {}
57 virtual void afterFile() {}
58 virtual void beforeDir() {}
59 virtual void afterDir() {}
60 virtual void beforeObj() {}
61 virtual void afterObj() {}
63
65 void setDirsToSkip(const char* skipDirs) {if (skipDirs) m_skipDirs = skipDirs;}
66
68 void addFailRegexp(const char* regexp);
69
71 void addPassRegexp(const char* regexp);
72
74 void passBeforeFailRegexp(Bool_t passBeforeFail = kTRUE) { m_passBeforeFail = passBeforeFail; }
75
77 void setVerbose(Bool_t verbose = kTRUE) {m_verbose = verbose;}
78
80 Bool_t verbose() const {return m_verbose;}
81
83 const TFile* file() const { return m_file; }
84
86 TString rootDir() const { return m_rootDir; }
87
88protected:
89 TFile* m_file{nullptr};
90 TString m_rootDir;
91 TString m_skipDirs;
92 Bool_t m_verbose{kFALSE};
93 Bool_t m_passBeforeFail{kFALSE};
94 Int_t m_errorCode{0};
95
96 std::vector<TPRegexp> m_failRE;
97 std::vector<TPRegexp> m_passRE;
98
99 std::vector<std::string> m_skippedObjects;
100
101 TString getPathFromDir(const TDirectory& dir);
102 TString getKeyPath(const TDirectory& dir, const TKey& key);
103
104 void processDir(TDirectory& dir);
105 void processFile(const char* filename, const char* rootDir = 0);
106 Bool_t skipDir(const TDirectory& dir);
107 Bool_t skipObject(const char* name);
108 TString getDrawOptions(const TH1& h);
109};
110
111#endif
Header file for AthHistogramAlgorithm.
virtual void afterFile()
Definition TFileLooper.h:57
void addFailRegexp(const char *regexp)
Skip keys that match this regexp.
void addPassRegexp(const char *regexp)
Never skip keys that match this regexp.
TString m_rootDir
Definition TFileLooper.h:90
TFileLooper(const TFileLooper &other)=delete
TString rootDir() const
Current directory.
Definition TFileLooper.h:86
std::vector< std::string > m_skippedObjects
Definition TFileLooper.h:99
void processDir(TDirectory &dir)
TFile * m_file
Definition TFileLooper.h:89
void setVerbose(Bool_t verbose=kTRUE)
Set verbose mode.
Definition TFileLooper.h:77
std::vector< TPRegexp > m_failRE
Definition TFileLooper.h:96
TString getKeyPath(const TDirectory &dir, const TKey &key)
TFileLooper & operator=(const TFileLooper &other)=delete
virtual void beforeObj()
Definition TFileLooper.h:60
virtual ~TFileLooper()=default
virtual void beforeFile()
Definition TFileLooper.h:56
virtual void beginJob()
Definition TFileLooper.h:54
Bool_t m_verbose
Definition TFileLooper.h:92
virtual void endJob()
Definition TFileLooper.h:55
void passBeforeFailRegexp(Bool_t passBeforeFail=kTRUE)
Reverse pass/fail logic. First check on pass then on fail.
Definition TFileLooper.h:74
TString getDrawOptions(const TH1 &h)
void setDirsToSkip(const char *skipDirs)
Skip this comma separated list of directories.
Definition TFileLooper.h:65
Bool_t verbose() const
Query verbose mode.
Definition TFileLooper.h:80
virtual void beforeDir()
Definition TFileLooper.h:58
TFileLooper()=default
const TFile * file() const
Current ROOT file.
Definition TFileLooper.h:83
std::vector< TPRegexp > m_passRE
Definition TFileLooper.h:97
Bool_t skipObject(const char *name)
Bool_t m_passBeforeFail
Definition TFileLooper.h:93
Bool_t skipDir(const TDirectory &dir)
TString getPathFromDir(const TDirectory &dir)
Int_t m_errorCode
Definition TFileLooper.h:94
void processFile(const char *filename, const char *rootDir=0)
virtual void afterObj()
Definition TFileLooper.h:61
TString m_skipDirs
Definition TFileLooper.h:91
virtual void afterDir()
Definition TFileLooper.h:59
virtual void processKey(TDirectory &dir, TKey &key)
Method called for every key.
Definition run.py:1