source: trunk/MagicSoft/Mars/mtemp/mifae/macros/computeCoeff.C@ 7136

Last change on this file since 7136 was 6486, checked in by rico, 20 years ago
*** empty log message ***
File size: 1.8 KB
Line 
1
2
3void computeCoeff()
4{
5 MEffAreaAndCoeffCalc calc;
6 calc.AddFile("/data/star_gamma_test.root");
7
8 /************************************************/
9 /* Build spectrum */
10 /* now it's just a cross check with the same MC */
11 /************************************************/
12 const Int_t ebins = 20; // number of bins to build spectrum
13 const Double_t emin=10;
14 const Double_t emax=200;
15 const Int_t tbins = 2;
16 const Double_t thetab[tbins+1] = {0,10,20};
17 calc.SetEbins(ebins);
18 calc.SetEmin(emin);
19 calc.SetEmax(emax);
20 calc.SetThetaBinning(tbins,thetab);
21
22 // define the funtion of the desired spectrum
23 calc.SetFunction("4.e9*pow(x,-2.6+1)");
24 calc.ComputeAllFactors();
25
26 const UInt_t ncutfiles=1;
27 Char_t* cutName[ncutfiles]={"/data/star_gamma_test.root"};
28
29 TChain* ccut = new TChain("Events");
30 for(Int_t i = 0; i < ncutfiles; i++)
31 ccut->Add(cutName[i]);
32 ccut->SetAlias("logestenergy","log10(MHillas.fSize/0.18/15.)");
33 ccut->SetAlias("theta","MMcEvt.fTelescopeTheta*180./3.14159");
34
35
36 const Double_t logemin = TMath::Log10(emin);
37 const Double_t logemax = TMath::Log10(emax);
38 TH1D* hspec = new TH1D("hspec","Spectrum",ebins,logemin,logemax);
39 hspec->Sumw2();
40 ccut->Draw("logestenergy>>hspec","theta<10","goff");
41
42 for(Int_t i=0;i<ebins;i++)
43 {
44 const Float_t uncorrval = hspec->GetBinContent(i+1);
45 const Float_t effa = calc.GetEffectiveAreaHisto()->GetBinContent(i+1,1);
46 const Float_t unfold = calc.GetCoefficientHisto()->GetBinContent(i+1,1);
47 Float_t corrval;
48 if(effa)
49 corrval = uncorrval*unfold/effa*1e9;
50 else
51 corrval = 0;
52 hspec->SetBinContent(i+1,corrval);
53 }
54
55 // SAVE RESULTS
56 TFile file("prueba.root","RECREATE");
57 hspec->Write();
58 calc.GetEffectiveAreaHisto()->Write();
59 calc.GetCoefficientHisto()->Write();
60 return;
61}
Note: See TracBrowser for help on using the repository browser.