source: trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc@ 2590

Last change on this file since 2590 was 2590, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 2.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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2002-2003
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MEventRateCalc
28//
29// This task calculates the event rates from the event times and numbers.
30//
31// It is under construction: More information comming soon....
32//
33//
34// Input Containers:
35// MTime
36//
37// Output Containers:
38// MEventRate
39// MTimeRate [MTime] (missing)
40//
41//////////////////////////////////////////////////////////////////////////////
42#include "MEventRateCalc.h"
43
44#include "MParList.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49#include "MTime.h"
50#include "MEventRate.h"
51
52ClassImp(MEventRateCalc);
53
54using namespace std;
55
56// --------------------------------------------------------------------------
57//
58// Default constructor.
59//
60MEventRateCalc::MEventRateCalc(const char *name, const char *title)
61 : fNumEvents(10000)
62{
63 fName = name ? name : "MEventRateCalc";
64 fTitle = title ? title : "Calculate trigger rate";
65}
66
67// --------------------------------------------------------------------------
68//
69// The PreProcess searches for the following input containers:
70// ...
71//
72Int_t MEventRateCalc::PreProcess(MParList *pList)
73{
74 fTime = (MTime*)pList->FindObject("MTime");
75 if (!fTime)
76 {
77 *fLog << err << "MTime not found... aborting." << endl;
78 return kFALSE;
79 }
80
81 fRate = (MEventRate*)pList->FindCreateObj("MEventRate");
82 if (!fRate)
83 return kFALSE;
84
85 fEvtNumber = 0;
86
87 return kTRUE;
88}
89
90// --------------------------------------------------------------------------
91//
92//
93#include <TSystem.h>
94Int_t MEventRateCalc::Process()
95{
96 fTime->SetTime(gSystem->Now());
97
98 const ULong_t exec = GetNumExecutions();
99
100 if (fEvtNumber>0)
101 {
102 if (exec<fEvtNumber)
103 return kTRUE;
104
105 const Double_t rate = (Double_t)fNumEvents/(*fTime - fEvtTime);
106
107 *fLog << inf << "Event Rate [Hz]: " << rate << endl;
108
109 fRate->SetRate(rate);
110 fRate->SetReadyToSave();
111 }
112
113 fEvtNumber = exec+fNumEvents;
114 fEvtTime = *fTime;
115
116 return kTRUE;
117}
Note: See TracBrowser for help on using the repository browser.