source: trunk/MagicSoft/Mars/status.cc@ 2522

Last change on this file since 2522 was 2521, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 7.9 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 ----- PRELIMINARY
30//
31/////////////////////////////////////////////////////////////////////////////
32
33#include "MStatusDisplay.h"
34#include "MArray.h"
35#include "MLog.h"
36#include "MArgs.h"
37#include "MLogManip.h"
38#include "MParList.h"
39#include "MTaskList.h"
40#include "MReadMarsFile.h"
41#include "MGeomApply.h"
42#include "MMcPedestalCopy.h"
43#include "MMcPedestalNSBAdd.h"
44#include "MCerPhotCalc.h"
45#include "MCerPhotAnal2.h"
46//#include "MBlindPixelCalc.h"
47#include "MSigmabarCalc.h"
48#include "MImgCleanStd.h"
49#include "MHillasCalc.h"
50#include "MHillasSrcCalc.h"
51#include "MCT1SupercutsCalc.h"
52#include "MHCamEvent.h"
53#include "MFillH.h"
54#include "MEvtLoop.h"
55#include "MFDataMember.h"
56
57#include <TApplication.h>
58#include <TSystem.h>
59
60static void StartUpMessage()
61{
62 gLog << all << endl;
63
64 // 1 2 3 4 5
65 // 12345678901234567890123456789012345678901234567890
66 gLog << "==================================================" << endl;
67 gLog << " status - MARS V" << MARSVER << endl;
68 gLog << " MARS - Merging and Preprocessing Program" << endl;
69 gLog << " Compiled on <" << __DATE__ << ">" << endl;
70 gLog << " Using ROOT v" << ROOTVER << endl;
71 gLog << " PROGRAM IS PRELIMINARY - FOR TEST CASES ONLY" << endl;
72 gLog << "==================================================" << endl;
73 gLog << endl;
74}
75
76static void Usage()
77{
78 gLog << all << endl;
79 gLog << "Sorry the usage is:" << endl;
80 gLog << " status [-a0] [-vn] [-cn] inputfile[.root]" << endl << endl;
81 gLog << " input file: Mars root file." << endl;
82 gLog << " -a0: Do not use Ansii codes." << endl;
83 gLog << " -vn: Verbosity level n [default=2]" << endl;
84 gLog << " -?/-h: This help" << endl << endl;
85}
86
87
88int main(int argc, char **argv)
89{
90 StartUpMessage();
91
92 //
93 // Evaluate arguments
94 //
95 MArgs arg(argc, (const char**)argv);
96
97 if (arg.HasOption("-?") || arg.HasOption("-h"))
98 {
99 Usage();
100 return -1;
101 }
102
103 //
104 // Set verbosity to highest level.
105 //
106 gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
107
108 if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
109 gLog.SetNoColors();
110
111 //
112 // check for the right usage of the program
113 //
114 if (arg.GetNumArguments()!=1)
115 {
116 Usage();
117 return -1;
118 }
119
120 //
121 // This is to make argv[i] more readable insidethe code
122 //
123 TString kNamein = arg.GetArgumentStr(0);
124
125 if (!kNamein.EndsWith(".root"))
126 kNamein += ".root";
127
128 //
129 // check whether the given files are OK.
130 //
131 if (gSystem->AccessPathName(kNamein, kFileExists))
132 {
133 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
134 return -1;
135 }
136
137 TApplication app("Status", &argc, argv);
138 if (gROOT->IsBatch() || !gClient)
139 {
140 gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
141 return 1;
142 }
143
144 MArray::Class()->IgnoreTObjectStreamer();
145 MParContainer::Class()->IgnoreTObjectStreamer();
146
147 //
148 // Update frequency by default = 1Hz
149 //
150 MStatusDisplay *d = new MStatusDisplay;
151
152 // Set update time to 5s
153 // d->SetUpdateTime(5000);
154
155 // Disable online update
156 // d->SetUpdateTime(-1);
157
158 d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
159 gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
160 //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
161
162 //
163 // Create a empty Parameter List and an empty Task List
164 // The tasklist is identified in the eventloop by its name
165 //
166 MParList plist;
167
168 MTaskList tlist;
169 plist.AddToList(&tlist);
170
171 /*
172 MSrcPosCam src;
173 src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
174 plist.AddToList(&src);
175 */
176
177 //
178 // Now setup the tasks and tasklist:
179 // ---------------------------------
180 //
181 MReadMarsFile read("Events");
182 //read.DisableAutoScheme();
183
184 // ------------- user change -----------------
185 read.AddFile(kNamein);
186
187 MGeomApply geomapl;
188 MMcPedestalCopy pcopy;
189 MMcPedestalNSBAdd pnsb;
190 MCerPhotCalc ncalc;
191 MCerPhotAnal2 nanal;
192
193 MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
194 MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
195
196 ncalc.SetFilter(&f1);
197 nanal.SetFilter(&f2);
198/*
199 TArrayS blinds(6);
200 blinds[0] = 0;
201 blinds[1] = 195;
202 blinds[2] = 227;
203 blinds[3] = 248;
204 blinds[4] = 271;
205 blinds[5] = 291;
206
207 blinds[3] = 51;
208 blinds[4] = 56;
209 blinds[5] = 112;
210 blinds[6] = 31;
211 blinds[7] = 116;
212 blinds[8] = 507;
213 blinds[9] = 559;
214 blinds[10]= 291; // 311, 119, 54, 85, 125, 92, 133, 224
215
216 MBlindPixelCalc blind;
217 blind.SetPixelIndices(blinds);
218 //blind.SetUseInterpolation();
219*/
220 // MSigmabarCalc sgcal;
221 MImgCleanStd clean;
222 MHillasCalc hcalc;
223 MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
224 // MCT1SupercutsCalc calc1;
225
226 MHCamEvent hist("PedestalRms");
227 hist.SetType(1);
228 plist.AddToList(&hist);
229
230 // -------------------------------------------
231 MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
232 MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
233 MFillH hfill2("PedestalRms", "MPedestalCam");
234 MFillH hfill3("MHHillas", "MHillas");
235 MFillH hfill4("MHHillasExt");
236 MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
237 MFillH hfill6("MHHillasSrc","MHillasSrc");
238 MFillH hfill7("MHNewImagePar","MNewImagePar");
239 //MFillH hfill8a("MHStarMap", "MHillas");
240 //MFillH hfill8b("MHStarMap2", "MHillas");
241 MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
242 //MFillH hfill10("MHHadronness", "MHadronness");
243 //MFillH hfill11("MHSigmaTheta");
244
245 tlist.AddToList(&read);
246 tlist.AddToList(&f1);
247 tlist.AddToList(&f2);
248 tlist.AddToList(&geomapl);
249 tlist.AddToList(&pcopy);
250 tlist.AddToList(&pnsb);
251 tlist.AddToList(&ncalc);
252 tlist.AddToList(&nanal);
253 //tlist.AddToList(&blind);
254 tlist.AddToList(&hfill0);
255 //tlist.AddToList(&sgcal);
256 tlist.AddToList(&clean);
257 tlist.AddToList(&hcalc);
258 tlist.AddToList(&scalc);
259 //tlist.AddToList(&calc1);
260 tlist.AddToList(&hfill1);
261 tlist.AddToList(&hfill2);
262 tlist.AddToList(&hfill3);
263 tlist.AddToList(&hfill4);
264 tlist.AddToList(&hfill5);
265 tlist.AddToList(&hfill6);
266 tlist.AddToList(&hfill7);
267 //tlist.AddToList(&hfill8a);
268 //tlist.AddToList(&hfill8b);
269 tlist.AddToList(&hfill9);
270 //tlist.AddToList(&hfill10);
271 //tlist.AddToList(&hfill11);
272
273 MEvtLoop evtloop;
274 evtloop.SetParList(&plist);
275 evtloop.SetDisplay(d);
276
277 //
278 // Execute your analysis
279 //
280 if (!evtloop.Eventloop())
281 return 1;
282
283 tlist.PrintStatistics();
284 return 0;
285}
Note: See TracBrowser for help on using the repository browser.