source: branches/Mars_McMismatchStudy/Tables/useTables.C@ 19997

Last change on this file since 19997 was 17988, checked in by ghughes, 10 years ago
Energy reconstruction stuff
File size: 1.8 KB
Line 
1#define PI 3.1415
2#define D2R PI/180.
3#define R2D 180./PI
4
5void useTables( string sInFile, string sTableFile )
6{
7
8 gStyle->SetOptStat(111111);
9 gStyle->SetOptFit(111111);
10
11 gStyle->SetOptStat(0);
12
13 TFile *fTableFile = new TFile( sTableFile.c_str() );
14 if( fTableFile->IsZombie() )
15 {
16 cout << "File Error " << sTableFile.c_str() << endl;
17 exit(-1);
18 }
19
20 TFile *fInFile = new TFile( sInFile.c_str() );
21 if( fInFile->IsZombie() )
22 {
23 cout << "File Error " << sInFile.c_str() << endl;
24 exit(-1);
25 }
26
27 TTree *hTree = (TTree*)fInFile->Get("hillastree");
28
29 float fMCEnergy;
30 float fMCZd;
31 double fLength;
32 double fWidth;
33 double fDistance;
34 double fSize;
35
36 hTree->SetBranchAddress("MCEnergy",&fMCEnergy);
37 hTree->SetBranchAddress("MCZd",&fMCZd);
38 hTree->SetBranchAddress("Length",&fLength);
39 hTree->SetBranchAddress("Width",&fWidth);
40 hTree->SetBranchAddress("Size",&fSize);
41 hTree->SetBranchAddress("Distance",&fDistance);
42
43 TH2F *hTableEnergy = (TH2F*)fTableFile->Get("hTableEnergy");
44 TH2F *hTableLength = (TH2F*)fTableFile->Get("hTableLength");
45 TH2F *hTableWidth = (TH2F*)fTableFile->Get("hTableWidth");
46 TH2F *hTableNorm = (TH2F*)fTableFile->Get("hTableNorm");
47
48 TH1F *hRes = new TH1F("hRes","Energy Resolution",30,-2.,2.);
49 hRes->GetXaxis()->SetTitle("(Energy-True)/True");
50
51 int BIG = int(hTree->GetEntries()/2.);
52
53 for( int i = BIG; i < hTree->GetEntries(); i++ )
54 {
55
56 hTree->GetEntry(i);
57
58 if( fabs(fMCZd*R2D - 10.) < 5.0 )
59 {
60 Int_t iX = hTableEnergy->GetXaxis()->FindBin(log10(fSize));
61 Int_t iY = hTableEnergy->GetYaxis()->FindBin(fDistance);
62
63 float energy = hTableEnergy->GetBinContent(iX,iY);
64
65 if( energy != 0. ) hRes->Fill((pow(10.,energy)-fMCEnergy)/fMCEnergy);
66
67 }
68
69 }
70
71 hRes->Draw();
72 hRes->Fit("gaus");
73
74}
Note: See TracBrowser for help on using the repository browser.