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