source: trunk/MagicSoft/Mars/mmain/MAnalysis.cc@ 949

Last change on this file since 949 was 949, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 5.3 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!
18! Author(s): Thomas Bretz 9/2001 (tbretz@uni-sw.gwdg.de)
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25#include "MAnalysis.h"
26
27#include <TGButton.h> // TGTextButton
28
29ClassImp(MAnalysis)
30
31enum {
32 M_BUTTON_HILLAS
33};
34
35MAnalysis::MAnalysis(const TGWindow *main, const TGWindow *p,
36 const UInt_t w, const UInt_t h)
37: MBrowser(main, p, w, h)
38{
39 TGTextButton *hillas = new TGTextButton(fTop2, "Calculate Standard Hillas", M_BUTTON_HILLAS);
40
41 hillas->Associate(this);
42
43 fList->Add(hillas);
44
45 TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
46 fList->Add(laybut);
47
48 fTop2->AddFrame(hillas, laybut);
49
50 MapSubwindows();
51
52 Layout();
53
54 SetWindowName("Analysis Window");
55 SetIconName("Analysis");
56
57 MapWindow();
58}
59
60// ======================================================================
61
62#include "MParList.h"
63#include "MTaskList.h"
64#include "MGeomCamMagic.h"
65#include "MPedestalCam.h"
66#include "MHHillas.h"
67#include "MHStarMap.h"
68#include "MReadTree.h"
69#include "MCerPhotCalc.h"
70#include "MImgCleanStd.h"
71#include "MHillasCalc.h"
72#include "MFillH.h"
73#include "MEvtLoop.h"
74#include "MHillas.h"
75
76void MAnalysis::CalculateHillas(const char *fname)
77{
78 //
79 // This is a demonstration program which calculates the Hillas
80 // parameter out of a Magic root file.
81
82 //
83 // Create a empty Parameter List and an empty Task List
84 // The tasklist is identified in the eventloop by its name
85 //
86 MParList plist;
87
88 MTaskList tlist;
89 plist.AddToList(&tlist);
90
91 //
92 // The geometry container must be created by yourself to make sure
93 // that you don't choos a wrong geometry by chance
94 //
95 MGeomCamMagic geomcam;
96 plist.AddToList(&geomcam);
97
98 MPedestalCam pedest;
99 plist.AddToList(&pedest);
100
101 //
102 // The Hillas histograms (MHHillas) could be created automatically
103 // but to make sure, that they are not deleted when the macro is
104 // finished you must create them yourself and add it to the list
105 //
106 MHillas hillas;
107 plist.AddToList(&hillas);
108
109 MHHillas *hists = new MHHillas;
110 plist.AddToList(hists);
111
112 MHStarMap *smap = new MHStarMap;
113 plist.AddToList(smap);
114
115 // FIXME: Where do we delete this two objects???
116
117 //
118 // Now setup the tasks and tasklist:
119 //
120 // 1) read in the data from a magic root file MReadTree
121 // 2) calculate number of cerenkov photons MCerPhotCalc
122 // 3) clean the image MImgCleanStd
123 // 4) calculate hillas MHillasCalc
124 // 5) fill the hillas into the histograms MFillH
125 //
126
127 //
128 // The first argument is the tree you want to read.
129 // Events: Cosmic ray events
130 // PedEvents: Pedestal Events
131 // CalEvents: Calibration Events
132 //
133 MReadTree read("Events", fname);
134 MCerPhotCalc ncalc;
135 MImgCleanStd clean;
136 MHillasCalc hcalc;
137 MFillH hfill(&hillas, hists);
138 MFillH sfill(&hillas, smap);
139 //
140 // FIXME:
141 // -----
142 // I cannot use MFillH fill("name", "name") here.
143 // for me it is not yet clear why this doesn't work
144 //
145
146 /*
147 MWriteRootFile write("hillas.root");
148 write.AddContainer("MHillas");
149 write.AddContainer("MHHillas");
150 write.AddContainer(smap);
151 */
152
153 tlist.AddToList(&read);
154 tlist.AddToList(&ncalc);
155 tlist.AddToList(&clean);
156 tlist.AddToList(&hcalc);
157 tlist.AddToList(&hfill);
158 tlist.AddToList(&sfill);
159 //tlist.AddToList(&write);
160
161 //
162 // Create and setup the eventloop
163 //
164 MEvtLoop evtloop;
165 evtloop.SetParList(&plist);
166
167 //
168 // Execute your analysis
169 //
170 if (!evtloop.Eventloop())
171 return;
172
173 //
174 // After the analysis is finished we can display the histograms
175 //
176 hists->Draw();
177 smap->Draw();
178}
179
180// ======================================================================
181
182Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
183{
184 // Process events generated by the buttons in the frame.
185
186 if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
187 return MBrowser::ProcessMessage(msg, parm1, parm2);
188
189 switch (parm1)
190 {
191 case M_BUTTON_HILLAS:
192 if (!InputFileSelected())
193 {
194 DisplError("No Input (root) File selected!");
195 return kTRUE;
196 }
197
198 switch (parm1)
199 {
200 case M_BUTTON_HILLAS:
201 CalculateHillas(fInputFile);
202 return kTRUE;
203 }
204 return kTRUE;
205 }
206
207 return MBrowser::ProcessMessage(msg, parm1, parm2);
208}
Note: See TracBrowser for help on using the repository browser.