source: trunk/MagicSoft/Mars/mraw/MRawCrateArray.cc@ 2471

Last change on this file since 2471 was 1082, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 3.6 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@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MRawCrateArray
28//
29// This class exists to make it possible to read in the crate data
30// TClones Array. In principal we can directly write the TClonesArray
31// to the root file, but when we read in again the root file we cannot
32// put the TClonesArray into our parameter list, becaus it isn't derived
33// from MParContainer. This class is derived from MParContainer and can be
34// put in the list. The TClones Array containes conatiners which store
35// the information about one crate (MRawCrateData).
36//
37/////////////////////////////////////////////////////////////////////////////
38#include "MRawCrateArray.h"
39
40#include <TClonesArray.h>
41
42#include "MLog.h"
43#include "MRawCrateData.h"
44
45ClassImp(MRawCrateArray);
46
47// --------------------------------------------------------------------------
48//
49// Default Constructor. It creates the TClonesArray which is used to store
50// the crate data.
51//
52MRawCrateArray::MRawCrateArray(const char *name, const char *title)
53{
54 fName = name ? name : "MRawCrateArray";
55 fTitle = title ? title : "Array of MRawCrateData Information";
56
57 //
58 // craete an (almost) empty array. The size is easily determined
59 // while filling the array
60 //
61 fArray = new TClonesArray("MRawCrateData", 0);
62}
63
64// --------------------------------------------------------------------------
65//
66// Destructor. Deletes the TClones Array which stores the crate information
67//
68MRawCrateArray::~MRawCrateArray()
69{
70 // FIXME: Is the contained data deleted, too?
71 delete fArray;
72}
73
74// --------------------------------------------------------------------------
75//
76// clear the entries in the TClonesArray
77//
78void MRawCrateArray::Clear(Option_t *opt)
79{
80 fArray->Clear();
81}
82
83void MRawCrateArray::SetSize(Int_t i)
84{
85 if (fArray->GetEntriesFast() == i)
86 return;
87
88 fArray->ExpandCreateFast(i);
89}
90
91// --------------------------------------------------------------------------
92//
93// Return a pointer the i-th entry in the array, without range check
94//
95MRawCrateData *MRawCrateArray::GetEntry(Int_t i)
96{
97 return (MRawCrateData*)fArray->UncheckedAt(i); // AddrAt would be with rcheck
98}
99
100// --------------------------------------------------------------------------
101//
102// Return the i-th entry in the array, with range check
103//
104MRawCrateData* &MRawCrateArray::operator[](Int_t i)
105{
106 return (MRawCrateData*&)(*fArray)[i];
107}
108
109// --------------------------------------------------------------------------
110//
111// return a pointer to the pointer of the array
112// (actually not used. You may need it if you want to write
113// the TClonesArray directly)
114//
115TClonesArray **MRawCrateArray::GetArray()
116{
117 return &fArray;
118}
119
Note: See TracBrowser for help on using the repository browser.