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