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