Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
309 f9daq 1
#include <stdlib.h>
2
#include <stdio.h>
3
#include <TCanvas.h>
4
#include <TGraph.h>
5
 
6
int TDraw(const char *fname ){
7
 FILE *fp=fopen(fname,"r");
8
 if (!fp) return -1;
9
 unsigned long t;
10
 int type;
11
 float temp0;
12
 
13
 TGraph *gr[3];
14
 
15
 float f[10];
16
 int j=0;  
17
 int ndim=400;
18
 char line[400];
19
 int colorTable[14] = { kBlack, kGray, kRed, kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange, kSpring, kTeal, kAzure, kViolet, kPink };
20
 char SensorType[3][16]={"T","Tmin","Tmax"}
21
 double time0;
22
 int first=1;
23
 TLegend *leg= new TLegend(0.85,0.8,1,0.95);
24
 for (int i=0;i<3;i++) {
25
  gr[i] = new TGraph();
26
  gr[i]->SetLineColor(colorTable[i%14]);
27
  gr[i]->SetLineWidth(3);
28
  gr[i]->SetMarkerColor(colorTable[i%14]);
29
  gr[i]->SetMarkerStyle(20+i);
30
  sprintf(line,"%s;t(s);T(deg.)",fname);
31
  gr[i]->SetTitle(line);
32
  sprintf(line,"%s",SensorType[i]);
33
  leg->AddEntry(gr[i],line,"l");
34
 
35
 }
36
 
37
 while (fgets(line,ndim,fp)!=NULL) {
38
    printf("%d***********\n",j++);
39
    printf("***%s\n", line);   
40
    sscanf(line,"%ul%d%f",&t,&type,&temp0);
41
        if(first){
42
                time0=t;
43
                first=0;
44
        }
45
    printf("%ul\t%d\t%f\n",t,type,temp0);
46
    if (type<3 && type>-1) gr[type]->SetPoint (gr[type]->GetN(), t-time0, temp0);      
47
 }
48
 fclose(fp);
49
 
50
 
51
 TCanvas *c1 = new TCanvas("c1","Merger temperature",200,10,1400,1000);
52
 c1->SetFillColor(kWhite);
53
 c1->SetGrid();
54
 
55
 //gr[0]->GetXaxis()->SetTimeDisplay(1); // The X axis is a time axis
56
 //gr[0]->GetXaxis()->SetTimeFormat("%d.%m.%H:%M");
57
 gr[0]->GetYaxis()->SetLabelSize(0.02);
58
 gr[0]->GetXaxis()->SetLabelSize(0.02);
59
 gr[0]->Draw("AWL");
60
 gr[0]->GetYaxis()->SetRangeUser(0,80);
61
 
62
 for (int j = 0; j < 3; j++)   {
63
   gr[j]->Draw("LSAME");       
64
 }
65
 leg->Draw();
66
 c1->Modified();
67
 c1->Update();
68
 char picname[1024];
69
 
70
 sprintf(picname,"%s.png",fname);
71
 c1->SaveAs(picname);
72
 
73
 return 0;
74
 
75
}