Subversion Repositories f9daq

Rev

Rev 229 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. void plottdc(char *filename) {
  2.   FILE *fp =fopen(filename,"r");
  3.   if (fp) {
  4.    
  5.     unsigned int hdr[10];
  6.     int nb = fread(hdr,sizeof(unsigned int), 5, fp);
  7.     int size = hdr[1]/sizeof(int);
  8.    
  9.     printf("FILE %s opened\nheader read nb=%d\ndata size %d\n", filename, nb ,size);
  10.     //int *data = new unsigned int[size];
  11.     float *data = new float[size];  
  12.     nb = fread(data, sizeof(float), size, fp);
  13.     printf("FILE data elements %d\n", nb);
  14.     fclose(fp);
  15.     TFile *f = new TFile(TString(filename)+".root","RECREATE");
  16.     TH1F *h = new TH1F("h","TDC;tdc(bin);N",size, -0.5, size-0.5);
  17.     for (int i=0; i< size; i++ ) h->SetBinContent(i+1,data[i]);
  18.     h->DrawCopy();
  19.     f->Write();
  20.     f->Close();
  21.    
  22.   }
  23.  
  24. }
  25.