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/2002 <mailto:tbretz@uni-sw.gwdg.de>
|
---|
19 | ! Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MEnergyEstimate
|
---|
29 | //
|
---|
30 | // Task to estimate the energy by a rule, eg:
|
---|
31 | //
|
---|
32 | // MEnergyEstimate est;
|
---|
33 | // est.SetRule("0.5 + (1.1*MHillas.fLength) + (2.2*MHillasSrc.fDist) + (3.3*MHillas.fSize) +"
|
---|
34 | // "(4.4*MHillas.fSize*MHillas.fLength) + (5.5*MHillasSrc.fDist*MHillas.fLength)");
|
---|
35 | //
|
---|
36 | // For description of rules, see MDataChain.
|
---|
37 | //
|
---|
38 | // The default rule is "MMcEvt.fEnergy"
|
---|
39 | //
|
---|
40 | // Output:
|
---|
41 | // MEnergyEst
|
---|
42 | //
|
---|
43 | /////////////////////////////////////////////////////////////////////////////
|
---|
44 | #include "MEnergyEstimate.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MDataChain.h"
|
---|
49 | #include "MEnergyEst.h"
|
---|
50 |
|
---|
51 | #include "MLog.h"
|
---|
52 | #include "MLogManip.h"
|
---|
53 |
|
---|
54 | ClassImp(MEnergyEstimate);
|
---|
55 |
|
---|
56 | using namespace std;
|
---|
57 |
|
---|
58 | // --------------------------------------------------------------------------
|
---|
59 | //
|
---|
60 | // Default constructor. Initialize fData with default rule "MMcEvt.fEnergy"
|
---|
61 | //
|
---|
62 | MEnergyEstimate::MEnergyEstimate(const char *name, const char *title)
|
---|
63 | : fData(0), fEnergy(0)
|
---|
64 | {
|
---|
65 | fName = name ? name : "MEnergyEstimate";
|
---|
66 | fTitle = title ? title : "Task to estimate the energy by a rule";
|
---|
67 |
|
---|
68 | fData = new MDataChain("MMcEvt.fEnergy");
|
---|
69 | }
|
---|
70 |
|
---|
71 | // --------------------------------------------------------------------------
|
---|
72 | //
|
---|
73 | // delete fData
|
---|
74 | //
|
---|
75 | MEnergyEstimate::~MEnergyEstimate()
|
---|
76 | {
|
---|
77 | delete fData;
|
---|
78 | }
|
---|
79 |
|
---|
80 | // --------------------------------------------------------------------------
|
---|
81 | //
|
---|
82 | // Delete fData. Initialize a new MDataChain with rule.
|
---|
83 | // Returns if fData->IsValid()
|
---|
84 | //
|
---|
85 | Bool_t MEnergyEstimate::SetRule(const char *rule)
|
---|
86 | {
|
---|
87 | delete fData;
|
---|
88 | fData = new MDataChain(rule);
|
---|
89 |
|
---|
90 | return fData->IsValid();
|
---|
91 | }
|
---|
92 |
|
---|
93 | // --------------------------------------------------------------------------
|
---|
94 | //
|
---|
95 | // Forwards SetVariables to fData to allow optimizations.
|
---|
96 | //
|
---|
97 | void MEnergyEstimate::SetVariables(const TArrayD &arr)
|
---|
98 | {
|
---|
99 | fData->SetVariables(arr);
|
---|
100 | }
|
---|
101 |
|
---|
102 | // --------------------------------------------------------------------------
|
---|
103 | //
|
---|
104 | // FindCreate "MEnergyEst"
|
---|
105 | // PreProcess fData.
|
---|
106 | //
|
---|
107 | Int_t MEnergyEstimate::PreProcess(MParList *plist)
|
---|
108 | {
|
---|
109 | fEnergy = (MEnergyEst*)plist->FindCreateObj("MEnergyEst");
|
---|
110 | if (!fEnergy)
|
---|
111 | return kFALSE;
|
---|
112 |
|
---|
113 | if (!fData->PreProcess(plist))
|
---|
114 | return kFALSE;
|
---|
115 |
|
---|
116 | *fLog << inf << "Rule for energy estimation: " << fData->GetRule() << endl;
|
---|
117 |
|
---|
118 | return kTRUE;
|
---|
119 | }
|
---|
120 |
|
---|
121 | // --------------------------------------------------------------------------
|
---|
122 | //
|
---|
123 | // Get value from fData and set it to fEnergy. SetReadyToSave for fEnergy.
|
---|
124 | // Return kCONTINUE if value is NaN (Not a Number)
|
---|
125 | //
|
---|
126 | Int_t MEnergyEstimate::Process()
|
---|
127 | {
|
---|
128 | const Double_t val = fData->GetValue();
|
---|
129 | if (TMath::IsNaN(val))
|
---|
130 | return kCONTINUE;
|
---|
131 |
|
---|
132 | fEnergy->SetEnergy(val);
|
---|
133 | fEnergy->SetReadyToSave();
|
---|
134 | return kTRUE;
|
---|
135 | }
|
---|