source: trunk/MagicSoft/Mars/mjobs/MJCut.cc@ 6987

Last change on this file since 6987 was 6979, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 22.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, 1/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2005
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MJCut
28//
29// FIXME: Preparation for wobble mode missing
30//
31/////////////////////////////////////////////////////////////////////////////
32#include "MJCut.h"
33
34#include <TEnv.h>
35#include <TFile.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40#include "MParList.h"
41#include "MTaskList.h"
42#include "MEvtLoop.h"
43
44#include "MStatusDisplay.h"
45
46#include "MReadReports.h"
47#include "MReadMarsFile.h"
48#include "MPrint.h"
49#include "MContinue.h"
50//#include "MEnergyEstimate.h"
51#include "MTaskEnv.h"
52#include "MSrcPosCalc.h"
53#include "MHillasCalc.h"
54#include "MFillH.h"
55#include "MWriteRootFile.h"
56
57#include "../mhflux/MAlphaFitter.h"
58#include "../mhflux/MHAlpha.h"
59
60#include "MH3.h"
61#include "MBinning.h"
62#include "MDataSet.h"
63#include "MParameters.h"
64#include "MPointingPos.h"
65#include "MObservatory.h"
66
67ClassImp(MJCut);
68
69using namespace std;
70
71// --------------------------------------------------------------------------
72//
73// Default constructor. Set defaults for fStoreSummary, fStoreresult,
74// fWriteOnly, fIsWobble and fFullDisplay to kFALSE and initialize
75// /*fEstimateEnergy and*/ fCalcHadronness with NULL.
76//
77MJCut::MJCut(const char *name, const char *title)
78 : fStoreSummary(kFALSE), fStoreResult(kTRUE), fWriteOnly(kFALSE),
79 fIsWobble(kFALSE), fIsMonteCarlo(kFALSE), fFullDisplay(kFALSE), /*fSubstraction(kFALSE),*/
80 /*fEstimateEnergy(0),*/ fCalcHadronness(0)
81{
82 fName = name ? name : "MJCut";
83 fTitle = title ? title : "Standard program to perform g/h-separation cuts";
84}
85
86// --------------------------------------------------------------------------
87//
88// Destructor. Delete fEstimateEnergy and fCalcHadronness if != NULL
89//
90MJCut::~MJCut()
91{
92 //if (fEstimateEnergy)
93 // delete fEstimateEnergy;
94 if (fCalcHadronness)
95 delete fCalcHadronness;
96}
97
98// --------------------------------------------------------------------------
99//
100// Set the name of the summary file (events after cut0)
101// If you give a name the storage of this file is enabled implicitly.
102// If you give no filename the storage is neither enabled nor disabled,
103// but the storage file name is reset.
104// If no filename is set the default filename is used.
105// You can explicitly enable or disable the storage using EnableStoreOf*()
106// The default argument is no filename.
107//
108void MJCut::SetNameSummaryFile(const char *name)
109{
110 fNameSummary=name;
111 if (!fNameSummary.IsNull())
112 EnableStorageOfSummary();
113}
114
115// --------------------------------------------------------------------------
116//
117// Set the name of the summary file (events after cut3)
118// If you give a name the storage of this file is enabled implicitly.
119// If you give no filename the storage is neither enabled nor disabled,
120// but the storage file name is reset.
121// If no filename is set the default filename is used.
122// You can explicitly enable or disable the storage using EnableStoreOf*()
123// The default argument is no filename.
124//
125void MJCut::SetNameResultFile(const char *name)
126{
127 fNameResult=name;
128 if (!fNameResult.IsNull())
129 EnableStorageOfResult();
130}
131
132// --------------------------------------------------------------------------
133//
134// Setup a task estimating the energy. The given task is cloned.
135//
136/*
137void MJCut::SetEnergyEstimator(const MTask *task)
138{
139 if (fEstimateEnergy)
140 delete fEstimateEnergy;
141 fEstimateEnergy = task ? (MTask*)task->Clone() : 0;
142}
143*/
144
145// --------------------------------------------------------------------------
146//
147// Setup a task calculating the hadronness. The given task is cloned.
148//
149void MJCut::SetHadronnessCalculator(const MTask *task)
150{
151 if (fCalcHadronness)
152 delete fCalcHadronness;
153 fCalcHadronness = task ? (MTask*)task->Clone() : 0;
154}
155
156// --------------------------------------------------------------------------
157//
158// return fOutputPath+"/ganymed%08d.root", num
159//
160TString MJCut::GetOutputFile(UInt_t num) const
161{
162 TString p(fPathOut);
163 p += "/";
164 p += fNameOutput.IsNull() ? Form("ganymed%08d.root", num) : fNameOutput.Data();
165 return p;
166}
167
168/*
169Bool_t MJCut::ReadTasks(const char *fname, MTask* &env1, MTask* &env2) const
170{
171 // const TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
172
173 *fLog << inf << "Reading from file: " << fname << endl;
174
175 TFile file(fname, "READ");
176 if (!file.IsOpen())
177 {
178 *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
179 return kFALSE;
180 }
181
182 TObject *o = file.Get("EstimateEnergy");
183 if (o && !o->InheritsFrom(MTask::Class()))
184 {
185 *fLog << err << dbginf << "ERROR - EstimateEnergy read from " << fname << " doesn't inherit from MTask!" << endl;
186 return kFALSE;
187 }
188 env1 = o ? (MTask*)o->Clone() : FNULL;
189
190 o = file.Get("CalcHadronness");
191 if (o && !o->InheritsFrom(MTask::Class()))
192 {
193 *fLog << err << dbginf << "ERROR - CalcHadronness read from " << fname << " doesn't inherit from MTask!" << endl;
194 return kFALSE;
195 }
196 env2 = o ? (MTask*)o->Clone() : NULL;
197
198 return kTRUE;
199}
200*/
201
202// --------------------------------------------------------------------------
203//
204// Write the tasks in cont to the file corresponding to analysis number num,
205// see GetOutputFile()
206//
207Bool_t MJCut::WriteTasks(UInt_t num, TObjArray &cont) const
208{
209 if (fPathOut.IsNull())
210 {
211 *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
212 return kTRUE;
213 }
214
215 const TString oname(GetOutputFile(num));
216
217 *fLog << inf << "Writing to file: " << oname << endl;
218
219 TFile *file = 0;
220 if (fNameResult.IsNull() && fStoreResult)
221 {
222 file = (TFile*)gROOT->GetListOfFiles()->FindObject(oname);
223 if (file)
224 file->cd();
225 }
226 else
227 file = TFile::Open(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCut", 9);
228
229 if (!file)
230 {
231 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
232 return kFALSE;
233 }
234
235 const Bool_t rc = WriteContainer(cont);
236
237 if (!(fNameResult.IsNull() && fStoreResult))
238 delete file;
239
240 return rc;
241}
242
243// --------------------------------------------------------------------------
244//
245// Write the result plots and other results to the file corresponding to
246// analysis number num, see GetOutputFile()
247//
248Bool_t MJCut::WriteResult(const MParList &plist, UInt_t num) const
249{
250 TObjArray arr;
251
252 // Save all MBinnings
253 TIter Next(plist);
254 TObject *o=0;
255 while ((o=Next()))
256 if (o->InheritsFrom(MBinning::Class()))
257 arr.Add(o);
258
259 // Save also the result, not only the setup
260 const MHAlpha *halpha = (MHAlpha*)plist.FindObject("MHAlpha");
261 if (halpha)
262 arr.Add((TObject*)(&halpha->GetAlphaFitter()));
263
264 const TString fname(GetOutputFile(num));
265
266 // If requested, write to already open output file
267 if (fNameResult.IsNull() && fStoreResult)
268 {
269 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fname);
270 if (file)
271 {
272 file->cd();
273 return WriteContainer(arr);
274 }
275 }
276
277 return WriteContainer(arr, fname, "UPDATE");
278}
279
280// --------------------------------------------------------------------------
281//
282// MJCut allows to setup several option by a resource file:
283// MJCut.WriteSummary: yes, no
284// MJCut.SummaryFile: filename
285// MJCut.WriteResult: yes, no
286// MJCut.ResultFile: filename
287//
288Bool_t MJCut::CheckEnvLocal()
289{
290 const TString f0(GetEnv("SummaryFile", ""));
291 const TString f1(GetEnv("ResultFile", ""));
292 if (!f0.IsNull())
293 SetNameSummaryFile(f0);
294 if (!f1.IsNull())
295 SetNameResultFile(f1);
296
297 EnableStorageOfSummary(GetEnv("SummaryFile", fStoreSummary));
298 EnableStorageOfResult(GetEnv("ResultFile", fStoreResult));
299 EnableWobbleMode(GetEnv("WobbleMode", fIsWobble));
300 EnableMonteCarloMode(GetEnv("MonteCarlo", fIsMonteCarlo));
301 EnableFullDisplay(GetEnv("FullDisplay", fFullDisplay));
302 //EnableSubstraction(GetEnv("HistogramSubstraction", fSubstraction));
303
304 return kTRUE;
305}
306
307// --------------------------------------------------------------------------
308//
309// Setup write to write:
310// container tree optional?
311// -------------- ---------- -----------
312// "MHillas" to "Events"
313// "MHillasSrc" to "Events"
314// "MHadronness" to "Events" yes
315// "MEnergyEst" to "Events" yes
316// "DataType" to "Events"
317//
318void MJCut::SetupWriter(MWriteRootFile *write, const char *name) const
319{
320 if (!write)
321 return;
322
323 write->SetName(name);
324 write->AddContainer("MHillas", "Events");
325 write->AddContainer("MHillasSrc", "Events");
326 write->AddContainer("MHillasExt", "Events");
327 write->AddContainer("MPointingPos", "Events");
328 write->AddContainer("MHillasSrcAnti", "Events", kFALSE);
329 write->AddContainer("MNewImagePar", "Events", kFALSE);
330 write->AddContainer("MNewImagePar2", "Events", kFALSE);
331 write->AddContainer("MHadronness", "Events", kFALSE);
332 write->AddContainer("MEnergyEst", "Events", kFALSE);
333 write->AddContainer("MMcEvt", "Events", kFALSE);
334 write->AddContainer("DataType", "Events");
335
336 // Should not be the default: Either as option, or as
337 // setup from resource file
338 // write.AddContainer("MHillasExt", "Events");
339 // write.AddContainer("MImagePar", "Events");
340 // write.AddContainer("MNewImagePar", "Events");
341}
342
343void MJCut::DisplayResult(const MParList &plist) const
344{
345 /*
346 TObject *h1 = plist.FindObject("MHHillasOffPre", "MHHillas");
347 TObject *h2 = plist.FindObject("MHHillasOffPost", "MHHillas");
348 TObject *h3 = plist.FindObject("MHVsSizeOffPost", "MHVsSize");
349 TObject *h4 = plist.FindObject("MHHilExtOffPost", "MHHillasExt");
350 TObject *h5 = plist.FindObject("MHHilSrcOffPost", "MHHillasSrc");
351 TObject *h6 = plist.FindObject("MHImgParOffPost", "MHImagePar");
352 TObject *h7 = plist.FindObject("MHNewParOffPost", "MHNewImagePar");
353 */
354}
355
356Bool_t MJCut::Process(const MDataSet &set)
357{
358 if (!set.IsValid())
359 {
360 *fLog << err << "ERROR - DataSet invalid!" << endl;
361 return kFALSE;
362 }
363
364 CheckEnv();
365
366 // --------------------------------------------------------------------------------
367
368 *fLog << inf;
369 fLog->Separator(GetDescriptor());
370 *fLog << "Perform cuts for data set " << set.GetName() << endl;
371 *fLog << endl;
372
373 // --------------------------------------------------------------------------------
374
375 // Setup Parlist
376 MParList plist;
377 plist.AddToList(this); // take care of fDisplay!
378
379 MParameterI par("DataType");
380 plist.AddToList(&par);
381
382 // Setup Tasklist
383 MTaskList tlist;
384 plist.AddToList(&tlist);
385
386 // La Palma Magic1
387 MObservatory obs;
388 plist.AddToList(&obs);
389
390 // Possible source position (eg. Wobble Mode)
391 MPointingPos source("MSourcePos");
392 if (set.GetSourcePos(source))
393 {
394 plist.AddToList(&source);
395 *fLog << inf << "Using Source Position: " << source.GetTitle() << endl;
396 }
397 else
398 *fLog << inf << "No source position applied..." << endl;
399
400 // Initialize default binnings
401 MBinning bins1(18, 0, 90, "BinningAlpha", "lin");
402 MBinning bins2(15, 10, 1e6 , "BinningEnergyEst", "log");
403 MBinning bins3(50, 0, 60, "BinningTheta", "cos");
404 MBinning bins4("BinningFalseSource");
405 MBinning bins5("BinningWidth");
406 MBinning bins6("BinningLength");
407 MBinning bins7("BinningDist");
408 MBinning bins8("BinningMaxDist");
409 plist.AddToList(&bins1);
410 plist.AddToList(&bins2);
411 plist.AddToList(&bins3);
412 plist.AddToList(&bins4);
413 plist.AddToList(&bins5);
414 plist.AddToList(&bins6);
415 plist.AddToList(&bins7);
416 plist.AddToList(&bins8);
417
418 // --------------------------------------------------------------------------------
419
420 // Setup fitter and histograms
421 MAlphaFitter fit;
422 plist.AddToList(&fit);
423 if (fIsWobble)
424 fit.SetScaleMode(MAlphaFitter::kNone);
425
426 MHAlpha halphaoff("MHAlphaOff");
427 halphaoff.ForceUsingSize();
428 plist.AddToList(&halphaoff);
429
430 MFillH falpha("MHAlphaOff [MHAlpha]", "MHillasSrc", "FillAlpha");
431 MFillH ffs("MHFalseSourceOff [MHFalseSource]", "MHillas", "FillFS");
432
433 // FIXME: If fPathIn read cuts and energy estimator from file!
434 MContinue cont0("", "Cut0");
435 MContinue cont1("", "Cut1");
436 MContinue cont2("", "Cut2");
437 MContinue cont3("", "Cut3");
438 cont0.SetAllowEmpty();
439 cont1.SetAllowEmpty();
440 cont2.SetAllowEmpty();
441 cont3.SetAllowEmpty();
442
443 // ------------- Loop Off Data --------------------
444 MReadReports readoffdata;
445 readoffdata.AddTree("Events", "MTime.", kTRUE);
446 readoffdata.AddTree("Drive");
447 readoffdata.AddTree("EffectiveOnTime");
448
449 MReadMarsFile readoffmc("Events");
450 readoffmc.DisableAutoScheme();
451
452 MRead &readoff = fIsMonteCarlo ? (MRead&)readoffmc : (MRead&)readoffdata;
453 if (fIsWobble)
454 set.AddFilesOn(readoff);
455 else
456 set.AddFilesOff(readoff);
457
458 const TString path(Form("%s/", fPathOut.Data()));
459 TString fname0(path);
460 TString fname1(path);
461 fname0 += fNameSummary.IsNull() ? (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
462 fname1 += fNameResult.IsNull() ? (TString) Form("ganymed%08d.root", set.GetNumAnalysis()) : fNameResult;
463
464 MWriteRootFile *write0 = CanStoreSummary() ? new MWriteRootFile(fPathOut.IsNull()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW") : 0;
465 MWriteRootFile *write1 = CanStoreResult() ? new MWriteRootFile(fPathOut.IsNull()?0:fname1.Data(), fOverwrite?"RECREATE":"NEW") : 0;
466 SetupWriter(write0, "WriteAfterCut0");
467 SetupWriter(write1, "WriteAfterCut3");
468
469/*
470 MEnergyEstimate est;
471
472 MTaskEnv taskenv1("EstimateEnergy");
473 taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est);
474 */
475 MTaskEnv taskenv2("CalcHadronness");
476 taskenv2.SetDefault(fCalcHadronness);
477
478 MFillH fill1a("MHHillasOffPre [MHHillas]", "MHillas", "FillHillasPre");
479 MFillH fill2a("MHHillasOffPost [MHHillas]", "MHillas", "FillHillasPost");
480 MFillH fill3a("MHVsSizeOffPost [MHVsSize]", "MHillasSrc", "FillVsSizePost");
481 MFillH fill4a("MHHilExtOffPost [MHHillasExt]", "MHillasSrc", "FillHilExtPost");
482 MFillH fill5a("MHHilSrcOffPost [MHHillasSrc]", "MHillasSrc", "FillHilSrcPost");
483 MFillH fill6a("MHImgParOffPost [MHImagePar]", "MImagePar", "FillImgParPost");
484 MFillH fill7a("MHNewParOffPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
485 fill1a.SetNameTab("PreCut");
486 fill2a.SetNameTab("PostCut");
487 fill3a.SetNameTab("VsSize");
488 fill4a.SetNameTab("HilExt");
489 fill5a.SetNameTab("HilSrc");
490 fill6a.SetNameTab("ImgPar");
491 fill7a.SetNameTab("NewPar");
492
493 MPrint print2("MEffectiveOnTime");
494 print2.EnableSkip();
495
496 // How to get source position from off- and on-data?
497 MSrcPosCalc scalc;
498 if (fIsWobble)
499 scalc.SetWobbleMode(); /********************/
500 MHillasCalc hcalc;
501 MHillasCalc hcalc2("MHillasCalcAnti");
502 hcalc.SetFlags(MHillasCalc::kCalcHillasSrc);
503 hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc);
504 hcalc2.SetNameHillasSrc("MHillasSrcAnti");
505 hcalc2.SetNameSrcPosCam("MSrcPosAnti");
506
507 MTaskList tlist2;
508 tlist2.AddToList(&scalc);
509 tlist2.AddToList(&hcalc);
510 if (fIsWobble)
511 tlist2.AddToList(&hcalc2);
512 //tlist2.AddToList(&taskenv1);
513 tlist2.AddToList(&taskenv2);
514 tlist2.AddToList(&cont0);
515 if (write0)
516 tlist2.AddToList(write0);
517 if (!fWriteOnly)
518 tlist2.AddToList(&fill1a);
519 tlist2.AddToList(&cont1);
520 if (!fWriteOnly && !fIsWobble)
521 tlist2.AddToList(&ffs);
522 tlist2.AddToList(&cont2);
523 if (!fWriteOnly)
524 {
525 tlist2.AddToList(&fill2a);
526 if (fFullDisplay)
527 {
528 tlist2.AddToList(&fill3a);
529 tlist2.AddToList(&fill4a);
530 tlist2.AddToList(&fill5a);
531 tlist2.AddToList(&fill6a);
532 tlist2.AddToList(&fill7a);
533 }
534 }
535 if (!fWriteOnly)
536 tlist2.AddToList(&falpha);
537 tlist2.AddToList(&cont3);
538 if (write1)
539 tlist2.AddToList(write1);
540
541 tlist.AddToList(&readoff);
542 tlist.AddToList(&print2, "EffectiveOnTime");
543 tlist.AddToList(&tlist2, "Events");
544
545 par.SetVal(0);
546
547 // Create and setup the eventloop
548 MEvtLoop evtloop(fName);
549 evtloop.SetParList(&plist);
550 evtloop.SetDisplay(fDisplay);
551 evtloop.SetLogStream(fLog);
552 if (!SetupEnv(evtloop))
553 return kFALSE;
554
555 TObjArray cont;
556 cont.Add(&cont0);
557 cont.Add(&cont1);
558 cont.Add(&cont2);
559 cont.Add(&cont3);
560 //if (taskenv1.GetTask())
561 // cont.Add(taskenv1.GetTask());
562 if (taskenv2.GetTask())
563 cont.Add(taskenv2.GetTask());
564
565 if (!WriteTasks(set.GetNumAnalysis(), cont))
566 return kFALSE;
567
568 if (set.HasOffSequences() || fIsWobble)
569 {
570 // Execute first analysis
571 if (!evtloop.Eventloop(fMaxEvents))
572 {
573 *fLog << err << GetDescriptor() << ": Processing of off-sequences failed." << endl;
574 return kFALSE;
575 }
576
577 tlist.PrintStatistics();
578
579 if (!evtloop.GetDisplay())
580 {
581 *fLog << err << GetDescriptor() << ": Execution stopped by user." << endl;
582 return kFALSE;
583 }
584
585 //plist.FindObject("MTimeEffectiveOnTime")->Clear();
586 }
587
588 // ------------- Loop On Data --------------------
589 MReadReports readondata;
590 readondata.AddTree("Events", "MTime.", kTRUE);
591 readondata.AddTree("Drive");
592 readondata.AddTree("EffectiveOnTime");
593
594 MReadMarsFile readonmc("Events");
595 readonmc.DisableAutoScheme();
596
597 MRead &readon = fIsMonteCarlo ? (MRead&)readonmc : (MRead&)readondata;
598 set.AddFilesOn(readon);
599
600 if (fIsWobble)
601 scalc.SetWobbleMode(kFALSE); /********************/
602
603 MFillH fill1b("MHHillasOnPre [MHHillas]", "MHillas", "FillHillasPre");
604 MFillH fill2b("MHHillasOnPost [MHHillas]", "MHillas", "FillHillasPost");
605 MFillH fill3b("MHVsSizeOnPost [MHVsSize]", "MHillasSrc", "FillVsSizePost");
606 MFillH fill4b("MHHilExtOnPost [MHHillasExt]", "MHillasSrc", "FillHilExtPost");
607 MFillH fill5b("MHHilSrcOnPost [MHHillasSrc]", "MHillasSrc", "FillHilSrcPost");
608 MFillH fill6b("MHImgParOnPost [MHImagePar]", "MImagePar", "FillImgParPost");
609 MFillH fill7b("MHNewParOnPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
610 fill1b.SetNameTab("PreCut");
611 fill2b.SetNameTab("PostCut");
612 fill3b.SetNameTab("VsSize");
613 fill4b.SetNameTab("HilExt");
614 fill5b.SetNameTab("HilSrc");
615 fill6b.SetNameTab("ImgPar");
616 fill7b.SetNameTab("NewPar");
617 fill1b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
618 fill2b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
619 fill3b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
620 fill4b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
621 fill5b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
622 fill6b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
623 fill7b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
624
625 /*
626 MHVsTime hvs("MEffectiveOnTime.fVal");
627 hvs.SetTitle("Effective On-Time vs. Time;;T_{on}");
628 MFillH fillvs(&hvs, "MTimeEffectiveOnTime", "FillOnTime");
629 fillvs.SetNameTab("OnTime");
630 */
631 MH3 hvs("MPointingPos.fZd");
632 hvs.SetName("Theta");
633 hvs.SetTitle("Effective On-Time vs. Zenith Angle;\\Theta [\\circ];T_{on} [s]");
634 MFillH fillvs(&hvs, "", "FillOnTime");
635 fillvs.SetWeight("MEffectiveOnTime");
636 fillvs.SetNameTab("OnTime");
637
638 /*
639 MParameterD weight;
640 weight.SetVal(-1);
641 fill2a.SetWeight(&weight);
642 fill3a.SetWeight(&weight);
643 fill4a.SetWeight(&weight);
644 fill5a.SetWeight(&weight);
645 fill6a.SetWeight(&weight);
646 fill7a.SetWeight(&weight);
647 if (fSubstraction)
648 {
649 fill2a.SetNameTab("PostCut-");
650 fill3a.SetNameTab("VsSize-");
651 fill4a.SetNameTab("HilExt-");
652 fill5a.SetNameTab("HilSrc-");
653 fill6a.SetNameTab("ImgPar-");
654 fill7a.SetNameTab("NewPar-");
655 }
656 */
657 MHAlpha halphaon("MHAlpha");
658 halphaon.ForceUsingSize();
659 plist.AddToList(&halphaon);
660
661 MFillH falpha2("MHAlpha", "MHillasSrc", "FillAlpha");
662 MFillH ffs2("MHFalseSource", "MHillas", "FillFS");
663
664 tlist.Replace(&readon);
665 if (!fWriteOnly)
666 {
667 tlist2.Replace(&fill1b);
668/* if (fIsWobble)
669 {
670 tlist2.AddToListAfter(&fill2b, &fill2a);
671 tlist2.AddToListAfter(&fill3b, &fill3a);
672 }
673 else
674 */
675 tlist2.Replace(&fill2b);
676 if (fFullDisplay)
677 {
678 tlist2.Replace(&fill3b);
679 tlist2.Replace(&fill4b);
680 tlist2.Replace(&fill5b);
681 tlist2.Replace(&fill6b);
682 tlist2.Replace(&fill7b);
683 }
684 tlist2.Replace(&falpha2);
685 if (!fIsWobble)
686 tlist2.Replace(&ffs2);
687
688 if (!fIsMonteCarlo)
689 tlist.AddToList(&fillvs, "EffectiveOnTime");
690 }
691
692 par.SetVal(1);
693
694 // Execute first analysis
695 if (!evtloop.Eventloop(fMaxEvents))
696 {
697 *fLog << err << GetDescriptor() << ": Processing of on-sequences failed." << endl;
698 return kFALSE;
699 }
700
701 if (write0)
702 delete write0;
703 if (write1)
704 delete write1;
705
706 tlist.PrintStatistics();
707
708 DisplayResult(plist);
709
710 // FIXME: Perform fit and plot energy dependant alpha plots
711 // and fit result to new tabs!
712 if (!WriteResult(plist, set.GetNumAnalysis()))
713 return kFALSE;
714
715 *fLog << all << GetDescriptor() << ": Done." << endl;
716 *fLog << endl << endl;
717
718 return kTRUE;
719}
Note: See TracBrowser for help on using the repository browser.