source: trunk/MagicSoft/Mars/macros/status.C@ 2384

Last change on this file since 2384 was 2377, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.6 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, 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// Status - Example how to use the MStatusDisplay
28//
29// Use a camera file as input
30//
31/////////////////////////////////////////////////////////////////////////////
32
33void status(const char *fname="*1947*cosmic*.root")
34{
35 //
36 // Update frequency by default = 1Hz
37 //
38 MStatusDisplay *d = new MStatusDisplay;
39
40 // Set update time to 5s
41 // d->SetUpdateTime(5000);
42
43 // Disable online update
44 // d->SetUpdateTime(-1);
45
46 d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
47 gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
48 //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
49
50 //
51 // Create a empty Parameter List and an empty Task List
52 // The tasklist is identified in the eventloop by its name
53 //
54 MParList plist;
55
56 MTaskList tlist;
57 plist.AddToList(&tlist);
58
59 /*
60 MSrcPosCam src;
61 src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
62 plist.AddToList(&src);
63 */
64
65 //
66 // Now setup the tasks and tasklist:
67 // ---------------------------------
68 //
69 MReadMarsFile read("Events");
70 read.DisableAutoScheme();
71
72 // ------------- user change -----------------
73 read.AddFile(fname);
74
75 MGeomApply geomapl;
76
77 MMcPedestalCopy pcopy;
78 MMcPedestalNSBAdd pnsb;
79 MCerPhotCalc ncalc;
80
81 TArrayS blinds(2);
82 blinds[0] = 271;
83 blinds[1] = 291;
84
85 MBlindPixelCalc blind;
86 //blind.SetPixelIndices(blinds);
87 blind.SetUseInterpolation();
88
89 MSigmabarCalc sgcal;
90 MImgCleanStd clean;
91 MHillasCalc hcalc;
92 MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
93 MCT1SupercutsCalc calc1;
94
95 MHCamEvent hist("PedestalRms");
96 hist.SetType(1);
97 plist.AddToList(&hist);
98
99 // -------------------------------------------
100 MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
101 MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
102 MFillH hfill2("PedestalRms", "MPedestalCam");
103 MFillH hfill3("MHHillas", "MHillas");
104 MFillH hfill4("MHHillasExt");
105 MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
106 MFillH hfill6("MHHillasSrc","MHillasSrc");
107 MFillH hfill7("MHNewImagePar","MNewImagePar");
108 MFillH hfill8("MHStarMap", "MHillas");
109 MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
110 MFillH hfill10("MHHadronness", "MHadronness");
111 MFillH hfill11("MHSigmaTheta");
112
113 tlist.AddToList(&read);
114 tlist.AddToList(&geomapl);
115 tlist.AddToList(&pcopy);
116 tlist.AddToList(&pnsb);
117 tlist.AddToList(&ncalc);
118 tlist.AddToList(&blind);
119 tlist.AddToList(&hfill0);
120 //tlist.AddToList(&sgcal);
121 tlist.AddToList(&clean);
122 tlist.AddToList(&hcalc);
123 tlist.AddToList(&scalc);
124 //tlist.AddToList(&calc1);
125 tlist.AddToList(&hfill1);
126 tlist.AddToList(&hfill2);
127 tlist.AddToList(&hfill3);
128 tlist.AddToList(&hfill4);
129 tlist.AddToList(&hfill5);
130 tlist.AddToList(&hfill6);
131 tlist.AddToList(&hfill7);
132 tlist.AddToList(&hfill8);
133 tlist.AddToList(&hfill9);
134 //tlist.AddToList(&hfill10);
135
136 MEvtLoop evtloop;
137 evtloop.SetParList(&plist);
138 evtloop.SetDisplay(d);
139
140 //
141 // Execute your analysis
142 //
143 if (!evtloop.Eventloop())
144 return;
145
146 tlist.PrintStatistics();
147
148 MHCamera &uncl = *((MHCamEvent*)plist.FindObject("Uncleaned"))->GetHistByName();
149 MHCamera &hped = *((MHCamEvent*)plist.FindObject("Pedestals"))->GetHistByName();
150 MHCamera &hrms = *((MHCamEvent*)plist.FindObject("PedestalRms"))->GetHistByName();
151
152 for (int i=0; i<577; i++)
153 {
154 if (uncl.IsUsed(i))
155 {
156 if (uncl[i+1]>uncl.GetMean()+3*uncl.GetRMS())
157 cout << "Mean Charge of Pixel-Index #" << i << ": " << uncl[i+1] << " > 3*rms" << endl;
158 if (uncl[i+1]==0)
159 cout << "Mean Charge of Pixel-Index #" << i << ": " << uncl[i+1] << " <= 0" << endl;
160 if (uncl[i+1]<uncl.GetMean()-3*uncl.GetRMS())
161 cout << "Mean Charge of Pixel-Index #" << i << ": " << uncl[i+1] << " < 3*rms" << endl;
162 }
163 if (hped.IsUsed(i))
164 {
165 if (hped[i+1]>hped.GetMean()+1.5*hped.GetRMS())
166 cout << "Mean Pedestal of Pixel-Index #" << i << ": " << hped[i+1] << " > 1.5*rms" << endl;
167 if (hped[i+1]==0)
168 cout << "Mean Pedestal of Pixel-Index #" << i << ": " << hped[i+1] << " <= 0" << endl;
169 if (hped[i+1]<hped.GetMean()-1.5*hped.GetRMS())
170 cout << "Mean Pedestal of Pixel-Index #" << i << ": " << hped[i+1] << " < 1.5*rms" << endl;
171 }
172 if (hrms.IsUsed(i))
173 {
174 if (hrms[i+1]>hrms.GetMean()+4*hrms.GetRMS())
175 cout << "Mean PedestalRMS of Pixel-Index #" << i << ": " << hrms[i+1] << " > 4*rms" << endl;
176 if (hrms[i+1]==0)
177 cout << "Mean PedestalRMS of Pixel-Index #" << i << ": " << hrms[i+1] << " <= 0" << endl;
178 if (hrms[i+1]<hrms.GetMean()-4*hrms.GetRMS())
179 cout << "Mean PedestalRMS of Pixel-Index #" << i << ": " << hrms[i+1] << " < 4*rms" << endl;
180 }
181 }
182
183 //
184 // Make sure the display hasn't been deleted by the user while the
185 // eventloop was running.
186 //
187 if ((d = evtloop.GetDisplay()))
188 {
189 // Save data in a postscriptfile (status.ps)
190 //d->SaveAsPS();
191 /*
192 * ----------- Write status to a root file ------------
193 *
194 TFile file("status.root", "RECREATE");
195 d->Write();
196 file.Close();
197 delete d;
198 */
199 }
200 /*
201 * ----------- Read status from a root file ------------
202 *
203 TFile file2("status.root", "READ");
204 MStatusDisplay *d2 = new MStatusDisplay;
205 d2->Read();
206 */
207}
Note: See TracBrowser for help on using the repository browser.