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