1 |
/** |
/** |
2 |
* Header Scan |
* Header_Scan |
3 |
* Author Nagni |
* Author Nagni |
4 |
* version 1.0 |
* version 1.0 |
5 |
* |
* |
43 |
* There is no default value, without this input the program will not run |
* There is no default value, without this input the program will not run |
44 |
* TString outDir - the path where to save the output image (Default = ./) |
* TString outDir - the path where to save the output image (Default = ./) |
45 |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
46 |
|
* |
47 |
|
* |
48 |
|
* Version 1.7 |
49 |
|
* Date 16 June 2006 - Malvezzi |
50 |
|
* |
51 |
|
* Description of changes: |
52 |
|
* Implementation of the case: numebr of events <= 0. |
53 |
|
* Remove graph "grPcktId1"; see PacketScan for the same information. |
54 |
|
* Fixed bugs: for a large namber of events is not possible to have vectors, so I have subsituted graphs with histograms |
55 |
|
* or divided the graphs in more than one canvas. |
56 |
|
* |
57 |
*/ |
*/ |
58 |
|
|
59 |
|
|
60 |
|
#include <fstream> |
61 |
|
#include <math.h> |
62 |
|
#include "TLatex.h" |
63 |
|
#include "TF1.h" |
64 |
|
#include "TPaveText.h" |
65 |
|
#include "TMultiGraph.h" |
66 |
#include <sstream> |
#include <sstream> |
67 |
#include <iostream> |
#include <iostream> |
68 |
#include "TString.h" |
#include "TString.h" |
78 |
#include "EventHeader.h" |
#include "EventHeader.h" |
79 |
#include "PscuHeader.h" |
#include "PscuHeader.h" |
80 |
|
|
|
|
|
81 |
using namespace std; |
using namespace std; |
82 |
|
|
83 |
void HeaderScan(TString base, TString outDir, TString format) |
void HeaderScan(TString base, TString outDir, TString format) |
84 |
{ |
{ |
85 |
|
|
86 |
TList *list = new TList; |
//------------------- Variables initilization -------------------------// |
87 |
Int_t numkey; |
Long64_t nevents=0; |
88 |
TObject *key = new TObject; |
ULong_t lastime, firstime,obt;// offset, lastoffset, firstoffset; |
89 |
const char *name; |
double obmin=0.; |
90 |
TTree* tr = new TTree; |
double obmax=0.; |
91 |
Long64_t totevents=0, totphysevents=0; |
stringstream oss, oss1, oss2, oss3, noentries; |
|
Float_t id; |
|
|
Long64_t nevents=0; |
|
|
|
|
92 |
//------- load root file -------------- |
//------- load root file -------------- |
|
|
|
93 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
|
|
|
94 |
if (!file){ |
if (!file){ |
95 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
96 |
return; |
return; |
97 |
} |
} |
|
if (outDir == "" ) outDir = "."; |
|
|
|
|
|
list = file->GetListOfKeys(); |
|
|
|
|
|
numkey = file->GetNkeys(); |
|
|
|
|
|
pamela::EventHeader *eh=0; |
|
|
pamela::PscuHeader *ph=0; |
|
98 |
|
|
99 |
///-----to know the total number f events end of physics events----////// |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
100 |
|
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
101 |
for (Int_t i=0; i<numkey; i++){ |
|
102 |
key = list->At(i); |
pamela::EventHeader *eh = 0; |
103 |
name=(key->GetName()); |
pamela::PscuHeader *ph = 0; |
104 |
//cout<<name<<"\n"; |
|
105 |
tr = (TTree*)file->Get(name); |
PhysicsTr->SetBranchAddress("Header", &eh); |
106 |
if (tr->IsZombie()) continue; |
|
107 |
nevents = tr->GetEntries(); |
nevents = headBr->GetEntries(); |
|
totevents+=nevents; |
|
|
tr->SetBranchAddress("Header", &eh); |
|
|
for (Int_t j = 0; j < nevents; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
if(ph->GetPacketId1() == 0x10) ++totphysevents; |
|
|
} |
|
|
|
|
|
} |
|
108 |
|
|
|
const Long64_t totalevents=totevents; |
|
|
const Long64_t totalphysevents=totphysevents; |
|
|
|
|
|
///////////////////////////////////////////////// |
|
|
|
|
109 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
110 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
|
stringstream oss; |
|
|
oss.str(""); |
|
|
oss << filename.Data(); |
|
|
|
|
|
Float_t obt[totalevents], pcktId[totalevents], pcktLenght[totalphysevents], pcktCounter[totalphysevents], offset[totalevents], allCounter[totalevents]; |
|
|
Float_t obtphysevents=0; |
|
|
|
|
111 |
|
|
112 |
totphysevents=0; |
//----------- If nevents < = 0 ---------------------------------/ |
113 |
totevents=0; |
if (nevents<=0) { |
114 |
for (Int_t i=0; i<numkey; i++){ |
printf("nevents = %i \n", nevents); |
115 |
key = list->At(i); |
printf(" \n"); |
116 |
name=(char *)(key->GetName()); |
|
117 |
tr = (TTree*)file->Get(name); |
TCanvas *canv = new TCanvas("No entries", "No entries ", 400, 200); |
118 |
if (tr->IsZombie()) continue; |
canv->SetFillColor(10); |
119 |
tr->SetBranchAddress("Header", &eh); |
canv->cd(); |
120 |
nevents = tr->GetEntries(); |
|
121 |
for (Int_t j = 0; j < nevents; j++){ |
TLatex *l = new TLatex(); |
122 |
tr->GetEntry(j); |
l->SetTextAlign(12); |
123 |
ph = eh->GetPscuHeader(); |
l->SetTextSize(0.15); |
124 |
obt[j+totevents]=ph->GetOrbitalTime() ; |
l->SetTextColor(2); |
125 |
pcktId[j+totevents]=ph->GetPacketId1(); |
noentries.str(""); |
126 |
offset[j+totevents]=ph->GetFileOffset(); |
noentries<< "HeaderScan_QL:"; |
127 |
if(pcktId[j+totevents]==16){ |
l->DrawLatex(0.05, 0.7, noentries.str().c_str()); |
128 |
pcktLenght[totphysevents]=ph->GetPacketLenght(); |
noentries.str(""); |
129 |
pcktCounter[totphysevents]=ph->GetCounter(); |
noentries<< "No Physics entries for this files"; |
130 |
totphysevents=totphysevents+1; |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
131 |
} |
|
132 |
offset[j+totevents]=ph->GetFileOffset(); |
if (outDir == "./") { |
133 |
allCounter[j+totevents]= ph->GetCounter(); |
oss.str(""); |
134 |
} |
oss << filename.Data() << "_HeaderScan_QL." << format.Data(); |
135 |
totevents=totevents+nevents; |
} else { |
136 |
} |
oss.str(""); |
137 |
|
oss << outDir.Data() << filename.Data() << "_HeaderScan_QL." << format.Data(); |
138 |
|
} |
|
Float_t mintime=obt[0], maxtime=obt[0], minlen=pcktLenght[0], maxlen=pcktLenght[0], mincount=pcktCounter[0], maxcount=pcktCounter[0]; |
|
|
|
|
139 |
|
|
140 |
for (Int_t t=0; t<totalevents; t++){ |
canv->Update(); |
141 |
if(obt[t]<mintime) mintime=obt[t]; |
canv->SaveAs(oss.str().c_str()); |
142 |
if(obt[t]>maxtime) maxtime=obt[t]; |
|
143 |
} |
return; |
|
for (Int_t t=0; t<totalphysevents; t++){ |
|
|
if(pcktLenght[t]<=minlen) minlen=pcktLenght[t]; |
|
|
if(pcktLenght[t]>=maxlen) maxlen=pcktLenght[t]; |
|
|
if(pcktCounter[t]<=mincount) mincount=pcktCounter[t]; |
|
|
if(pcktCounter[t]>=maxcount) maxcount=pcktCounter[t]; |
|
144 |
} |
} |
145 |
|
|
146 |
|
//-------------- to know the max and min OBT ----------------------------// |
147 |
|
for (Int_t i = 0; i < nevents; i++){ |
148 |
|
headBr->GetEntry(i); |
149 |
|
ph = eh->GetPscuHeader(); |
150 |
|
obt = ph->GetOrbitalTime(); |
151 |
|
//if(obt <= firstime) firstime=obt; |
152 |
|
if(obt >= lastime) lastime=obt; |
153 |
|
} |
154 |
|
|
155 |
|
//------------------------ First histogram -----------------------------------// |
156 |
|
headBr->GetEntry(0); |
157 |
|
ph = eh->GetPscuHeader(); |
158 |
|
firstime = ph->GetOrbitalTime(); |
159 |
|
obmin=firstime; |
160 |
|
obmax=lastime; |
161 |
|
|
162 |
Float_t nbintime = (maxtime-mintime)/1000; |
oss1.str(""); |
163 |
Float_t nbinlen = (maxlen-minlen)/100; |
oss1 <<"File name= "<< filename.Data() <<". Start time= " << obmin << ", end time= "<< obmax <<" ms"<<". Physics Packet per minute"; |
164 |
Float_t nbincount = (maxcount-mincount)/100; |
Int_t nbin = (lastime-firstime)/60000; |
165 |
|
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
166 |
|
|
167 |
///---------------------------TO GRAPH---------------------------------------------/// |
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
168 |
|
const Int_t size = 10000; |
169 |
|
Int_t ev=0; |
170 |
|
Double_t PscuCounter[size], FileOffset[size], tempo[size], PcktLenght[size]; |
171 |
|
Int_t m=0; |
172 |
|
Int_t pag= (nevents/10000)+1; |
173 |
|
|
174 |
|
TMultiGraph *mg1 = new TMultiGraph(); |
175 |
|
oss1.str(""); |
176 |
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
177 |
|
mg1->SetTitle(oss1.str().c_str()); |
178 |
|
|
179 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
180 |
|
oss1.str(""); |
181 |
|
oss1 << filename.Data() <<": OBT vs FileOffset."; |
182 |
|
mg2->SetTitle(oss1.str().c_str()); |
183 |
|
|
184 |
|
TMultiGraph *mg3 = new TMultiGraph(); |
185 |
|
oss2.str(""); |
186 |
|
oss2 << filename.Data() <<": Lenght of Physic packets"; |
187 |
|
mg3->SetTitle(oss2.str().c_str()); |
188 |
|
|
189 |
|
TMultiGraph *mg4 = new TMultiGraph(); |
190 |
|
oss3.str(""); |
191 |
|
oss3 << filename.Data() <<": Physics Counter"; |
192 |
|
mg4->SetTitle(oss3.str().c_str()); |
193 |
|
|
194 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
195 |
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
finalCanv1->Divide(1,3); |
|
finalCanv1->Divide(3); |
|
196 |
finalCanv1->SetFillColor(10); |
finalCanv1->SetFillColor(10); |
197 |
finalCanv2->Divide(2); |
|
198 |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
199 |
|
finalCanv2->Divide(1,2); |
200 |
finalCanv2->SetFillColor(10); |
finalCanv2->SetFillColor(10); |
201 |
|
|
202 |
|
/////ciclo sulle pagine//////////////////// |
203 |
TGraph *grPcktId1 = new TGraph(totalevents, obt, pcktId); |
for (Int_t interval=0; interval<pag; interval++){ |
|
TGraph *grPcktLenght = new TGraph(totalevents, obt, pcktLenght); |
|
|
TGraph *grPcktCounter = new TGraph(totalevents, obt, pcktCounter); |
|
|
TGraph *grFileOffset = new TGraph(totalevents, offset, allCounter); |
|
|
|
|
|
TGaxis::SetMaxDigits(3); |
|
204 |
|
|
205 |
//-----canvas 1-------------------------------/// |
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
206 |
finalCanv1->cd(1); |
headBr->GetEntry(ev+l); |
207 |
|
ph = eh->GetPscuHeader(); |
208 |
stringstream oss1; |
PscuCounter[l]= ph->GetCounter(); // = PcktCounter[l] |
209 |
oss1.str(""); |
FileOffset[l]=ph->GetFileOffset(); |
210 |
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
tempo[l]=ph->GetOrbitalTime(); |
211 |
|
PcktLenght[l]=ph->GetPacketLenght(); |
212 |
gStyle->SetTitleH(0.06); |
h1->Fill(ph->GetOrbitalTime()); |
213 |
grPcktId1->SetTitle(oss.str().c_str()); |
m=l; |
214 |
grPcktId1->GetXaxis()->SetTitle(oss1.str().c_str()); |
} |
215 |
grPcktId1->GetXaxis()->CenterTitle(); |
|
216 |
grPcktId1->GetXaxis()->SetLabelSize(0.03); |
TGraph *graph1= new TGraph(m, tempo, PcktLenght); |
217 |
grPcktId1->GetYaxis()->SetTitle("Packet ID"); |
graph1->SetMarkerColor(2); |
218 |
grPcktId1->GetYaxis()->CenterTitle(); |
graph1->SetMarkerSize(.5); |
219 |
grPcktId1->SetMarkerSize(4); |
graph1->SetMarkerStyle(21); |
220 |
grPcktId1->Draw("AP"); |
mg3->Add(graph1); |
221 |
|
|
222 |
|
TGraph *graph2= new TGraph(m, tempo, PscuCounter); |
223 |
finalCanv1->cd(2); |
graph2->SetMarkerColor(4); |
224 |
oss1.str(""); |
graph2->SetMarkerSize(.5); |
225 |
oss1 << "OBT (min) with t0 = " << mintime << "ms"; |
graph2->SetMarkerStyle(21); |
226 |
|
mg4->Add(graph2); |
227 |
TH1F *h1 = new TH1F ("h1", oss.str().c_str(), (int)(nbintime/60), mintime, maxtime); |
|
228 |
|
TGraph *graph3= new TGraph(m, FileOffset, PscuCounter); |
229 |
for (Int_t i=0; i<numkey; i++){ |
graph3->SetMarkerColor(3); |
230 |
key = list->At(i); |
graph3->SetMarkerSize(.5); |
231 |
name=(char *)(key->GetName()); |
graph3->SetMarkerStyle(21); |
232 |
tr = (TTree*)file->Get(name); |
mg1->Add(graph3); |
233 |
if (tr->IsZombie()) continue; |
|
234 |
tr->SetBranchAddress("Header", &eh); |
TGraph *graph4= new TGraph(m, FileOffset, tempo); |
235 |
nevents = tr->GetEntries(); |
graph4->SetMarkerColor(kBlue); |
236 |
for (Int_t j = 0; j < nevents; j++){ |
graph4->SetMarkerSize(.5); |
237 |
tr->GetEntry(j); |
graph4->SetMarkerStyle(21); |
238 |
ph = eh->GetPscuHeader(); |
mg2->Add(graph4); |
239 |
if((ph->GetPacketId1()) == 16){ |
|
240 |
obtphysevents=ph->GetOrbitalTime(); |
ev=ev+10000; |
|
h1->Fill(obtphysevents); |
|
|
} |
|
|
} |
|
241 |
} |
} |
242 |
|
//------------ First Canvas ---------------------// |
243 |
h1->SetMarkerStyle(6); |
|
244 |
h1->GetXaxis()->SetTitle(oss1.str().c_str()); |
finalCanv1->cd(1); |
245 |
|
h1->SetStats(kFALSE); |
246 |
|
h1->GetXaxis()->SetTitle("OBT (ms)"); |
247 |
h1->GetXaxis()->CenterTitle(); |
h1->GetXaxis()->CenterTitle(); |
248 |
h1->GetXaxis()->SetLabelSize(0.03); |
h1->GetXaxis()->SetLabelSize(0.04); |
249 |
h1->GetYaxis()->SetTitle("number of Physic packets"); |
h1->GetYaxis()->SetTitle("Number of events "); |
250 |
h1->GetYaxis()->CenterTitle(); |
h1->GetYaxis()->CenterTitle(); |
251 |
|
h1->GetYaxis()->SetTitleSize(0.06); |
252 |
|
h1->GetYaxis()->SetTitleOffset(0.8); |
253 |
h1->Draw(); |
h1->Draw(); |
254 |
|
|
|
|
|
|
finalCanv1->cd(3); |
|
|
oss1.str(""); |
|
|
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
|
|
|
|
|
grPcktLenght->SetTitle(oss.str().c_str()); |
|
|
grPcktLenght->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
|
grPcktLenght->GetXaxis()->CenterTitle(); |
|
|
grPcktLenght->GetXaxis()->SetLabelSize(0.03); |
|
|
grPcktLenght->GetYaxis()->SetTitle("Lenght of Physic packets (byte)"); |
|
|
grPcktLenght->GetYaxis()->CenterTitle(); |
|
|
grPcktLenght->GetYaxis()->SetLabelSize(0.03); |
|
|
grPcktLenght->SetMarkerSize(4); |
|
|
grPcktLenght->Draw("AP"); |
|
|
|
|
|
|
|
255 |
finalCanv1->cd(2); |
finalCanv1->cd(2); |
256 |
h1->Draw(); |
mg3->Draw("AP"); |
257 |
|
mg3->GetXaxis()->SetTitle("OBT (ms)"); |
258 |
finalCanv1->Update(); |
mg3->GetXaxis()->CenterTitle(); |
259 |
|
mg3->GetXaxis()->SetLabelSize(0.04); |
260 |
|
mg3->GetYaxis()->SetTitle("Lenght (byte)"); |
261 |
///---------canvas 2-----------------------------// |
mg3->GetYaxis()->CenterTitle(); |
262 |
finalCanv2->cd(1); |
mg3->GetYaxis()->SetLabelSize(0.04); |
263 |
|
mg3->GetYaxis()->SetTitleSize(0.06); |
264 |
grPcktCounter->SetTitle(oss.str().c_str()); |
mg3->GetYaxis()->SetTitleOffset(0.8); |
265 |
grPcktCounter->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
266 |
grPcktCounter->GetXaxis()->SetTitleSize(0.04); |
|
267 |
grPcktCounter->GetXaxis()->CenterTitle(); |
finalCanv1->cd(3); |
268 |
grPcktCounter->GetXaxis()->SetLabelSize(0.03); |
mg4->Draw("AP"); |
269 |
grPcktCounter->GetYaxis()->SetTitle("PacketCounter of Physic packets"); |
mg4->GetXaxis()->SetTitle("OBT (ms)"); |
270 |
grPcktCounter->GetYaxis()->SetTitleSize(0.04); |
mg4->GetXaxis()->SetTitleSize(0.05); |
271 |
grPcktCounter->GetYaxis()->CenterTitle(); |
mg4->GetXaxis()->CenterTitle(); |
272 |
grPcktCounter->GetYaxis()->SetLabelSize(0.03); |
mg4->GetXaxis()->SetLabelSize(0.04); |
273 |
grPcktCounter->SetMarkerSize(4); |
mg4->GetYaxis()->SetTitle("Counter"); |
274 |
grPcktCounter->SetMinimum(mincount); |
mg4->GetYaxis()->SetTitleSize(0.05); |
275 |
grPcktCounter->SetMaximum(maxcount); |
mg4->GetYaxis()->CenterTitle(); |
276 |
grPcktCounter->Draw("AP"); |
mg4->GetYaxis()->SetLabelSize(0.04); |
277 |
|
mg4->GetYaxis()->SetTitleSize(0.06); |
278 |
finalCanv2->cd(2); |
mg4->GetYaxis()->SetTitleOffset(0.8); |
279 |
|
|
|
grFileOffset->SetTitle(oss.str().c_str()); |
|
|
grFileOffset->GetXaxis()->SetTitle("File Offset"); |
|
|
grFileOffset->GetXaxis()->CenterTitle(); |
|
|
grFileOffset->GetXaxis()->SetTitleSize(0.04); |
|
|
grFileOffset->GetXaxis()->SetLabelSize(0.03); |
|
|
grFileOffset->GetYaxis()->SetTitle("Packet counter"); |
|
|
grFileOffset->GetYaxis()->CenterTitle(); |
|
|
grFileOffset->GetYaxis()->SetTitleSize(0.04); |
|
|
grFileOffset->GetYaxis()->SetLabelSize(0.03); |
|
|
grFileOffset->SetMarkerSize(4); |
|
|
grFileOffset->Draw("AP"); |
|
|
|
|
280 |
finalCanv1->Update(); |
finalCanv1->Update(); |
281 |
|
|
|
|
|
|
//-------to save---------------------------/// |
|
282 |
oss.str(""); |
oss.str(""); |
|
oss1.str(""); |
|
|
|
|
283 |
oss << outDir.Data() << filename.Data(); |
oss << outDir.Data() << filename.Data(); |
|
oss1 << outDir.Data() << filename.Data(); |
|
|
|
|
284 |
oss << "_HeaderScan_1." << format.Data(); |
oss << "_HeaderScan_1." << format.Data(); |
|
oss1 << "_HeaderScan_2." << format.Data(); |
|
|
|
|
285 |
finalCanv1->SaveAs(oss.str().c_str()); |
finalCanv1->SaveAs(oss.str().c_str()); |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
//------------ Second Canvas ---------------------// |
290 |
|
finalCanv2->cd(1); |
291 |
|
mg1->Draw("AP"); |
292 |
|
mg1->GetXaxis()->SetTitle("File Offset"); |
293 |
|
mg1->GetXaxis()->CenterTitle(); |
294 |
|
mg1->GetXaxis()->SetTitleSize(0.05); |
295 |
|
mg1->GetXaxis()->SetLabelSize(0.04); |
296 |
|
mg1->GetYaxis()->SetTitle("Counter"); |
297 |
|
mg1->GetYaxis()->CenterTitle(); |
298 |
|
mg1->GetYaxis()->SetTitleSize(0.05); |
299 |
|
mg1->GetYaxis()->SetLabelSize(0.04); |
300 |
|
|
301 |
|
finalCanv2->cd(2); |
302 |
|
mg2->Draw("AP"); |
303 |
|
mg2->GetXaxis()->SetTitle("File Offset"); |
304 |
|
mg2->GetXaxis()->CenterTitle(); |
305 |
|
mg2->GetXaxis()->SetTitleSize(0.05); |
306 |
|
mg2->GetXaxis()->SetLabelSize(0.04); |
307 |
|
mg2->GetYaxis()->SetTitle("OBT"); |
308 |
|
mg2->GetYaxis()->CenterTitle(); |
309 |
|
mg2->GetYaxis()->SetTitleSize(0.05); |
310 |
|
mg2->GetYaxis()->SetLabelSize(0.04); |
311 |
|
|
312 |
|
finalCanv2->Update(); |
313 |
|
|
314 |
|
oss1.str(""); |
315 |
|
oss1 << outDir.Data() << filename.Data(); |
316 |
|
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
317 |
|
|
318 |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
319 |
|
|
320 |
file->Close(); |
file->Close(); |
321 |
|
|
322 |
} |
} |
323 |
|
|
|
|
|
|
|
|
324 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
325 |
TString path; |
TString path; |
326 |
TString outDir = "./"; |
TString outDir = "./"; |
327 |
TString format = "jpg"; |
TString format = "jpg"; |
|
|
|
328 |
if (argc < 2){ |
if (argc < 2){ |
329 |
printf("You have to insert at least the file to analyze \n"); |
printf("You have to insert at least the file to analyze \n"); |
330 |
printf("Try '--help' for more information. \n"); |
printf("Try '--help' for more information. \n"); |
331 |
exit(1); |
exit(1); |
332 |
} |
} |
|
|
|
333 |
if (!strcmp(argv[1], "--help")){ |
if (!strcmp(argv[1], "--help")){ |
334 |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
335 |
printf( "\t --help Print this help and exit \n"); |
printf( "\t --help Print this help and exit \n"); |
337 |
printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n"); |
printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n"); |
338 |
exit(1); |
exit(1); |
339 |
} |
} |
|
|
|
|
|
|
340 |
path=argv[1]; |
path=argv[1]; |
341 |
|
for (int i = 2; i < argc; i++){ |
|
for (int i = 2; i < argc; i++){ |
|
|
|
|
342 |
if (!strcmp(argv[i], "-outDir")){ |
if (!strcmp(argv[i], "-outDir")){ |
343 |
if (++i >= argc){ |
if (++i >= argc){ |
344 |
printf( "-outDir needs arguments. \n"); |
printf( "-outDir needs arguments. \n"); |
349 |
outDir = argv[i]; |
outDir = argv[i]; |
350 |
continue; |
continue; |
351 |
} |
} |
352 |
} |
} |
|
|
|
353 |
if (!strcmp(argv[i], "-format")){ |
if (!strcmp(argv[i], "-format")){ |
354 |
if (++i >= argc){ |
if (++i >= argc){ |
355 |
printf( "-format needs arguments. \n"); |
printf( "-format needs arguments. \n"); |
361 |
continue; |
continue; |
362 |
} |
} |
363 |
} |
} |
|
|
|
|
|
|
364 |
} |
} |
|
|
|
365 |
HeaderScan(argv[1], outDir, format); |
HeaderScan(argv[1], outDir, format); |
|
|
|
366 |
} |
} |