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

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