source: trunk/Mars/mraw/MRawCrateArray.cc@ 14916

Last change on this file since 14916 was 3183, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.8 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// 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::Print(Option_t *t) const
84{
85 fArray->Print();
86}
87
88void MRawCrateArray::SetSize(Int_t i)
89{
90 if (fArray->GetEntriesFast() == i)
91 return;
92
93 fArray->ExpandCreateFast(i);
94}
95
96Int_t MRawCrateArray::GetSize() const
97{
98 return fArray->GetEntriesFast();
99}
100
101// --------------------------------------------------------------------------
102//
103// Return a pointer the i-th entry in the array, without range check
104//
105MRawCrateData *MRawCrateArray::GetEntry(Int_t i)
106{
107 return (MRawCrateData*)fArray->UncheckedAt(i); // AddrAt would be with rcheck
108}
109
110// --------------------------------------------------------------------------
111//
112// Return the i-th entry in the array, with range check
113//
114MRawCrateData* &MRawCrateArray::operator[](Int_t i)
115{
116 return (MRawCrateData*&)(*fArray)[i];
117}
118
119// --------------------------------------------------------------------------
120//
121// return a pointer to the pointer of the array
122// (actually not used. You may need it if you want to write
123// the TClonesArray directly)
124//
125TClonesArray **MRawCrateArray::GetArray()
126{
127 return &fArray;
128}
Note: See TracBrowser for help on using the repository browser.