source: branches/Mars_McMismatchStudy/macros/tutorials/evtrate.C@ 18558

Last change on this file since 18558 was 7159, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 2.2 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, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////////
26//
27// evtrate.C
28// =========
29//
30// Example macro how to calulate the eventrate (per event) and display
31// the result versus time.
32//
33// As an input you need a merpped raw-data file containing correct times.
34// The output is the plot: Eventrate vs. time.
35//
36///////////////////////////////////////////////////////////////////////////
37
38void evtrate()
39{
40 // Setup parameter- and tasklist
41 MParList plist;
42 MTaskList tlist;
43 plist.AddToList(&tlist);
44
45 // Setup reading task
46 MReadMarsFile read("Events");
47 read.DisableAutoScheme();
48 read.AddFile("test-time.root");
49
50 // Setup event rate calculator
51 MEventRateCalc calc;
52 // Setup number of events to be averaged
53 calc.SetNumEvents(200);
54
55 // Setup histogram to be filles with rate
56 MHVsTime rate("MEventRate.fRate");
57
58 // Setup task to fill the histogram
59 MFillH fill(&rate, "MTime");
60
61 // Setup tasklist
62 tlist.AddToList(&read);
63 tlist.AddToList(&calc);
64 tlist.AddToList(&fill);
65
66 // Execute your eventloop
67 MEvtLoop loop;
68 loop.SetParList(&plist);
69
70 if (!loop.Eventloop())
71 return;
72
73 // print some execution statistics
74 tlist.PrintStatistics();
75
76 // Draw result
77 rate.DrawClone();
78}
Note: See TracBrowser for help on using the repository browser.