Fixes in order to treat correctly event and sub-event header extensions.
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorDataTPC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Data structure for the TPC monitor tree branch                           //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24
25 #include "AliLog.h"
26 #include "AliMonitorDataTPC.h"
27
28
29 ClassImp(AliMonitorDataTPC) 
30
31
32 //_____________________________________________________________________________
33 AliMonitorDataTPC::AliMonitorDataTPC():
34   TObject(),
35   fNTracks(0),
36   fPt(NULL),
37   fEta(NULL),
38   fPhi(NULL),
39   fSize(0)
40 {
41 // default constructor
42
43 }
44
45 //_____________________________________________________________________________
46 AliMonitorDataTPC::AliMonitorDataTPC(Int_t size):
47   TObject(),
48   fNTracks(0),
49   fPt(new Float_t[size]),
50   fEta(new Float_t[size]),
51   fPhi(new Float_t[size]),
52   fSize(size)
53 {
54 // constructor with given size
55
56 }
57
58 //_____________________________________________________________________________
59 AliMonitorDataTPC::~AliMonitorDataTPC()
60 {
61 // destructor: free allocated memory
62
63   delete[] fPt;
64   delete[] fEta;
65   delete[] fPhi;
66 }
67
68 //_____________________________________________________________________________
69 void AliMonitorDataTPC::SetSize(Int_t size)
70 {
71 // set a new array size and allocate memory if necessary
72
73   if (size > fSize) {
74     delete[] fPt;
75     delete[] fEta;
76     delete[] fPhi;
77     fPt = new Float_t[size];
78     fEta = new Float_t[size];
79     fPhi = new Float_t[size];
80     fSize = size;
81   }
82 }
83
84 //_____________________________________________________________________________
85 void AliMonitorDataTPC::SetNTracks(Int_t nTracks)
86 {
87 // set the number of tracks
88
89   SetSize(nTracks);
90   fNTracks = nTracks;
91 }
92
93 //_____________________________________________________________________________
94 void AliMonitorDataTPC::SetData(Int_t i, Float_t pt, Float_t eta, Float_t phi)
95 {
96 // set the data of the i-th track
97
98   if ((i < 0) || (i >= fSize)) {
99     AliError(Form("index %d out of range (0-%d)", i, fSize));
100     return;
101   }
102   fPt[i] = pt;
103   fEta[i] = eta;
104   fPhi[i] = phi;
105 }