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

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