source: trunk/MagicSoft/Mars/manalysis/MSigmabarCalc.cc@ 4277

Last change on this file since 4277 was 2798, checked in by wittek, 21 years ago
*** empty log message ***
File size: 5.1 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): Robert Wagner, 10/2002 <rwagner@mppmu.mpg.de>
19! Author(s): Thomas Bretz, 4/2003 <tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MSigmabarCalc
29//
30// This task calculates Sigmabar using the MSigmabar container and stores
31// its extremal values together with the corresponding Theta values
32// in MSigmabarParam. For the time being, Theta is taken from a Monte
33// Carlo container. This is preliminary and to be changed ASAP.
34//
35// Input Containers:
36// MGeomCam
37// MPedPhotCam
38// MRawRunHeader
39// MMcEvt (FIXME: Must be replaced by a 'real-data' container)
40// MCerPhotEvt
41//
42// Output Containers:
43// MSigmabar
44// MSigmabarParam
45//
46/////////////////////////////////////////////////////////////////////////////
47#include "MSigmabarCalc.h"
48
49#include "MLog.h"
50#include "MLogManip.h"
51
52#include "MParList.h"
53
54#include "MGeomCam.h"
55#include "MPedPhotCam.h"
56
57#include "MSigmabar.h"
58#include "MSigmabarParam.h"
59
60#include "MMcEvt.hxx"
61
62ClassImp(MSigmabarCalc);
63
64using namespace std;
65
66// --------------------------------------------------------------------------
67//
68// Default constructor.
69//
70MSigmabarCalc::MSigmabarCalc(const char *name, const char *title)
71{
72 fName = name ? name : "MSigmabarCalc";
73 fTitle = title ? title : "Task to calculate Sigmabar";
74
75 Reset();
76}
77
78// --------------------------------------------------------------------------
79//
80// check if necessary containers exists in the Parameter list already.
81// if not create one and add them to the list
82//
83Int_t MSigmabarCalc::PreProcess(MParList *pList)
84{
85 fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
86 if (!fCam)
87 {
88 *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
89 return kFALSE;
90 }
91
92 fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
93 if (!fPed)
94 {
95 *fLog << err << "MPedPhotCam not found... aborting." << endl;
96 return kFALSE;
97 }
98
99 fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
100 if (!fRun)
101 {
102 *fLog << err << "MRawRunHeader not found... aborting." << endl;
103 return kFALSE;
104 }
105
106 // This is needed for determining min/max Theta
107 fMcEvt = (MMcEvt*)pList->FindObject(AddSerialNumber("MMcEvt"));
108 if (!fMcEvt)
109 {
110 *fLog << warn << "MMcEvt not found... aborting." << endl;
111 fThetaMin = 0;
112 fThetaMax = 90;
113 }
114
115 fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
116 if (!fEvt)
117 {
118 *fLog << err << "MCerPhotEvt not found... aborting." << endl;
119 return kFALSE;
120 }
121
122 fSig = (MSigmabar*)pList->FindCreateObj(AddSerialNumber("MSigmabar"));
123 if (!fSig)
124 return kFALSE;
125
126 // FIXME: This might have to change in a
127 // 'more-than-one-telescope-environment'
128 fSigParam = (MSigmabarParam*)pList->FindCreateObj(AddSerialNumber("MSigmabarParam"));
129 if (!fSigParam)
130 return kFALSE;
131
132
133 return kTRUE;
134}
135
136// --------------------------------------------------------------------------
137//
138// Calculating a new Sigmabar is not necessary on event basis as long as
139// we deal with CT1 data. Therefore, the real calculation is done in
140// the ReInit function. Process just takes care for finding the extremal
141// values. Preliminary.
142//
143Int_t MSigmabarCalc::Process()
144{
145 const Double_t rc = fSig->Calc(*fCam, *fPed, *fEvt);
146
147 if (rc>fSigmabarMax) fSigmabarMax=rc;
148 if (rc<fSigmabarMin) fSigmabarMin=rc;
149
150 if (!fMcEvt)
151 return kTRUE;
152
153 const Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
154
155 if (theta>fSigmabarMax) fSigmabarMax=theta;
156 if (theta<fSigmabarMax) fSigmabarMin=theta;
157
158 return kTRUE;
159}
160
161// --------------------------------------------------------------------------
162//
163// Calculates Sigmabar (for CT1 only needed at Reinit, i.e. when reading
164// a new file)
165//
166Bool_t MSigmabarCalc::ReInit(MParList *pList)
167{
168 fSigParam->SetParams(1, fSigmabarMin, fSigmabarMax, fThetaMin, fThetaMax);
169 fSigParam->SetRunNumber(fRun->GetRunNumber());
170
171 Reset();
172
173 return kTRUE;
174}
175
176void MSigmabarCalc::Reset()
177{
178 if (!fMcEvt)
179 return;
180
181 fThetaMin = FLT_MAX;
182 fThetaMax = 0;
183 fSigmabarMin = FLT_MAX;
184 fSigmabarMax = 0;
185}
186
Note: See TracBrowser for help on using the repository browser.