]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDsegmentArray.cxx
for non-miscalibrated digits, set an ad-hoc conversion factor fAdC->fToT to have...
[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 "AliLog.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   if (!fTree) {
118     AliError("Digits tree is not defined\n");
119     return kFALSE;
120   }
121
122   // Get the branch
123   fBranch = fTree->GetBranch(branchname);
124   if (!fBranch) {
125     AliError(Form("Branch %s is not defined\n",branchname));
126     return kFALSE;
127   }
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++) {
132     AliTRDdataArray *dataArray = (AliTRDdataArray *) fSegment->At(iSegment);
133     if (!dataArray) {
134       status = kFALSE;
135       break;    
136     }
137     fBranch->SetAddress(&dataArray);
138     fBranch->GetEntry(iSegment);
139   }
140
141   return status;
142
143 }
144
145 //_____________________________________________________________________________
146 Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname, TTree *tree)
147 {
148   //
149   // Stores all segments of the array in the branch <branchname> of 
150   // the digits tree <tree>
151   //
152
153   fTree = tree;
154
155   if (!fTree) {
156     AliError("Digits tree is not defined\n");
157     return kFALSE;
158   }
159
160   // Get the branch
161   fBranch = fTree->GetBranch(branchname);
162   if (!fBranch) {
163     AliError(Form("Branch %s is not defined\n",branchname));
164     return kFALSE;
165   }
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++) {
170     const AliTRDdataArray *kDataArray = 
171          (AliTRDdataArray *) AliTRDsegmentArrayBase::At(iSegment);
172     if (!kDataArray) {
173       status = kFALSE;
174       break;
175     }
176     fBranch->SetAddress(&kDataArray);
177     fBranch->Fill();
178   }
179
180   return status;
181
182 }
183
184 //_____________________________________________________________________________
185 AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det) const
186 {
187   //
188   // Returns the data array for a given detector
189   //
190
191   return ((AliTRDdataArray *) AliTRDsegmentArrayBase::At(det));
192
193 }
194
195 //_____________________________________________________________________________
196 AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla
197                                                 , Int_t cha
198                                                 , Int_t sec) const
199 {
200   //
201   // Returns the data array for a given detector
202   //
203
204   Int_t det = AliTRDgeometry::GetDetector(pla,cha,sec);
205   return GetDataArray(det);
206
207 }