source: trunk/MagicSoft/Mars/mtemp/mpisa/macros/AlphaPlot.C@ 4787

Last change on this file since 4787 was 4350, checked in by galante, 21 years ago
*** empty log message ***
File size: 1.6 KB
Line 
1void AlphaPlot(TString onsource="hillas_Mrk421.root", TString offsource="hillas_OffMrk421.root")
2{
3 const Int_t kMinDeg = 25;
4
5 Int_t i;
6 Float_t EvtOn = 0;
7 Float_t EvtOff = 0;
8
9 TH1F *hon = new TH1F("hon","On Source Histogram",19,0,95);
10 TH1F *hoff = new TH1F("hoff","Off Source Histogram",19,0,95);
11 TH1F *htemp;
12
13 fon = new TFile(onsource,"READ");
14
15 htemp = (TH1F *)fon->FindObjectAny("hAlpha");
16
17 for(i=0;i<19;i++)
18 hon->SetBinContent(i,htemp->GetBinContent(i));
19
20 for(i=0;i<hon->GetNbinsX();i++){
21 if(hon->GetBinCenter(i) > kMinDeg)
22 EvtOn += hon->GetBinContent(i);
23 }
24
25 fon->Close();
26
27 foff = new TFile(offsource,"READ");
28
29 htemp = (TH1F *)foff->FindObjectAny("hAlpha");
30 for(i=0;i<19;i++)
31 hoff->SetBinContent(i,htemp->GetBinContent(i));
32
33 for(i=0;i<hoff->GetNbinsX();i++){
34 if(hoff->GetBinCenter(i) > kMinDeg)
35 EvtOff += hoff->GetBinContent(i);
36 }
37
38 foff->Close();
39
40 Float_t norm = EvtOn/EvtOff;
41 cout << "EvtOn/EvtOff = " << norm << endl;
42
43 Float_t eccessi = 0;
44 Float_t Noff = 0;
45
46 TH1F *hAlphaPlot = new TH1F("hAlphaPlot","Alpha Plot", 19,0,95);
47 for(i=0; i<hon->GetNbinsX(); i++){
48 hAlphaPlot->SetBinContent(i,hon->GetBinContent(i)-hoff->GetBinContent(i)*norm);
49 if(hAlphaPlot->GetBinCenter(i) < 15){
50 eccessi += hAlphaPlot->GetBinContent(i);
51 Noff += norm*hoff->GetBinContent(i);
52 }
53 }
54
55 cout << "Eccessi = " << eccessi << " Nsigma = " << eccessi/(TMath::Sqrt(Noff)) <<endl;
56
57 new TCanvas("Alpha On","Alpha plot ON source");
58 hon->DrawCopy();
59 new TCanvas("Alpha Off","Alpha plot OFF source");
60 hoff->DrawCopy();
61 new TCanvas("Alpha","Resulting alpha plot");
62 hAlphaPlot->DrawCopy();
63}
Note: See TracBrowser for help on using the repository browser.