source: trunk/MagicSoft/Mars/macros/merpp.C@ 5111

Last change on this file since 5111 was 3957, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.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/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// merpp.C
28// =======
29//
30// This is an easy implementation of the Merging process (as root Macro)
31//
32// at the moment it reads a binary file ("rawtest.raw") which was written
33// in the DAQ raw format.
34//
35// The data are stored in root container objects (classes derived from
36// TObject like MRawRunHeader)
37//
38// This containers are written to a root file ("rawtest.root")
39//
40// It also demonstrates how you can loop over files in a single or more
41// than one directory and process them. For details see MRunIter.
42//
43/////////////////////////////////////////////////////////////////////////////
44
45void ProcessFile(TString fname)
46{
47 //
48 // create a (empty) list of parameters which can be used by the tasks
49 // and an (empty) list of tasks which should be executed
50 //
51 MTaskList tasks;
52 MParList plist;
53
54 plist.AddToList(&tasks);
55
56 //
57 // create the tasks which should be executed and add them to the list
58 // in the case you don't need parameter containers, all of them can
59 // be created by MRawFileRead::PreProcess
60 //
61 // REMARK: Don't change the order of the two instantiations.
62 // I don't have an idea why, but here it crashes the
63 // Interpreter.
64 // (Using root 2.25/03, with Cint 5.14.50 on OSF1)
65 //
66 MRawFileRead reader(fname);
67 MRawFileWrite writer(fname(0, fname.Last('.')+1) + "root", "RECREATE", fname, 1);
68 tasks.AddToList(&reader);
69 tasks.AddToList(&writer);
70
71 //
72 // create the looping object and thell it about the parameters to use
73 // and the tasks to execute
74 //
75 MEvtLoop magic;
76
77 magic.SetParList(&plist);
78
79 //
80 // Start the eventloop which reads the raw file (MRawFileRead) and
81 // write all the information into a root file (MRawFileWrite)
82 //
83 // between reading and writing we can do, transformations, checks, etc.
84 // (I'm think of a task like MRawDataCheck)
85 //
86 magic.Eventloop();
87}
88
89void merpp(const char *dirname="/home/MAGIC/online_data/rawdata/")
90{
91 MDirIter Next;
92 Next.AddDirectory(dirname, "*.raw", -1);
93
94 while (1)
95 {
96 TString fname = Next();
97 if (fname.IsNull())
98 break;
99
100 ProcessFile(fname);
101 }
102}
103
Note: See TracBrowser for help on using the repository browser.