Subversion Repositories f9daq

Rev

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

int pedestals(char *fname=NULL){
 char fpede[255]="pedestals.dat";

 
 if (fname!=NULL){
    cout << "Rootname:" << fname << endl;
    delete gROOT->GetListOfFiles()->FindObject(fname); // clear memory of file name
    if( gSystem->AccessPathName(fname) ) {
      cout << endl << "File: " << fname << " not there!!!" << endl << endl;
      return 0;
    }
    TFile *rootfile = new TFile(fname);
  }

 TH1I *gICh = (TH1I * ) gDirectory->Get("mapping");
 char hname[50];
 char hn[50];
 TCanvas *c;
 
 
 
 fp=fopen(fpede,"w");
 for (int i=0;i<4;i++) {
    sprintf(hname,"cy%d",i);
    sprintf(hn,"Single Pmt %d",i);
    c =new TCanvas(hname,hn, 1000,1000);
    c->Divide(4,4);
    for (int j=0;j<16;j++){
        c->cd(gICh->GetBinContent(j+1)+1)->SetLogy(1);
     
        sprintf(hn,"ach%d",i*16+j);
        TH1F*h=   (TH1F * ) gDirectory->Get(hn);
        float mean=h->GetMean();
        h->Fit("gaus","","",mean-200,mean+100);

        TF1 *res = h->GetFunction("gaus");

        fprintf(fp, "%d %g\n",i*16+j,res->GetParameter(1));
       
    }
    c->Modified();
    c->Update();
  }
  fclose(fp);

  printf("pedestals are stored in file %s\n", fpede);


  /*
 char fsumpede[255]="sumpedestals.dat";
 FILE *fp=fopen(fsumpede,"w");
 c =new TCanvas("c","c", 600,600);
 c->Divide(2,2);
 for (int i=0;i<4;i++){
    sprintf(hn,"pmt%d",i);
    c->cd(i+1);
    TH1F *h= ((TH1F * )gDirectory->Get(hn));
    if (h) {
      h->Fit("gaus", "","",3000, 6000);
      TF1 *res = h->GetFunction("gaus");
      fprintf(fp, "%d %g\n",i,res->GetParameter(1));
    }  
 }
 c->Modified();
 c->Update();
 fclose(fp);
 printf("pedestals are stored in file %s\n", fsumpede);
 */

 
return 0;
}