ATLAS Offline Software
Loading...
Searching...
No Matches
TIDDirectory.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
15
16
17#ifndef TIDA_TIDDIRECTORY_H
18#define TIDA_TIDDIRECTORY_H
19
20#include "TDirectory.h"
21#include "TH1.h"
22
23// #include "utils.h"
24
26
27public:
28
29 // TIDDirectory() : mHAddState(true), mDAddState(true), mPop(0), mDir(0) { }
30
31 TIDDirectory(const std::string& n="") :
32 mname(n), mPop(gDirectory), mDir(0) {
33
34 if ( n=="" ) {
35 mDir = gDirectory;
36 return;
37 }
38
39
40
41 if ( n.find("/")==std::string::npos ) {
43 mDir = gDirectory->GetDirectory(n.c_str());
44 if ( mDir==0 ) mDir = gDirectory->mkdir(n.c_str());
45 return;
46 }
47
48 std::string _dir = n;
49
50 if ( _dir.find("/")!=std::string::npos ) {
51
52 std::string dir = chop( _dir, "/" );
53
54 if ( _dir == "" ) {
56 mDir = gDirectory->GetDirectory( dir.c_str());
57 if ( mDir==0 ) mDir = gDirectory->mkdir( dir.c_str() );
58 return;
59 }
60
62 mDir = gDirectory->GetDirectory( dir.c_str());
63 if ( mDir==0 ) mDir = gDirectory->mkdir( dir.c_str() );
64 push();
65
67 TIDDirectory d(_dir);
68 mDir = d.cwd();
69 pop();
70 }
71
72 // push();
73 }
74
75
76 virtual ~TIDDirectory() { }
77
78 void push() { mPop = gDirectory; if (mDir) mDir->cd(); }
79 void pop() { if (mPop) mPop->cd(); }
80
81 void Write() { push(); mDir->Write(); pop(); }
82
83 void pwd() const { mDir->pwd(); }
84 TDirectory* cwd() { return mDir; }
85
86 void disable() { }
87 void restore() { }
88
89 const std::string& name() const { return mname; }
90
91 protected:
92
93 std::string chop( std::string& s1, const std::string& s2="/" ) {
94 std::string s3 = "";
95 std::string::size_type pos = s1.find(s2);
96 if ( pos != std::string::npos ) {
97 s3 = s1.substr(0, pos+s2.size());
98 s1.erase(0, pos+s2.size());
99 }
100 return s3;
101 }
102
103 protected:
104
105 // bool mHAddState;
106 // bool mDAddState;
107
108 std::string mname;
109
110 TDirectory* mPop;
111 TDirectory* mDir;
112
113};
114
115
116
117#endif /* TIDA_TIDDIRECTORY_H */
118
119
if(febId1==febId2)
const std::string & name() const
std::string mname
virtual ~TIDDirectory()
TDirectory * mDir
void pwd() const
TDirectory * cwd()
TIDDirectory(const std::string &n="")
std::string chop(std::string &s1, const std::string &s2="/")
TDirectory * mPop