FairRoot/PandaRoot
getpars.C
Go to the documentation of this file.
1 #include "TFile.h"
2 #include "TTree.h"
3 #include "TH1F.h"
4 #include "TF1.h"
5 #include "TRegexp.h"
6 #include "TCanvas.h"
7 
8 #include <iostream>
9 
10 int getpars(TString fname)
11 {
12  TRegexp regntp("n[0-9]+");
13  TString ntp = fname(regntp);
14  TString smode = ntp(1,ntp.Length());
15  int mode = smode.Atoi()/10;
16 
17  bool dst = (mode == 11 || mode == 13 || mode == 15);
18 
19  TFile *f=new TFile(fname,"READ");
20  TTree *t=(TTree*)f->Get(ntp);
21 
22  TCanvas *c1=new TCanvas("c1","c1",800,600);
23  t->Draw("xm>>h","xmct");
24 
25  TH1F *h=(TH1F*)gDirectory->Get("h");
26 
27  TF1 f1("f1","gaus(0)");
28  f1.SetParameters(h->GetMaximum(), h->GetMean(), h->GetRMS());
29 
30  h->Fit("f1","q");
31 
32  printf("MEAN = %6.4f SIGMA = %6.4f\n", f1.GetParameter(1), f1.GetParameter(2));
33 
34  if (dst)
35  {
36  t->Draw("xmdif>>hd","xmct");
37 
38  TH1F *hd=(TH1F*)gDirectory->Get("hd");
39 
40  TF1 f2("f2","gaus(0)");
41  f2.SetParameters(hd->GetMaximum(), hd->GetMean(), hd->GetRMS());
42 
43  hd->Fit("f2","q");
44 
45  printf("dM: MEAN = %6.4f SIGMA = %6.4f\n", f2.GetParameter(1), f2.GetParameter(2));
46  }
47  return 0;
48 }
int getpars(TString fname)
Definition: getpars.C:10
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TF1 * f1
Definition: reco_analys2.C:50
Int_t mode
Definition: autocutx.C:47
TFile * f
Definition: bump_analys.C:12
c1
Definition: plot_dirc.C:35
TFile * f2
TTree * t
Definition: bump_analys.C:13