source: branches/removing_cpp11_features/macros/comprob.C@ 18459

Last change on this file since 18459 was 3957, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.2 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17! macro comprob.C
18!
19! Author(s): Abelardo Moralejo
20! Author(s): Thomas Bretz, 2002 <mailto:tbretz@astro.uni-wuerzburg.de>
21!
22! Copyright: MAGIC Software Development, 2000-2004
23!
24!
25\* ======================================================================== */
26
27///////////////////////////////////////////////////////////////////////////
28//
29// This macro demonstrates one way of gamma hadron separation using the
30// composite probability method. To use it you need a star-file (which is
31// a file ouput by the star.C macro containing image parameters)
32//
33///////////////////////////////////////////////////////////////////////////
34void comprob()
35{
36 //
37 // Create a empty Parameter List and an empty Task List
38 // The tasklist is identified in the eventloop by its name
39 //
40 MParList plist;
41
42 // Create task list and add it to the parameter list:
43 MTaskList tlist;
44 plist.AddToList(&tlist);
45
46 // First task in list: read the star file (reference data)
47 MReadMarsFile read("Events", "star.root");
48 read.DisableAutoScheme();
49 tlist.AddToList(&read);
50
51 //
52 // Task to do the composite analysis of Hillas parameters:
53 // Add(rule, number of bins, lower limit, upper limit)
54 // For the meaning of the rule see MDataChain
55 //
56 MHCompProb compprob(500);
57 compprob.Add("MHillas.fWidth", 500, 0, 160);
58 compprob.Add("MHillas.fLength", 500, 0, 300);
59 compprob.Add("abs(MHillas.fAsym)", 500, 0, 400);
60 compprob.Add("MHillasSrc.fDist", 500, 0, 400);
61 compprob.Add("abs(MHillasSrc.fHeadTail)", 500, 0, 400);
62 compprob.Add("abs(MHillas.fM3Long)", 500, 0, 300);
63 compprob.Add("abs(MHillas.fM3Trans)", 500, 0, 150);
64 compprob.Add("MHillas.fConc1", 500, 0, 0.6);
65 compprob.Add("MHillas.fConc", 500, 0, 0.9);
66 compprob.Add("log10(MHillas.fSize)", 500, 0, 5);
67
68 plist.AddToList(&compprob);
69
70 MFillH fill(&compprob, "MMcEvt");
71
72 // Use this if you want to do it for a fixed energy range:
73 /*
74 MF filter("MMcEvt.fEnergy < 100");
75 fill->SetFilter(&filter);
76 tlist.AddToList(&filter);
77 */
78
79 tlist.AddToList(&fill);
80
81 //
82 // Create and setup the eventloop
83 //
84 MEvtLoop evtloop;
85 evtloop.SetParList(&plist);
86
87 // Loop over all data to fill the "normal" histograms:
88 if (!evtloop.Eventloop())
89 return;
90
91 tlist.PrintStatistics();
92
93 gLog.SetDebugLevel(2);
94
95 // Loop to fill the variable bin histograms:
96 read.SetEventNum(0);
97 if (!evtloop.Eventloop())
98 return;
99
100 // ------------------------------------------------------------------
101
102 // Create task list and replace the old task list with the new one
103 MTaskList tlist2;
104 plist.Replace(&tlist2);
105
106 // First task in list: read star file (test data)
107 MReadMarsFile read2("Events", "star2.root");
108 read2.DisableAutoScheme();
109 tlist2.AddToList(&read2);
110
111 // create task to calculate composite probabilities
112 MCompProbCalc calc;
113 tlist2.AddToList(&calc);
114
115 // fill probabilities (hadroness) into histogram
116 MFillH fill2("MHHadronness");
117 tlist2.AddToList(&fill2);
118
119 // Loop to fill the hadronness histograms:
120 if (!evtloop.Eventloop())
121 return;
122
123 //
124 // Display the hadroness histograms and print some informations on
125 // the console window
126 //
127 plist.FindObject("MHHadronness")->DrawClone();
128 plist.FindObject("MHHadronness")->Print();
129}
130
Note: See TracBrowser for help on using the repository browser.