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(); |
|
98 |
|
|
99 |
pamela::EventHeader *eh=0; |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
100 |
pamela::PscuHeader *ph=0; |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
101 |
|
|
102 |
///-----to know the total number f events end of physics events----////// |
pamela::EventHeader *eh = 0; |
103 |
|
pamela::PscuHeader *ph = 0; |
104 |
for (Int_t i=0; i<numkey; i++){ |
|
105 |
key = list->At(i); |
PhysicsTr->SetBranchAddress("Header", &eh); |
106 |
name=(key->GetName()); |
|
107 |
//cout<<name<<"\n"; |
nevents = headBr->GetEntries(); |
|
tr = (TTree*)file->Get(name); |
|
|
if (tr->IsZombie()) continue; |
|
|
nevents = tr->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(); |
111 |
stringstream oss; |
|
112 |
oss.str(""); |
//----------- If nevents < = 0 ---------------------------------/ |
113 |
oss << filename.Data(); |
if (nevents<=0) { |
114 |
|
printf("nevents = %i \n", nevents); |
115 |
Float_t obt[totalevents], pcktId[totalevents], pcktLenght[totalphysevents], pcktCounter[totalphysevents], offset[totalevents], allCounter[totalevents]; |
printf(" \n"); |
116 |
Float_t obtphysevents=0; |
|
117 |
|
TCanvas *canv = new TCanvas("No entries", "No entries ", 400, 200); |
118 |
|
canv->SetFillColor(10); |
119 |
|
canv->cd(); |
120 |
|
|
121 |
|
TLatex *l = new TLatex(); |
122 |
|
l->SetTextAlign(12); |
123 |
|
l->SetTextSize(0.15); |
124 |
|
l->SetTextColor(2); |
125 |
|
noentries.str(""); |
126 |
|
noentries<< "HeaderScan_QL:"; |
127 |
|
l->DrawLatex(0.05, 0.7, noentries.str().c_str()); |
128 |
|
noentries.str(""); |
129 |
|
noentries<< "No Physics entries for this files"; |
130 |
|
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
131 |
|
|
132 |
|
if (outDir == "./") { |
133 |
|
oss.str(""); |
134 |
|
oss << filename.Data() << "_HeaderScan_QL." << format.Data(); |
135 |
|
} else { |
136 |
|
oss.str(""); |
137 |
|
oss << outDir.Data() << filename.Data() << "_HeaderScan_QL." << format.Data(); |
138 |
|
} |
139 |
|
|
140 |
|
canv->Update(); |
141 |
|
canv->SaveAs(oss.str().c_str()); |
142 |
|
|
143 |
totphysevents=0; |
return; |
|
totevents=0; |
|
|
for (Int_t i=0; i<numkey; i++){ |
|
|
key = list->At(i); |
|
|
name=(char *)(key->GetName()); |
|
|
tr = (TTree*)file->Get(name); |
|
|
if (tr->IsZombie()) continue; |
|
|
tr->SetBranchAddress("Header", &eh); |
|
|
nevents = tr->GetEntries(); |
|
|
for (Int_t j = 0; j < nevents; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
obt[j+totevents]=ph->GetOrbitalTime() ; |
|
|
pcktId[j+totevents]=ph->GetPacketId1(); |
|
|
offset[j+totevents]=ph->GetFileOffset(); |
|
|
if(pcktId[j+totevents]==16){ |
|
|
pcktLenght[totphysevents]=ph->GetPacketLenght(); |
|
|
pcktCounter[totphysevents]=ph->GetCounter(); |
|
|
totphysevents=totphysevents+1; |
|
|
} |
|
|
offset[j+totevents]=ph->GetFileOffset(); |
|
|
allCounter[j+totevents]= ph->GetCounter(); |
|
|
} |
|
|
totevents=totevents+nevents; |
|
144 |
} |
} |
145 |
|
|
146 |
|
//-------------- to know the max and min OBT ----------------------------// |
147 |
Float_t mintime=obt[0], maxtime=obt[0], minlen=pcktLenght[0], maxlen=pcktLenght[0], mincount=pcktCounter[0], maxcount=pcktCounter[0]; |
for (Int_t i = 0; i < nevents; i++){ |
148 |
|
headBr->GetEntry(i); |
149 |
|
ph = eh->GetPscuHeader(); |
150 |
for (Int_t t=0; t<totalevents; t++){ |
obt = ph->GetOrbitalTime(); |
151 |
if(obt[t]<mintime) mintime=obt[t]; |
offset=ph->GetFileOffset(); |
152 |
if(obt[t]>maxtime) maxtime=obt[t]; |
if(obt <= firstime) firstime=obt; |
153 |
} |
if(obt >= lastime) lastime=obt; |
154 |
for (Int_t t=0; t<totalphysevents; t++){ |
} |
155 |
if(pcktLenght[t]<=minlen) minlen=pcktLenght[t]; |
|
156 |
if(pcktLenght[t]>=maxlen) maxlen=pcktLenght[t]; |
//*************************** Histograms ************************************************************// |
157 |
if(pcktCounter[t]<=mincount) mincount=pcktCounter[t]; |
//------------------------ First histogram -----------------------------------// |
158 |
if(pcktCounter[t]>=maxcount) maxcount=pcktCounter[t]; |
obmin=firstime; |
159 |
|
obmax=lastime; |
160 |
|
oss1.str(""); |
161 |
|
oss1 <<"File name= "<< filename.Data() <<". Start time= " << obmin << ", end time= "<< obmax <<" ms"<<". Physics Packet per minute"; |
162 |
|
Int_t nbin = (lastime-firstime)/60000; |
163 |
|
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
164 |
|
|
165 |
|
//------------------------ Second histogram -----------------------------------// |
166 |
|
oss2.str(""); |
167 |
|
oss2 << " Lenght of Physic packets;"; |
168 |
|
Int_t nint = (lastime-firstime); |
169 |
|
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
170 |
|
|
171 |
|
//------------------------ Third histogram -----------------------------------// |
172 |
|
oss3.str(""); |
173 |
|
oss3 << " Physics Counter"; |
174 |
|
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
175 |
|
|
176 |
|
//**************************************************************************************************// |
177 |
|
//------- fill histograms ---------// |
178 |
|
Int_t l=0; |
179 |
|
for (Int_t i = 0; i < nevents; i++){ |
180 |
|
headBr->GetEntry(i); |
181 |
|
ph = eh->GetPscuHeader(); |
182 |
|
h1->Fill(ph->GetOrbitalTime()); |
183 |
|
PcktLenght->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
184 |
|
PcktCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
185 |
} |
} |
186 |
|
|
187 |
|
//****************************** Canvases *******************************// |
188 |
Float_t nbintime = (maxtime-mintime)/1000; |
//TGaxis::SetMaxDigits(4); |
189 |
Float_t nbinlen = (maxlen-minlen)/100; |
//------------------- First Canvas --------------------------------// |
|
Float_t nbincount = (maxcount-mincount)/100; |
|
|
|
|
|
|
|
|
///---------------------------TO GRAPH---------------------------------------------/// |
|
190 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
191 |
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
finalCanv1->Divide(1,3); |
|
finalCanv1->Divide(3); |
|
192 |
finalCanv1->SetFillColor(10); |
finalCanv1->SetFillColor(10); |
|
finalCanv2->Divide(2); |
|
|
finalCanv2->SetFillColor(10); |
|
193 |
|
|
|
|
|
|
TGraph *grPcktId1 = new TGraph(totalevents, obt, pcktId); |
|
|
TGraph *grPcktLenght = new TGraph(totalevents, obt, pcktLenght); |
|
|
TGraph *grPcktCounter = new TGraph(totalevents, obt, pcktCounter); |
|
|
TGraph *grFileOffset = new TGraph(totalevents, offset, allCounter); |
|
|
|
|
|
TGaxis::SetMaxDigits(3); |
|
|
|
|
|
//-----canvas 1-------------------------------/// |
|
194 |
finalCanv1->cd(1); |
finalCanv1->cd(1); |
195 |
|
h1->SetStats(kFALSE); |
196 |
stringstream oss1; |
h1->GetXaxis()->SetTitle("OBT (ms)"); |
|
oss1.str(""); |
|
|
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
|
|
|
|
|
gStyle->SetTitleH(0.06); |
|
|
grPcktId1->SetTitle(oss.str().c_str()); |
|
|
grPcktId1->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
|
grPcktId1->GetXaxis()->CenterTitle(); |
|
|
grPcktId1->GetXaxis()->SetLabelSize(0.03); |
|
|
grPcktId1->GetYaxis()->SetTitle("Packet ID"); |
|
|
grPcktId1->GetYaxis()->CenterTitle(); |
|
|
grPcktId1->SetMarkerSize(4); |
|
|
grPcktId1->Draw("AP"); |
|
|
|
|
|
|
|
|
finalCanv1->cd(2); |
|
|
oss1.str(""); |
|
|
oss1 << "OBT (min) with t0 = " << mintime << "ms"; |
|
|
|
|
|
TH1F *h1 = new TH1F ("h1", oss.str().c_str(), (int)(nbintime/60), mintime, maxtime); |
|
|
|
|
|
for (Int_t i=0; i<numkey; i++){ |
|
|
key = list->At(i); |
|
|
name=(char *)(key->GetName()); |
|
|
tr = (TTree*)file->Get(name); |
|
|
if (tr->IsZombie()) continue; |
|
|
tr->SetBranchAddress("Header", &eh); |
|
|
nevents = tr->GetEntries(); |
|
|
for (Int_t j = 0; j < nevents; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
if((ph->GetPacketId1()) == 16){ |
|
|
obtphysevents=ph->GetOrbitalTime(); |
|
|
h1->Fill(obtphysevents); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
h1->SetMarkerStyle(6); |
|
|
h1->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
197 |
h1->GetXaxis()->CenterTitle(); |
h1->GetXaxis()->CenterTitle(); |
198 |
h1->GetXaxis()->SetLabelSize(0.03); |
h1->GetXaxis()->SetLabelSize(0.04); |
199 |
h1->GetYaxis()->SetTitle("number of Physic packets"); |
h1->GetYaxis()->SetTitle("Number of events "); |
200 |
h1->GetYaxis()->CenterTitle(); |
h1->GetYaxis()->CenterTitle(); |
201 |
|
h1->GetYaxis()->SetTitleSize(0.06); |
202 |
|
h1->GetYaxis()->SetTitleOffset(0.8); |
203 |
h1->Draw(); |
h1->Draw(); |
204 |
|
|
|
|
|
|
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"); |
|
|
|
|
|
|
|
205 |
finalCanv1->cd(2); |
finalCanv1->cd(2); |
206 |
h1->Draw(); |
PcktLenght->SetStats(kFALSE); |
207 |
|
PcktLenght->GetXaxis()->SetTitle("OBT (ms)"); |
208 |
finalCanv1->Update(); |
PcktLenght->GetXaxis()->CenterTitle(); |
209 |
|
PcktLenght->GetXaxis()->SetLabelSize(0.04); |
210 |
|
PcktLenght->GetYaxis()->SetTitle("Lenght (byte)"); |
211 |
///---------canvas 2-----------------------------// |
PcktLenght->GetYaxis()->CenterTitle(); |
212 |
finalCanv2->cd(1); |
PcktLenght->GetYaxis()->SetLabelSize(0.04); |
213 |
|
PcktLenght->GetYaxis()->SetTitleSize(0.06); |
214 |
grPcktCounter->SetTitle(oss.str().c_str()); |
PcktLenght->GetYaxis()->SetTitleOffset(0.8); |
215 |
grPcktCounter->GetXaxis()->SetTitle(oss1.str().c_str()); |
PcktLenght->SetMarkerColor(2); |
216 |
grPcktCounter->GetXaxis()->SetTitleSize(0.04); |
PcktLenght->SetMarkerSize(.5); |
217 |
grPcktCounter->GetXaxis()->CenterTitle(); |
PcktLenght->SetMarkerStyle(21); |
218 |
grPcktCounter->GetXaxis()->SetLabelSize(0.03); |
PcktLenght->Draw("9p"); |
219 |
grPcktCounter->GetYaxis()->SetTitle("PacketCounter of Physic packets"); |
|
220 |
grPcktCounter->GetYaxis()->SetTitleSize(0.04); |
finalCanv1->cd(3); |
221 |
grPcktCounter->GetYaxis()->CenterTitle(); |
PcktCounter->SetStats(kFALSE); |
222 |
grPcktCounter->GetYaxis()->SetLabelSize(0.03); |
PcktCounter->GetXaxis()->SetTitle("OBT (ms)"); |
223 |
grPcktCounter->SetMarkerSize(4); |
PcktCounter->GetXaxis()->SetTitleSize(0.05); |
224 |
grPcktCounter->SetMinimum(mincount); |
PcktCounter->GetXaxis()->CenterTitle(); |
225 |
grPcktCounter->SetMaximum(maxcount); |
PcktCounter->GetXaxis()->SetLabelSize(0.04); |
226 |
grPcktCounter->Draw("AP"); |
PcktCounter->GetYaxis()->SetTitle("Counter"); |
227 |
|
PcktCounter->GetYaxis()->SetTitleSize(0.05); |
228 |
finalCanv2->cd(2); |
PcktCounter->GetYaxis()->CenterTitle(); |
229 |
|
PcktCounter->GetYaxis()->SetLabelSize(0.04); |
230 |
grFileOffset->SetTitle(oss.str().c_str()); |
PcktCounter->GetYaxis()->SetTitleSize(0.06); |
231 |
grFileOffset->GetXaxis()->SetTitle("File Offset"); |
PcktCounter->GetYaxis()->SetTitleOffset(0.8); |
232 |
grFileOffset->GetXaxis()->CenterTitle(); |
PcktCounter->SetMarkerColor(4); |
233 |
grFileOffset->GetXaxis()->SetTitleSize(0.04); |
PcktCounter->SetMarkerSize(.5); |
234 |
grFileOffset->GetXaxis()->SetLabelSize(0.03); |
PcktCounter->SetMarkerStyle(21); |
235 |
grFileOffset->GetYaxis()->SetTitle("Packet counter"); |
PcktCounter->Draw("9p"); |
236 |
grFileOffset->GetYaxis()->CenterTitle(); |
|
|
grFileOffset->GetYaxis()->SetTitleSize(0.04); |
|
|
grFileOffset->GetYaxis()->SetLabelSize(0.03); |
|
|
grFileOffset->SetMarkerSize(4); |
|
|
grFileOffset->Draw("AP"); |
|
|
|
|
|
finalCanv1->Update(); |
|
|
|
|
|
|
|
|
//-------to save---------------------------/// |
|
237 |
oss.str(""); |
oss.str(""); |
|
oss1.str(""); |
|
|
|
|
238 |
oss << outDir.Data() << filename.Data(); |
oss << outDir.Data() << filename.Data(); |
|
oss1 << outDir.Data() << filename.Data(); |
|
|
|
|
239 |
oss << "_HeaderScan_1." << format.Data(); |
oss << "_HeaderScan_1." << format.Data(); |
|
oss1 << "_HeaderScan_2." << format.Data(); |
|
|
|
|
240 |
finalCanv1->SaveAs(oss.str().c_str()); |
finalCanv1->SaveAs(oss.str().c_str()); |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
|
|
|
|
|
|
|
|
file->Close(); |
|
|
|
|
|
} |
|
241 |
|
|
242 |
|
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
243 |
|
const Int_t size = 100000; |
244 |
|
Int_t ev=0; |
245 |
|
Double_t PscuCounter[size], FileOffset[size]; |
246 |
|
Int_t m=0; |
247 |
|
Int_t pag= (nevents/100000)+1; |
248 |
|
|
249 |
|
TMultiGraph *mg1 = new TMultiGraph(); |
250 |
|
oss1.str(""); |
251 |
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
252 |
|
mg1->SetTitle(oss1.str().c_str()); |
253 |
|
|
254 |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
255 |
|
finalCanv2->SetFillColor(10); |
256 |
|
|
257 |
|
/////ciclo sulle pagine//////////////////// |
258 |
|
for (Int_t interval=0; interval<pag; interval++){ |
259 |
|
|
260 |
|
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
261 |
|
headBr->GetEntry(ev+l); |
262 |
|
ph = eh->GetPscuHeader(); |
263 |
|
PscuCounter[l]= ph->GetCounter(); |
264 |
|
FileOffset[l]=ph->GetFileOffset(); |
265 |
|
m=l; |
266 |
|
} |
267 |
|
|
268 |
|
TGraph *graph= new TGraph(m, FileOffset, PscuCounter); |
269 |
|
graph->SetMarkerColor(3); |
270 |
|
graph->SetMarkerSize(.5); |
271 |
|
graph->SetMarkerStyle(21); |
272 |
|
mg1->Add(graph); |
273 |
|
|
274 |
|
ev=ev+100000; |
275 |
|
} |
276 |
|
finalCanv2->cd(); |
277 |
|
mg1->Draw("AP"); |
278 |
|
mg1->SetTitle(oss1.str().c_str()); |
279 |
|
mg1->GetXaxis()->SetTitle("File Offset"); |
280 |
|
mg1->GetXaxis()->CenterTitle(); |
281 |
|
mg1->GetXaxis()->SetTitleSize(0.04); |
282 |
|
mg1->GetXaxis()->SetLabelSize(0.02); |
283 |
|
mg1->GetYaxis()->SetTitle("Counter"); |
284 |
|
mg1->GetYaxis()->CenterTitle(); |
285 |
|
mg1->GetYaxis()->SetTitleSize(0.04); |
286 |
|
mg1->GetYaxis()->SetLabelSize(0.02); |
287 |
|
|
288 |
|
|
289 |
|
finalCanv2->Update(); |
290 |
|
|
291 |
|
oss1.str(""); |
292 |
|
oss1 << outDir.Data() << filename.Data(); |
293 |
|
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
294 |
|
|
295 |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
296 |
|
|
297 |
|
file->Close(); |
298 |
|
|
299 |
|
} |
300 |
|
|
301 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
302 |
TString path; |
TString path; |
303 |
TString outDir = "./"; |
TString outDir = "./"; |
304 |
TString format = "jpg"; |
TString format = "jpg"; |
|
|
|
305 |
if (argc < 2){ |
if (argc < 2){ |
306 |
printf("You have to insert at least the file to analyze \n"); |
printf("You have to insert at least the file to analyze \n"); |
307 |
printf("Try '--help' for more information. \n"); |
printf("Try '--help' for more information. \n"); |
308 |
exit(1); |
exit(1); |
309 |
} |
} |
|
|
|
310 |
if (!strcmp(argv[1], "--help")){ |
if (!strcmp(argv[1], "--help")){ |
311 |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
312 |
printf( "\t --help Print this help and exit \n"); |
printf( "\t --help Print this help and exit \n"); |
314 |
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"); |
315 |
exit(1); |
exit(1); |
316 |
} |
} |
|
|
|
|
|
|
317 |
path=argv[1]; |
path=argv[1]; |
318 |
|
for (int i = 2; i < argc; i++){ |
|
for (int i = 2; i < argc; i++){ |
|
|
|
|
319 |
if (!strcmp(argv[i], "-outDir")){ |
if (!strcmp(argv[i], "-outDir")){ |
320 |
if (++i >= argc){ |
if (++i >= argc){ |
321 |
printf( "-outDir needs arguments. \n"); |
printf( "-outDir needs arguments. \n"); |
326 |
outDir = argv[i]; |
outDir = argv[i]; |
327 |
continue; |
continue; |
328 |
} |
} |
329 |
} |
} |
|
|
|
330 |
if (!strcmp(argv[i], "-format")){ |
if (!strcmp(argv[i], "-format")){ |
331 |
if (++i >= argc){ |
if (++i >= argc){ |
332 |
printf( "-format needs arguments. \n"); |
printf( "-format needs arguments. \n"); |
338 |
continue; |
continue; |
339 |
} |
} |
340 |
} |
} |
|
|
|
|
|
|
341 |
} |
} |
|
|
|
342 |
HeaderScan(argv[1], outDir, format); |
HeaderScan(argv[1], outDir, format); |
|
|
|
343 |
} |
} |