| 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 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
|
|---|
| 19 | ! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MHillasSrcCalc
|
|---|
| 29 | //
|
|---|
| 30 | // Task to calculate the source dependant part of the hillas parameters
|
|---|
| 31 | //
|
|---|
| 32 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MHillasSrcCalc.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <fstream.h>
|
|---|
| 36 |
|
|---|
| 37 | #include "MParList.h"
|
|---|
| 38 |
|
|---|
| 39 | #include "MSrcPosCam.h"
|
|---|
| 40 | #include "MHillasSrc.h"
|
|---|
| 41 |
|
|---|
| 42 | #include "MLog.h"
|
|---|
| 43 | #include "MLogManip.h"
|
|---|
| 44 |
|
|---|
| 45 | ClassImp(MHillasSrcCalc);
|
|---|
| 46 |
|
|---|
| 47 | static const TString gsDefName = "MHillasSrcCalc";
|
|---|
| 48 | static const TString gsDefTitle = "Calculate position dependant image parameters";
|
|---|
| 49 |
|
|---|
| 50 | // -------------------------------------------------------------------------
|
|---|
| 51 | //
|
|---|
| 52 | // Default constructor. The first argument is the name of a container
|
|---|
| 53 | // containing the source position in the camera plain (MScrPosCam).
|
|---|
| 54 | // The default is "MSrcPosCam". hil is the name of a container
|
|---|
| 55 | // of type MHillasSrc (or derived) in which the parameters are stored
|
|---|
| 56 | // The default is "MHillasSrc"
|
|---|
| 57 | //
|
|---|
| 58 | MHillasSrcCalc::MHillasSrcCalc(const char *src, const char *hil,
|
|---|
| 59 | const char *name, const char *title)
|
|---|
| 60 | : fHillas(NULL), fSrcPos(NULL), fHillasSrc(NULL)
|
|---|
| 61 | {
|
|---|
| 62 | fName = name ? name : gsDefName.Data();
|
|---|
| 63 | fTitle = title ? title : gsDefTitle.Data();
|
|---|
| 64 |
|
|---|
| 65 | fSrcName = src;
|
|---|
| 66 | fHillasName = hil;
|
|---|
| 67 | fHillasInput = "MHillas";
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | // -------------------------------------------------------------------------
|
|---|
| 71 | //
|
|---|
| 72 | Bool_t MHillasSrcCalc::PreProcess(MParList *pList)
|
|---|
| 73 | {
|
|---|
| 74 | fHillas = (MHillas*)pList->FindObject(fHillasInput, "MHillas");
|
|---|
| 75 | if (!fHillas)
|
|---|
| 76 | {
|
|---|
| 77 | *fLog << err << dbginf << "MHillas not found... aborting." << endl;
|
|---|
| 78 | return kFALSE;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | fSrcPos = (MSrcPosCam*)pList->FindObject(fSrcName, "MSrcPosCam");
|
|---|
| 82 | if (!fSrcPos)
|
|---|
| 83 | {
|
|---|
| 84 | *fLog << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
|
|---|
| 85 | return kFALSE;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", fHillasName);
|
|---|
| 89 | if (!fHillasSrc)
|
|---|
| 90 | return kFALSE;
|
|---|
| 91 |
|
|---|
| 92 | fHillasSrc->SetSrcPos(fSrcPos);
|
|---|
| 93 |
|
|---|
| 94 | fErrors = 0;
|
|---|
| 95 |
|
|---|
| 96 | return kTRUE;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | // -------------------------------------------------------------------------
|
|---|
| 100 | //
|
|---|
| 101 | Bool_t MHillasSrcCalc::Process()
|
|---|
| 102 | {
|
|---|
| 103 |
|
|---|
| 104 | if (!fHillasSrc->Calc(fHillas))
|
|---|
| 105 | {
|
|---|
| 106 | fErrors++;
|
|---|
| 107 | return kCONTINUE;
|
|---|
| 108 |
|
|---|
| 109 | }
|
|---|
| 110 | return kTRUE;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | // --------------------------------------------------------------------------
|
|---|
| 114 | //
|
|---|
| 115 | // Prints some statistics about the hillas calculation. The percentage
|
|---|
| 116 | // is calculated with respect to the number of executions of this task.
|
|---|
| 117 | //
|
|---|
| 118 | Bool_t MHillasSrcCalc::PostProcess()
|
|---|
| 119 | {
|
|---|
| 120 | if (GetNumExecutions()==0)
|
|---|
| 121 | return kTRUE;
|
|---|
| 122 |
|
|---|
| 123 | *fLog << inf << endl;
|
|---|
| 124 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
|---|
| 125 | *fLog << dec << setfill(' ');
|
|---|
| 126 | *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: Dist==0" << endl;
|
|---|
| 127 | *fLog << endl;
|
|---|
| 128 |
|
|---|
| 129 | return kTRUE;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | // --------------------------------------------------------------------------
|
|---|
| 133 | //
|
|---|
| 134 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
|---|
| 135 | // to a macro. In the original root implementation it is used to write
|
|---|
| 136 | // gui elements to a macro-file.
|
|---|
| 137 | //
|
|---|
| 138 | void MHillasSrcCalc::StreamPrimitive(ofstream &out) const
|
|---|
| 139 | {
|
|---|
| 140 | if (fHillas)
|
|---|
| 141 | fHillas->SavePrimitive(out);
|
|---|
| 142 |
|
|---|
| 143 | if (fSrcPos)
|
|---|
| 144 | fSrcPos->SavePrimitive(out);
|
|---|
| 145 |
|
|---|
| 146 | if (fHillasSrc)
|
|---|
| 147 | fHillasSrc->SavePrimitive(out);
|
|---|
| 148 |
|
|---|
| 149 | out << " MHillasSrcCalc " << GetUniqueName() << "(";
|
|---|
| 150 |
|
|---|
| 151 | if (fSrcPos)
|
|---|
| 152 | out << "&" << fSrcPos->GetUniqueName();
|
|---|
| 153 | else
|
|---|
| 154 | out << "\"" << fSrcName << "\"";
|
|---|
| 155 |
|
|---|
| 156 | out << ", ";
|
|---|
| 157 |
|
|---|
| 158 | if (fHillasSrc)
|
|---|
| 159 | out << "&" << fHillasSrc->GetUniqueName();
|
|---|
| 160 | else
|
|---|
| 161 | out << "\"" << fHillasName << "\"";
|
|---|
| 162 |
|
|---|
| 163 | if (fName!=gsDefName || fTitle!=gsDefTitle)
|
|---|
| 164 | {
|
|---|
| 165 | out << ", \"" << fName << "\"";
|
|---|
| 166 | if (fTitle!=gsDefTitle)
|
|---|
| 167 | out << ", \"" << fTitle << "\"";
|
|---|
| 168 | }
|
|---|
| 169 | out << ");" << endl;
|
|---|
| 170 | }
|
|---|