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

Last change on this file since 7175 was 7169, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 23.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, 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(kTRUE),
80 fNameHist("MHThetaSq"), 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("Hist", "MHAlpha");
261 if (halpha)
262 arr.Add((TObject*)(&halpha->GetAlphaFitter()));
263
264 const TString fname(fNameOutput.IsNull() ? Form("ganymed%08d.root", num) : fNameOutput.Data());
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// MJCut.HistName: MHAlpha
288//
289Bool_t MJCut::CheckEnvLocal()
290{
291 const TString f0(GetEnv("SummaryFile", ""));
292 const TString f1(GetEnv("ResultFile", ""));
293 if (!f0.IsNull())
294 SetNameSummaryFile(f0);
295 if (!f1.IsNull())
296 SetNameResultFile(f1);
297
298 EnableStorageOfSummary(GetEnv("SummaryFile", fStoreSummary));
299 EnableStorageOfResult(GetEnv("ResultFile", fStoreResult));
300 EnableWobbleMode(GetEnv("WobbleMode", fIsWobble));
301 EnableMonteCarloMode(GetEnv("MonteCarlo", fIsMonteCarlo));
302 EnableFullDisplay(GetEnv("FullDisplay", fFullDisplay));
303 //EnableSubstraction(GetEnv("HistogramSubstraction", fSubstraction));
304
305 SetNameHist(GetEnv("NameHist", fNameHist));
306 SetNameHistFS(GetEnv("NameHistFS", fNameHistFS));
307
308 return kTRUE;
309}
310
311// --------------------------------------------------------------------------
312//
313// Setup write to write:
314// container tree optional?
315// -------------- ---------- -----------
316// "MHillas" to "Events"
317// "MHillasSrc" to "Events"
318// "MHadronness" to "Events" yes
319// "MEnergyEst" to "Events" yes
320// "DataType" to "Events"
321//
322void MJCut::SetupWriter(MWriteRootFile *write, const char *name) const
323{
324 if (!write)
325 return;
326
327 write->SetName(name);
328 write->AddContainer("MHillas", "Events");
329 write->AddContainer("MHillasSrc", "Events");
330 write->AddContainer("MHillasExt", "Events");
331 write->AddContainer("MPointingPos", "Events");
332 write->AddContainer("MHillasSrcAnti", "Events", kFALSE);
333 write->AddContainer("MImagePar", "Events", kFALSE);
334 write->AddContainer("MNewImagePar", "Events", kFALSE);
335 write->AddContainer("MNewImagePar2", "Events", kFALSE);
336 write->AddContainer("MHadronness", "Events", kFALSE);
337 write->AddContainer("MEnergyEst", "Events", kFALSE);
338 write->AddContainer("ThetaSquared", "Events", kFALSE);
339 write->AddContainer("MMcEvt", "Events", kFALSE);
340 write->AddContainer("DataType", "Events");
341}
342
343// --------------------------------------------------------------------------
344//
345// Create a new instance of an object with name name of class
346// type fNameHist in parlist. It must derive from MHAlpha.
347// Call ForceUsingSize for it and return its pointer.
348// If something fails NULL is returned.
349//
350MHAlpha *MJCut::CreateNewHist(MParList &plist, const char *name) const
351{
352 TClass *cls = gROOT->GetClass(fNameHist);
353 if (!cls)
354 {
355 *fLog << err << "Class " << fNameHist << " not found in dictionary... abort." << endl;
356 return NULL;
357 }
358 if (!cls->InheritsFrom(MHAlpha::Class()))
359 {
360 *fLog << err << "Class " << fNameHist << " doesn't inherit from MHAlpha... abort." << endl;
361 return NULL;
362 }
363
364 const TString objname(Form("Hist%s", name));
365 MHAlpha *h = (MHAlpha*)plist.FindCreateObj(fNameHist, objname);
366 if (!h)
367 return NULL;
368
369 h->ForceUsingSize();
370
371 return h;
372}
373
374// --------------------------------------------------------------------------
375//
376// Create a new instance of an object with name name of class
377// type fNameHistFS in parlist. It must derive from MHFalseSource
378// If something fails NULL is returned.
379//
380MH *MJCut::CreateNewHistFS(MParList &plist, const char *name) const
381{
382 const TString cname(fNameHistFS.IsNull()?"MHFalseSource":fNameHistFS);
383
384 TClass *cls = gROOT->GetClass(cname);
385 if (!cls)
386 {
387 *fLog << err << "Class " << cname << " not found in dictionary... abort." << endl;
388 return NULL;
389 }
390 if (!cls->InheritsFrom("MHFalseSource"))
391 {
392 *fLog << err << "Class " << cname << " doesn't inherit from MHFalseSource... abort." << endl;
393 return NULL;
394 }
395
396 const TString objname(Form("FS%s", name));
397 return (MH*)plist.FindCreateObj(cname, objname);
398}
399
400Bool_t MJCut::Process(const MDataSet &set)
401{
402 if (!set.IsValid())
403 {
404 *fLog << err << "ERROR - DataSet invalid!" << endl;
405 return kFALSE;
406 }
407
408 CheckEnv();
409
410 // --------------------------------------------------------------------------------
411
412 *fLog << inf;
413 fLog->Separator(GetDescriptor());
414 *fLog << "Perform cuts for data set " << set.GetName() << endl;
415 *fLog << endl;
416
417 // --------------------------------------------------------------------------------
418
419 // Setup Parlist
420 MParList plist;
421 plist.AddToList(this); // take care of fDisplay!
422
423 MParameterI par("DataType");
424 plist.AddToList(&par);
425
426 // Setup Tasklist
427 MTaskList tlist;
428 plist.AddToList(&tlist);
429
430 // La Palma Magic1
431 MObservatory obs;
432 plist.AddToList(&obs);
433
434 // Possible source position (eg. Wobble Mode)
435 MPointingPos source("MSourcePos");
436 if (set.HasSource())
437 {
438 if (!set.GetSourcePos(source))
439 return kFALSE;
440 plist.AddToList(&source);
441 *fLog << inf << "Using Source Position: " << source.GetTitle() << endl;
442 }
443 else
444 *fLog << inf << "No source position applied..." << endl;
445
446 // Initialize default binnings
447 MBinning bins1(18, 0, 90, "BinningAlpha", "lin");
448 MBinning bins2(15, 10, 1e6 , "BinningEnergyEst", "log");
449 MBinning bins3(51, -0.005, 0.505, "BinningTheta", "asin");
450 MBinning bins4("BinningFalseSource");
451 MBinning bins5("BinningWidth");
452 MBinning bins6("BinningLength");
453 MBinning bins7("BinningDist");
454 MBinning bins8("BinningMaxDist");
455 MBinning bins9("BinningM3Long");
456 MBinning bins0("BinningConc1");
457 plist.AddToList(&bins1);
458 plist.AddToList(&bins2);
459 plist.AddToList(&bins3);
460 plist.AddToList(&bins4);
461 plist.AddToList(&bins5);
462 plist.AddToList(&bins6);
463 plist.AddToList(&bins7);
464 plist.AddToList(&bins8);
465 plist.AddToList(&bins9);
466 plist.AddToList(&bins0);
467
468 // --------------------------------------------------------------------------------
469
470 // Setup fitter and histograms
471 MAlphaFitter fit;
472 plist.AddToList(&fit);
473 if (fIsWobble)
474 fit.SetScaleMode(MAlphaFitter::kNone);
475
476 MHAlpha *halphaoff = CreateNewHist(plist, "Off");
477 MFillH falpha(halphaoff, "", "FillHist");
478 MH *hfsoff = CreateNewHistFS(plist, "Off");
479 MFillH ffs(hfsoff, "MHillas", "FillFS");
480
481 // FIXME: If fPathIn read cuts and energy estimator from file!
482 MContinue cont0("", "Cut0");
483 MContinue cont1("", "Cut1");
484 MContinue cont2("", "Cut2");
485 MContinue cont3("", "Cut3");
486 cont0.SetAllowEmpty();
487 cont1.SetAllowEmpty();
488 cont2.SetAllowEmpty();
489 cont3.SetAllowEmpty();
490
491 // ------------- Loop Off Data --------------------
492 MReadReports readoffdata;
493 readoffdata.AddTree("Events", "MTime.", MReadReports::kMaster);
494 readoffdata.AddTree("Drive", MReadReports::kRequired);
495 readoffdata.AddTree("EffectiveOnTime");
496
497 MReadMarsFile readoffmc("Events");
498 readoffmc.DisableAutoScheme();
499
500 MRead &readoff = fIsMonteCarlo ? (MRead&)readoffmc : (MRead&)readoffdata;
501 if (fIsWobble)
502 set.AddFilesOn(readoff);
503 else
504 set.AddFilesOff(readoff);
505
506 const TString path(Form("%s/", fPathOut.Data()));
507 TString fname0(path);
508 TString fname1(path);
509 fname0 += fNameSummary.IsNull() ? (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
510 fname1 += fNameResult.IsNull() ? (TString) Form("ganymed%08d.root", set.GetNumAnalysis()) : fNameResult;
511
512 MWriteRootFile *write0 = CanStoreSummary() ? new MWriteRootFile(fPathOut.IsNull()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW") : 0;
513 MWriteRootFile *write1 = CanStoreResult() ? new MWriteRootFile(fPathOut.IsNull()?0:fname1.Data(), fOverwrite?"RECREATE":"NEW") : 0;
514 SetupWriter(write0, "WriteAfterCut0");
515 SetupWriter(write1, "WriteAfterCut3");
516
517/*
518 MEnergyEstimate est;
519
520 MTaskEnv taskenv1("EstimateEnergy");
521 taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est);
522 */
523 MTaskEnv taskenv2("CalcHadronness");
524 taskenv2.SetDefault(fCalcHadronness);
525
526 MFillH fill1a("MHHillasOffPre [MHHillas]", "MHillas", "FillHillasPre");
527 MFillH fill2a("MHHillasOffPost [MHHillas]", "MHillas", "FillHillasPost");
528 MFillH fill3a("MHVsSizeOffPost [MHVsSize]", "MHillasSrc", "FillVsSizePost");
529 MFillH fill4a("MHHilExtOffPost [MHHillasExt]", "MHillasSrc", "FillHilExtPost");
530 MFillH fill5a("MHHilSrcOffPost [MHHillasSrc]", "MHillasSrc", "FillHilSrcPost");
531 MFillH fill6a("MHImgParOffPost [MHImagePar]", "MImagePar", "FillImgParPost");
532 MFillH fill7a("MHNewParOffPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
533 fill1a.SetNameTab("PreCut");
534 fill2a.SetNameTab("PostCut");
535 fill3a.SetNameTab("VsSize");
536 fill4a.SetNameTab("HilExt");
537 fill5a.SetNameTab("HilSrc");
538 fill6a.SetNameTab("ImgPar");
539 fill7a.SetNameTab("NewPar");
540
541 MPrint print2("MEffectiveOnTime");
542 print2.EnableSkip();
543
544 // How to get source position from off- and on-data?
545 MSrcPosCalc scalc;
546 if (fIsWobble)
547 scalc.SetWobbleMode(); /********************/
548 MHillasCalc hcalc;
549 MHillasCalc hcalc2("MHillasCalcAnti");
550 hcalc.SetFlags(MHillasCalc::kCalcHillasSrc);
551 hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc);
552 hcalc2.SetNameHillasSrc("MHillasSrcAnti");
553 hcalc2.SetNameSrcPosCam("MSrcPosAnti");
554
555 MTaskList tlist2;
556 tlist2.AddToList(&scalc);
557 tlist2.AddToList(&hcalc);
558 if (fIsWobble)
559 tlist2.AddToList(&hcalc2);
560 //tlist2.AddToList(&taskenv1);
561 tlist2.AddToList(&taskenv2);
562 tlist2.AddToList(&cont0);
563 if (write0)
564 tlist2.AddToList(write0);
565 if (!fWriteOnly)
566 tlist2.AddToList(&fill1a);
567 tlist2.AddToList(&cont1);
568 if (!fWriteOnly && (!fIsWobble || !fNameHistFS.IsNull()))
569 tlist2.AddToList(&ffs);
570 tlist2.AddToList(&cont2);
571 if (!fWriteOnly)
572 {
573 tlist2.AddToList(&fill2a);
574 if (fFullDisplay)
575 {
576 tlist2.AddToList(&fill3a);
577 tlist2.AddToList(&fill4a);
578 tlist2.AddToList(&fill5a);
579 tlist2.AddToList(&fill6a);
580 tlist2.AddToList(&fill7a);
581 }
582 }
583 if (!fWriteOnly)
584 tlist2.AddToList(&falpha);
585 tlist2.AddToList(&cont3);
586 if (write1)
587 tlist2.AddToList(write1);
588
589 tlist.AddToList(&readoff);
590 tlist.AddToList(&print2, "EffectiveOnTime");
591 tlist.AddToList(&tlist2, "Events");
592
593 par.SetVal(0);
594
595 // Create and setup the eventloop
596 MEvtLoop evtloop(fName);
597 evtloop.SetParList(&plist);
598 evtloop.SetDisplay(fDisplay);
599 evtloop.SetLogStream(fLog);
600 if (!SetupEnv(evtloop))
601 return kFALSE;
602
603 TObjArray cont;
604 cont.Add(&cont0);
605 cont.Add(&cont1);
606 cont.Add(&cont2);
607 cont.Add(&cont3);
608 //if (taskenv1.GetTask())
609 // cont.Add(taskenv1.GetTask());
610 if (taskenv2.GetTask())
611 cont.Add(taskenv2.GetTask());
612
613 if (!WriteTasks(set.GetNumAnalysis(), cont))
614 return kFALSE;
615
616 if (set.HasOffSequences() || fIsWobble)
617 {
618 // Execute first analysis
619 if (!evtloop.Eventloop(fMaxEvents))
620 {
621 *fLog << err << GetDescriptor() << ": Processing of off-sequences failed." << endl;
622 return kFALSE;
623 }
624
625 if (!evtloop.GetDisplay())
626 {
627 *fLog << err << GetDescriptor() << ": Execution stopped by user." << endl;
628 return kFALSE;
629 }
630
631 //plist.FindObject("MTimeEffectiveOnTime")->Clear();
632 }
633
634 // ------------- Loop On Data --------------------
635 MReadReports readondata;
636 readondata.AddTree("Events", "MTime.", MReadReports::kMaster);
637 readondata.AddTree("Drive", MReadReports::kRequired);
638 readondata.AddTree("EffectiveOnTime");
639
640 MReadMarsFile readonmc("Events");
641 readonmc.DisableAutoScheme();
642
643 MRead &readon = fIsMonteCarlo ? (MRead&)readonmc : (MRead&)readondata;
644 set.AddFilesOn(readon);
645
646 if (fIsWobble)
647 scalc.SetWobbleMode(kFALSE); /********************/
648
649 MFillH fill1b("MHHillasOnPre [MHHillas]", "MHillas", "FillHillasPre");
650 MFillH fill2b("MHHillasOnPost [MHHillas]", "MHillas", "FillHillasPost");
651 MFillH fill3b("MHVsSizeOnPost [MHVsSize]", "MHillasSrc", "FillVsSizePost");
652 MFillH fill4b("MHHilExtOnPost [MHHillasExt]", "MHillasSrc", "FillHilExtPost");
653 MFillH fill5b("MHHilSrcOnPost [MHHillasSrc]", "MHillasSrc", "FillHilSrcPost");
654 MFillH fill6b("MHImgParOnPost [MHImagePar]", "MImagePar", "FillImgParPost");
655 MFillH fill7b("MHNewParOnPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
656 fill1b.SetNameTab("PreCut");
657 fill2b.SetNameTab("PostCut");
658 fill3b.SetNameTab("VsSize");
659 fill4b.SetNameTab("HilExt");
660 fill5b.SetNameTab("HilSrc");
661 fill6b.SetNameTab("ImgPar");
662 fill7b.SetNameTab("NewPar");
663 fill1b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
664 fill2b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
665 fill3b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
666 fill4b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
667 fill5b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
668 fill6b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
669 fill7b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
670
671 /*
672 MHVsTime hvs("MEffectiveOnTime.fVal");
673 hvs.SetTitle("Effective On-Time vs. Time;;T_{on}");
674 MFillH fillvs(&hvs, "MTimeEffectiveOnTime", "FillOnTime");
675 fillvs.SetNameTab("OnTime");
676 */
677 MH3 hvs("MPointingPos.fZd");
678 hvs.SetName("Theta");
679 hvs.SetTitle("Effective On-Time vs. Zenith Angle;\\Theta [\\circ];T_{on} [s]");
680 MFillH fillvs(&hvs, "", "FillOnTime");
681 if (!fIsMonteCarlo)
682 fillvs.SetWeight("MEffectiveOnTime");
683 fillvs.SetNameTab("OnTime");
684
685 /*
686 MParameterD weight;
687 weight.SetVal(-1);
688 fill2a.SetWeight(&weight);
689 fill3a.SetWeight(&weight);
690 fill4a.SetWeight(&weight);
691 fill5a.SetWeight(&weight);
692 fill6a.SetWeight(&weight);
693 fill7a.SetWeight(&weight);
694 if (fSubstraction)
695 {
696 fill2a.SetNameTab("PostCut-");
697 fill3a.SetNameTab("VsSize-");
698 fill4a.SetNameTab("HilExt-");
699 fill5a.SetNameTab("HilSrc-");
700 fill6a.SetNameTab("ImgPar-");
701 fill7a.SetNameTab("NewPar-");
702 }
703 */
704 MHAlpha *halphaon=CreateNewHist(plist);
705 MFillH falpha2(halphaon, "", "FillHist");
706 MH *hfs=CreateNewHistFS(plist);
707 MFillH ffs2(hfs, "MHillas", "FillFS");
708
709 tlist.Replace(&readon);
710 if (!fWriteOnly)
711 {
712 tlist2.Replace(&fill1b);
713/* if (fIsWobble)
714 {
715 tlist2.AddToListAfter(&fill2b, &fill2a);
716 tlist2.AddToListAfter(&fill3b, &fill3a);
717 }
718 else
719 */
720 tlist2.Replace(&fill2b);
721 if (fFullDisplay)
722 {
723 tlist2.Replace(&fill3b);
724 tlist2.Replace(&fill4b);
725 tlist2.Replace(&fill5b);
726 tlist2.Replace(&fill6b);
727 tlist2.Replace(&fill7b);
728 }
729 tlist2.Replace(&falpha2);
730 if (!fIsWobble || !fNameHist.IsNull())
731 tlist2.Replace(&ffs2);
732 if (fIsWobble && !fNameHist.IsNull())
733 tlist2.RemoveFromList(&ffs);
734
735 if (!fIsMonteCarlo)
736 tlist.AddToList(&fillvs, "EffectiveOnTime");
737 else
738 tlist2.AddToListBefore(&fillvs, &scalc);
739 }
740
741 par.SetVal(1);
742
743 // Execute first analysis
744 if (!evtloop.Eventloop(fMaxEvents))
745 {
746 *fLog << err << GetDescriptor() << ": Processing of on-sequences failed." << endl;
747 return kFALSE;
748 }
749
750 if (write0)
751 delete write0;
752 if (write1)
753 delete write1;
754
755 // FIXME: Perform fit and plot energy dependant alpha plots
756 // and fit result to new tabs!
757 if (!WriteResult(plist, set.GetNumAnalysis()))
758 return kFALSE;
759
760 *fLog << all << GetDescriptor() << ": Done." << endl;
761 *fLog << endl << endl;
762
763 return kTRUE;
764}
Note: See TracBrowser for help on using the repository browser.