source: trunk/MagicSoft/Mars/macros/comprob.C@ 1952

Last change on this file since 1952 was 1609, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.1 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-2002
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//
33void comprob()
34{
35 //
36 // Create a empty Parameter List and an empty Task List
37 // The tasklist is identified in the eventloop by its name
38 //
39 MParList plist;
40
41 // Create task list and add it to the parameter list:
42 MTaskList tlist;
43 plist.AddToList(&tlist);
44
45 // First task in list: read the star file (reference data)
46 MReadMarsFile read("Events", "star.root");
47 read.DisableAutoScheme();
48 tlist.AddToList(&read);
49
50 //
51 // Task to do the composite analysis of Hillas parameters:
52 // Add(rule, number of bins, lower limit, upper limit)
53 // For the meaning of the rule see MDataChain
54 //
55 MHCompProb compprob(500);
56 compprob.Add("MHillas.fWidth", 500, 0, 160);
57 compprob.Add("MHillas.fLength", 500, 0, 300);
58 compprob.Add("abs(MHillas.fAsym)", 500, 0, 400);
59 compprob.Add("MHillasSrc.fDist", 500, 0, 400);
60 compprob.Add("abs(MHillasSrc.fHeadTail)", 500, 0, 400);
61 compprob.Add("abs(MHillas.fM3Long)", 500, 0, 300);
62 compprob.Add("abs(MHillas.fM3Trans)", 500, 0, 150);
63 compprob.Add("MHillas.fConc1", 500, 0, 0.6);
64 compprob.Add("MHillas.fConc", 500, 0, 0.9);
65 compprob.Add("log10(MHillas.fSize)", 500, 0, 5);
66
67 plist.AddToList(&compprob);
68
69 MFillH fill(&compprob, "MMcEvt");
70
71 // Use this if you want to do it for a fixed energy range:
72 /*
73 MF filter("MMcEvt.fEnergy < 100");
74 fill->SetFilter(&filter);
75 tlist.AddToList(&filter);
76 */
77
78 tlist.AddToList(&fill);
79
80 //
81 // Create and setup the eventloop
82 //
83 MEvtLoop evtloop;
84 evtloop.SetParList(&plist);
85
86 // Loop over all data to fill the "normal" histograms:
87 if (!evtloop.Eventloop())
88 return;
89
90 tlist.PrintStatistics();
91
92 gLog.SetDebugLevel(2);
93
94 // Loop to fill the variable bin histograms:
95 read.SetEventNum(0);
96 if (!evtloop.Eventloop())
97 return;
98
99 // ------------------------------------------------------------------
100
101 // Create task list and replace the old task list with the new one
102 MTaskList tlist2;
103 plist.Replace(&tlist2);
104
105 // First task in list: read star file (test data)
106 MReadMarsFile read2("Events", "star2.root");
107 read2.DisableAutoScheme();
108 tlist2.AddToList(&read2);
109
110 // create task to calculate composite probabilities
111 MCompProbCalc calc;
112 tlist2.AddToList(&calc);
113
114 // fill probabilities (hadroness) into histogram
115 MFillH fill2("MHHadronness");
116 tlist2.AddToList(&fill2);
117
118 // Loop to fill the hadronness histograms:
119 if (!evtloop.Eventloop())
120 return;
121
122 //
123 // Display the hadroness histograms and print some informations on
124 // the console window
125 //
126 plist.FindObject("MHHadronness")->DrawClone();
127 plist.FindObject("MHHadronness")->Print();
128}
129
Note: See TracBrowser for help on using the repository browser.