Subversion Repositories f9daq

Rev

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

Rev Author Line No. Line
1 f9daq 1
int pedestals(char *fname=NULL){
2
 char fpede[255]="pedestals.dat";
3
 
4
 
5
 if (fname!=NULL){
6
    cout << "Rootname:" << fname << endl;
7
    delete gROOT->GetListOfFiles()->FindObject(fname); // clear memory of file name
8
    if( gSystem->AccessPathName(fname) ) {
9
      cout << endl << "File: " << fname << " not there!!!" << endl << endl;
10
      return 0;
11
    }
12
    TFile *rootfile = new TFile(fname);
13
  }
14
 
15
 TH1I *gICh = (TH1I * ) gDirectory->Get("mapping");
16
 char hname[50];
17
 char hn[50];
18
 TCanvas *c;
19
 
20
 
21
 
22
 fp=fopen(fpede,"w");
23
 for (int i=0;i<4;i++) {
24
    sprintf(hname,"cy%d",i);
25
    sprintf(hn,"Single Pmt %d",i);
26
    c =new TCanvas(hname,hn, 1000,1000);
27
    c->Divide(4,4);
28
    for (int j=0;j<16;j++){
29
        c->cd(gICh->GetBinContent(j+1)+1)->SetLogy(1);
30
 
31
        sprintf(hn,"ach%d",i*16+j);
32
        TH1F*h=   (TH1F * ) gDirectory->Get(hn);
33
        float mean=h->GetMean();
34
        h->Fit("gaus","","",mean-200,mean+100);
35
 
36
        TF1 *res = h->GetFunction("gaus");
37
 
38
        fprintf(fp, "%d %g\n",i*16+j,res->GetParameter(1));
39
 
40
    }
41
    c->Modified();
42
    c->Update();
43
  }
44
  fclose(fp);
45
 
46
  printf("pedestals are stored in file %s\n", fpede);
47
 
48
 
49
  /*
50
 char fsumpede[255]="sumpedestals.dat";
51
 FILE *fp=fopen(fsumpede,"w");
52
 c =new TCanvas("c","c", 600,600);
53
 c->Divide(2,2);
54
 for (int i=0;i<4;i++){
55
    sprintf(hn,"pmt%d",i);
56
    c->cd(i+1);
57
    TH1F *h= ((TH1F * )gDirectory->Get(hn));
58
    if (h) {
59
      h->Fit("gaus", "","",3000, 6000);
60
      TF1 *res = h->GetFunction("gaus");
61
      fprintf(fp, "%d %g\n",i,res->GetParameter(1));
62
    }  
63
 }
64
 c->Modified();
65
 c->Update();
66
 fclose(fp);
67
 printf("pedestals are stored in file %s\n", fsumpede);
68
 */
69
 
70
return 0;
71
}