]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | /* | |
17 | $Log$ | |
793ff80c | 18 | |
19 | Revision 1.1.4.5 2000/10/15 23:40:01 cblume | |
20 | Remove AliTRDconst | |
21 | ||
22 | Revision 1.1.4.4 2000/10/06 16:49:46 cblume | |
23 | Made Getters const | |
24 | ||
25 | Revision 1.1.4.3 2000/10/04 16:34:58 cblume | |
26 | Replace include files by forward declarations | |
27 | ||
28 | Revision 1.1.4.2 2000/09/22 14:49:49 cblume | |
29 | Adapted to tracking code | |
30 | ||
31 | Revision 1.5 2000/10/02 21:28:19 fca | |
32 | Removal of useless dependecies via forward declarations | |
33 | ||
34 | Revision 1.4 2000/06/09 11:10:07 cblume | |
35 | Compiler warnings and coding conventions, next round | |
36 | ||
37 | Revision 1.3 2000/06/08 18:32:58 cblume | |
38 | Make code compliant to coding conventions | |
39 | ||
40 | Revision 1.2 2000/05/08 16:17:27 cblume | |
41 | Merge TRD-develop | |
42 | ||
43 | Revision 1.1.4.1 2000/05/08 15:08:03 cblume | |
44 | Remove the class AliTRDcluster | |
45 | ||
94de3818 | 46 | Revision 1.4 2000/06/09 11:10:07 cblume |
47 | Compiler warnings and coding conventions, next round | |
48 | ||
dd9a6ee3 | 49 | Revision 1.3 2000/06/08 18:32:58 cblume |
50 | Make code compliant to coding conventions | |
51 | ||
8230f242 | 52 | Revision 1.2 2000/05/08 16:17:27 cblume |
53 | Merge TRD-develop | |
54 | ||
6f1e466d | 55 | Revision 1.1.4.1 2000/05/08 15:08:03 cblume |
56 | Remove the class AliTRDcluster | |
57 | ||
58 | Revision 1.1 2000/02/28 18:57:58 cblume | |
59 | Add new TRD classes | |
60 | ||
f7336fa3 | 61 | */ |
62 | ||
63 | /////////////////////////////////////////////////////////////////////////////// | |
64 | // // | |
65 | // TRD cluster finder base class // | |
66 | // // | |
67 | /////////////////////////////////////////////////////////////////////////////// | |
68 | ||
94de3818 | 69 | #include <TROOT.h> |
70 | #include <TTree.h> | |
793ff80c | 71 | #include <TFile.h> |
f7336fa3 | 72 | |
94de3818 | 73 | #include "AliRun.h" |
f7336fa3 | 74 | #include "AliTRD.h" |
75 | #include "AliTRDclusterizer.h" | |
793ff80c | 76 | #include "AliTRDrecPoint.h" |
77 | #include "AliTRDgeometry.h" | |
f7336fa3 | 78 | |
79 | ClassImp(AliTRDclusterizer) | |
80 | ||
81 | //_____________________________________________________________________________ | |
82 | AliTRDclusterizer::AliTRDclusterizer():TNamed() | |
83 | { | |
84 | // | |
85 | // AliTRDclusterizer default constructor | |
86 | // | |
87 | ||
88 | fInputFile = NULL; | |
89 | fEvent = 0; | |
90 | ||
91 | } | |
92 | ||
93 | //_____________________________________________________________________________ | |
94 | AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title) | |
95 | :TNamed(name, title) | |
96 | { | |
97 | // | |
98 | // AliTRDclusterizer default constructor | |
99 | // | |
100 | ||
101 | fInputFile = NULL; | |
102 | fEvent = 0; | |
103 | ||
104 | Init(); | |
105 | ||
106 | } | |
107 | ||
8230f242 | 108 | //_____________________________________________________________________________ |
dd9a6ee3 | 109 | AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c) |
8230f242 | 110 | { |
111 | // | |
112 | // AliTRDclusterizer copy constructor | |
113 | // | |
114 | ||
dd9a6ee3 | 115 | ((AliTRDclusterizer &) c).Copy(*this); |
8230f242 | 116 | |
117 | } | |
118 | ||
f7336fa3 | 119 | //_____________________________________________________________________________ |
120 | AliTRDclusterizer::~AliTRDclusterizer() | |
121 | { | |
8230f242 | 122 | // |
123 | // AliTRDclusterizer destructor | |
124 | // | |
f7336fa3 | 125 | |
126 | if (fInputFile) { | |
127 | fInputFile->Close(); | |
128 | delete fInputFile; | |
129 | } | |
130 | ||
131 | } | |
132 | ||
8230f242 | 133 | //_____________________________________________________________________________ |
dd9a6ee3 | 134 | AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c) |
135 | { | |
136 | // | |
137 | // Assignment operator | |
138 | // | |
139 | ||
140 | if (this != &c) ((AliTRDclusterizer &) c).Copy(*this); | |
141 | return *this; | |
142 | ||
143 | } | |
144 | ||
145 | //_____________________________________________________________________________ | |
146 | void AliTRDclusterizer::Copy(TObject &c) | |
8230f242 | 147 | { |
148 | // | |
149 | // Copy function | |
150 | // | |
151 | ||
dd9a6ee3 | 152 | ((AliTRDclusterizer &) c).fInputFile = NULL; |
153 | ((AliTRDclusterizer &) c).fEvent = 0; | |
8230f242 | 154 | |
155 | } | |
156 | ||
f7336fa3 | 157 | //_____________________________________________________________________________ |
158 | void AliTRDclusterizer::Init() | |
159 | { | |
160 | // | |
161 | // Initializes the cluster finder | |
162 | // | |
163 | ||
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
167 | Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent) | |
168 | { | |
169 | // | |
170 | // Opens a ROOT-file with TRD-hits and reads in the digits-tree | |
171 | // | |
172 | ||
173 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
174 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); | |
175 | if (!fInputFile) { | |
176 | printf("AliTRDclusterizer::Open -- "); | |
177 | printf("Open the ALIROOT-file %s.\n",name); | |
178 | fInputFile = new TFile(name,"UPDATE"); | |
179 | } | |
180 | else { | |
181 | printf("AliTRDclusterizer::Open -- "); | |
182 | printf("%s is already open.\n",name); | |
183 | } | |
184 | ||
185 | // Get AliRun object from file or create it if not on file | |
186 | //if (!gAlice) { | |
187 | gAlice = (AliRun*) fInputFile->Get("gAlice"); | |
188 | if (gAlice) { | |
189 | printf("AliTRDclusterizer::Open -- "); | |
190 | printf("AliRun object found on file.\n"); | |
191 | } | |
192 | else { | |
193 | printf("AliTRDclusterizer::Open -- "); | |
194 | printf("Could not find AliRun object.\n"); | |
195 | return kFALSE; | |
196 | } | |
197 | //} | |
198 | ||
199 | fEvent = nEvent; | |
200 | ||
201 | // Import the Trees for the event nEvent in the file | |
202 | Int_t nparticles = gAlice->GetEvent(fEvent); | |
203 | if (nparticles <= 0) { | |
204 | printf("AliTRDclusterizer::Open -- "); | |
205 | printf("No entries in the trees for event %d.\n",fEvent); | |
206 | return kFALSE; | |
207 | } | |
208 | ||
209 | return kTRUE; | |
210 | ||
211 | } | |
212 | ||
213 | //_____________________________________________________________________________ | |
793ff80c | 214 | Bool_t AliTRDclusterizer::WriteClusters(Int_t det) |
f7336fa3 | 215 | { |
216 | // | |
793ff80c | 217 | // Fills TRDrecPoints branch in TRDrecPoints## tree with rec. points |
218 | // found in detector = det. For det=-1 writes the tree. | |
219 | // For det=-2 recreates the tree. | |
220 | ||
221 | Char_t treeName[14]; | |
222 | sprintf(treeName,"TRDrecPoints%d", fEvent); | |
223 | ||
224 | if (det == -2) { | |
225 | fInputFile->Delete(treeName); | |
226 | TTree *tree = new TTree(treeName,"Tree with TRD rec. points"); | |
227 | tree->Write(); | |
228 | return kTRUE; | |
229 | } | |
f7336fa3 | 230 | |
793ff80c | 231 | TTree *tree=(TTree*)fInputFile->Get(treeName); |
232 | TBranch *branch=tree->GetBranch("TRDrecPoints"); | |
f7336fa3 | 233 | |
793ff80c | 234 | if(!branch) { |
235 | TObjArray *ioArray = 0; | |
236 | branch = tree->Branch("TRDrecPoints","TObjArray",&ioArray,32000,0); | |
237 | } | |
238 | ||
239 | if ((det >= 0) && (det < AliTRDgeometry::Ndet())) { | |
240 | ||
241 | AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
242 | Int_t nRecPoints = TRD->RecPoints()->GetEntriesFast(); | |
243 | TObjArray *fDetRecPoints = new TObjArray(400); | |
244 | ||
245 | for (Int_t i=0; i<nRecPoints; i++) { | |
246 | AliTRDrecPoint *p=(AliTRDrecPoint*)TRD->RecPoints()->UncheckedAt(i); | |
247 | if(det == p->GetDetector()) fDetRecPoints->AddLast(p); | |
248 | else printf("attempt to write a RecPoint with unexpected detector index"); | |
249 | } | |
250 | ||
251 | branch->SetAddress(&fDetRecPoints); | |
252 | tree->Fill(); | |
253 | return kTRUE; | |
254 | } | |
255 | ||
256 | if (det == -1) { | |
257 | ||
258 | printf("\rAliTRDclusterizer::WriteClusters -- "); | |
259 | printf("Writing the cluster tree %-18s for event %d.\n" | |
260 | ,tree->GetName(),fEvent); | |
261 | ||
262 | tree->Write(); | |
263 | return kTRUE; | |
264 | } | |
265 | ||
266 | printf("\rAliTRDclusterizer::WriteClusters -- "); | |
267 | printf("Unexpected detector index %d.\n", det); | |
268 | return kFALSE; | |
f7336fa3 | 269 | |
270 | } | |
793ff80c | 271 | |
272 | ||
273 |