source: releases/Mars.2014.05.26/macros/tutorials/readrep.C@ 19594

Last change on this file since 19594 was 7159, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// This macro demonstrates how to read a central control report file.
28// (rootification, see merpp, too)
29//
30// In a second eventloop it gives an example on how to read such a root file.
31//
32//////////////////////////////////////////////////////////////////////////////
33
34void readrep(const char *fname="CC_2003_11_04_23_53_18.rep")
35{
36 //
37 // Read a report file and write containers into a root file
38 //
39 MParList plist;
40 MTaskList tlist;
41 plist.AddToList(&tlist);
42
43 MReportFileRead read(fname);
44 tlist.AddToList(&read);
45
46 read.AddToList("DAQ");
47 read.AddToList("Drive");
48 read.AddToList("Camera");
49 read.AddToList("Trigger");
50
51 MWriteRootFile write("test.root");
52 write.AddContainer("MReportCamera", "Camera");
53 write.AddContainer("MTimeCamera", "Camera");
54 write.AddContainer("MCameraAUX", "Camera");
55 write.AddContainer("MCameraCalibration", "Camera");
56 write.AddContainer("MCameraCooling", "Camera");
57 write.AddContainer("MCameraHV", "Camera");
58 write.AddContainer("MCameraLV", "Camera");
59 write.AddContainer("MCameraLids", "Camera");
60 write.AddContainer("MReportTrigger", "Trigger");
61 write.AddContainer("MTimeTrigger", "Trigger");
62 write.AddContainer("MReportDrive", "Drive");
63 write.AddContainer("MTimeDrive", "Drive");
64 tlist.AddToList(&write);
65
66 MEvtLoop evtloop;
67 evtloop.SetParList(&plist);
68
69 if (!evtloop.Eventloop())
70 return;
71
72 tlist.PrintStatistics();
73
74 // ----------------------------------------------------------------
75 //
76 // Read a report file and write containers into a root file
77 //
78 MTaskList tlist2;
79 plist.Replace(&tlist2);
80
81 // Create a tasklist to process the read events from the Camera tree
82 MTaskList list1("ProcessCamera");
83 MPrint print1("MTimeCamera");
84 list1.AddToList(&print1);
85
86 // Create a tasklist to process the read events from the Drive tree
87 MTaskList list2("ProcessDrive");
88 MPrint print2("MTimeDrive");
89 list2.AddToList(&print2);
90
91 // Tell the reader to read the trees Drive, Trigger and Camera
92 MReadReports read;
93 read.AddTree("Drive");
94 read.AddTree("Trigger");
95 read.AddTree("Camera");
96 //read.AddTree("Events", "MTime."); // for later use!
97
98 // Now (not earlier!) set the file to read!
99 read.AddFile("test.root");
100
101 // First read the events
102 tlist.AddToList(&read);
103 // Process the events from the Camera tree with the task list list1
104 tlist.AddToList(&list1, "Camera");
105 // Process the events from the Camera tree with the task list list2
106 tlist.AddToList(&list2, "Drive");
107
108 // The task lists list1 and list2 are only executed (according to
109 // their stream id - the second argument of AddToList) if a
110 // corresponding event was read and MReadReports has set the stream
111 // id accoringly. MReadReports always sets the stream id to the name
112 // of the tree from which the event was read
113
114 MEvtLoop evtloop;
115 evtloop.SetParList(&plist);
116
117 //
118 // Execute the eventloop which should print the time-stamps of the subsystem
119 // events from Drive and Camera in the correct order...
120 //
121 if (!evtloop.Eventloop())
122 return;
123
124 tlist.PrintStatistics();
125}
Note: See TracBrowser for help on using the repository browser.