1 |
/** |
2 |
* \file TrkProcess.cpp |
3 |
* \author Elena Vannuccini |
4 |
*/ |
5 |
#include <TrkProcess.h> |
6 |
#include <iostream> |
7 |
using namespace std; |
8 |
|
9 |
TrkProcess::TrkProcess(){ |
10 |
|
11 |
idrun = 0; |
12 |
DEBUG = false; |
13 |
get1 = 0; |
14 |
get2 = 1; |
15 |
standalone = false; |
16 |
frame2 = "root"; |
17 |
frame1 = "hbook"; |
18 |
outdir = gSystem->WorkingDirectory(); |
19 |
pfolder = "/TrackerFolder"; |
20 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
21 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
22 |
|
23 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
24 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
25 |
|
26 |
file1 = ""; |
27 |
file2 = ""; |
28 |
|
29 |
}; |
30 |
|
31 |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
32 |
|
33 |
idrun = run; |
34 |
DEBUG = false; |
35 |
get1 = 0; |
36 |
get2 = 1; |
37 |
standalone = false; |
38 |
frame2 = "root"; |
39 |
frame1 = "hbook"; |
40 |
ifroot1 = false; |
41 |
ifroot2 = true; |
42 |
file1 = ""; |
43 |
if(f2->IsOpen()){ |
44 |
file2 = f2->GetPath(); |
45 |
// TString temp = file2(0,file2.Last(':')); |
46 |
// outdir = temp(0,temp.Last('/')); |
47 |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
48 |
// check if the indicated output directory exists |
49 |
FileStat_t t; |
50 |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
51 |
}else{ |
52 |
file2 = ""; |
53 |
outdir = gSystem->WorkingDirectory(); |
54 |
}; |
55 |
pfolder = "/TrackerFolder"; |
56 |
|
57 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
58 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
59 |
|
60 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
61 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
62 |
|
63 |
|
64 |
}; |
65 |
|
66 |
int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
67 |
|
68 |
for (int i=0; i< ncustom; i++){ |
69 |
|
70 |
// -----------------------------------------------------// |
71 |
if (!strcmp(vcustom[i], "-processFolder")){ |
72 |
if (++i >= ncustom) throw -3; |
73 |
pfolder = vcustom[i]; |
74 |
continue; |
75 |
} |
76 |
// -----------------------------------------------------// |
77 |
if (!strcmp(vcustom[i], "--get1")){ |
78 |
get1 = 1; |
79 |
continue; |
80 |
} |
81 |
// -----------------------------------------------------// |
82 |
if (!strcmp(vcustom[i], "--dontget2")){ |
83 |
get2 = 0; |
84 |
continue; |
85 |
} |
86 |
// -----------------------------------------------------// |
87 |
if (!strcmp(vcustom[i], "--standalone") || !strcmp(vcustom[i], "-s")){ |
88 |
standalone = true; |
89 |
continue; |
90 |
} |
91 |
// -----------------------------------------------------// |
92 |
if (!strcmp(vcustom[i], "-processFile1")){ |
93 |
if (++i >= ncustom) throw -3; |
94 |
get1 = 1; |
95 |
file1 = vcustom[i]; |
96 |
continue; |
97 |
} |
98 |
// -----------------------------------------------------// |
99 |
if (!strcmp(vcustom[i], "-frame1")){ |
100 |
if (++i >= ncustom)throw -3; |
101 |
get1 = 1; |
102 |
frame1 = vcustom[i]; |
103 |
continue; |
104 |
} |
105 |
// -----------------------------------------------------// |
106 |
if (!strcmp(vcustom[i], "-frame2")){ |
107 |
if (++i >= ncustom)throw -3; |
108 |
get2 = 1; |
109 |
frame2 = vcustom[i]; |
110 |
continue; |
111 |
} |
112 |
// -----------------------------------------------------// |
113 |
else if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
114 |
DEBUG = true; |
115 |
continue; |
116 |
} |
117 |
} |
118 |
|
119 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
120 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
121 |
else throw -201; |
122 |
|
123 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
124 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
125 |
else throw -201; |
126 |
|
127 |
if(get1){ |
128 |
TString filety; |
129 |
if ( ifroot1) filety=".root"; |
130 |
else if (!ifroot1) filety=".rz"; |
131 |
else throw -200; |
132 |
// file1 = outdir + "/"+ pfolder + "/" + file2(file2.Last('/')+1,file2.Last('.')) + ".Level1" + filety; |
133 |
// cout << p->file1 << endl; |
134 |
// TString path = gSystem->DirName(p->file1); |
135 |
// FileStat_t t; |
136 |
// // check if processFolder directory exists, and possibly create it |
137 |
// if( gSystem->GetPathInfo(path.Data(),t) ) { |
138 |
// if( gSystem->MakeDirectory(path.Data()) == -1)throw -13; |
139 |
// }; |
140 |
// // if it does, open/create teh putput file |
141 |
|
142 |
}; |
143 |
|
144 |
|
145 |
return 0; |
146 |
}; |
147 |
|
148 |
void TrkProcess::Dump(){ |
149 |
|
150 |
cout <<endl<< "Tracker process parameters: "<< endl; |
151 |
cout << " idRun " << idrun << endl; |
152 |
cout << " get1 " << get1 << endl; |
153 |
cout << " get2 " << get2 << endl; |
154 |
cout << " frame1 " << frame1 << endl; |
155 |
cout << " frame2 " << frame2 << endl; |
156 |
cout << " file1 " << file1 << endl; |
157 |
cout << " file2 " << file2 << endl; |
158 |
cout << " outdir " << outdir << endl; |
159 |
cout << " process folder " << pfolder << endl; |
160 |
cout << " standalone mode " << standalone << endl; |
161 |
cout << " debug mode " << DEBUG << endl<< endl; |
162 |
|
163 |
} |