Subversion Repositories f9daq

Rev

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

void plottdc(char *filename) {
  FILE *fp =fopen(filename,"r");
  if (fp) {
   
    unsigned int hdr[10];
    int nb = fread(hdr,sizeof(unsigned int), 5, fp);
    int size = hdr[1]/sizeof(int);
   
    printf("FILE %s opened\nheader read nb=%d\ndata size %d\n", filename, nb ,size);
    //int *data = new unsigned int[size];
    float *data = new float[size];  
    nb = fread(data, sizeof(float), size, fp);
    printf("FILE data elements %d\n", nb);
    fclose(fp);
    TFile *f = new TFile(TString(filename)+".root","RECREATE");
    TH1F *h = new TH1F("h","TDC;tdc(bin);N",size, -0.5, size-0.5);
    for (int i=0; i< size; i++ ) h->SetBinContent(i+1,data[i]);
    h->DrawCopy();
    f->Write();
    f->Close();
   
  }

}