]>
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 | ||
88cb7938 | 16 | /* $Id$ */ |
f7336fa3 | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // TRD cluster finder base class // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
94de3818 | 24 | #include <TROOT.h> |
25 | #include <TTree.h> | |
793ff80c | 26 | #include <TFile.h> |
6d50f529 | 27 | #include <TObjArray.h> |
f7336fa3 | 28 | |
88cb7938 | 29 | #include "AliRunLoader.h" |
30 | #include "AliLoader.h" | |
6d50f529 | 31 | #include "AliLog.h" |
88cb7938 | 32 | |
f7336fa3 | 33 | #include "AliTRDclusterizer.h" |
3e1a3ad8 | 34 | #include "AliTRDcluster.h" |
793ff80c | 35 | #include "AliTRDgeometry.h" |
3551db50 | 36 | #include "AliTRDcalibDB.h" |
b43a3e17 | 37 | #include "AliTRDCommonParam.h" |
f7336fa3 | 38 | |
39 | ClassImp(AliTRDclusterizer) | |
40 | ||
41 | //_____________________________________________________________________________ | |
6d50f529 | 42 | AliTRDclusterizer::AliTRDclusterizer() |
43 | :TNamed() | |
44 | ,fRunLoader(NULL) | |
45 | ,fClusterTree(NULL) | |
46 | ,fRecPoints(NULL) | |
f7336fa3 | 47 | { |
48 | // | |
49 | // AliTRDclusterizer default constructor | |
50 | // | |
51 | ||
f7336fa3 | 52 | } |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title) | |
6d50f529 | 56 | :TNamed(name,title) |
57 | ,fRunLoader(NULL) | |
58 | ,fClusterTree(NULL) | |
59 | ,fRecPoints(NULL) | |
f7336fa3 | 60 | { |
61 | // | |
6d50f529 | 62 | // AliTRDclusterizer constructor |
f7336fa3 | 63 | // |
64 | ||
f7336fa3 | 65 | } |
66 | ||
8230f242 | 67 | //_____________________________________________________________________________ |
6d50f529 | 68 | AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c) |
69 | :TNamed(c) | |
70 | ,fRunLoader(NULL) | |
71 | ,fClusterTree(NULL) | |
72 | ,fRecPoints(NULL) | |
8230f242 | 73 | { |
74 | // | |
75 | // AliTRDclusterizer copy constructor | |
76 | // | |
77 | ||
8230f242 | 78 | } |
79 | ||
f7336fa3 | 80 | //_____________________________________________________________________________ |
81 | AliTRDclusterizer::~AliTRDclusterizer() | |
82 | { | |
8230f242 | 83 | // |
84 | // AliTRDclusterizer destructor | |
85 | // | |
f7336fa3 | 86 | |
bdbb05bb | 87 | if (fRecPoints) { |
88 | fRecPoints->Delete(); | |
89 | delete fRecPoints; | |
90 | } | |
6d50f529 | 91 | |
f7336fa3 | 92 | } |
93 | ||
8230f242 | 94 | //_____________________________________________________________________________ |
dd9a6ee3 | 95 | AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c) |
96 | { | |
97 | // | |
98 | // Assignment operator | |
99 | // | |
100 | ||
b43a3e17 | 101 | if (this != &c) { |
102 | ((AliTRDclusterizer &) c).Copy(*this); | |
103 | } | |
dd9a6ee3 | 104 | return *this; |
105 | ||
106 | } | |
107 | ||
108 | //_____________________________________________________________________________ | |
e0d47c25 | 109 | void AliTRDclusterizer::Copy(TObject &c) const |
8230f242 | 110 | { |
111 | // | |
112 | // Copy function | |
113 | // | |
114 | ||
3e1a3ad8 | 115 | ((AliTRDclusterizer &) c).fClusterTree = NULL; |
bdbb05bb | 116 | ((AliTRDclusterizer &) c).fRecPoints = NULL; |
8230f242 | 117 | |
118 | } | |
119 | ||
f7336fa3 | 120 | //_____________________________________________________________________________ |
3e1a3ad8 | 121 | Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent) |
f7336fa3 | 122 | { |
123 | // | |
3e1a3ad8 | 124 | // Opens the AliROOT file. Output and input are in the same file |
f7336fa3 | 125 | // |
6d50f529 | 126 | |
e191bb57 | 127 | TString evfoldname = AliConfig::GetDefaultEventFolderName(); |
6d50f529 | 128 | fRunLoader = AliRunLoader::GetRunLoader(evfoldname); |
129 | ||
130 | if (!fRunLoader) { | |
19dd5b2f | 131 | fRunLoader = AliRunLoader::Open(name); |
6d50f529 | 132 | } |
133 | ||
134 | if (!fRunLoader) { | |
135 | AliError(Form("Can not open session for file %s.",name)); | |
136 | return kFALSE; | |
137 | } | |
88cb7938 | 138 | |
139 | OpenInput(nEvent); | |
140 | OpenOutput(); | |
6d50f529 | 141 | |
3e1a3ad8 | 142 | return kTRUE; |
f7336fa3 | 143 | |
6d50f529 | 144 | } |
3e1a3ad8 | 145 | |
146 | //_____________________________________________________________________________ | |
88cb7938 | 147 | Bool_t AliTRDclusterizer::OpenOutput() |
3e1a3ad8 | 148 | { |
149 | // | |
150 | // Open the output file | |
151 | // | |
152 | ||
3e1a3ad8 | 153 | TObjArray *ioArray = 0; |
88cb7938 | 154 | |
155 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); | |
156 | loader->MakeTree("R"); | |
6d50f529 | 157 | |
88cb7938 | 158 | fClusterTree = loader->TreeR(); |
365d0374 | 159 | fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); |
3e1a3ad8 | 160 | |
3e1a3ad8 | 161 | return kTRUE; |
162 | ||
163 | } | |
164 | ||
25ca55ce | 165 | //_____________________________________________________________________________ |
166 | Bool_t AliTRDclusterizer::OpenOutput(TTree *clusterTree) | |
167 | { | |
168 | // | |
169 | // Connect the output tree | |
170 | // | |
171 | ||
172 | TObjArray *ioArray = 0; | |
173 | ||
174 | fClusterTree = clusterTree; | |
175 | fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); | |
176 | ||
177 | return kTRUE; | |
178 | ||
179 | } | |
180 | ||
3e1a3ad8 | 181 | //_____________________________________________________________________________ |
88cb7938 | 182 | Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent) |
f7336fa3 | 183 | { |
184 | // | |
185 | // Opens a ROOT-file with TRD-hits and reads in the digits-tree | |
186 | // | |
187 | ||
f7336fa3 | 188 | // Import the Trees for the event nEvent in the file |
bdbb05bb | 189 | fRunLoader->GetEvent(nEvent); |
88cb7938 | 190 | |
f7336fa3 | 191 | return kTRUE; |
192 | ||
193 | } | |
194 | ||
195 | //_____________________________________________________________________________ | |
793ff80c | 196 | Bool_t AliTRDclusterizer::WriteClusters(Int_t det) |
f7336fa3 | 197 | { |
198 | // | |
3e1a3ad8 | 199 | // Fills TRDcluster branch in the tree with the clusters |
793ff80c | 200 | // found in detector = det. For det=-1 writes the tree. |
a3c76cdc | 201 | // |
793ff80c | 202 | |
6d50f529 | 203 | if ((det < -1) || |
204 | (det >= AliTRDgeometry::Ndet())) { | |
205 | AliError(Form("Unexpected detector index %d.\n",det)); | |
3e1a3ad8 | 206 | return kFALSE; |
793ff80c | 207 | } |
3e1a3ad8 | 208 | |
3e1a3ad8 | 209 | TBranch *branch = fClusterTree->GetBranch("TRDcluster"); |
210 | if (!branch) { | |
793ff80c | 211 | TObjArray *ioArray = 0; |
3e1a3ad8 | 212 | branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); |
793ff80c | 213 | } |
214 | ||
6d50f529 | 215 | if ((det >= 0) && |
216 | (det < AliTRDgeometry::Ndet())) { | |
793ff80c | 217 | |
bdbb05bb | 218 | Int_t nRecPoints = RecPoints()->GetEntriesFast(); |
3e1a3ad8 | 219 | TObjArray *detRecPoints = new TObjArray(400); |
220 | ||
221 | for (Int_t i = 0; i < nRecPoints; i++) { | |
bdbb05bb | 222 | AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i); |
3e1a3ad8 | 223 | if (det == c->GetDetector()) { |
224 | detRecPoints->AddLast(c); | |
225 | } | |
226 | else { | |
6d50f529 | 227 | AliError("Attempt to write a cluster with unexpected detector index\n"); |
3e1a3ad8 | 228 | } |
793ff80c | 229 | } |
230 | ||
3e1a3ad8 | 231 | branch->SetAddress(&detRecPoints); |
232 | fClusterTree->Fill(); | |
233 | ||
d9b8978b | 234 | delete detRecPoints; |
235 | ||
793ff80c | 236 | return kTRUE; |
3e1a3ad8 | 237 | |
793ff80c | 238 | } |
239 | ||
240 | if (det == -1) { | |
241 | ||
6d50f529 | 242 | AliInfo(Form("Writing the cluster tree %s for event %d." |
243 | ,fClusterTree->GetName(),fRunLoader->GetEventNumber())); | |
244 | ||
a6dd11e9 | 245 | if (fRecPoints) { |
246 | ||
247 | branch->SetAddress(&fRecPoints); | |
248 | ||
249 | AliLoader *loader = fRunLoader->GetLoader("TRDLoader"); | |
250 | loader->WriteRecPoints("OVERWRITE"); | |
c630aafd | 251 | |
a6dd11e9 | 252 | } |
253 | else { | |
254 | ||
255 | AliError("Cluster tree does not exist. Cannot write clusters.\n"); | |
256 | return kFALSE; | |
257 | ||
258 | } | |
259 | ||
793ff80c | 260 | return kTRUE; |
3e1a3ad8 | 261 | |
793ff80c | 262 | } |
6d50f529 | 263 | |
264 | AliError(Form("Unexpected detector index %d.\n",det)); | |
3e1a3ad8 | 265 | |
793ff80c | 266 | return kFALSE; |
88cb7938 | 267 | |
f7336fa3 | 268 | } |
793ff80c | 269 | |
270 | ||
bdbb05bb | 271 | //_____________________________________________________________________________ |
6d50f529 | 272 | AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin |
273 | , Int_t det, Double_t amp | |
274 | , Int_t *tracks, Double_t *sig | |
524fc8fa | 275 | , Int_t iType, Int_t col |
d74f970b | 276 | , UShort_t volid |
524fc8fa | 277 | , Float_t center) |
bdbb05bb | 278 | { |
279 | // | |
280 | // Add a cluster for the TRD | |
281 | // | |
793ff80c | 282 | |
bdbb05bb | 283 | AliTRDcluster *c = new AliTRDcluster(); |
284 | ||
285 | c->SetDetector(det); | |
bdbb05bb | 286 | c->SetQ(amp); |
3551db50 | 287 | c->SetX(pos[2]); |
bdbb05bb | 288 | c->SetY(pos[0]); |
289 | c->SetZ(pos[1]); | |
290 | c->SetSigmaY2(sig[0]); | |
291 | c->SetSigmaZ2(sig[1]); | |
3551db50 | 292 | c->SetLocalTimeBin(timebin); |
828b670e | 293 | c->SetCenter(center); |
524fc8fa | 294 | c->SetPad(col); |
d74f970b | 295 | c->SetVolumeId(volid); |
6d50f529 | 296 | |
a6dd11e9 | 297 | if (tracks) { |
298 | c->AddTrackIndex(tracks); | |
299 | } | |
300 | ||
bdbb05bb | 301 | switch (iType) { |
302 | case 0: | |
303 | c->Set2pad(); | |
304 | break; | |
305 | case 1: | |
306 | c->Set3pad(); | |
307 | break; | |
308 | case 2: | |
309 | c->Set4pad(); | |
310 | break; | |
311 | case 3: | |
312 | c->Set5pad(); | |
313 | break; | |
314 | case 4: | |
315 | c->SetLarge(); | |
316 | break; | |
317 | }; | |
318 | ||
319 | RecPoints()->Add(c); | |
c85a4951 | 320 | return c; |
6d50f529 | 321 | |
bdbb05bb | 322 | } |
3551db50 | 323 | |
324 | //_____________________________________________________________________________ | |
6d50f529 | 325 | Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet |
326 | , Int_t col, Int_t row) | |
3551db50 | 327 | { |
328 | // | |
6d50f529 | 329 | // Calculates the local x position in the detector from the timebin, |
330 | // depends on the drift velocity and t0 | |
3551db50 | 331 | // |
332 | ||
b43a3e17 | 333 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); |
6d50f529 | 334 | if (!calibration) { |
a6dd11e9 | 335 | AliError("Cannot find calibration object"); |
3551db50 | 336 | return -1; |
6d50f529 | 337 | } |
b43a3e17 | 338 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); |
339 | if (!parCom) { | |
340 | AliError("Could not get common parameters\n"); | |
341 | return kFALSE; | |
342 | } | |
88719a08 | 343 | |
6d50f529 | 344 | Float_t vdrift = calibration->GetVdrift(idet,col,row); |
345 | Float_t t0 = calibration->GetT0(idet,col,row); | |
b43a3e17 | 346 | Float_t samplingFrequency = parCom->GetSamplingFrequency(); |
88719a08 | 347 | |
348 | timebin -= t0; | |
349 | ||
350 | return timebin / samplingFrequency * vdrift; | |
6d50f529 | 351 | |
352 | } | |
353 | ||
354 | //_____________________________________________________________________________ | |
355 | void AliTRDclusterizer::ResetRecPoints() | |
356 | { | |
357 | // | |
358 | // Resets the list of rec points | |
359 | // | |
360 | ||
361 | if (fRecPoints) { | |
362 | fRecPoints->Delete(); | |
363 | } | |
364 | ||
365 | } | |
366 | ||
367 | //_____________________________________________________________________________ | |
368 | TObjArray* AliTRDclusterizer::RecPoints() | |
369 | { | |
370 | // | |
371 | // Returns the list of rec points | |
372 | // | |
373 | ||
374 | if (!fRecPoints) { | |
375 | fRecPoints = new TObjArray(400); | |
376 | } | |
377 | ||
378 | return fRecPoints; | |
379 | ||
3551db50 | 380 | } |