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

Last change on this file since 6359 was 6359, checked in by rico, 20 years ago
*** empty log message ***
File size: 3.7 KB
Line 
1
2
3void computeCoeff()
4{
5 MEffAreaAndCoeffCalc calc;
6
7 // initial MC files
8 calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_0_7_1000to1009_w0.root");
9 calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_0_7_1130to1139_w0.root");
10 calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_0_7_1520to1529_w0.root");
11 calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_90_7_1260to1269_w0.root");
12 calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_90_7_1390to1399_w0.root");
13 calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_90_7_1650to1659_w0.root");
14
15
16 // files with remaining events after cuts (or where to apply cuts) see warning above
17 calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_0_7_1000to1009_w0_cleaned4035.root");
18 calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_0_7_1130to1139_w0_cleaned4035.root");
19 calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_0_7_1520to1529_w0_cleaned4035.root");
20 calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_90_7_1260to1269_w0_cleaned4035.root");
21 calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_90_7_1390to1399_w0_cleaned4035.root");
22 calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_90_7_1650to1659_w0_cleaned4035.root");
23
24
25 // define the funtion of the desired spectrum
26 calc.SetFunction("4.e9*pow(x,-2.6+1)",10.,10000.);
27 calc.ComputeAllFactors();
28
29 /************************************************/
30 /* Build spectrum */
31 /* now it's just a cross check with the same MC */
32 /************************************************/
33 const Int_t ebins = 10; // number of bins to build spectrum
34 const Int_t esubbins = 20; // number of subbins per big bin
35 const Double_t emin=10;
36 const Double_t emax=10000;
37 const Double_t logemin = TMath::Log10(emin);
38 const Double_t logemax = TMath::Log10(emax);
39 const Double_t de = (logemax-logemin)/ebins; // bin size (in log)
40 const Double_t desub = de/esubbins; // subbin size (in log)
41 const Int_t esbins = ebins*esubbins; // total number of subbins
42
43 // remaining events after cuts
44 const UInt_t ncutfiles=6;
45 Char_t* cutName[ncutfiles]={
46 "/data/camera_CL/Gamma_zbin0_0_7_1000to1009_w0_cleaned4035.root",
47 "/data/camera_CL/Gamma_zbin0_0_7_1130to1139_w0_cleaned4035.root",
48 "/data/camera_CL/Gamma_zbin0_0_7_1520to1529_w0_cleaned4035.root",
49 "/data/camera_CL/Gamma_zbin0_90_7_1260to1269_w0_cleaned4035.root",
50 "/data/camera_CL/Gamma_zbin0_90_7_1390to1399_w0_cleaned4035.root",
51 "/data/camera_CL/Gamma_zbin0_90_7_1650to1659_w0_cleaned4035.root"
52 };
53
54 TChain* ccut = new TChain("Events");
55 for(Int_t i = 0; i < ncutfiles; i++)
56 ccut->Add(cutName[i]);
57 ccut->SetAlias("logestenergy","log10(MHillas.fSize/15.)");
58 const Int_t nentries = Int_t(ccut->GetEntries());
59
60 MHillas* hillas;
61 MMcEvt* mcevt;
62 ccut->SetBranchStatus("*",0);
63 ccut->SetBranchStatus("MHillas.*",1);
64 ccut->SetBranchStatus("MMcEvt.*",1);
65 ccut->SetBranchAddress("MHillas.",&hillas);
66 ccut->SetBranchAddress("MMcEvt.",&mcevt);
67
68 TH1D* hspec = new TH1D("hspec","Spectrum",ebins,logemin,logemax);
69 hspec->Sumw2();
70
71 for(Int_t i=0;i<nentries;i++)
72 {
73 ccut->GetEntry(i);
74
75 // OJO!! Estimated energy will be taken directly from some input container
76 Float_t estim = hillas->GetSize()/15.;
77
78 UInt_t effabin = UInt_t((TMath::Log10(estim)-logemin)/desub);
79 UInt_t coefbin = UInt_t((TMath::Log10(estim)-logemin)/de);
80
81 Float_t effa = calc.GetEffectiveArea(effabin);
82 Float_t unfold = calc.GetCoefficient(coefbin);
83
84 if(effa)
85 hspec->Fill(TMath::Log10(estim),unfold/effa*1e9);
86 }
87
88 // SAVE RESULTS
89 TFile file("prueba.root","RECREATE");
90 hspec->Write();
91
92 return;
93}
Note: See TracBrowser for help on using the repository browser.