-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRSTPC_Globals.cc
More file actions
155 lines (124 loc) · 2.89 KB
/
RSTPC_Globals.cc
File metadata and controls
155 lines (124 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "RSTPC_Globals.hh"
#include <iostream>
using namespace std;
RSTPC_Options* RSTPC_Options::globalThis = NULL;
RSTPC_Options* RSTPC_Options::GetInstance()
{
if(!globalThis) globalThis = new RSTPC_Options();
return globalThis;
}
RSTPC_Options* RSTPC_Options::GetInstance(int argc, char** argv)
{
if(!globalThis) globalThis = new RSTPC_Options(argc, argv);
return globalThis;
}
RSTPC_Options::RSTPC_Options()
{
fRunNumber = -1;
fRunSetFlag = false;
//fXmlProcFlag = false;
fT1ProcFlag = true; //This is always true unless a T2 process is defined
//fT2ProcFlag = false;
fOutDirModeFlag = false;
fManOutFileFlag = false;
}
RSTPC_Options::RSTPC_Options(int argc, char** argv)
{
fRunNumber = -1;
fRunSetFlag = false;
//fXmlProcFlag = false;
fT1ProcFlag = true; //This is always true unless a T2 process is defined
//fT2ProcFlag = false;
fOutDirModeFlag = false;
fManOutFileFlag = false;
vector<string> args(argc-1);
for(int iArg=0; iArg<(argc-1); iArg++){
args.at(iArg) = argv[iArg+1];
}
if(!parseArgs(args))
{
usage();
exit(1);
}
}
bool RSTPC_Options::parseArgs(const vector<string> &args)
{
string tmpstr;
for(unsigned iArg=0; iArg<args.size(); iArg++)
{
if(args.at(iArg)==string("-r"))
{
tmpstr = args.at(iArg+1);
if(tmpstr.at(0)=='-') return false;
fRunNumber = atoi(tmpstr.c_str());
if(fRunNumber>=0) fRunSetFlag = true;
iArg++;
}
else if(args.at(iArg)==string("-f"))
{
tmpstr = args.at(iArg+1);
//cout << "\nOutput file (manual): <" << outfilename << ">" << endl;
if(tmpstr.at(0)=='-') return false;
SetOutFile(tmpstr);
iArg++;
}
else if(args.at(iArg)==string("-O"))
{
if(!fManOutFileFlag)
{
tmpstr = args.at(iArg+1);
if(tmpstr.at(0)=='-') return false;
SetOutDir(tmpstr);
//cout << "\nOutput main directory (manual): <" << gXuOptions.outdir << ">" << endl;
}
iArg++;
}
else
{
cerr << "\nERROR --> RSTPC_Options::parseArgs: Unknown option \"" << args.at(iArg) << "\"\n" << endl;
return false;
}
/*
switch(args.at(iArg))
{
case string("-p"):
fXmlProcFile = args(iArg+1);
//cout << "\nSingle file to process: <" << rootfilename << ">" << endl;
if(fXmlProcFile.at(0)=='-') return false;
iArg++;
fXmlProcFlag = true;
break;
case string("-T1"):
iArg++;
fT1ProcFlag = true; //Only T1 processing
break;
case string("-T2"): //Only T2 processing
iArg++;
fT2ProcFlag = true;
break;
}
*/
}
return true;
}
void RSTPC_Options::SetOutFile(string outfilename)
{
fManOutFileFlag = true;
Bool_t path = false;
if(outfilename.find('/')!=string::npos)
{
path = true;
}
if( !path )
{
fManOutFile=outfilename;
}
else
{
size_t strsize = outfilename.size();
size_t find1 = outfilename.find_last_of("/");
string dir = outfilename.substr( 0, find1);
SetOutDir(dir);
fManOutFile = outfilename.substr( find1+1, strsize-find1);
}
}