]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDsegmentArray.cxx
Macros for Simulation, Reconstruction and ESD analysis
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArray.cxx
CommitLineData
f7336fa3 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
88cb7938 16/* $Id$ */
f7336fa3 17
18///////////////////////////////////////////////////////////////////////////////
19// //
8230f242 20// Alice segment manager class //
21// //
f7336fa3 22///////////////////////////////////////////////////////////////////////////////
23
94de3818 24#include <TTree.h>
25
793ff80c 26#include "AliRun.h"
27
f7336fa3 28#include "AliTRD.h"
29#include "AliTRDgeometry.h"
30#include "AliTRDsegmentArray.h"
6244debe 31#include "AliTRDdataArray.h"
f7336fa3 32
33ClassImp(AliTRDsegmentArray)
34
35//_____________________________________________________________________________
36AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase()
37{
38 //
39 // Default constructor
40 //
41
42}
43
44//_____________________________________________________________________________
6f1e466d 45AliTRDsegmentArray::AliTRDsegmentArray(Text_t *classname, Int_t n)
46 :AliTRDsegmentArrayBase(classname,n)
f7336fa3 47{
48 //
49 // Constructor creating an array of AliTRDdataArray of size <n>
50 //
51
8230f242 52 AliTRDdataArray *dataArray;
f7336fa3 53
54 for (Int_t i = 0; i < n; i++) {
8230f242 55 dataArray = (AliTRDdataArray *) AddSegment(i);
f7336fa3 56 }
57
58}
59
8230f242 60//_____________________________________________________________________________
61AliTRDsegmentArray::AliTRDsegmentArray(AliTRDsegmentArray &a)
73ae7b59 62:AliTRDsegmentArrayBase(a)
8230f242 63{
64 //
65 // AliTRDsegmentArray copy constructor
66 //
67
68 a.Copy(*this);
69
70}
71
72//_____________________________________________________________________________
73AliTRDsegmentArray::~AliTRDsegmentArray()
74{
75 //
76 // AliTRDsegmentArray destructor
77 //
17eee78a 78
79 Delete();
80
8230f242 81}
82
83//_____________________________________________________________________________
43da34c0 84void AliTRDsegmentArray::Copy(TObject &a)
8230f242 85{
86 //
87 // Copy function
88 //
89
90 AliTRDsegmentArrayBase::Copy(a);
91
92}
93
f7336fa3 94//_____________________________________________________________________________
95void AliTRDsegmentArray::Delete()
96{
97 //
98 // Deletes all detector segments from the array
99 //
100
101 for (Int_t iDet = 0; iDet < fNSegment; iDet++) {
102 ClearSegment(iDet);
103 }
104
105}
106
107//_____________________________________________________________________________
abaf1f1d 108Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname, TTree *tree)
f7336fa3 109{
110 //
111 // Loads all segments of the array from the branch <branchname> of
abaf1f1d 112 // the digits tree <tree>
f7336fa3 113 //
114
abaf1f1d 115 fTree = tree;
116
117 // Connect the digits tree as default
118 if (!fTree) {
119 printf("AliTRDsegmentArray::LoadArray -- ");
120 printf("Use default TreeD\n");
121 fTree = gAlice->TreeD();
122 if (!fTree) return kFALSE;
123 }
f7336fa3 124
125 // Get the branch
126 fBranch = fTree->GetBranch(branchname);
127 if (!fBranch) return kFALSE;
128
129 // Loop through all segments and read them from the tree
130 Bool_t status = kTRUE;
131 for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) {
8230f242 132 AliTRDdataArray *dataArray = (AliTRDdataArray *) fSegment->At(iSegment);
133 if (!dataArray) {
f7336fa3 134 status = kFALSE;
135 break;
136 }
8230f242 137 fBranch->SetAddress(&dataArray);
f7336fa3 138 fBranch->GetEntry(iSegment);
139 }
140
141 return status;
142
143}
144
145//_____________________________________________________________________________
abaf1f1d 146Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname, TTree *tree)
f7336fa3 147{
148 //
149 // Stores all segments of the array in the branch <branchname> of
abaf1f1d 150 // the digits tree <tree>
f7336fa3 151 //
152
abaf1f1d 153 fTree = tree;
154
155 // Connect the digits tree as default
156 if (!fTree) {
157 printf("AliTRDsegmentArray::StoreArray -- ");
158 printf("Use default TreeD\n");
159 fTree = gAlice->TreeD();
160 if (!fTree) return kFALSE;
161 }
f7336fa3 162
163 // Get the branch
164 fBranch = fTree->GetBranch(branchname);
165 if (!fBranch) return kFALSE;
166
167 // Loop through all segments and fill them into the tree
168 Bool_t status = kTRUE;
169 for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) {
8230f242 170 const AliTRDdataArray *kDataArray =
f7336fa3 171 (AliTRDdataArray *) AliTRDsegmentArrayBase::At(iSegment);
8230f242 172 if (!kDataArray) {
f7336fa3 173 status = kFALSE;
174 break;
175 }
8230f242 176 fBranch->SetAddress(&kDataArray);
f7336fa3 177 fBranch->Fill();
178 }
179
180 return status;
181
182}
183
184//_____________________________________________________________________________
793ff80c 185AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det) const
f7336fa3 186{
187 //
188 // Returns the data array for a given detector
189 //
190
191 return ((AliTRDdataArray *) AliTRDsegmentArrayBase::At(det));
192
193}
194
195//_____________________________________________________________________________
793ff80c 196AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla
197 , Int_t cha, Int_t sec) const
f7336fa3 198{
199 //
200 // Returns the data array for a given detector
201 //
202
203 if (gAlice) {
204
8230f242 205 AliTRDgeometry *geo = ((AliTRD*) gAlice->GetDetector("TRD"))->GetGeometry();
206 Int_t det = geo->GetDetector(pla,cha,sec);
f7336fa3 207 return GetDataArray(det);
208
209 }
210 else {
211
212 printf("AliTRDsegmentArray::GetDigits -- ");
213 printf("gAlice is not defined\n");
214 return NULL;
215
216 }
217
218}