Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

#include <stdlib.h>
#include <stdio.h>
#include <TCanvas.h>
#include <TGraph.h>

int TDraw(const char *fname ){
 FILE *fp=fopen(fname,"r");
 if (!fp) return -1;
 unsigned long t;
 int type;
 float temp0;
 
 TGraph *gr[3];
 
 float f[10];
 int j=0;  
 int ndim=400;
 char line[400];
 int colorTable[14] = { kBlack, kGray, kRed, kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange, kSpring, kTeal, kAzure, kViolet, kPink };
 char SensorType[3][16]={"T","Tmin","Tmax"}
 double time0;
 int first=1;
 TLegend *leg= new TLegend(0.85,0.8,1,0.95);
 for (int i=0;i<3;i++) {
  gr[i] = new TGraph();
  gr[i]->SetLineColor(colorTable[i%14]);
  gr[i]->SetLineWidth(3);
  gr[i]->SetMarkerColor(colorTable[i%14]);
  gr[i]->SetMarkerStyle(20+i);
  sprintf(line,"%s;t(s);T(deg.)",fname);
  gr[i]->SetTitle(line);
  sprintf(line,"%s",SensorType[i]);
  leg->AddEntry(gr[i],line,"l");

 }
 
 while (fgets(line,ndim,fp)!=NULL) {
    printf("%d***********\n",j++);
    printf("***%s\n", line);   
    sscanf(line,"%ul%d%f",&t,&type,&temp0);
        if(first){
                time0=t;
                first=0;
        }
    printf("%ul\t%d\t%f\n",t,type,temp0);
    if (type<3 && type>-1) gr[type]->SetPoint (gr[type]->GetN(), t-time0, temp0);      
 }
 fclose(fp);
 
 
 TCanvas *c1 = new TCanvas("c1","Merger temperature",200,10,1400,1000);
 c1->SetFillColor(kWhite);
 c1->SetGrid();

 //gr[0]->GetXaxis()->SetTimeDisplay(1); // The X axis is a time axis
 //gr[0]->GetXaxis()->SetTimeFormat("%d.%m.%H:%M");
 gr[0]->GetYaxis()->SetLabelSize(0.02);
 gr[0]->GetXaxis()->SetLabelSize(0.02);
 gr[0]->Draw("AWL");
 gr[0]->GetYaxis()->SetRangeUser(0,80);

 for (int j = 0; j < 3; j++)   {
   gr[j]->Draw("LSAME");       
 }
 leg->Draw();
 c1->Modified();
 c1->Update();
 char picname[1024];

 sprintf(picname,"%s.png",fname);
 c1->SaveAs(picname);

 return 0;

}