/[PAMELA software]/quicklook/QLflightTmtc_Header/PacketScan.cpp
ViewVC logotype

Contents of /quicklook/QLflightTmtc_Header/PacketScan.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Thu Mar 8 09:53:45 2007 UTC (17 years, 8 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v3r04, v3r05, HEAD
Changes since 1.3: +11 -5 lines
fixed bug on OBT

1 /**
2 * Packet Scan
3 * author Marcelli
4 * version 1.0 - 2 February 2006
5 *
6 * Description: This script creates a Multigraph to show packetID variable (for all packets) vs. OBT with an axplicative legend
7 *
8 ** Version 1.25 - 13 January 2005
9 * Changed Int_t to Float because of variable range size
10 * (UInt_t has been excluded beacuse of uncompatibility with TGraph)
11 *
12 * version 1.3 - 22 February 2005 - Nagni
13 * For compatibility with batch mode excution:
14 * 1) Added "include <iostream>" and "using namespace std"
15 * 2) Removed gROOT->Reset()
16 *
17 * Version 1.4
18 * Date 08 March 2005 - Nagni
19 * Added "format" parameter for saving the produced image in various formats
20 * (for a complete list of types refer to TPad::SaveAs method)
21 *
22 * Version 1.5
23 * Date 09 February 2006 - Marcelli
24 * Update to work with new Yoda output
25 *
26 *
27 * Version 1.6
28 * Date 27 February 2006 - Marcelli
29 * For compilation:
30 * Added function "int main(int argc, char* argv[])"
31 *
32 * Version 1.7
33 * Date 7 March 2007 - Malvezzi
34 *
35 * Description: to read correctly the OBT changed the type of time variables from signed to unsigned
36 *
37 *
38 * Description: To show packet type recorded by PAMELA (Packet type vs. OBT)
39 *
40 * Parameters:
41 * TSTring base - the path to the root directory for the specific Pamela unpack session
42 * There is no default value, without this input the program will not run
43 * TString outDir - the path where to save the output image (Default = ./)
44 * TString format - the format which will be used fo rsave the produced images (Default = "jpg")
45 *
46 */
47
48
49 #include <stdio.h>
50 #include <string.h>
51 #include <fstream>
52 #include <sstream>
53 #include <iostream>
54 #include "TString.h"
55 #include "TFile.h"
56 #include "TGraph.h"
57 #include "TTree.h"
58 #include "TMultiGraph.h"
59 #include "TCanvas.h"
60 #include "TLegend.h"
61 #include "TObjString.h"
62 #include "EventHeader.h"
63 #include "PscuHeader.h"
64
65
66 using namespace std;
67
68 void PacketScan(TString base, TString outDir, TString format){
69
70 TFile *file = new TFile(base.Data());
71
72 if (!file){
73 printf("No such file in the directory has been found");
74 return;
75 }
76 if (outDir == "" ) outDir = ".";
77
78 TList *list=file->GetListOfKeys();
79
80 Int_t numkey = file->GetNkeys();
81
82 pamela::EventHeader *eh = 0;
83 pamela::PscuHeader *ph = 0;
84
85 ULong_t utile=0;
86 Double_t obt[1]={0};
87 Double_t id[1]={0};
88 Int_t cont[48]={0};
89 std::stringstream oss, oss1, oss2, oss3;
90
91
92 TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString();
93 filename = ((TObjString*)filename.Tokenize('.')->First())->GetString();
94 oss.str("");
95 oss << "PACKET ID - OBT: " << filename.Data();
96
97
98 TCanvas *finalCanv1 = new TCanvas("Packet_1", "PacketScan1", 1280, 1024);
99 finalCanv1->SetFillColor(10);
100 TMultiGraph *mg1 = new TMultiGraph();
101 mg1->SetTitle(oss.str().c_str());
102 TLegend *leg1b = new TLegend(0.80,0.67,0.99,0.99, "");
103
104
105 TCanvas *finalCanv2 = new TCanvas("Packet_2", "PacketScan2", 1280, 1024);
106 finalCanv2->SetFillColor(10);
107 TMultiGraph *mg2 = new TMultiGraph();
108 mg2->SetTitle(oss.str().c_str());
109 TLegend *leg2 = new TLegend(0.87,0.70,0.99,0.99, "");
110
111
112
113 TCanvas *finalCanv3 = new TCanvas("Packet_3", "PacketScan3", 1280, 1024);
114 finalCanv3->SetFillColor(10);
115 TMultiGraph *mg3 = new TMultiGraph();
116 mg3->SetTitle(oss.str().c_str());
117 TLegend *leg3 = new TLegend(0.87,0.65,0.99,0.99, "");
118
119 TObject *key = new TObject;
120 const char *name;
121 char *SoftInfo="SoftInfo";
122 for (Int_t i=0; i<numkey; i++){
123 key = list->At(i);
124 name=(char *)(key->GetName());
125 if(strcmp(name,SoftInfo)==0)continue;
126 TTree* tr = (TTree*)file->Get(name);
127 if (tr->IsZombie()) continue;
128 Long64_t nevents = tr->GetEntries();
129 const Int_t size = nevents;
130 tr->SetBranchAddress("Header", &eh);
131 for (Int_t j = 0; j < size; j++){
132 tr->GetEntry(j);
133 ph = eh->GetPscuHeader();
134 utile=ph->GetOrbitalTime();
135 obt[0]= utile;
136 id[0]=(ph->GetPacketId1());
137 Int_t type = (int)id[0];
138 switch(type){
139 //physic block
140 case 7: {
141 TGraph *graph = new TGraph(1, obt, id);
142 graph->SetMarkerColor(2);
143 graph->SetMarkerStyle(21);
144 graph->SetMarkerSize(0.6);
145 mg1->Add(graph);
146 if (cont[0]==0) leg1b->AddEntry(graph,"PhysEndRun (0x07)","p");
147 cont[0]++;
148 break;
149 }
150 case 16:{
151 TGraph *graph = new TGraph(1, obt, id);
152 graph->SetMarkerColor(2);
153 graph->SetMarkerStyle(21);
154 graph->SetMarkerSize(0.5);
155 mg1->Add(graph);
156 if (cont[1]==0) leg1b->AddEntry(graph,"Physics (0x10)","p");
157 cont[1]++;
158 break;
159 }
160 case 32:{
161 TGraph *graph = new TGraph(1, obt, id);
162 graph->SetMarkerColor(4);
163 graph->SetMarkerStyle(21);
164 graph->SetMarkerSize(0.9);
165 mg1->Add(graph);
166 if (cont[2]==0) leg1b->AddEntry(graph,"RunHeader/Trailer (0x20/21)","p");
167 cont[2]++;
168 break;
169 }
170 case 33:{
171 TGraph *graph = new TGraph(1, obt, id);
172 graph->SetMarkerColor(4);
173 graph->SetMarkerStyle(21);
174 graph->SetMarkerSize(0.9);
175 mg1->Add(graph);
176 if (cont[2]==0) leg1b->AddEntry(graph,"RunHeader/Trailer (0x20/21)","p");
177 cont[2]++;
178 break;
179 }
180 //calibration block
181 case 8:{
182 TGraph *graph = new TGraph(1, obt, id);
183 graph->SetMarkerColor(2);
184 graph->SetMarkerStyle(23);
185 graph->SetMarkerSize(1.2);
186 mg1->Add(graph);
187 if (cont[23]==0) leg1b->AddEntry(graph,"CalibCalPulse1 (0x08)","p");
188 cont[23]++;
189 break;
190 }
191 case 9:{
192 TGraph *graph = new TGraph(1, obt, id);
193 graph->SetMarkerColor(3);
194 graph->SetMarkerStyle(23);
195 graph->SetMarkerSize(1.2);
196 mg1->Add(graph);
197 if (cont[24]==0) leg1b->AddEntry(graph,"CalibCalPulse2 (0x09)","p");
198 cont[24]++;
199 break;
200 }
201 case 17:{
202 TGraph *graph = new TGraph(1, obt, id);
203 graph->SetMarkerColor(4);
204 graph->SetMarkerStyle(23);
205 graph->SetMarkerSize(1.2);
206 mg1->Add(graph);
207 if (cont[25]==0) leg1b->AddEntry(graph,"CalibTrkBoth (0x11)","p");
208 cont[25]++;
209 break;
210 }
211 case 18:{
212 TGraph *graph = new TGraph(1, obt, id);
213 graph->SetMarkerColor(5);
214 graph->SetMarkerStyle(23);
215 graph->SetMarkerSize(1.2);
216 mg1->Add(graph);
217 if (cont[26]==0) leg1b->AddEntry(graph,"CalibTrk1 (0x12)","p");
218 cont[26]++;
219 break;
220 }
221 case 19:{
222 TGraph *graph = new TGraph(1, obt, id);
223 graph->SetMarkerColor(6);
224 graph->SetMarkerStyle(23);
225 graph->SetMarkerSize(1.2);
226 mg1->Add(graph);
227 if (cont[27]==0) leg1b->AddEntry(graph,"CalibTrk2 (0x13)","p");
228 cont[27]++;
229 break;
230 }
231 case 29:{
232 TGraph *graph = new TGraph(1, obt, id);
233 graph->SetMarkerColor(30);
234 graph->SetMarkerStyle(23);
235 graph->SetMarkerSize(1.2);
236 mg1->Add(graph);
237 if (cont[28]==0) leg1b->AddEntry(graph,"Calib_Cal (0x1d)","p");
238 cont[28]++;
239 break;
240 }
241 case 22:{
242 TGraph *graph = new TGraph(1, obt, id);
243 graph->SetMarkerColor(9);
244 graph->SetMarkerStyle(23);
245 graph->SetMarkerSize(1.2);
246 mg1->Add(graph);
247 if (cont[29]==0) leg1b->AddEntry(graph,"CalibTof (0x16)","p");
248 cont[29]++;
249 break;
250 }
251 case 23:{
252 TGraph *graph = new TGraph(1, obt, id);
253 graph->SetMarkerColor(7);
254 graph->SetMarkerStyle(23);
255 graph->SetMarkerSize(1.2);
256 mg1->Add(graph);
257 if (cont[30]==0) leg1b->AddEntry(graph,"CalibS4 (0x17)","p");
258 cont[30]++;
259 break;
260 }
261 case 24:{
262 TGraph *graph = new TGraph(1, obt, id);
263 graph->SetMarkerColor(49);
264 graph->SetMarkerStyle(23);
265 graph->SetMarkerSize(1.2);
266 mg1->Add(graph);
267 if (cont[31]==0) leg1b->AddEntry(graph,"CalibCalPed (0x18)","p");
268 cont[31]++;
269 break;
270 }
271 case 25:{
272 TGraph *graph = new TGraph(1,obt,id);
273 graph->SetMarkerColor(33);
274 graph->SetMarkerStyle(23);
275 graph->SetMarkerSize(1.2);
276 mg1->Add(graph);
277 if (cont[32]==0) leg1b->AddEntry(graph,"Calib1_Ac1 (0x19)","p");
278 cont[32]++;
279 break;
280 }
281 case 26:{
282 TGraph *graph = new TGraph(1, obt, id);
283 graph->SetMarkerColor(21);
284 graph->SetMarkerStyle(23);
285 graph->SetMarkerSize(1.2);
286 mg1->Add(graph);
287 if (cont[33]==0) leg1b->AddEntry(graph,"Calib2_Ac1 (0x1a)","p");
288 cont[33]++;
289 break;
290 }
291 case 27:{
292 TGraph *graph = new TGraph(1, obt, id);
293 graph->SetMarkerColor(16);
294 graph->SetMarkerStyle(23);
295 graph->SetMarkerSize(1.2);
296 mg1->Add(graph);
297 if (cont[34]==0) leg1b->AddEntry(graph,"Calib1_Ac2 (0x1b)","p");
298 cont[34]++;
299 break;
300 }
301 case 28:{
302 TGraph *graph = new TGraph(1, obt, id);
303 graph->SetMarkerColor(37);
304 graph->SetMarkerStyle(23);
305 graph->SetMarkerSize(1.2);
306 mg1->Add(graph);
307 if (cont[35]==0) leg1b->AddEntry(graph,"Calib2_Ac2 (0x1c)","p");
308 cont[35]++;
309 break;
310 }
311 case 34:{
312 TGraph *graph = new TGraph(1, obt, id);
313 graph->SetMarkerColor(41);
314 graph->SetMarkerStyle(23);
315 graph->SetMarkerSize(1.2);
316 mg1->Add(graph);
317 if (cont[36]==0) leg1b->AddEntry(graph,"CalibHeader/Trailer (0x22/23)","p");
318 cont[36]++;
319 break;
320 }
321 case 35:{
322 TGraph *graph = new TGraph(1, obt, id);
323 graph->SetMarkerColor(41);
324 graph->SetMarkerStyle(23);
325 graph->SetMarkerSize(1.2);
326 mg1->Add(graph);
327 if (cont[36]==0) leg1b->AddEntry(graph,"CalibHeader/Trailer (0x22/23)","p");
328 cont[36]++;
329 break;
330 }
331 //initialization block
332 case 36:{
333 TGraph *graph = new TGraph(1, obt, id);
334 graph->SetMarkerColor(20);
335 graph->SetMarkerStyle(22);
336 graph->SetMarkerSize(1.2);
337 mg1->Add(graph);
338 if (cont[4]==0) leg1b->AddEntry(graph,"InitHeader/Trailer (0x24/25)","p");
339 cont[4]++;
340 break;
341 }
342 case 37:{
343 TGraph *graph = new TGraph(1, obt, id);
344 graph->SetMarkerColor(20);
345 graph->SetMarkerStyle(22);
346 graph->SetMarkerSize(1.2);
347 mg1->Add(graph);
348 if (cont[4]==0) leg1b->AddEntry(graph,"InitHeader/Trailer (0x24/25)","p");
349 cont[4]++;
350 break;
351 }
352 case 48:{
353 TGraph *graph = new TGraph(1, obt, id);
354 graph->SetMarkerColor(3);
355 graph->SetMarkerStyle(21);
356 graph->SetMarkerSize(0.9);
357 mg2->Add(graph);
358 if (cont[38]==0) leg2->AddEntry(graph,"EventTrk (0x30)","p");
359 cont[38]++;
360 break;
361 }
362 //test block
363 case 64:{
364 TGraph *graph = new TGraph(1, obt, id);
365 graph->SetMarkerColor(2);
366 graph->SetMarkerStyle(22);
367 graph->SetMarkerSize(0.9);
368 mg2->Add(graph);
369 if (cont[39]==0) leg2->AddEntry(graph,"Test_trk (0x40)","p");
370 cont[39]++;
371 break;
372 }
373 case 65:{
374 TGraph *graph = new TGraph(1, obt, id);
375 graph->SetMarkerColor(3);
376 graph->SetMarkerStyle(22);
377 graph->SetMarkerSize(0.9);
378 mg2->Add(graph);
379 if (cont[40]==0) leg2->AddEntry(graph,"Test_Tof (0x41)","p");
380 cont[40]++;
381 break;
382 }
383 //Log block
384 case 80:{
385 TGraph *graph = new TGraph(1, obt, id);
386 graph->SetMarkerColor(3);
387 graph->SetMarkerStyle(21);
388 graph->SetMarkerSize(0.9);
389 mg2->Add(graph);
390 if (cont[41]==0) leg2->AddEntry(graph,"Log (0x50)","p");
391 cont[41]++;
392 break;
393 }
394 //Arrdump-Vardump-Tabdump block
395 case 81:{
396 TGraph *graph = new TGraph(1, obt, id);
397 graph->SetMarkerColor(2);
398 graph->SetMarkerStyle(23);
399 graph->SetMarkerSize(0.9);
400 mg2->Add(graph);
401 if (cont[42]==0) leg2->AddEntry(graph,"VarDump (0X51)","p");
402 cont[42]++;
403 break;
404 }
405 case 82:{
406 TGraph *graph = new TGraph(1, obt, id);
407 graph->SetMarkerColor(3);
408 graph->SetMarkerStyle(23);
409 graph->SetMarkerSize(0.9);
410 mg2->Add(graph);
411 if (cont[43]==0) leg2->AddEntry(graph,"ArrDump (x52)","p");
412 cont[43]++;
413 break;
414 }
415 case 83:{
416 TGraph *graph = new TGraph(1, obt, id);
417 graph->SetMarkerColor(4);
418 graph->SetMarkerStyle(23);
419 graph->SetMarkerSize(0.9);
420 mg2->Add(graph);
421 if (cont[44]==0) leg2->AddEntry(graph,"TabDump (0x53)","p");
422 cont[44]++;
423 break;
424 }
425 //Tmtc Block
426 case 84:{
427 TGraph *graph = new TGraph(1, obt, id);
428 graph->SetMarkerColor(2);
429 graph->SetMarkerStyle(21);
430 graph->SetMarkerSize(0.9);
431 mg2->Add(graph);
432 if (cont[45]==0) leg2->AddEntry(graph,"Tmtc (0x54)","p");
433 cont[45]++;
434 break;
435 }
436 //Mcmd Block
437 case 85:{
438 TGraph *graph = new TGraph(1, obt, id);
439 graph->SetMarkerColor(4);
440 graph->SetMarkerStyle(21);
441 graph->SetMarkerSize(0.9);
442 mg2->Add(graph);
443 if (cont[46]==0) leg2->AddEntry(graph,"Mcmd (0x55)","p");
444 cont[46]++;
445 break;
446 }
447 case 96:{
448 TGraph *graph = new TGraph(1, obt, id);
449 graph->SetMarkerColor(20);
450 graph->SetMarkerStyle(21);
451 graph->SetMarkerSize(0.9);
452 mg2->Add(graph);
453 if (cont[22]==0) leg2->AddEntry(graph,"ForceFECmd (0x60)","p");
454 cont[22]++;
455 break;
456 }
457 case 112:{
458 TGraph *graph = new TGraph(1, obt, id);
459 graph->SetMarkerColor(1);
460 graph->SetMarkerStyle(22);
461 graph->SetMarkerSize(0.9);
462 mg3->Add(graph);
463 if (cont[6]==0) leg3->AddEntry(graph,"Ac1Init (0x70)","p");
464 cont[6]++;
465 break;
466 }
467 case 113:{
468 TGraph *graph = new TGraph(1, obt, id);
469 graph->SetMarkerColor(2);
470 graph->SetMarkerStyle(22);
471 graph->SetMarkerSize(0.9);
472 mg3->Add(graph);
473 if (cont[7]==0) leg3->AddEntry(graph,"CalInit (0x71)","p");
474 cont[7]++;
475 break;
476 }
477 case 114:{
478 TGraph *graph = new TGraph(1, obt, id);
479 graph->SetMarkerColor(3);
480 graph->SetMarkerStyle(22);
481 graph->SetMarkerSize(0.9);
482 mg3->Add(graph);
483 if (cont[8]==0) leg3->AddEntry(graph,"TrkInit (0x72)","p");
484 cont[8]++;
485 break;
486 }
487 case 115:{
488 TGraph *graph = new TGraph(1, obt, id);
489 graph->SetMarkerColor(4);
490 graph->SetMarkerStyle(22);
491 graph->SetMarkerSize(0.9);
492 mg3->Add(graph);
493 if (cont[9]==0) leg3->AddEntry(graph,"TofInit (0x73)","p");
494 cont[9]++;
495 break;
496 }
497 case 116:{
498 TGraph *graph = new TGraph(1, obt, id);
499 graph->SetMarkerColor(5);
500 graph->SetMarkerStyle(22);
501 graph->SetMarkerSize(0.9);
502 mg3->Add(graph);
503 if (cont[10]==0) leg3->AddEntry(graph,"TrgInit (0x74)","p");
504 cont[10]++;
505 break;
506 }
507 case 117:{
508 TGraph *graph = new TGraph(1, obt, id);
509 graph->SetMarkerColor(6);
510 graph->SetMarkerStyle(22);
511 graph->SetMarkerSize(0.9);
512 mg3->Add(graph);
513 if (cont[11]==0) leg3->AddEntry(graph,"NdInit (0x75)","p");
514 cont[11]++;
515 break;
516 }
517 case 118:{
518 TGraph *graph = new TGraph(1, obt, id);
519 graph->SetMarkerColor(7);
520 graph->SetMarkerStyle(22);
521 graph->SetMarkerSize(0.9);
522 mg3->Add(graph);
523 if (cont[12]==0) leg3->AddEntry(graph,"S4Init (0x76)","p");
524 cont[12]++;
525 break;
526 }
527 case 119:{
528 TGraph *graph = new TGraph(1, obt, id);
529 graph->SetMarkerColor(32);
530 graph->SetMarkerStyle(22);
531 graph->SetMarkerSize(0.9);
532 mg3->Add(graph);
533 if (cont[13]==0) leg3->AddEntry(graph,"Ac2Init (0x77)","p");
534 cont[13]++;
535 break;
536 }
537 //Alarm block
538 case 129:{
539 TGraph *graph = new TGraph(1, obt, id);
540 graph->SetMarkerColor(1);
541 graph->SetMarkerStyle(21);
542 graph->SetMarkerSize(0.7);
543 mg3->Add(graph);
544 if (cont[14]==0) leg3->AddEntry(graph,"CalAlarm (0x81)","p");
545 cont[14]++;
546 break;
547 }
548 case 130:{
549 TGraph *graph = new TGraph(1, obt, id);
550 graph->SetMarkerColor(42);
551 graph->SetMarkerStyle(21);
552 graph->SetMarkerSize(0.7);
553 mg3->Add(graph);
554 if (cont[15]==0) leg3->AddEntry(graph,"Ac1Alarm (0x82)","p");
555 cont[15]++;
556 break;
557 }
558 case 131:{
559 TGraph *graph = new TGraph(1, obt, id);
560 graph->SetMarkerColor(3);
561 graph->SetMarkerStyle(21);
562 graph->SetMarkerSize(0.7);
563 mg3->Add(graph);
564 if (cont[16]==0) leg3->AddEntry(graph,"TrkAlarm (0x83)","p");
565 cont[16]++;
566 break;
567 }
568 case 132:{
569 TGraph *graph = new TGraph(1, obt, id);
570 graph->SetMarkerColor(4);
571 graph->SetMarkerStyle(21);
572 graph->SetMarkerSize(0.7);
573 mg3->Add(graph);
574 if (cont[17]==0) leg3->AddEntry(graph,"TrgAlarm (0x84)","p");
575 cont[17]++;
576 break;
577 }
578 case 133:{
579 TGraph *graph = new TGraph(1, obt, id);
580 graph->SetMarkerColor(5);
581 graph->SetMarkerStyle(21);
582 graph->SetMarkerSize(0.7);
583 mg3->Add(graph);
584 if (cont[18]==0) leg3->AddEntry(graph,"TofAlarm (0x85)","p");
585 cont[18]++;
586 break;
587 }
588 case 134:{
589 TGraph *graph = new TGraph(1, obt, id);
590 graph->SetMarkerColor(6);
591 graph->SetMarkerStyle(21);
592 graph->SetMarkerSize(0.7);
593 mg3->Add(graph);
594 if (cont[19]==0) leg3->AddEntry(graph,"S4Alarm (0x86)","p");
595 cont[19]++;
596 break;
597 }
598 case 136:{
599 TGraph *graph = new TGraph(1, obt, id);
600 graph->SetMarkerColor(7);
601 graph->SetMarkerStyle(21);
602 graph->SetMarkerSize(0.7);
603 mg3->Add(graph);
604 if (cont[20]==0) leg3->AddEntry(graph,"Ac2Alarm (0x88)","p");
605 cont[20]++;
606 break;
607 }
608 /*case 137:{
609 TGraph *graph = new TGraph(1, obt, id);
610 graph->SetMarkerColor(32);
611 graph->SetMarkerStyle(21);
612 graph->SetMarkerSize(1.3);
613 mg3->Add(graph);
614 if (cont[21]==0) leg3->AddEntry(graph,"ac2_alarm (137=0x89)","p");
615 cont[21]++;
616 break;
617 }
618 case 138:{
619 TGraph *graph = new TGraph(1, obt, id);
620 graph->SetMarkerColor(20);
621 graph->SetMarkerStyle(21);
622 graph->SetMarkerSize(1.3);
623 mg3->Add(graph);
624 if (cont[22]==0) leg3->AddEntry(graph,"s4_adc_ac_2 (138=0x8a)","p");
625 cont[22]++;
626 break;
627 }*/
628 case 161:{
629 TGraph *graph = new TGraph(1, obt, id);
630 graph->SetMarkerColor(2);
631 graph->SetMarkerStyle(3);
632 graph->SetMarkerSize(1.1);
633 mg3->Add(graph);
634 if (cont[3]==0) leg3->AddEntry(graph,"TsbT (0xA1)","p");
635 cont[3]++;
636 break;
637 }
638 case 171:{
639 TGraph *graph = new TGraph(1, obt, id);
640 graph->SetMarkerColor(4);
641 graph->SetMarkerStyle(3);
642 graph->SetMarkerSize(1.1);
643 mg3->Add(graph);
644 if (cont[5]==0) leg3->AddEntry(graph,"TsbB (0xAB)","p");
645 cont[5]++;
646 break;
647 }
648 }
649
650 }
651 }
652
653
654 //*******************************TO DRAW AND SAVE*****************************************************///
655
656
657 finalCanv1->cd();
658 mg1->SetMinimum(0);
659 mg1->SetMaximum(55);
660 mg1->Draw("AP");
661 mg1->GetXaxis()->SetTitle("OBT (ms)");
662 mg1->GetXaxis()->CenterTitle();
663 mg1->GetYaxis()->SetTitle("Packet ID");
664 mg1->GetYaxis()->CenterTitle();
665 leg1b->Draw();
666 oss1.str("");
667 oss1 << outDir.Data() << filename.Data() << "_PacketScan_1." << format.Data();
668 finalCanv1->Update();
669 finalCanv1->SaveAs(oss1.str().c_str());
670
671
672 finalCanv2->cd();
673 mg2->SetMinimum(60);
674 mg2->SetMaximum(100);
675 mg2->Draw("AP");
676 mg2->GetXaxis()->SetTitle("OBT (ms)");
677 mg2->GetXaxis()->CenterTitle();
678 mg2->GetYaxis()->SetTitle("Packet ID");
679 mg2->GetYaxis()->CenterTitle();
680 leg2->Draw();
681 oss2.str("");
682 oss2 << outDir.Data() << filename.Data() << "_PacketScan_2." << format.Data();
683 finalCanv2->Update();
684 finalCanv2->SaveAs(oss2.str().c_str());
685
686
687 finalCanv3->cd();
688 mg3->SetMinimum(110);
689 mg3->SetMaximum(180);
690 mg3->Draw("AP");
691 mg3->GetXaxis()->SetTitle("OBT (ms)");
692 mg3->GetXaxis()->CenterTitle();
693 mg3->GetYaxis()->SetTitle("Packet ID");
694 mg3->GetYaxis()->CenterTitle();
695 leg3->Draw();
696 oss3.str("");
697 oss3 << outDir.Data() << filename.Data() << "_PacketScan_3." << format.Data();
698 finalCanv3->Update();
699 finalCanv3->SaveAs(oss3.str().c_str());
700
701
702 file->Close();
703
704 }
705
706
707
708 int main(int argc, char* argv[]){
709 TString path;
710 TString outDir = "./";
711 TString format = "jpg";
712
713
714 if (argc < 2){
715 printf("You have to insert at least the file to analyze \n");
716 printf("Try '--help' for more information. \n");
717 exit(1);
718 }
719
720 if (!strcmp(argv[1], "--help")){
721 printf( "Usage: PacketScan FILE [OPTION] \n");
722 printf( "\t --help Print this help and exit \n");
723 printf( "\t -outDir[path] Path where to put the output [default ./] \n");
724 printf( "\t -format[ps|gif|jpg] Format for output files [default 'jpg'] \n");
725 exit(1);
726 }
727
728 path=argv[1];
729
730
731
732 for (int i = 2; i < argc; i++){
733
734 if (!strcmp(argv[i], "-outDir")){
735 if (++i >= argc){
736 printf( "-outDir needs arguments. \n");
737 printf( "Try '--help' for more information. \n");
738 exit(1);
739 }
740 else{
741 outDir = argv[i];
742 continue;
743 }
744 }
745
746 if (!strcmp(argv[i], "-format")){
747 if (++i >= argc){
748 printf( "-format needs arguments. \n");
749 printf( "Try '--help' for more information. \n");
750 exit(1);
751 }
752 else{
753 format = argv[i];
754 continue;
755 }
756 }
757
758
759 }
760
761 PacketScan(argv[1], outDir, format);
762
763 }

  ViewVC Help
Powered by ViewVC 1.1.23