source: trunk/MagicSoft/Mars/mtemp/mpadova/macros/area.C@ 6068

Last change on this file since 6068 was 5122, checked in by moralejo, 20 years ago
*** empty log message ***
File size: 2.8 KB
Line 
1void area(Char_t* infilename = "star_S500_all.root", Float_t maxhadronness = 0.1)
2{
3 //
4 // N_gamma_original: Number of generated Corsika showers in the MC sample
5 // from which the star file has been produced. VERY IMPORTANT!
6
7 const Double_t N_gamma_original = 3.9e6;
8 const Double_t MC_diff_spectrum = -2.6;
9 const Double_t E_MC_min = 10.;
10 const Double_t E_MC_max = 30000.;
11 const Double_t sizecut = 0.;
12 const Double_t mincorepixels = 5;
13 const Double_t leakagemax = 1.;
14
15 MHMcCollectionArea collarea;
16
17 //
18 // Calculate approximately the original number of events in each
19 // energy bin:
20 //
21
22 const Double_t expo = 1 + MC_diff_spectrum;
23 const Double_t k = N_gamma_original /
24 (pow(E_MC_max,expo) - pow(E_MC_min,expo)) ;
25
26 TH2D* hall = collarea.GetHistAll();
27
28 const Int_t nbinx = hall.GetNbinsX();
29
30 TAxis &axe = *hall.GetXaxis();
31 for (Int_t i = 1; i <= nbinx; i++)
32 {
33 const Float_t e1 = axe.GetBinLowEdge(i);
34 const Float_t e2 = axe.GetBinLowEdge(i+1);
35
36 if (e1 < E_MC_min || e2 > E_MC_max)
37 continue;
38
39 const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
40 //
41 // We fill the i-th energy bin, with the total number of events
42 // Second argument of Fill would be impact parameter of each
43 // event, but we don't really need it for the collection area,
44 // so we just put a dummy value (1.)
45 //
46
47 const Float_t energy = (e1+e2)/2.;
48 hall.Fill(energy, 1., events);
49 }
50
51 //
52 // Now open input file, loop over the Events tree and fill the energy
53 // histogram for events passing all required cuts.
54 //
55
56 TChain chain("Events");
57 chain.Add(infilename);
58
59 MMcEvt *mcevt;
60 MHillas *mhillas;
61 MNewImagePar *mnew;
62 MHadronness *mhadronness;
63
64 chain.SetBranchAddress("MMcEvt.", &mcevt);
65 chain.SetBranchAddress("MHillas.", &mhillas);
66 chain.SetBranchAddress("MNewImagePar.", &mnew);
67 chain.SetBranchAddress("MHadronness.", &mhadronness);
68
69 chain.SetBranchStatus("MMcEvt.", 1);
70 chain.SetBranchStatus("MHillas.", 1);
71 chain.SetBranchStatus("MNewImagePar.", 1);
72 chain.SetBranchStatus("MHadronness.", 1);
73
74 for (Int_t ievt = 0; ievt < chain.GetEntries(); ievt++)
75 {
76 chain.GetEvent(ievt);
77
78 if (mcevt->GetPartId() > 1)
79 continue;
80
81 if (mhillas->GetSize() < sizecut)
82 continue;
83
84 if (mnew->GetNumCorePixels() < mincorepixels)
85 continue;
86
87 if (mnew->GetLeakage1() > leakagemax)
88 continue;
89
90 if (mhadronness->GetHadronness() > maxhadronness)
91 continue;
92
93 const Float_t energy = mcevt->GetEnergy();
94
95 collarea.FillSel(energy,1.);
96 // Second argument is again just a dummy value
97 }
98
99
100 gStyle->SetOptStat(0);
101 gStyle->SetOptLogy();
102 collarea.CalcEfficiency2();
103 collarea.DrawClone();
104
105 // infile->Close();
106
107 TFile *out = new TFile("area.root", "recreate");
108 collarea.Write();
109 out->Close();
110
111 return;
112
113}
Note: See TracBrowser for help on using the repository browser.