]>
Commit | Line | Data |
---|---|---|
4c039060 | 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$ | |
42157e55 | 18 | Revision 1.66 2003/02/11 16:54:07 hristov |
19 | Updated AliTrackReference class (S.Radomski) | |
20 | ||
2d74ba4f | 21 | Revision 1.65 2002/11/21 22:43:32 alibrary |
22 | Removing AliMC and AliMCProcess | |
23 | ||
4c475d27 | 24 | Revision 1.64 2002/10/23 07:17:33 alibrary |
25 | Introducing Riostream.h | |
26 | ||
19364939 | 27 | Revision 1.63 2002/10/14 14:57:42 hristov |
28 | Merging the VirtualMC branch to the main development branch (HEAD) | |
29 | ||
b9d0a01d | 30 | Revision 1.54.4.3 2002/10/11 08:34:48 hristov |
31 | Updating VirtualMC to v3-09-02 | |
32 | ||
33 | Revision 1.62 2002/09/23 09:22:56 hristov | |
34 | The address of the TrackReferences is set (M.Ivanov) | |
35 | ||
b6e0d3fe | 36 | Revision 1.61 2002/09/10 07:06:42 kowal2 |
37 | Corrected for the memory leak. Thanks to J. Chudoba and M. Ivanov | |
38 | ||
df32adf9 | 39 | Revision 1.60 2002/06/12 14:56:56 kowal2 |
40 | Added track length to the reference hits | |
41 | ||
ac4fb434 | 42 | Revision 1.59 2002/06/05 15:37:31 kowal2 |
43 | Added cross-talk from the wires beyond the first and the last rows | |
44 | ||
b584c7dd | 45 | Revision 1.58 2002/05/27 14:33:14 hristov |
46 | The new class AliTrackReference used (M.Ivanov) | |
47 | ||
da33556f | 48 | Revision 1.57 2002/05/07 17:23:11 kowal2 |
49 | Linear gain inefficiency instead of the step one at the wire edges. | |
50 | ||
e8f678d7 | 51 | Revision 1.56 2002/04/04 16:26:33 kowal2 |
52 | Digits (Sdigits) go to separate files now. | |
53 | ||
12d8d654 | 54 | Revision 1.55 2002/03/29 06:57:45 kowal2 |
55 | Restored backward compatibility to use the hits from Dec. 2000 production. | |
56 | ||
7a09f434 | 57 | Revision 1.54 2002/03/18 17:59:13 kowal2 |
58 | Chnges in the pad geometry - 3 pad lengths introduced. | |
59 | ||
f03e3423 | 60 | Revision 1.53 2002/02/25 11:02:56 kowal2 |
61 | Changes towards speeding up the code. Thanks to Marian Ivanov. | |
62 | ||
de61d5d5 | 63 | Revision 1.52 2002/02/18 09:26:09 kowal2 |
64 | Removed compiler warning | |
65 | ||
43510af3 | 66 | Revision 1.51 2002/01/21 17:13:21 kowal2 |
67 | New track hits using root containers. Setting active sectors added. | |
68 | ||
792bb11c | 69 | Revision 1.50 2001/12/06 14:16:19 kowal2 |
70 | meaningfull printouts | |
71 | ||
0a9b058d | 72 | Revision 1.49 2001/11/30 11:55:37 hristov |
73 | Noise table created in Hits2SDigits (M.Ivanov) | |
74 | ||
180f4872 | 75 | Revision 1.48 2001/11/24 16:10:21 kowal2 |
76 | Faster algorithms. | |
77 | ||
407ff276 | 78 | Revision 1.47 2001/11/19 10:25:34 kowal2 |
79 | Nearest integer instead of integer when converting to ADC counts | |
80 | ||
68771f83 | 81 | Revision 1.46 2001/11/07 06:47:12 kowal2 |
82 | Removed printouts | |
83 | ||
9fe90376 | 84 | Revision 1.45 2001/11/03 13:33:48 kowal2 |
85 | Updated algorithms in Hits2SDigits, SDigits2Digits, | |
86 | Hits2ExactClusters. | |
87 | Added method Merge | |
88 | ||
5f16d237 | 89 | Revision 1.44 2001/08/30 09:28:48 hristov |
90 | TTree names are explicitly set via SetName(name) and then Write() is called | |
91 | ||
6bc3458d | 92 | Revision 1.43 2001/07/28 12:02:54 hristov |
93 | Branch split level set to 99 | |
94 | ||
8f90302f | 95 | Revision 1.42 2001/07/28 11:38:52 hristov |
96 | Loop variable declared once | |
97 | ||
43272665 | 98 | Revision 1.41 2001/07/28 10:53:50 hristov |
99 | Digitisation done according to the general scheme (M.Ivanov) | |
100 | ||
0a61bf9d | 101 | Revision 1.40 2001/07/27 13:03:14 hristov |
102 | Default Branch split level set to 99 | |
103 | ||
d0f40f23 | 104 | Revision 1.39 2001/07/26 09:09:34 kowal2 |
105 | Hits2Reco method added | |
106 | ||
a62d28a2 | 107 | Revision 1.38 2001/07/20 14:32:43 kowal2 |
108 | Processing of many events possible now | |
109 | ||
afc42102 | 110 | Revision 1.37 2001/06/12 07:17:18 kowal2 |
111 | Hits2SDigits method implemented (summable digits) | |
112 | ||
f8cf550c | 113 | Revision 1.36 2001/05/16 14:57:25 alibrary |
114 | New files for folders and Stack | |
115 | ||
9e1a0ddb | 116 | Revision 1.35 2001/05/08 16:02:22 kowal2 |
117 | Updated material specifications | |
118 | ||
ba1d05f9 | 119 | Revision 1.34 2001/05/08 15:00:15 hristov |
120 | Corrections for tracking in arbitrary magnenetic field. Changes towards a concept of global Alice track. Back propagation of reconstructed tracks (Yu.Belikov) | |
121 | ||
b9de75e1 | 122 | Revision 1.33 2001/04/03 12:40:43 kowal2 |
123 | Removed printouts | |
124 | ||
5a28a08f | 125 | Revision 1.32 2001/03/12 17:47:36 hristov |
126 | Changes needed on Sun with CC 5.0 | |
127 | ||
5cf7bbad | 128 | Revision 1.31 2001/03/12 08:21:50 kowal2 |
129 | Corrected C++ bug in the material definitions | |
130 | ||
9a3667bd | 131 | Revision 1.30 2001/03/01 17:34:47 kowal2 |
132 | Correction due to the accuracy problem | |
133 | ||
710dacf5 | 134 | Revision 1.29 2001/02/28 16:34:40 kowal2 |
135 | Protection against nonphysical values of the avalanche size, | |
136 | 10**6 is the maximum | |
137 | ||
1705494b | 138 | Revision 1.28 2001/01/26 19:57:19 hristov |
139 | Major upgrade of AliRoot code | |
140 | ||
2ab0c725 | 141 | Revision 1.27 2001/01/13 17:29:33 kowal2 |
142 | Sun compiler correction | |
143 | ||
f2e8b846 | 144 | Revision 1.26 2001/01/10 07:59:43 kowal2 |
145 | Corrections to load points from the noncompressed hits. | |
146 | ||
53048f2e | 147 | Revision 1.25 2000/11/02 07:25:31 kowal2 |
148 | Changes due to the new hit structure. | |
149 | Memory leak removed. | |
150 | ||
39c8eb58 | 151 | Revision 1.24 2000/10/05 16:06:09 kowal2 |
152 | Forward declarations. Changes due to a new class AliComplexCluster. | |
153 | ||
2b06d5c3 | 154 | Revision 1.23 2000/10/02 21:28:18 fca |
155 | Removal of useless dependecies via forward declarations | |
156 | ||
94de3818 | 157 | Revision 1.22 2000/07/10 20:57:39 hristov |
158 | Update of TPC code and macros by M.Kowalski | |
159 | ||
73042f01 | 160 | Revision 1.19.2.4 2000/06/26 07:39:42 kowal2 |
161 | Changes to obey the coding rules | |
162 | ||
163 | Revision 1.19.2.3 2000/06/25 08:38:41 kowal2 | |
164 | Splitted from AliTPCtracking | |
165 | ||
166 | Revision 1.19.2.2 2000/06/16 12:59:28 kowal2 | |
167 | Changed parameter settings | |
168 | ||
169 | Revision 1.19.2.1 2000/06/09 07:15:07 kowal2 | |
170 | ||
171 | Defaults loaded automatically (hard-wired) | |
172 | Optional parameters can be set via macro called in the constructor | |
173 | ||
174 | Revision 1.19 2000/04/18 19:00:59 fca | |
175 | Small bug fixes to TPC files | |
176 | ||
4d68a14a | 177 | Revision 1.18 2000/04/17 09:37:33 kowal2 |
178 | removed obsolete AliTPCDigitsDisplay.C | |
179 | ||
cc80f89e | 180 | Revision 1.17.2.2 2000/04/10 08:15:12 kowal2 |
181 | ||
182 | New, experimental data structure from M. Ivanov | |
183 | New tracking algorithm | |
184 | Different pad geometry for different sectors | |
185 | Digitization rewritten | |
186 | ||
187 | Revision 1.17.2.1 2000/04/10 07:56:53 kowal2 | |
188 | Not used anymore - removed | |
189 | ||
190 | Revision 1.17 2000/01/19 17:17:30 fca | |
191 | Introducing a list of lists of hits -- more hits allowed for detector now | |
192 | ||
1cedd08a | 193 | Revision 1.16 1999/11/05 09:29:23 fca |
194 | Accept only signals > 0 | |
195 | ||
921bf71a | 196 | Revision 1.15 1999/10/08 06:26:53 fca |
197 | Removed ClustersIndex - not used anymore | |
198 | ||
e674b993 | 199 | Revision 1.14 1999/09/29 09:24:33 fca |
200 | Introduction of the Copyright and cvs Log | |
201 | ||
4c039060 | 202 | */ |
203 | ||
fe4da5cc | 204 | /////////////////////////////////////////////////////////////////////////////// |
205 | // // | |
206 | // Time Projection Chamber // | |
207 | // This class contains the basic functions for the Time Projection Chamber // | |
208 | // detector. Functions specific to one particular geometry are // | |
209 | // contained in the derived classes // | |
210 | // // | |
211 | //Begin_Html | |
212 | /* | |
1439f98e | 213 | <img src="picts/AliTPCClass.gif"> |
fe4da5cc | 214 | */ |
215 | //End_Html | |
216 | // // | |
8c555625 | 217 | // // |
fe4da5cc | 218 | /////////////////////////////////////////////////////////////////////////////// |
219 | ||
73042f01 | 220 | // |
221 | ||
fe4da5cc | 222 | #include <TMath.h> |
223 | #include <TRandom.h> | |
224 | #include <TVector.h> | |
8c555625 | 225 | #include <TMatrix.h> |
fe4da5cc | 226 | #include <TGeometry.h> |
227 | #include <TNode.h> | |
228 | #include <TTUBS.h> | |
229 | #include <TObjectTable.h> | |
1578254f | 230 | #include "TParticle.h" |
fe4da5cc | 231 | #include "AliTPC.h" |
afc42102 | 232 | #include <TFile.h> |
233 | #include <TROOT.h> | |
234 | #include <TSystem.h> | |
fe4da5cc | 235 | #include "AliRun.h" |
19364939 | 236 | #include <Riostream.h> |
2ab0c725 | 237 | #include <stdlib.h> |
19364939 | 238 | #include <Riostream.h> |
94de3818 | 239 | #include "AliMagF.h" |
da33556f | 240 | #include "AliTrackReference.h" |
fe4da5cc | 241 | |
cc80f89e | 242 | |
73042f01 | 243 | #include "AliTPCParamSR.h" |
8c555625 | 244 | #include "AliTPCPRF2D.h" |
245 | #include "AliTPCRF1D.h" | |
cc80f89e | 246 | #include "AliDigits.h" |
247 | #include "AliSimDigits.h" | |
39c8eb58 | 248 | #include "AliTPCTrackHits.h" |
792bb11c | 249 | #include "AliTPCTrackHitsV2.h" |
39c8eb58 | 250 | #include "AliPoints.h" |
251 | #include "AliArrayBranch.h" | |
252 | ||
cc80f89e | 253 | |
254 | #include "AliTPCDigitsArray.h" | |
2b06d5c3 | 255 | #include "AliComplexCluster.h" |
cc80f89e | 256 | #include "AliClusters.h" |
257 | #include "AliTPCClustersRow.h" | |
258 | #include "AliTPCClustersArray.h" | |
8c555625 | 259 | |
73042f01 | 260 | #include "AliTPCcluster.h" |
261 | #include "AliTPCclusterer.h" | |
262 | #include "AliTPCtracker.h" | |
8c555625 | 263 | |
73042f01 | 264 | #include <TInterpreter.h> |
2b06d5c3 | 265 | #include <TTree.h> |
1283eee5 | 266 | |
39c8eb58 | 267 | |
268 | ||
fe4da5cc | 269 | ClassImp(AliTPC) |
270 | ||
de61d5d5 | 271 | //_____________________________________________________________________________ |
272 | // helper class for fast matrix and vector manipulation - no range checking | |
273 | // origin - Marian Ivanov | |
274 | ||
275 | class AliTPCFastMatrix : public TMatrix { | |
276 | public : | |
277 | AliTPCFastMatrix(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb); | |
278 | inline Float_t & UncheckedAt(Int_t rown, Int_t coln) const {return (fIndex[coln])[rown];} //fast acces | |
279 | inline Float_t UncheckedAtFast(Int_t rown, Int_t coln) const {return (fIndex[coln])[rown];} //fast acces | |
280 | }; | |
281 | ||
282 | AliTPCFastMatrix::AliTPCFastMatrix(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb): | |
283 | TMatrix(row_lwb, row_upb,col_lwb,col_upb) | |
284 | { | |
285 | }; | |
286 | //_____________________________________________________________________________ | |
287 | class AliTPCFastVector : public TVector { | |
288 | public : | |
289 | AliTPCFastVector(Int_t size); | |
b6e0d3fe | 290 | virtual ~AliTPCFastVector(){;} |
de61d5d5 | 291 | inline Float_t & UncheckedAt(Int_t index) const {return fElements[index];} //fast acces |
b6e0d3fe | 292 | |
de61d5d5 | 293 | }; |
294 | ||
295 | AliTPCFastVector::AliTPCFastVector(Int_t size):TVector(size){ | |
296 | }; | |
297 | ||
fe4da5cc | 298 | //_____________________________________________________________________________ |
299 | AliTPC::AliTPC() | |
300 | { | |
301 | // | |
302 | // Default constructor | |
303 | // | |
304 | fIshunt = 0; | |
fe4da5cc | 305 | fHits = 0; |
306 | fDigits = 0; | |
fe4da5cc | 307 | fNsectors = 0; |
cc80f89e | 308 | fDigitsArray = 0; |
309 | fClustersArray = 0; | |
afc42102 | 310 | fDefaults = 0; |
792bb11c | 311 | fTrackHits = 0; |
312 | fTrackHitsOld = 0; | |
da33556f | 313 | fHitType = 2; //default CONTAINERS - based on ROOT structure |
407ff276 | 314 | fTPCParam = 0; |
315 | fNoiseTable = 0; | |
792bb11c | 316 | fActiveSectors =0; |
407ff276 | 317 | |
fe4da5cc | 318 | } |
319 | ||
320 | //_____________________________________________________________________________ | |
321 | AliTPC::AliTPC(const char *name, const char *title) | |
322 | : AliDetector(name,title) | |
323 | { | |
324 | // | |
325 | // Standard constructor | |
326 | // | |
327 | ||
328 | // | |
329 | // Initialise arrays of hits and digits | |
330 | fHits = new TClonesArray("AliTPChit", 176); | |
792bb11c | 331 | gAlice->AddHitList(fHits); |
cc80f89e | 332 | fDigitsArray = 0; |
333 | fClustersArray= 0; | |
afc42102 | 334 | fDefaults = 0; |
fe4da5cc | 335 | // |
792bb11c | 336 | fTrackHits = new AliTPCTrackHitsV2; |
39c8eb58 | 337 | fTrackHits->SetHitPrecision(0.002); |
338 | fTrackHits->SetStepPrecision(0.003); | |
792bb11c | 339 | fTrackHits->SetMaxDistance(100); |
340 | ||
341 | fTrackHitsOld = new AliTPCTrackHits; //MI - 13.09.2000 | |
342 | fTrackHitsOld->SetHitPrecision(0.002); | |
343 | fTrackHitsOld->SetStepPrecision(0.003); | |
344 | fTrackHitsOld->SetMaxDistance(100); | |
345 | ||
407ff276 | 346 | fNoiseTable =0; |
39c8eb58 | 347 | |
da33556f | 348 | fHitType = 2; |
792bb11c | 349 | fActiveSectors = 0; |
39c8eb58 | 350 | // |
fe4da5cc | 351 | // Initialise counters |
cc80f89e | 352 | fNsectors = 0; |
cc80f89e | 353 | |
fe4da5cc | 354 | // |
355 | fIshunt = 0; | |
356 | // | |
357 | // Initialise color attributes | |
358 | SetMarkerColor(kYellow); | |
73042f01 | 359 | |
360 | // | |
361 | // Set TPC parameters | |
362 | // | |
363 | ||
afc42102 | 364 | |
365 | if (!strcmp(title,"Default")) { | |
366 | fTPCParam = new AliTPCParamSR; | |
73042f01 | 367 | } else { |
368 | cerr<<"AliTPC warning: in Config.C you must set non-default parameters\n"; | |
369 | fTPCParam=0; | |
370 | } | |
371 | ||
fe4da5cc | 372 | } |
373 | ||
374 | //_____________________________________________________________________________ | |
375 | AliTPC::~AliTPC() | |
376 | { | |
377 | // | |
378 | // TPC destructor | |
379 | // | |
73042f01 | 380 | |
fe4da5cc | 381 | fIshunt = 0; |
382 | delete fHits; | |
383 | delete fDigits; | |
73042f01 | 384 | delete fTPCParam; |
39c8eb58 | 385 | delete fTrackHits; //MI 15.09.2000 |
792bb11c | 386 | delete fTrackHitsOld; //MI 10.12.2001 |
407ff276 | 387 | if (fNoiseTable) delete [] fNoiseTable; |
388 | ||
fe4da5cc | 389 | } |
390 | ||
fe4da5cc | 391 | //_____________________________________________________________________________ |
392 | void AliTPC::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
393 | { | |
394 | // | |
395 | // Add a hit to the list | |
396 | // | |
39c8eb58 | 397 | // TClonesArray &lhits = *fHits; |
398 | // new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits); | |
399 | if (fHitType&1){ | |
400 | TClonesArray &lhits = *fHits; | |
401 | new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits); | |
402 | } | |
792bb11c | 403 | if (fHitType>1) |
39c8eb58 | 404 | AddHit2(track,vol,hits); |
fe4da5cc | 405 | } |
da33556f | 406 | |
2d74ba4f | 407 | void AliTPC::AddTrackReference(Int_t label, TVirtualMC *vMC){ |
da33556f | 408 | // |
409 | // add a trackrefernce to the list | |
410 | if (!fTrackReferences) { | |
411 | cerr<<"Container trackrefernce not active\n"; | |
412 | return; | |
413 | } | |
414 | Int_t nref = fTrackReferences->GetEntriesFast(); | |
415 | TClonesArray &lref = *fTrackReferences; | |
2d74ba4f | 416 | new(lref[nref]) AliTrackReference(label, vMC); |
da33556f | 417 | } |
fe4da5cc | 418 | |
fe4da5cc | 419 | //_____________________________________________________________________________ |
420 | void AliTPC::BuildGeometry() | |
421 | { | |
cc80f89e | 422 | |
fe4da5cc | 423 | // |
424 | // Build TPC ROOT TNode geometry for the event display | |
425 | // | |
73042f01 | 426 | TNode *nNode, *nTop; |
fe4da5cc | 427 | TTUBS *tubs; |
428 | Int_t i; | |
429 | const int kColorTPC=19; | |
1283eee5 | 430 | char name[5], title[25]; |
fe4da5cc | 431 | const Double_t kDegrad=TMath::Pi()/180; |
1283eee5 | 432 | const Double_t kRaddeg=180./TMath::Pi(); |
433 | ||
1283eee5 | 434 | |
73042f01 | 435 | Float_t innerOpenAngle = fTPCParam->GetInnerAngle(); |
436 | Float_t outerOpenAngle = fTPCParam->GetOuterAngle(); | |
1283eee5 | 437 | |
73042f01 | 438 | Float_t innerAngleShift = fTPCParam->GetInnerAngleShift(); |
439 | Float_t outerAngleShift = fTPCParam->GetOuterAngleShift(); | |
1283eee5 | 440 | |
441 | Int_t nLo = fTPCParam->GetNInnerSector()/2; | |
442 | Int_t nHi = fTPCParam->GetNOuterSector()/2; | |
443 | ||
73042f01 | 444 | const Double_t kloAng = (Double_t)TMath::Nint(innerOpenAngle*kRaddeg); |
445 | const Double_t khiAng = (Double_t)TMath::Nint(outerOpenAngle*kRaddeg); | |
446 | const Double_t kloAngSh = (Double_t)TMath::Nint(innerAngleShift*kRaddeg); | |
447 | const Double_t khiAngSh = (Double_t)TMath::Nint(outerAngleShift*kRaddeg); | |
1283eee5 | 448 | |
449 | ||
73042f01 | 450 | const Double_t kloCorr = 1/TMath::Cos(0.5*kloAng*kDegrad); |
451 | const Double_t khiCorr = 1/TMath::Cos(0.5*khiAng*kDegrad); | |
1283eee5 | 452 | |
453 | Double_t rl,ru; | |
454 | ||
455 | ||
fe4da5cc | 456 | // |
457 | // Get ALICE top node | |
fe4da5cc | 458 | // |
1283eee5 | 459 | |
73042f01 | 460 | nTop=gAlice->GetGeometry()->GetNode("alice"); |
1283eee5 | 461 | |
462 | // inner sectors | |
463 | ||
cc80f89e | 464 | rl = fTPCParam->GetInnerRadiusLow(); |
465 | ru = fTPCParam->GetInnerRadiusUp(); | |
1283eee5 | 466 | |
467 | ||
fe4da5cc | 468 | for(i=0;i<nLo;i++) { |
469 | sprintf(name,"LS%2.2d",i); | |
1283eee5 | 470 | name[4]='\0'; |
471 | sprintf(title,"TPC low sector %3d",i); | |
472 | title[24]='\0'; | |
473 | ||
73042f01 | 474 | tubs = new TTUBS(name,title,"void",rl*kloCorr,ru*kloCorr,250., |
475 | kloAng*(i-0.5)+kloAngSh,kloAng*(i+0.5)+kloAngSh); | |
fe4da5cc | 476 | tubs->SetNumberOfDivisions(1); |
73042f01 | 477 | nTop->cd(); |
478 | nNode = new TNode(name,title,name,0,0,0,""); | |
479 | nNode->SetLineColor(kColorTPC); | |
480 | fNodes->Add(nNode); | |
fe4da5cc | 481 | } |
1283eee5 | 482 | |
fe4da5cc | 483 | // Outer sectors |
1283eee5 | 484 | |
cc80f89e | 485 | rl = fTPCParam->GetOuterRadiusLow(); |
486 | ru = fTPCParam->GetOuterRadiusUp(); | |
1283eee5 | 487 | |
fe4da5cc | 488 | for(i=0;i<nHi;i++) { |
489 | sprintf(name,"US%2.2d",i); | |
1283eee5 | 490 | name[4]='\0'; |
fe4da5cc | 491 | sprintf(title,"TPC upper sector %d",i); |
1283eee5 | 492 | title[24]='\0'; |
73042f01 | 493 | tubs = new TTUBS(name,title,"void",rl*khiCorr,ru*khiCorr,250, |
494 | khiAng*(i-0.5)+khiAngSh,khiAng*(i+0.5)+khiAngSh); | |
fe4da5cc | 495 | tubs->SetNumberOfDivisions(1); |
73042f01 | 496 | nTop->cd(); |
497 | nNode = new TNode(name,title,name,0,0,0,""); | |
498 | nNode->SetLineColor(kColorTPC); | |
499 | fNodes->Add(nNode); | |
fe4da5cc | 500 | } |
cc80f89e | 501 | |
73042f01 | 502 | } |
1283eee5 | 503 | |
fe4da5cc | 504 | //_____________________________________________________________________________ |
505 | Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t ) | |
506 | { | |
507 | // | |
508 | // Calculate distance from TPC to mouse on the display | |
509 | // Dummy procedure | |
510 | // | |
511 | return 9999; | |
512 | } | |
513 | ||
73042f01 | 514 | void AliTPC::Clusters2Tracks(TFile *of) { |
3c0f9266 | 515 | //----------------------------------------------------------------- |
516 | // This is a track finder. | |
3c0f9266 | 517 | //----------------------------------------------------------------- |
b9de75e1 | 518 | AliTPCtracker tracker(fTPCParam); |
519 | tracker.Clusters2Tracks(gFile,of); | |
fe4da5cc | 520 | } |
521 | ||
522 | //_____________________________________________________________________________ | |
523 | void AliTPC::CreateMaterials() | |
524 | { | |
8c555625 | 525 | //----------------------------------------------- |
37831078 | 526 | // Create Materials for for TPC simulations |
8c555625 | 527 | //----------------------------------------------- |
528 | ||
529 | //----------------------------------------------------------------- | |
530 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
531 | //----------------------------------------------------------------- | |
1283eee5 | 532 | |
73042f01 | 533 | Int_t iSXFLD=gAlice->Field()->Integ(); |
534 | Float_t sXMGMX=gAlice->Field()->Max(); | |
1283eee5 | 535 | |
536 | Float_t amat[5]; // atomic numbers | |
537 | Float_t zmat[5]; // z | |
538 | Float_t wmat[5]; // proportions | |
539 | ||
540 | Float_t density; | |
37831078 | 541 | Float_t apure[2]; |
1283eee5 | 542 | |
1283eee5 | 543 | |
37831078 | 544 | //***************** Gases ************************* |
545 | ||
546 | //------------------------------------------------- | |
1283eee5 | 547 | // pure gases |
37831078 | 548 | //------------------------------------------------- |
1283eee5 | 549 | |
37831078 | 550 | // Neon |
1283eee5 | 551 | |
552 | ||
37831078 | 553 | amat[0]= 20.18; |
554 | zmat[0]= 10.; | |
1283eee5 | 555 | density = 0.0009; |
37831078 | 556 | |
557 | apure[0]=amat[0]; | |
1283eee5 | 558 | |
37831078 | 559 | AliMaterial(20,"Ne",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 560 | |
37831078 | 561 | // Argon |
1283eee5 | 562 | |
37831078 | 563 | amat[0]= 39.948; |
564 | zmat[0]= 18.; | |
565 | density = 0.001782; | |
1283eee5 | 566 | |
37831078 | 567 | apure[1]=amat[0]; |
1283eee5 | 568 | |
37831078 | 569 | AliMaterial(21,"Ar",amat[0],zmat[0],density,999.,999.); |
570 | ||
1283eee5 | 571 | |
572 | //-------------------------------------------------------------- | |
573 | // gases - compounds | |
574 | //-------------------------------------------------------------- | |
575 | ||
576 | Float_t amol[3]; | |
577 | ||
37831078 | 578 | // CO2 |
1283eee5 | 579 | |
580 | amat[0]=12.011; | |
581 | amat[1]=15.9994; | |
582 | ||
583 | zmat[0]=6.; | |
584 | zmat[1]=8.; | |
585 | ||
586 | wmat[0]=1.; | |
587 | wmat[1]=2.; | |
588 | ||
589 | density=0.001977; | |
590 | ||
591 | amol[0] = amat[0]*wmat[0]+amat[1]*wmat[1]; | |
592 | ||
593 | AliMixture(10,"CO2",amat,zmat,density,-2,wmat); | |
37831078 | 594 | |
1283eee5 | 595 | // CF4 |
596 | ||
597 | amat[0]=12.011; | |
598 | amat[1]=18.998; | |
599 | ||
600 | zmat[0]=6.; | |
601 | zmat[1]=9.; | |
602 | ||
603 | wmat[0]=1.; | |
604 | wmat[1]=4.; | |
605 | ||
606 | density=0.003034; | |
607 | ||
608 | amol[1] = amat[0]*wmat[0]+amat[1]*wmat[1]; | |
609 | ||
610 | AliMixture(11,"CF4",amat,zmat,density,-2,wmat); | |
611 | ||
37831078 | 612 | |
1283eee5 | 613 | // CH4 |
614 | ||
615 | amat[0]=12.011; | |
616 | amat[1]=1.; | |
617 | ||
618 | zmat[0]=6.; | |
619 | zmat[1]=1.; | |
620 | ||
621 | wmat[0]=1.; | |
622 | wmat[1]=4.; | |
623 | ||
624 | density=0.000717; | |
625 | ||
626 | amol[2] = amat[0]*wmat[0]+amat[1]*wmat[1]; | |
627 | ||
628 | AliMixture(12,"CH4",amat,zmat,density,-2,wmat); | |
629 | ||
630 | //---------------------------------------------------------------- | |
631 | // gases - mixtures, ID >= 20 pure gases, <= 10 ID < 20 -compounds | |
632 | //---------------------------------------------------------------- | |
37831078 | 633 | |
634 | char namate[21]; | |
1283eee5 | 635 | density = 0.; |
636 | Float_t am=0; | |
637 | Int_t nc; | |
37831078 | 638 | Float_t rho,absl,X0,buf[1]; |
1283eee5 | 639 | Int_t nbuf; |
37831078 | 640 | Float_t a,z; |
1283eee5 | 641 | |
642 | for(nc = 0;nc<fNoComp;nc++) | |
643 | { | |
644 | ||
645 | // retrive material constants | |
646 | ||
37831078 | 647 | gMC->Gfmate((*fIdmate)[fMixtComp[nc]],namate,a,z,rho,X0,absl,buf,nbuf); |
1283eee5 | 648 | |
649 | amat[nc] = a; | |
650 | zmat[nc] = z; | |
651 | ||
652 | Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10; | |
653 | ||
37831078 | 654 | am += fMixtProp[nc]*((fMixtComp[nc]>=20) ? apure[nnc] : amol[nnc]); |
1283eee5 | 655 | density += fMixtProp[nc]*rho; // density of the mixture |
656 | ||
657 | } | |
658 | ||
659 | // mixture proportions by weight! | |
660 | ||
661 | for(nc = 0;nc<fNoComp;nc++) | |
662 | { | |
663 | ||
664 | Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10; | |
665 | ||
37831078 | 666 | wmat[nc] = fMixtProp[nc]*((fMixtComp[nc]>=20) ? |
667 | apure[nnc] : amol[nnc])/am; | |
668 | ||
669 | } | |
670 | ||
671 | // Drift gases 1 - nonsensitive, 2 - sensitive | |
1283eee5 | 672 | |
1283eee5 | 673 | AliMixture(31,"Drift gas 1",amat,zmat,density,fNoComp,wmat); |
674 | AliMixture(32,"Drift gas 2",amat,zmat,density,fNoComp,wmat); | |
1283eee5 | 675 | |
1283eee5 | 676 | |
37831078 | 677 | // Air |
678 | ||
679 | amat[0] = 14.61; | |
680 | zmat[0] = 7.3; | |
681 | density = 0.001205; | |
1283eee5 | 682 | |
37831078 | 683 | AliMaterial(24,"Air",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 684 | |
1283eee5 | 685 | |
686 | //---------------------------------------------------------------------- | |
687 | // solid materials | |
688 | //---------------------------------------------------------------------- | |
689 | ||
1283eee5 | 690 | |
37831078 | 691 | // Kevlar C14H22O2N2 |
1283eee5 | 692 | |
37831078 | 693 | amat[0] = 12.011; |
694 | amat[1] = 1.; | |
695 | amat[2] = 15.999; | |
696 | amat[3] = 14.006; | |
1283eee5 | 697 | |
37831078 | 698 | zmat[0] = 6.; |
699 | zmat[1] = 1.; | |
700 | zmat[2] = 8.; | |
701 | zmat[3] = 7.; | |
702 | ||
703 | wmat[0] = 14.; | |
704 | wmat[1] = 22.; | |
705 | wmat[2] = 2.; | |
706 | wmat[3] = 2.; | |
707 | ||
708 | density = 1.45; | |
709 | ||
710 | AliMixture(34,"Kevlar",amat,zmat,density,-4,wmat); | |
711 | ||
712 | // NOMEX | |
1283eee5 | 713 | |
37831078 | 714 | amat[0] = 12.011; |
715 | amat[1] = 1.; | |
716 | amat[2] = 15.999; | |
717 | amat[3] = 14.006; | |
718 | ||
719 | zmat[0] = 6.; | |
720 | zmat[1] = 1.; | |
721 | zmat[2] = 8.; | |
722 | zmat[3] = 7.; | |
723 | ||
724 | wmat[0] = 14.; | |
725 | wmat[1] = 22.; | |
726 | wmat[2] = 2.; | |
727 | wmat[3] = 2.; | |
728 | ||
729 | density = 0.03; | |
1283eee5 | 730 | |
fe4da5cc | 731 | |
37831078 | 732 | AliMixture(35,"NOMEX",amat,zmat,density,-4,wmat); |
733 | ||
734 | // Makrolon C16H18O3 | |
735 | ||
736 | amat[0] = 12.011; | |
737 | amat[1] = 1.; | |
738 | amat[2] = 15.999; | |
1283eee5 | 739 | |
37831078 | 740 | zmat[0] = 6.; |
741 | zmat[1] = 1.; | |
742 | zmat[2] = 8.; | |
743 | ||
744 | wmat[0] = 16.; | |
745 | wmat[1] = 18.; | |
746 | wmat[2] = 3.; | |
747 | ||
748 | density = 1.2; | |
749 | ||
750 | AliMixture(36,"Makrolon",amat,zmat,density,-3,wmat); | |
751 | ||
1283eee5 | 752 | // Mylar C5H4O2 |
753 | ||
754 | amat[0]=12.011; | |
755 | amat[1]=1.; | |
756 | amat[2]=15.9994; | |
757 | ||
758 | zmat[0]=6.; | |
759 | zmat[1]=1.; | |
760 | zmat[2]=8.; | |
761 | ||
762 | wmat[0]=5.; | |
763 | wmat[1]=4.; | |
764 | wmat[2]=2.; | |
765 | ||
766 | density = 1.39; | |
fe4da5cc | 767 | |
37831078 | 768 | AliMixture(37, "Mylar",amat,zmat,density,-3,wmat); |
1283eee5 | 769 | |
ba1d05f9 | 770 | // SiO2 - used later for the glass fiber |
1283eee5 | 771 | |
37831078 | 772 | amat[0]=28.086; |
773 | amat[1]=15.9994; | |
1283eee5 | 774 | |
37831078 | 775 | zmat[0]=14.; |
776 | zmat[1]=8.; | |
1283eee5 | 777 | |
37831078 | 778 | wmat[0]=1.; |
779 | wmat[1]=2.; | |
1283eee5 | 780 | |
1283eee5 | 781 | |
ba1d05f9 | 782 | AliMixture(38,"SiO2",amat,zmat,2.2,-2,wmat); //SiO2 - quartz (rho=2.2) |
1283eee5 | 783 | |
37831078 | 784 | // Al |
1283eee5 | 785 | |
37831078 | 786 | amat[0] = 26.98; |
787 | zmat[0] = 13.; | |
1283eee5 | 788 | |
37831078 | 789 | density = 2.7; |
1283eee5 | 790 | |
37831078 | 791 | AliMaterial(40,"Al",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 792 | |
37831078 | 793 | // Si |
1283eee5 | 794 | |
37831078 | 795 | amat[0] = 28.086; |
9a3667bd | 796 | zmat[0] = 14.; |
1283eee5 | 797 | |
37831078 | 798 | density = 2.33; |
1283eee5 | 799 | |
37831078 | 800 | AliMaterial(41,"Si",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 801 | |
37831078 | 802 | // Cu |
1283eee5 | 803 | |
37831078 | 804 | amat[0] = 63.546; |
805 | zmat[0] = 29.; | |
1283eee5 | 806 | |
37831078 | 807 | density = 8.96; |
1283eee5 | 808 | |
37831078 | 809 | AliMaterial(42,"Cu",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 810 | |
37831078 | 811 | // Tedlar C2H3F |
1283eee5 | 812 | |
37831078 | 813 | amat[0] = 12.011; |
814 | amat[1] = 1.; | |
815 | amat[2] = 18.998; | |
1283eee5 | 816 | |
37831078 | 817 | zmat[0] = 6.; |
818 | zmat[1] = 1.; | |
819 | zmat[2] = 9.; | |
1283eee5 | 820 | |
37831078 | 821 | wmat[0] = 2.; |
822 | wmat[1] = 3.; | |
823 | wmat[2] = 1.; | |
1283eee5 | 824 | |
37831078 | 825 | density = 1.71; |
1283eee5 | 826 | |
37831078 | 827 | AliMixture(43, "Tedlar",amat,zmat,density,-3,wmat); |
1283eee5 | 828 | |
1283eee5 | 829 | |
37831078 | 830 | // Plexiglas C5H8O2 |
1283eee5 | 831 | |
37831078 | 832 | amat[0]=12.011; |
833 | amat[1]=1.; | |
834 | amat[2]=15.9994; | |
1283eee5 | 835 | |
37831078 | 836 | zmat[0]=6.; |
837 | zmat[1]=1.; | |
838 | zmat[2]=8.; | |
1283eee5 | 839 | |
37831078 | 840 | wmat[0]=5.; |
841 | wmat[1]=8.; | |
842 | wmat[2]=2.; | |
1283eee5 | 843 | |
37831078 | 844 | density=1.18; |
1283eee5 | 845 | |
37831078 | 846 | AliMixture(44,"Plexiglas",amat,zmat,density,-3,wmat); |
1283eee5 | 847 | |
ba1d05f9 | 848 | // Epoxy - C14 H20 O3 |
1283eee5 | 849 | |
5a28a08f | 850 | |
851 | amat[0]=12.011; | |
852 | amat[1]=1.; | |
853 | amat[2]=15.9994; | |
854 | ||
855 | zmat[0]=6.; | |
856 | zmat[1]=1.; | |
857 | zmat[2]=8.; | |
858 | ||
ba1d05f9 | 859 | wmat[0]=14.; |
860 | wmat[1]=20.; | |
5a28a08f | 861 | wmat[2]=3.; |
862 | ||
ba1d05f9 | 863 | density=1.25; |
5a28a08f | 864 | |
865 | AliMixture(45,"Epoxy",amat,zmat,density,-3,wmat); | |
37831078 | 866 | |
ba1d05f9 | 867 | // Carbon |
868 | ||
869 | amat[0]=12.011; | |
870 | zmat[0]=6.; | |
871 | density= 2.265; | |
872 | ||
873 | AliMaterial(46,"C",amat[0],zmat[0],density,999.,999.); | |
874 | ||
875 | // get epoxy | |
876 | ||
877 | gMC->Gfmate((*fIdmate)[45],namate,amat[1],zmat[1],rho,X0,absl,buf,nbuf); | |
878 | ||
879 | // Carbon fiber | |
880 | ||
881 | wmat[0]=0.644; // by weight! | |
882 | wmat[1]=0.356; | |
883 | ||
884 | density=0.5*(1.25+2.265); | |
885 | ||
886 | AliMixture(47,"Cfiber",amat,zmat,density,2,wmat); | |
887 | ||
888 | // get SiO2 | |
889 | ||
890 | gMC->Gfmate((*fIdmate)[38],namate,amat[0],zmat[0],rho,X0,absl,buf,nbuf); | |
891 | ||
892 | wmat[0]=0.725; // by weight! | |
893 | wmat[1]=0.275; | |
894 | ||
895 | density=1.7; | |
896 | ||
897 | AliMixture(39,"G10",amat,zmat,density,2,wmat); | |
898 | ||
899 | ||
900 | ||
901 | ||
37831078 | 902 | //---------------------------------------------------------- |
903 | // tracking media for gases | |
904 | //---------------------------------------------------------- | |
905 | ||
906 | AliMedium(0, "Air", 24, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1); | |
907 | AliMedium(1, "Drift gas 1", 31, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001); | |
908 | AliMedium(2, "Drift gas 2", 32, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001); | |
909 | AliMedium(3,"CO2",10,0, iSXFLD, sXMGMX, 10., 999.,.1, .001, .001); | |
910 | ||
911 | //----------------------------------------------------------- | |
912 | // tracking media for solids | |
913 | //----------------------------------------------------------- | |
914 | ||
915 | AliMedium(4,"Al",40,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
916 | AliMedium(5,"Kevlar",34,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
917 | AliMedium(6,"Nomex",35,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
918 | AliMedium(7,"Makrolon",36,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
919 | AliMedium(8,"Mylar",37,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
920 | AliMedium(9,"Tedlar",43,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
921 | AliMedium(10,"Cu",42,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
922 | AliMedium(11,"Si",41,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
923 | AliMedium(12,"G10",39,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
924 | AliMedium(13,"Plexiglas",44,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
5a28a08f | 925 | AliMedium(14,"Epoxy",45,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); |
ba1d05f9 | 926 | AliMedium(15,"Cfiber",47,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); |
1283eee5 | 927 | |
fe4da5cc | 928 | } |
929 | ||
407ff276 | 930 | void AliTPC::GenerNoise(Int_t tablesize) |
931 | { | |
932 | // | |
933 | //Generate table with noise | |
934 | // | |
935 | if (fTPCParam==0) { | |
936 | // error message | |
937 | fNoiseDepth=0; | |
938 | return; | |
939 | } | |
940 | if (fNoiseTable) delete[] fNoiseTable; | |
941 | fNoiseTable = new Float_t[tablesize]; | |
942 | fNoiseDepth = tablesize; | |
943 | fCurrentNoise =0; //!index of the noise in the noise table | |
944 | ||
945 | Float_t norm = fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac(); | |
946 | for (Int_t i=0;i<tablesize;i++) fNoiseTable[i]= gRandom->Gaus(0,norm); | |
947 | } | |
948 | ||
949 | Float_t AliTPC::GetNoise() | |
950 | { | |
951 | // get noise from table | |
952 | // if ((fCurrentNoise%10)==0) | |
953 | // fCurrentNoise= gRandom->Rndm()*fNoiseDepth; | |
954 | if (fCurrentNoise>=fNoiseDepth) fCurrentNoise=0; | |
955 | return fNoiseTable[fCurrentNoise++]; | |
956 | //gRandom->Gaus(0, fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac()); | |
957 | } | |
958 | ||
959 | ||
792bb11c | 960 | Bool_t AliTPC::IsSectorActive(Int_t sec) |
961 | { | |
962 | // | |
963 | // check if the sector is active | |
964 | if (!fActiveSectors) return kTRUE; | |
965 | else return fActiveSectors[sec]; | |
966 | } | |
967 | ||
968 | void AliTPC::SetActiveSectors(Int_t * sectors, Int_t n) | |
969 | { | |
970 | // activate interesting sectors | |
971 | if (fActiveSectors) delete [] fActiveSectors; | |
972 | fActiveSectors = new Bool_t[fTPCParam->GetNSector()]; | |
973 | for (Int_t i=0;i<fTPCParam->GetNSector();i++) fActiveSectors[i]=kFALSE; | |
974 | for (Int_t i=0;i<n;i++) | |
975 | if ((sectors[i]>=0) && sectors[i]<fTPCParam->GetNSector()) fActiveSectors[sectors[i]]=kTRUE; | |
976 | ||
977 | } | |
978 | ||
12d8d654 | 979 | void AliTPC::SetActiveSectors(Int_t flag) |
792bb11c | 980 | { |
981 | // | |
982 | // activate sectors which were hitted by tracks | |
983 | //loop over tracks | |
984 | if (fHitType==0) return; // if Clones hit - not short volume ID information | |
985 | if (fActiveSectors) delete [] fActiveSectors; | |
986 | fActiveSectors = new Bool_t[fTPCParam->GetNSector()]; | |
12d8d654 | 987 | if (flag) { |
988 | for (Int_t i=0;i<fTPCParam->GetNSector();i++) fActiveSectors[i]=kTRUE; | |
989 | return; | |
990 | } | |
792bb11c | 991 | for (Int_t i=0;i<fTPCParam->GetNSector();i++) fActiveSectors[i]=kFALSE; |
992 | TBranch * branch=0; | |
993 | if (fHitType>1) branch = gAlice->TreeH()->GetBranch("TPC2"); | |
994 | else branch = gAlice->TreeH()->GetBranch("TPC"); | |
995 | Stat_t ntracks = gAlice->TreeH()->GetEntries(); | |
996 | // loop over all hits | |
997 | for(Int_t track=0;track<ntracks;track++){ | |
998 | ResetHits(); | |
999 | // | |
1000 | if (fTrackHits && fHitType&4) { | |
1001 | TBranch * br1 = gAlice->TreeH()->GetBranch("fVolumes"); | |
1002 | TBranch * br2 = gAlice->TreeH()->GetBranch("fNVolumes"); | |
1003 | br1->GetEvent(track); | |
1004 | br2->GetEvent(track); | |
1005 | Int_t *volumes = fTrackHits->GetVolumes(); | |
1006 | for (Int_t j=0;j<fTrackHits->GetNVolumes(); j++) | |
1007 | fActiveSectors[volumes[j]]=kTRUE; | |
1008 | } | |
1009 | ||
1010 | // | |
1011 | if (fTrackHitsOld && fHitType&2) { | |
1012 | TBranch * br = gAlice->TreeH()->GetBranch("fTrackHitsInfo"); | |
1013 | br->GetEvent(track); | |
1014 | AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo; | |
1015 | for (UInt_t j=0;j<ar->GetSize();j++){ | |
1016 | fActiveSectors[((AliTrackHitsInfo*)ar->At(j))->fVolumeID] =kTRUE; | |
1017 | } | |
1018 | } | |
1019 | } | |
1020 | ||
1021 | } | |
1022 | ||
1023 | ||
1024 | ||
fe4da5cc | 1025 | |
afc42102 | 1026 | void AliTPC::Digits2Clusters(TFile *of, Int_t eventnumber) |
fe4da5cc | 1027 | { |
3c0f9266 | 1028 | //----------------------------------------------------------------- |
1029 | // This is a simple cluster finder. | |
3c0f9266 | 1030 | //----------------------------------------------------------------- |
afc42102 | 1031 | AliTPCclusterer::Digits2Clusters(fTPCParam,of,eventnumber); |
fe4da5cc | 1032 | } |
1033 | ||
73042f01 | 1034 | extern Double_t SigmaY2(Double_t, Double_t, Double_t); |
1035 | extern Double_t SigmaZ2(Double_t, Double_t); | |
fe4da5cc | 1036 | //_____________________________________________________________________________ |
afc42102 | 1037 | void AliTPC::Hits2Clusters(TFile *of, Int_t eventn) |
fe4da5cc | 1038 | { |
8c555625 | 1039 | //-------------------------------------------------------- |
fe4da5cc | 1040 | // TPC simple cluster generator from hits |
1041 | // obtained from the TPC Fast Simulator | |
8c555625 | 1042 | // The point errors are taken from the parametrization |
1043 | //-------------------------------------------------------- | |
1044 | ||
1045 | //----------------------------------------------------------------- | |
1046 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1047 | //----------------------------------------------------------------- | |
73042f01 | 1048 | // Adopted to Marian's cluster data structure by I.Belikov, CERN, |
1049 | // Jouri.Belikov@cern.ch | |
1050 | //---------------------------------------------------------------- | |
1051 | ||
1052 | ///////////////////////////////////////////////////////////////////////////// | |
1053 | // | |
1054 | //--------------------------------------------------------------------- | |
1055 | // ALICE TPC Cluster Parameters | |
1056 | //-------------------------------------------------------------------- | |
1057 | ||
1058 | ||
1059 | ||
1060 | // Cluster width in rphi | |
1061 | const Float_t kACrphi=0.18322; | |
1062 | const Float_t kBCrphi=0.59551e-3; | |
1063 | const Float_t kCCrphi=0.60952e-1; | |
1064 | // Cluster width in z | |
1065 | const Float_t kACz=0.19081; | |
1066 | const Float_t kBCz=0.55938e-3; | |
1067 | const Float_t kCCz=0.30428; | |
1068 | ||
1069 | TDirectory *savedir=gDirectory; | |
1070 | ||
1071 | if (!of->IsOpen()) { | |
1072 | cerr<<"AliTPC::Hits2Clusters(): output file not open !\n"; | |
1073 | return; | |
1074 | } | |
3c0f9266 | 1075 | |
afc42102 | 1076 | //if(fDefaults == 0) SetDefaults(); |
cc80f89e | 1077 | |
73042f01 | 1078 | Float_t sigmaRphi,sigmaZ,clRphi,clZ; |
fe4da5cc | 1079 | // |
1578254f | 1080 | TParticle *particle; // pointer to a given particle |
fe4da5cc | 1081 | AliTPChit *tpcHit; // pointer to a sigle TPC hit |
39c8eb58 | 1082 | Int_t sector; |
fe4da5cc | 1083 | Int_t ipart; |
1084 | Float_t xyz[5]; | |
1085 | Float_t pl,pt,tanth,rpad,ratio; | |
fe4da5cc | 1086 | Float_t cph,sph; |
1087 | ||
1088 | //--------------------------------------------------------------- | |
1089 | // Get the access to the tracks | |
1090 | //--------------------------------------------------------------- | |
1091 | ||
73042f01 | 1092 | TTree *tH = gAlice->TreeH(); |
1093 | Stat_t ntracks = tH->GetEntries(); | |
73042f01 | 1094 | |
1095 | //Switch to the output file | |
1096 | of->cd(); | |
1097 | ||
afc42102 | 1098 | char cname[100]; |
1099 | ||
1100 | sprintf(cname,"TreeC_TPC_%d",eventn); | |
1101 | ||
73042f01 | 1102 | fTPCParam->Write(fTPCParam->GetTitle()); |
1103 | AliTPCClustersArray carray; | |
1104 | carray.Setup(fTPCParam); | |
1105 | carray.SetClusterType("AliTPCcluster"); | |
1106 | carray.MakeTree(); | |
1107 | ||
1108 | Int_t nclusters=0; //cluster counter | |
fe4da5cc | 1109 | |
1110 | //------------------------------------------------------------ | |
cc80f89e | 1111 | // Loop over all sectors (72 sectors for 20 deg |
1112 | // segmentation for both lower and upper sectors) | |
1113 | // Sectors 0-35 are lower sectors, 0-17 z>0, 17-35 z<0 | |
3c0f9266 | 1114 | // Sectors 36-71 are upper sectors, 36-53 z>0, 54-71 z<0 |
fe4da5cc | 1115 | // |
3c0f9266 | 1116 | // First cluster for sector 0 starts at "0" |
fe4da5cc | 1117 | //------------------------------------------------------------ |
cc80f89e | 1118 | |
1119 | for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++){ | |
8c555625 | 1120 | //MI change |
cc80f89e | 1121 | fTPCParam->AdjustCosSin(isec,cph,sph); |
fe4da5cc | 1122 | |
1123 | //------------------------------------------------------------ | |
1124 | // Loop over tracks | |
1125 | //------------------------------------------------------------ | |
1126 | ||
1127 | for(Int_t track=0;track<ntracks;track++){ | |
1128 | ResetHits(); | |
73042f01 | 1129 | tH->GetEvent(track); |
fe4da5cc | 1130 | // |
73042f01 | 1131 | // Get number of the TPC hits |
792bb11c | 1132 | // |
39c8eb58 | 1133 | tpcHit = (AliTPChit*)FirstHit(-1); |
1134 | ||
fe4da5cc | 1135 | // Loop over hits |
1136 | // | |
39c8eb58 | 1137 | while(tpcHit){ |
1138 | ||
1139 | if (tpcHit->fQ == 0.) { | |
1140 | tpcHit = (AliTPChit*) NextHit(); | |
1141 | continue; //information about track (I.Belikov) | |
1142 | } | |
fe4da5cc | 1143 | sector=tpcHit->fSector; // sector number |
39c8eb58 | 1144 | |
39c8eb58 | 1145 | if(sector != isec){ |
1146 | tpcHit = (AliTPChit*) NextHit(); | |
1147 | continue; | |
1148 | } | |
94de3818 | 1149 | ipart=tpcHit->Track(); |
2ab0c725 | 1150 | particle=gAlice->Particle(ipart); |
1578254f | 1151 | pl=particle->Pz(); |
1152 | pt=particle->Pt(); | |
fe4da5cc | 1153 | if(pt < 1.e-9) pt=1.e-9; |
1154 | tanth=pl/pt; | |
1155 | tanth = TMath::Abs(tanth); | |
94de3818 | 1156 | rpad=TMath::Sqrt(tpcHit->X()*tpcHit->X() + tpcHit->Y()*tpcHit->Y()); |
fe4da5cc | 1157 | ratio=0.001*rpad/pt; // pt must be in MeV/c - historical reason |
73042f01 | 1158 | |
fe4da5cc | 1159 | // space-point resolutions |
1160 | ||
73042f01 | 1161 | sigmaRphi=SigmaY2(rpad,tanth,pt); |
1162 | sigmaZ =SigmaZ2(rpad,tanth ); | |
fe4da5cc | 1163 | |
1164 | // cluster widths | |
1165 | ||
73042f01 | 1166 | clRphi=kACrphi-kBCrphi*rpad*tanth+kCCrphi*ratio*ratio; |
1167 | clZ=kACz-kBCz*rpad*tanth+kCCz*tanth*tanth; | |
fe4da5cc | 1168 | |
1169 | // temporary protection | |
1170 | ||
73042f01 | 1171 | if(sigmaRphi < 0.) sigmaRphi=0.4e-3; |
1172 | if(sigmaZ < 0.) sigmaZ=0.4e-3; | |
1173 | if(clRphi < 0.) clRphi=2.5e-3; | |
1174 | if(clZ < 0.) clZ=2.5e-5; | |
fe4da5cc | 1175 | |
1176 | // | |
cc80f89e | 1177 | |
1178 | // | |
1179 | // smearing --> rotate to the 1 (13) or to the 25 (49) sector, | |
fe4da5cc | 1180 | // then the inaccuracy in a X-Y plane is only along Y (pad row)! |
1181 | // | |
94de3818 | 1182 | Float_t xprim= tpcHit->X()*cph + tpcHit->Y()*sph; |
1183 | Float_t yprim=-tpcHit->X()*sph + tpcHit->Y()*cph; | |
73042f01 | 1184 | xyz[0]=gRandom->Gaus(yprim,TMath::Sqrt(sigmaRphi)); // y |
1185 | Float_t alpha=(isec < fTPCParam->GetNInnerSector()) ? | |
1186 | fTPCParam->GetInnerAngle() : fTPCParam->GetOuterAngle(); | |
1187 | Float_t ymax=xprim*TMath::Tan(0.5*alpha); | |
1188 | if (TMath::Abs(xyz[0])>ymax) xyz[0]=yprim; | |
94de3818 | 1189 | xyz[1]=gRandom->Gaus(tpcHit->Z(),TMath::Sqrt(sigmaZ)); // z |
1190 | if (TMath::Abs(xyz[1])>fTPCParam->GetZLength()) xyz[1]=tpcHit->Z(); | |
39c8eb58 | 1191 | xyz[2]=sigmaRphi; // fSigmaY2 |
1192 | xyz[3]=sigmaZ; // fSigmaZ2 | |
1193 | xyz[4]=tpcHit->fQ; // q | |
73042f01 | 1194 | |
1195 | AliTPCClustersRow *clrow=carray.GetRow(sector,tpcHit->fPadRow); | |
1196 | if (!clrow) clrow=carray.CreateRow(sector,tpcHit->fPadRow); | |
1197 | ||
94de3818 | 1198 | Int_t tracks[3]={tpcHit->Track(), -1, -1}; |
39c8eb58 | 1199 | AliTPCcluster cluster(tracks,xyz); |
73042f01 | 1200 | |
1201 | clrow->InsertCluster(&cluster); nclusters++; | |
1202 | ||
39c8eb58 | 1203 | tpcHit = (AliTPChit*)NextHit(); |
1204 | ||
1205 | ||
fe4da5cc | 1206 | } // end of loop over hits |
73042f01 | 1207 | |
1208 | } // end of loop over tracks | |
1209 | ||
1210 | Int_t nrows=fTPCParam->GetNRow(isec); | |
1211 | for (Int_t irow=0; irow<nrows; irow++) { | |
1212 | AliTPCClustersRow *clrow=carray.GetRow(isec,irow); | |
1213 | if (!clrow) continue; | |
1214 | carray.StoreRow(isec,irow); | |
1215 | carray.ClearRow(isec,irow); | |
1216 | } | |
1217 | ||
cc80f89e | 1218 | } // end of loop over sectors |
73042f01 | 1219 | |
1220 | cerr<<"Number of made clusters : "<<nclusters<<" \n"; | |
6bc3458d | 1221 | carray.GetTree()->SetName(cname); |
1222 | carray.GetTree()->Write(); | |
73042f01 | 1223 | |
1224 | savedir->cd(); //switch back to the input file | |
cc80f89e | 1225 | |
1226 | } // end of function | |
1227 | ||
1228 | //_________________________________________________________________ | |
1229 | void AliTPC::Hits2ExactClustersSector(Int_t isec) | |
1230 | { | |
1231 | //-------------------------------------------------------- | |
1232 | //calculate exact cross point of track and given pad row | |
1233 | //resulting values are expressed in "digit" coordinata | |
1234 | //-------------------------------------------------------- | |
1235 | ||
1236 | //----------------------------------------------------------------- | |
1237 | // Origin: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de | |
1238 | //----------------------------------------------------------------- | |
1239 | // | |
1240 | if (fClustersArray==0){ | |
1241 | return; | |
1242 | } | |
1243 | // | |
1244 | TParticle *particle; // pointer to a given particle | |
1245 | AliTPChit *tpcHit; // pointer to a sigle TPC hit | |
5f16d237 | 1246 | // Int_t sector,nhits; |
cc80f89e | 1247 | Int_t ipart; |
73042f01 | 1248 | const Int_t kcmaxhits=30000; |
de61d5d5 | 1249 | AliTPCFastVector * xxxx = new AliTPCFastVector(kcmaxhits*4); |
1250 | AliTPCFastVector & xxx = *xxxx; | |
73042f01 | 1251 | Int_t maxhits = kcmaxhits; |
cc80f89e | 1252 | //construct array for each padrow |
1253 | for (Int_t i=0; i<fTPCParam->GetNRow(isec);i++) | |
1254 | fClustersArray->CreateRow(isec,i); | |
fe4da5cc | 1255 | |
cc80f89e | 1256 | //--------------------------------------------------------------- |
1257 | // Get the access to the tracks | |
1258 | //--------------------------------------------------------------- | |
1259 | ||
73042f01 | 1260 | TTree *tH = gAlice->TreeH(); |
1261 | Stat_t ntracks = tH->GetEntries(); | |
2ab0c725 | 1262 | Int_t npart = gAlice->GetNtrack(); |
5f16d237 | 1263 | //MI change |
1264 | TBranch * branch=0; | |
792bb11c | 1265 | if (fHitType>1) branch = tH->GetBranch("TPC2"); |
5f16d237 | 1266 | else branch = tH->GetBranch("TPC"); |
1267 | ||
cc80f89e | 1268 | //------------------------------------------------------------ |
1269 | // Loop over tracks | |
1270 | //------------------------------------------------------------ | |
792bb11c | 1271 | |
5f16d237 | 1272 | for(Int_t track=0;track<ntracks;track++){ |
1273 | Bool_t isInSector=kTRUE; | |
cc80f89e | 1274 | ResetHits(); |
792bb11c | 1275 | isInSector = TrackInVolume(isec,track); |
5f16d237 | 1276 | if (!isInSector) continue; |
1277 | //MI change | |
1278 | branch->GetEntry(track); // get next track | |
cc80f89e | 1279 | // |
1280 | // Get number of the TPC hits and a pointer | |
1281 | // to the particles | |
cc80f89e | 1282 | // Loop over hits |
1283 | // | |
1284 | Int_t currentIndex=0; | |
1285 | Int_t lastrow=-1; //last writen row | |
5f16d237 | 1286 | |
1287 | //M.I. changes | |
1288 | ||
1289 | tpcHit = (AliTPChit*)FirstHit(-1); | |
1290 | while(tpcHit){ | |
1291 | ||
1292 | Int_t sector=tpcHit->fSector; // sector number | |
1293 | if(sector != isec){ | |
1294 | tpcHit = (AliTPChit*) NextHit(); | |
1295 | continue; | |
1296 | } | |
1297 | ||
94de3818 | 1298 | ipart=tpcHit->Track(); |
2ab0c725 | 1299 | if (ipart<npart) particle=gAlice->Particle(ipart); |
cc80f89e | 1300 | |
1301 | //find row number | |
1302 | ||
94de3818 | 1303 | Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()}; |
cc80f89e | 1304 | Int_t index[3]={1,isec,0}; |
1305 | Int_t currentrow = fTPCParam->GetPadRow(x,index) ; | |
5f16d237 | 1306 | if (currentrow<0) {tpcHit = (AliTPChit*)NextHit(); continue;} |
cc80f89e | 1307 | if (lastrow<0) lastrow=currentrow; |
1308 | if (currentrow==lastrow){ | |
1309 | if ( currentIndex>=maxhits){ | |
73042f01 | 1310 | maxhits+=kcmaxhits; |
cc80f89e | 1311 | xxx.ResizeTo(4*maxhits); |
1312 | } | |
1313 | xxx(currentIndex*4)=x[0]; | |
1314 | xxx(currentIndex*4+1)=x[1]; | |
1315 | xxx(currentIndex*4+2)=x[2]; | |
1316 | xxx(currentIndex*4+3)=tpcHit->fQ; | |
1317 | currentIndex++; | |
1318 | } | |
1319 | else | |
1320 | if (currentIndex>2){ | |
1321 | Float_t sumx=0; | |
1322 | Float_t sumx2=0; | |
1323 | Float_t sumx3=0; | |
1324 | Float_t sumx4=0; | |
1325 | Float_t sumy=0; | |
1326 | Float_t sumxy=0; | |
1327 | Float_t sumx2y=0; | |
1328 | Float_t sumz=0; | |
1329 | Float_t sumxz=0; | |
1330 | Float_t sumx2z=0; | |
1331 | Float_t sumq=0; | |
1332 | for (Int_t index=0;index<currentIndex;index++){ | |
1333 | Float_t x,x2,x3,x4; | |
1334 | x=x2=x3=x4=xxx(index*4); | |
1335 | x2*=x; | |
1336 | x3*=x2; | |
1337 | x4*=x3; | |
1338 | sumx+=x; | |
1339 | sumx2+=x2; | |
1340 | sumx3+=x3; | |
1341 | sumx4+=x4; | |
1342 | sumy+=xxx(index*4+1); | |
1343 | sumxy+=xxx(index*4+1)*x; | |
1344 | sumx2y+=xxx(index*4+1)*x2; | |
1345 | sumz+=xxx(index*4+2); | |
1346 | sumxz+=xxx(index*4+2)*x; | |
1347 | sumx2z+=xxx(index*4+2)*x2; | |
1348 | sumq+=xxx(index*4+3); | |
1349 | } | |
73042f01 | 1350 | Float_t centralPad = (fTPCParam->GetNPads(isec,lastrow)-1)/2; |
cc80f89e | 1351 | Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+ |
1352 | sumx2*(sumx*sumx3-sumx2*sumx2); | |
1353 | ||
1354 | Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+ | |
1355 | sumx2*(sumxy*sumx3-sumx2y*sumx2); | |
1356 | Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+ | |
1357 | sumx2*(sumxz*sumx3-sumx2z*sumx2); | |
1358 | ||
1359 | Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+ | |
1360 | sumx2*(sumx*sumx2y-sumx2*sumxy); | |
1361 | Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+ | |
1362 | sumx2*(sumx*sumx2z-sumx2*sumxz); | |
1363 | ||
da33556f | 1364 | if (TMath::Abs(det)<0.00001){ |
1365 | tpcHit = (AliTPChit*)NextHit(); | |
1366 | continue; | |
1367 | } | |
1368 | ||
73042f01 | 1369 | Float_t y=detay/det+centralPad; |
cc80f89e | 1370 | Float_t z=detaz/det; |
1371 | Float_t by=detby/det; //y angle | |
1372 | Float_t bz=detbz/det; //z angle | |
1373 | sumy/=Float_t(currentIndex); | |
1374 | sumz/=Float_t(currentIndex); | |
5f16d237 | 1375 | |
cc80f89e | 1376 | AliTPCClustersRow * row = (fClustersArray->GetRow(isec,lastrow)); |
5f16d237 | 1377 | if (row!=0) { |
1378 | AliComplexCluster* cl = new((AliComplexCluster*)row->Append()) AliComplexCluster ; | |
1379 | // AliComplexCluster cl; | |
1380 | cl->fX=z; | |
1381 | cl->fY=y; | |
1382 | cl->fQ=sumq; | |
1383 | cl->fSigmaX2=bz; | |
1384 | cl->fSigmaY2=by; | |
1385 | cl->fTracks[0]=ipart; | |
1386 | } | |
cc80f89e | 1387 | currentIndex=0; |
1388 | lastrow=currentrow; | |
1389 | } //end of calculating cluster for given row | |
1390 | ||
1391 | ||
5f16d237 | 1392 | tpcHit = (AliTPChit*)NextHit(); |
cc80f89e | 1393 | } // end of loop over hits |
1394 | } // end of loop over tracks | |
1395 | //write padrows to tree | |
1396 | for (Int_t ii=0; ii<fTPCParam->GetNRow(isec);ii++) { | |
1397 | fClustersArray->StoreRow(isec,ii); | |
1398 | fClustersArray->ClearRow(isec,ii); | |
1399 | } | |
1400 | xxxx->Delete(); | |
1401 | ||
fe4da5cc | 1402 | } |
0a61bf9d | 1403 | |
1404 | ||
1405 | ||
1406 | //__ | |
1407 | void AliTPC::SDigits2Digits2(Int_t eventnumber) | |
1408 | { | |
1409 | //create digits from summable digits | |
407ff276 | 1410 | GenerNoise(500000); //create teble with noise |
0a61bf9d | 1411 | char sname[100]; |
1412 | char dname[100]; | |
1413 | sprintf(sname,"TreeS_%s_%d",fTPCParam->GetTitle(),eventnumber); | |
1414 | sprintf(dname,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber); | |
1415 | ||
1416 | //conect tree with sSDigits | |
12d8d654 | 1417 | TTree *t; |
1418 | if (gAlice->GetTreeDFile()) { | |
1419 | t = (TTree *)gAlice->GetTreeDFile()->Get(sname); | |
1420 | } else { | |
1421 | t = (TTree *)gDirectory->Get(sname); | |
1422 | } | |
1423 | if (!t) { | |
1424 | cerr<<"TPC tree with sdigits not found"<<endl; | |
1425 | return; | |
1426 | } | |
0a61bf9d | 1427 | AliSimDigits digarr, *dummy=&digarr; |
1428 | t->GetBranch("Segment")->SetAddress(&dummy); | |
1429 | Stat_t nentries = t->GetEntries(); | |
1430 | ||
5f16d237 | 1431 | // set zero suppression |
1432 | ||
1433 | fTPCParam->SetZeroSup(2); | |
1434 | ||
1435 | // get zero suppression | |
1436 | ||
1437 | Int_t zerosup = fTPCParam->GetZeroSup(); | |
1438 | ||
1439 | //make tree with digits | |
1440 | ||
0a61bf9d | 1441 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; |
1442 | arr->SetClass("AliSimDigits"); | |
1443 | arr->Setup(fTPCParam); | |
12d8d654 | 1444 | // Note that methods arr->MakeTree have different signatures |
1445 | if (gAlice->GetTreeDFile()) { | |
1446 | arr->MakeTree(gAlice->GetTreeDFile()); | |
1447 | } else { | |
1448 | arr->MakeTree(fDigitsFile); | |
1449 | } | |
0a61bf9d | 1450 | |
1451 | AliTPCParam * par =fTPCParam; | |
5f16d237 | 1452 | |
0a61bf9d | 1453 | //Loop over segments of the TPC |
5f16d237 | 1454 | |
0a61bf9d | 1455 | for (Int_t n=0; n<nentries; n++) { |
1456 | t->GetEvent(n); | |
1457 | Int_t sec, row; | |
1458 | if (!par->AdjustSectorRow(digarr.GetID(),sec,row)) { | |
1459 | cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl; | |
1460 | continue; | |
1461 | } | |
792bb11c | 1462 | if (!IsSectorActive(sec)) continue; |
0a61bf9d | 1463 | AliSimDigits * digrow =(AliSimDigits*) arr->CreateRow(sec,row); |
1464 | Int_t nrows = digrow->GetNRows(); | |
1465 | Int_t ncols = digrow->GetNCols(); | |
1466 | ||
1467 | digrow->ExpandBuffer(); | |
1468 | digarr.ExpandBuffer(); | |
1469 | digrow->ExpandTrackBuffer(); | |
1470 | digarr.ExpandTrackBuffer(); | |
1471 | ||
5f16d237 | 1472 | |
407ff276 | 1473 | Short_t * pamp0 = digarr.GetDigits(); |
1474 | Int_t * ptracks0 = digarr.GetTracks(); | |
1475 | Short_t * pamp1 = digrow->GetDigits(); | |
1476 | Int_t * ptracks1 = digrow->GetTracks(); | |
1477 | Int_t nelems =nrows*ncols; | |
1478 | Int_t saturation = fTPCParam->GetADCSat(); | |
1479 | //use internal structure of the AliDigits - for speed reason | |
1480 | //if you cahnge implementation | |
1481 | //of the Alidigits - it must be rewriten - | |
1482 | for (Int_t i= 0; i<nelems; i++){ | |
1483 | // Float_t q = *pamp0; | |
1484 | //q/=16.; //conversion faktor | |
1485 | //Float_t noise= GetNoise(); | |
1486 | //q+=noise; | |
1487 | //q= TMath::Nint(q); | |
1488 | Float_t q = TMath::Nint(Float_t(*pamp0)/16.+GetNoise()); | |
1489 | if (q>zerosup){ | |
1490 | if (q>saturation) q=saturation; | |
1491 | *pamp1=(Short_t)q; | |
1492 | //if (ptracks0[0]==0) | |
1493 | // ptracks1[0]=1; | |
1494 | //else | |
1495 | ptracks1[0]=ptracks0[0]; | |
1496 | ptracks1[nelems]=ptracks0[nelems]; | |
1497 | ptracks1[2*nelems]=ptracks0[2*nelems]; | |
1498 | } | |
1499 | pamp0++; | |
1500 | pamp1++; | |
1501 | ptracks0++; | |
1502 | ptracks1++; | |
1503 | } | |
5f16d237 | 1504 | |
5f16d237 | 1505 | arr->StoreRow(sec,row); |
1506 | arr->ClearRow(sec,row); | |
9fe90376 | 1507 | // cerr<<sec<<"\t"<<row<<"\n"; |
5f16d237 | 1508 | } |
0a61bf9d | 1509 | |
0a61bf9d | 1510 | |
5f16d237 | 1511 | //write results |
0a61bf9d | 1512 | |
5f16d237 | 1513 | |
1514 | arr->GetTree()->SetName(dname); | |
12d8d654 | 1515 | arr->GetTree()->AutoSave(); |
5f16d237 | 1516 | delete arr; |
1517 | } | |
1518 | //_________________________________________ | |
1519 | void AliTPC::Merge(TTree * intree, Int_t *mask, Int_t nin, Int_t outid) | |
1520 | { | |
1521 | ||
1522 | //intree - pointer to array of trees with s digits | |
1523 | //mask - mask for each | |
1524 | //nin - number of inputs | |
1525 | //outid - event number of the output event | |
1526 | ||
1527 | //create digits from summable digits | |
1528 | //conect tree with sSDigits | |
1529 | ||
1530 | ||
1531 | AliSimDigits ** digarr = new AliSimDigits*[nin]; | |
1532 | for (Int_t i1=0;i1<nin; i1++){ | |
1533 | digarr[i1]=0; | |
1534 | intree[i1].GetBranch("Segment")->SetAddress(&digarr[i1]); | |
0a61bf9d | 1535 | } |
5f16d237 | 1536 | Stat_t nentries = intree[0].GetEntries(); |
1537 | ||
1538 | //make tree with digits | |
1539 | char dname[100]; | |
1540 | sprintf(dname,"TreeD_%s_%d",fTPCParam->GetTitle(),outid); | |
1541 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; | |
1542 | arr->SetClass("AliSimDigits"); | |
1543 | arr->Setup(fTPCParam); | |
1544 | arr->MakeTree(fDigitsFile); | |
0a61bf9d | 1545 | |
5f16d237 | 1546 | // set zero suppression |
0a61bf9d | 1547 | |
5f16d237 | 1548 | fTPCParam->SetZeroSup(2); |
0a61bf9d | 1549 | |
5f16d237 | 1550 | // get zero suppression |
1551 | ||
1552 | Int_t zerosup = fTPCParam->GetZeroSup(); | |
1553 | ||
1554 | ||
1555 | AliTPCParam * par =fTPCParam; | |
1556 | ||
1557 | //Loop over segments of the TPC | |
1558 | for (Int_t n=0; n<nentries; n++) { | |
0a61bf9d | 1559 | |
5f16d237 | 1560 | for (Int_t i=0;i<nin; i++){ |
1561 | //connect proper digits | |
1562 | intree[i].GetEvent(n); | |
1563 | digarr[i]->ExpandBuffer(); | |
1564 | digarr[i]->ExpandTrackBuffer(); | |
1565 | } | |
1566 | Int_t sec, row; | |
1567 | if (!par->AdjustSectorRow(digarr[0]->GetID(),sec,row)) { | |
1568 | cerr<<"AliTPC warning: invalid segment ID ! "<<digarr[0]->GetID()<<endl; | |
1569 | continue; | |
1570 | } | |
0a61bf9d | 1571 | |
5f16d237 | 1572 | AliSimDigits * digrow =(AliSimDigits*) arr->CreateRow(sec,row); |
1573 | Int_t nrows = digrow->GetNRows(); | |
1574 | Int_t ncols = digrow->GetNCols(); | |
0a61bf9d | 1575 | |
5f16d237 | 1576 | digrow->ExpandBuffer(); |
1577 | digrow->ExpandTrackBuffer(); | |
1578 | ||
1579 | for (Int_t rows=0;rows<nrows; rows++){ | |
1580 | for (Int_t col=0;col<ncols; col++){ | |
1581 | Float_t q=0; | |
1582 | Int_t label[1000]; // i hope no more than 300 events merged | |
1583 | Int_t labptr = 0; | |
1584 | // looop over digits | |
1585 | for (Int_t i=0;i<nin; i++){ | |
1586 | q += digarr[i]->GetDigitFast(rows,col); | |
1587 | for (Int_t tr=0;tr<3;tr++) { | |
1588 | Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr); | |
1589 | if ( lab > 1) { | |
1590 | label[labptr]=lab+mask[i]-2; | |
1591 | labptr++; | |
1592 | } | |
1593 | } | |
1594 | } | |
1595 | //add noise | |
1596 | q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac()*16); | |
1597 | ||
1598 | q/=16; //conversion faktor | |
1599 | q=(Short_t)q; | |
1600 | ||
1601 | if (q> zerosup){ | |
1602 | ||
43510af3 | 1603 | if(q > fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat(); |
1604 | digrow->SetDigitFast((Short_t)q,rows,col); | |
5f16d237 | 1605 | for (Int_t tr=0;tr<3;tr++){ |
1606 | if (tr<labptr) | |
1607 | ((AliSimDigits*)digrow)->SetTrackIDFast(label[tr],rows,col,tr); | |
1608 | else | |
1609 | ((AliSimDigits*)digrow)->SetTrackIDFast(-1,rows,col,tr); | |
1610 | } | |
1611 | } | |
1612 | } | |
1613 | } | |
1614 | arr->StoreRow(sec,row); | |
1615 | ||
1616 | arr->ClearRow(sec,row); | |
792bb11c | 1617 | |
5f16d237 | 1618 | } |
1619 | ||
1620 | delete digarr; | |
1621 | arr->GetTree()->SetName(dname); | |
1622 | arr->GetTree()->Write(); | |
1623 | ||
1624 | delete arr; | |
0a61bf9d | 1625 | |
0a61bf9d | 1626 | } |
1627 | ||
0a61bf9d | 1628 | /*_________________________________________ |
afc42102 | 1629 | void AliTPC::SDigits2Digits(Int_t eventnumber) |
2ab0c725 | 1630 | { |
afc42102 | 1631 | |
1632 | ||
1633 | cerr<<"Digitizing TPC...\n"; | |
1634 | ||
1635 | Hits2Digits(eventnumber); | |
1636 | ||
1637 | ||
1638 | //write results | |
1639 | ||
1640 | // char treeName[100]; | |
1641 | ||
1642 | // sprintf(treeName,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber); | |
1643 | ||
1644 | // GetDigitsArray()->GetTree()->Write(treeName); | |
1645 | } | |
0a61bf9d | 1646 | */ |
afc42102 | 1647 | //__________________________________________________________________ |
1648 | void AliTPC::SetDefaults(){ | |
1649 | ||
1650 | ||
1651 | cerr<<"Setting default parameters...\n"; | |
1652 | ||
1653 | // Set response functions | |
1654 | ||
2ab0c725 | 1655 | AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60"); |
7a09f434 | 1656 | if(param){ |
1657 | printf("You are using 2 pad-length geom hits with 3 pad-lenght geom digits...\n"); | |
1658 | delete param; | |
1659 | param = new AliTPCParamSR(); | |
1660 | } | |
1661 | else { | |
1662 | param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60_150x60"); | |
1663 | } | |
1664 | if(!param){ | |
1665 | printf("No TPC parameters found\n"); | |
1666 | exit(4); | |
1667 | } | |
1668 | ||
1669 | ||
2ab0c725 | 1670 | AliTPCPRF2D * prfinner = new AliTPCPRF2D; |
f03e3423 | 1671 | AliTPCPRF2D * prfouter1 = new AliTPCPRF2D; |
1672 | AliTPCPRF2D * prfouter2 = new AliTPCPRF2D; | |
2ab0c725 | 1673 | AliTPCRF1D * rf = new AliTPCRF1D(kTRUE); |
2ab0c725 | 1674 | rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.); |
1675 | rf->SetOffset(3*param->GetZSigma()); | |
1676 | rf->Update(); | |
afc42102 | 1677 | |
1678 | TDirectory *savedir=gDirectory; | |
2ab0c725 | 1679 | TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root"); |
1680 | if (!f->IsOpen()) { | |
afc42102 | 1681 | cerr<<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !\n" ; |
2ab0c725 | 1682 | exit(3); |
1683 | } | |
1684 | prfinner->Read("prf_07504_Gati_056068_d02"); | |
f03e3423 | 1685 | prfouter1->Read("prf_10006_Gati_047051_d03"); |
1686 | prfouter2->Read("prf_15006_Gati_047051_d03"); | |
2ab0c725 | 1687 | f->Close(); |
afc42102 | 1688 | savedir->cd(); |
1689 | ||
2ab0c725 | 1690 | param->SetInnerPRF(prfinner); |
f03e3423 | 1691 | param->SetOuter1PRF(prfouter1); |
1692 | param->SetOuter2PRF(prfouter2); | |
2ab0c725 | 1693 | param->SetTimeRF(rf); |
1694 | ||
afc42102 | 1695 | // set fTPCParam |
1696 | ||
2ab0c725 | 1697 | SetParam(param); |
1698 | ||
afc42102 | 1699 | |
1700 | fDefaults = 1; | |
1701 | ||
1702 | } | |
1703 | //__________________________________________________________________ | |
1704 | void AliTPC::Hits2Digits(Int_t eventnumber) | |
1705 | { | |
1706 | //---------------------------------------------------- | |
1707 | // Loop over all sectors for a single event | |
1708 | //---------------------------------------------------- | |
1709 | ||
1710 | ||
1711 | if(fDefaults == 0) SetDefaults(); // check if the parameters are set | |
407ff276 | 1712 | GenerNoise(500000); //create teble with noise |
2ab0c725 | 1713 | |
1714 | //setup TPCDigitsArray | |
afc42102 | 1715 | |
1716 | if(GetDigitsArray()) delete GetDigitsArray(); | |
1717 | ||
2ab0c725 | 1718 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; |
1719 | arr->SetClass("AliSimDigits"); | |
afc42102 | 1720 | arr->Setup(fTPCParam); |
12d8d654 | 1721 | // Note that methods arr->MakeTree have different signatures |
1722 | if (gAlice->GetTreeDFile()) { | |
1723 | arr->MakeTree(gAlice->GetTreeDFile()); | |
1724 | } else { | |
1725 | arr->MakeTree(fDigitsFile); | |
1726 | } | |
2ab0c725 | 1727 | SetDigitsArray(arr); |
1728 | ||
afc42102 | 1729 | fDigitsSwitch=0; // standard digits |
2ab0c725 | 1730 | |
0a9b058d | 1731 | cerr<<"Digitizing TPC -- normal digits...\n"; |
fe4da5cc | 1732 | |
f03e3423 | 1733 | for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) if (IsSectorActive(isec)) Hits2DigitsSector(isec); |
1734 | ||
afc42102 | 1735 | // write results |
1736 | ||
1737 | char treeName[100]; | |
1738 | ||
1739 | sprintf(treeName,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber); | |
f8cf550c | 1740 | |
6bc3458d | 1741 | GetDigitsArray()->GetTree()->SetName(treeName); |
12d8d654 | 1742 | GetDigitsArray()->GetTree()->AutoSave(); |
cc80f89e | 1743 | |
cc80f89e | 1744 | |
8c555625 | 1745 | } |
1746 | ||
afc42102 | 1747 | |
1748 | ||
f8cf550c | 1749 | //__________________________________________________________________ |
0a61bf9d | 1750 | void AliTPC::Hits2SDigits2(Int_t eventnumber) |
f8cf550c | 1751 | { |
1752 | ||
1753 | //----------------------------------------------------------- | |
1754 | // summable digits - 16 bit "ADC", no noise, no saturation | |
1755 | //----------------------------------------------------------- | |
1756 | ||
1757 | //---------------------------------------------------- | |
afc42102 | 1758 | // Loop over all sectors for a single event |
f8cf550c | 1759 | //---------------------------------------------------- |
1760 | ||
afc42102 | 1761 | |
1762 | if(fDefaults == 0) SetDefaults(); | |
407ff276 | 1763 | GenerNoise(500000); //create table with noise |
afc42102 | 1764 | //setup TPCDigitsArray |
1765 | ||
1766 | if(GetDigitsArray()) delete GetDigitsArray(); | |
1767 | ||
1768 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; | |
1769 | arr->SetClass("AliSimDigits"); | |
1770 | arr->Setup(fTPCParam); | |
12d8d654 | 1771 | // Note that methods arr->MakeTree have different signatures |
1772 | if (gAlice->GetTreeSFile()) { | |
1773 | arr->MakeTree(gAlice->GetTreeSFile()); | |
1774 | } else { | |
1775 | arr->MakeTree(fDigitsFile); | |
1776 | } | |
afc42102 | 1777 | SetDigitsArray(arr); |
1778 | ||
0a9b058d | 1779 | cerr<<"Digitizing TPC -- summable digits...\n"; |
afc42102 | 1780 | |
1781 | fDigitsSwitch=1; // summable digits | |
5f16d237 | 1782 | |
1783 | // set zero suppression to "0" | |
1784 | ||
1785 | fTPCParam->SetZeroSup(0); | |
f8cf550c | 1786 | |
792bb11c | 1787 | for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) if (IsSectorActive(isec)) Hits2DigitsSector(isec); |
f8cf550c | 1788 | |
afc42102 | 1789 | |
1790 | // write results | |
1791 | ||
1792 | char treeName[100]; | |
1793 | ||
1794 | sprintf(treeName,"TreeS_%s_%d",fTPCParam->GetTitle(),eventnumber); | |
1795 | ||
6bc3458d | 1796 | GetDigitsArray()->GetTree()->SetName(treeName); |
12d8d654 | 1797 | GetDigitsArray()->GetTree()->AutoSave(); |
afc42102 | 1798 | |
f8cf550c | 1799 | } |
8c555625 | 1800 | |
afc42102 | 1801 | |
1802 | ||
0a61bf9d | 1803 | //__________________________________________________________________ |
1804 | void AliTPC::Hits2SDigits() | |
1805 | { | |
1806 | ||
1807 | //----------------------------------------------------------- | |
1808 | // summable digits - 16 bit "ADC", no noise, no saturation | |
1809 | //----------------------------------------------------------- | |
1810 | ||
1811 | //---------------------------------------------------- | |
1812 | // Loop over all sectors for a single event | |
1813 | //---------------------------------------------------- | |
1814 | //MI change - for pp run | |
1815 | Int_t eventnumber = gAlice->GetEvNumber(); | |
1816 | ||
1817 | if(fDefaults == 0) SetDefaults(); | |
180f4872 | 1818 | GenerNoise(500000); //create table with noise |
0a61bf9d | 1819 | |
1820 | //setup TPCDigitsArray | |
1821 | ||
1822 | if(GetDigitsArray()) delete GetDigitsArray(); | |
1823 | ||
1824 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; | |
1825 | arr->SetClass("AliSimDigits"); | |
1826 | arr->Setup(fTPCParam); | |
12d8d654 | 1827 | // Note that methods arr->MakeTree have different signatures |
1828 | if (gAlice->GetTreeSFile()) { | |
1829 | arr->MakeTree(gAlice->GetTreeSFile()); | |
1830 | } else { | |
1831 | arr->MakeTree(fDigitsFile); | |
1832 | } | |
0a61bf9d | 1833 | SetDigitsArray(arr); |
1834 | ||
0a9b058d | 1835 | cerr<<"Digitizing TPC -- summable digits...\n"; |
0a61bf9d | 1836 | |
1837 | // fDigitsSwitch=1; // summable digits -for the moment direct | |
1838 | ||
792bb11c | 1839 | for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) if (IsSectorActive(isec)) Hits2DigitsSector(isec); |
0a61bf9d | 1840 | |
1841 | ||
1842 | // write results | |
1843 | char treeName[100]; | |
1844 | ||
1845 | sprintf(treeName,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber); | |
1846 | ||
6bc3458d | 1847 | GetDigitsArray()->GetTree()->SetName(treeName); |
12d8d654 | 1848 | GetDigitsArray()->GetTree()->AutoSave(); |
0a61bf9d | 1849 | |
1850 | } | |
1851 | ||
1852 | ||
fe4da5cc | 1853 | //_____________________________________________________________________________ |
8c555625 | 1854 | void AliTPC::Hits2DigitsSector(Int_t isec) |
fe4da5cc | 1855 | { |
8c555625 | 1856 | //------------------------------------------------------------------- |
fe4da5cc | 1857 | // TPC conversion from hits to digits. |
8c555625 | 1858 | //------------------------------------------------------------------- |
1859 | ||
1860 | //----------------------------------------------------------------- | |
1861 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1862 | //----------------------------------------------------------------- | |
1863 | ||
fe4da5cc | 1864 | //------------------------------------------------------- |
8c555625 | 1865 | // Get the access to the track hits |
fe4da5cc | 1866 | //------------------------------------------------------- |
8c555625 | 1867 | |
afc42102 | 1868 | // check if the parameters are set - important if one calls this method |
1869 | // directly, not from the Hits2Digits | |
1870 | ||
1871 | if(fDefaults == 0) SetDefaults(); | |
cc80f89e | 1872 | |
73042f01 | 1873 | TTree *tH = gAlice->TreeH(); // pointer to the hits tree |
1874 | Stat_t ntracks = tH->GetEntries(); | |
8c555625 | 1875 | |
1876 | if( ntracks > 0){ | |
1877 | ||
1878 | //------------------------------------------- | |
1879 | // Only if there are any tracks... | |
1880 | //------------------------------------------- | |
1881 | ||
8c555625 | 1882 | TObjArray **row; |
fe4da5cc | 1883 | |
a62d28a2 | 1884 | //printf("*** Processing sector number %d ***\n",isec); |
8c555625 | 1885 | |
1886 | Int_t nrows =fTPCParam->GetNRow(isec); | |
1887 | ||
b584c7dd | 1888 | row= new TObjArray* [nrows+2]; // 2 extra rows for cross talk |
fe4da5cc | 1889 | |
73042f01 | 1890 | MakeSector(isec,nrows,tH,ntracks,row); |
8c555625 | 1891 | |
1892 | //-------------------------------------------------------- | |
1893 | // Digitize this sector, row by row | |
de61d5d5 | 1894 | // row[i] is the pointer to the TObjArray of AliTPCFastVectors, |
8c555625 | 1895 | // each one containing electrons accepted on this |
1896 | // row, assigned into tracks | |
1897 | //-------------------------------------------------------- | |
1898 | ||
1899 | Int_t i; | |
1900 | ||
2ab0c725 | 1901 | if (fDigitsArray->GetTree()==0) fDigitsArray->MakeTree(fDigitsFile); |
8c555625 | 1902 | |
cc80f89e | 1903 | for (i=0;i<nrows;i++){ |
8c555625 | 1904 | |
afc42102 | 1905 | AliDigits * dig = fDigitsArray->CreateRow(isec,i); |
8c555625 | 1906 | |
cc80f89e | 1907 | DigitizeRow(i,isec,row); |
8c555625 | 1908 | |
cc80f89e | 1909 | fDigitsArray->StoreRow(isec,i); |
8c555625 | 1910 | |
792bb11c | 1911 | Int_t ndig = dig->GetDigitSize(); |
1912 | if (gDebug > 10) printf("*** Sector, row, compressed digits %d %d %d ***\n",isec,i,ndig); | |
1913 | ||
cc80f89e | 1914 | fDigitsArray->ClearRow(isec,i); |
8c555625 | 1915 | |
cc80f89e | 1916 | |
8c555625 | 1917 | } // end of the sector digitization |
8c555625 | 1918 | |
df32adf9 | 1919 | for(i=0;i<nrows+2;i++){ |
39c8eb58 | 1920 | row[i]->Delete(); |
1921 | delete row[i]; | |
cc80f89e | 1922 | } |
1923 | ||
8c555625 | 1924 | delete [] row; // delete the array of pointers to TObjArray-s |
1925 | ||
1926 | } // ntracks >0 | |
8c555625 | 1927 | |
cc80f89e | 1928 | } // end of Hits2DigitsSector |
8c555625 | 1929 | |
8c555625 | 1930 | |
8c555625 | 1931 | //_____________________________________________________________________________ |
cc80f89e | 1932 | void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows) |
8c555625 | 1933 | { |
1934 | //----------------------------------------------------------- | |
1935 | // Single row digitization, coupling from the neighbouring | |
1936 | // rows taken into account | |
1937 | //----------------------------------------------------------- | |
1938 | ||
1939 | //----------------------------------------------------------------- | |
1940 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
cc80f89e | 1941 | // Modified: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de |
8c555625 | 1942 | //----------------------------------------------------------------- |
1943 | ||
1944 | ||
8c555625 | 1945 | Float_t zerosup = fTPCParam->GetZeroSup(); |
b584c7dd | 1946 | // Int_t nrows =fTPCParam->GetNRow(isec); |
cc80f89e | 1947 | fCurrentIndex[1]= isec; |
8c555625 | 1948 | |
8c555625 | 1949 | |
73042f01 | 1950 | Int_t nofPads = fTPCParam->GetNPads(isec,irow); |
1951 | Int_t nofTbins = fTPCParam->GetMaxTBin(); | |
1952 | Int_t indexRange[4]; | |
8c555625 | 1953 | // |
1954 | // Integrated signal for this row | |
1955 | // and a single track signal | |
cc80f89e | 1956 | // |
de61d5d5 | 1957 | |
1958 | AliTPCFastMatrix *m1 = new AliTPCFastMatrix(0,nofPads,0,nofTbins); // integrated | |
1959 | AliTPCFastMatrix *m2 = new AliTPCFastMatrix(0,nofPads,0,nofTbins); // single | |
8c555625 | 1960 | // |
de61d5d5 | 1961 | AliTPCFastMatrix &total = *m1; |
8c555625 | 1962 | |
1963 | // Array of pointers to the label-signal list | |
1964 | ||
73042f01 | 1965 | Int_t nofDigits = nofPads*nofTbins; // number of digits for this row |
1966 | Float_t **pList = new Float_t* [nofDigits]; | |
8c555625 | 1967 | |
1968 | Int_t lp; | |
cc80f89e | 1969 | Int_t i1; |
73042f01 | 1970 | for(lp=0;lp<nofDigits;lp++)pList[lp]=0; // set all pointers to NULL |
8c555625 | 1971 | // |
cc80f89e | 1972 | //calculate signal |
1973 | // | |
b584c7dd | 1974 | //Int_t row1 = TMath::Max(irow-fTPCParam->GetNCrossRows(),0); |
1975 | //Int_t row2 = TMath::Min(irow+fTPCParam->GetNCrossRows(),nrows-1); | |
1976 | Int_t row1=irow; | |
1977 | Int_t row2=irow+2; | |
cc80f89e | 1978 | for (Int_t row= row1;row<=row2;row++){ |
1979 | Int_t nTracks= rows[row]->GetEntries(); | |
1980 | for (i1=0;i1<nTracks;i1++){ | |
1981 | fCurrentIndex[2]= row; | |
b584c7dd | 1982 | fCurrentIndex[3]=irow+1; |
1983 | if (row==irow+1){ | |
cc80f89e | 1984 | m2->Zero(); // clear single track signal matrix |
73042f01 | 1985 | Float_t trackLabel = GetSignal(rows[row],i1,m2,m1,indexRange); |
1986 | GetList(trackLabel,nofPads,m2,indexRange,pList); | |
cc80f89e | 1987 | } |
73042f01 | 1988 | else GetSignal(rows[row],i1,0,m1,indexRange); |
cc80f89e | 1989 | } |
8c555625 | 1990 | } |
cc80f89e | 1991 | |
8c555625 | 1992 | Int_t tracks[3]; |
8c555625 | 1993 | |
cc80f89e | 1994 | AliDigits *dig = fDigitsArray->GetRow(isec,irow); |
de61d5d5 | 1995 | Int_t gi=-1; |
1996 | Float_t fzerosup = zerosup+0.5; | |
1997 | for(Int_t it=0;it<nofTbins;it++){ | |
1998 | Float_t *pq = &(total.UncheckedAt(0,it)); | |
1999 | for(Int_t ip=0;ip<nofPads;ip++){ | |
2000 | gi++; | |
2001 | Float_t q=*pq; | |
2002 | pq++; | |
f8cf550c | 2003 | if(fDigitsSwitch == 0){ |
407ff276 | 2004 | q+=GetNoise(); |
de61d5d5 | 2005 | if(q <=fzerosup) continue; // do not fill zeros |
68771f83 | 2006 | q = TMath::Nint(q); |
f8cf550c | 2007 | if(q > fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat(); // saturation |
cc80f89e | 2008 | |
f8cf550c | 2009 | } |
2010 | ||
2011 | else { | |
5f16d237 | 2012 | if(q <= 0.) continue; // do not fill zeros |
68771f83 | 2013 | if(q>2000.) q=2000.; |
f8cf550c | 2014 | q *= 16.; |
68771f83 | 2015 | q = TMath::Nint(q); |
f8cf550c | 2016 | } |
8c555625 | 2017 | |
2018 | // | |
2019 | // "real" signal or electronic noise (list = -1)? | |
2020 | // | |
2021 | ||
2022 | for(Int_t j1=0;j1<3;j1++){ | |
407ff276 | 2023 | tracks[j1] = (pList[gi]) ?(Int_t)(*(pList[gi]+j1)) : -2; |
8c555625 | 2024 | } |
2025 | ||
cc80f89e | 2026 | //Begin_Html |
2027 | /* | |
2028 | <A NAME="AliDigits"></A> | |
2029 | using of AliDigits object | |
2030 | */ | |
2031 | //End_Html | |
2032 | dig->SetDigitFast((Short_t)q,it,ip); | |
2033 | if (fDigitsArray->IsSimulated()) | |
2034 | { | |
2035 | ((AliSimDigits*)dig)->SetTrackIDFast(tracks[0],it,ip,0); | |
2036 | ((AliSimDigits*)dig)->SetTrackIDFast(tracks[1],it,ip,1); | |
2037 | ((AliSimDigits*)dig)->SetTrackIDFast(tracks[2],it,ip,2); | |
2038 | } | |
2039 | ||
8c555625 | 2040 | |
2041 | } // end of loop over time buckets | |
2042 | } // end of lop over pads | |
2043 | ||
2044 | // | |
2045 | // This row has been digitized, delete nonused stuff | |
2046 | // | |
2047 | ||
73042f01 | 2048 | for(lp=0;lp<nofDigits;lp++){ |
8c555625 | 2049 | if(pList[lp]) delete [] pList[lp]; |
2050 | } | |
2051 | ||
2052 | delete [] pList; | |
2053 | ||
2054 | delete m1; | |
2055 | delete m2; | |
cc80f89e | 2056 | // delete m3; |
8c555625 | 2057 | |
2058 | } // end of DigitizeRow | |
cc80f89e | 2059 | |
8c555625 | 2060 | //_____________________________________________________________________________ |
cc80f89e | 2061 | |
de61d5d5 | 2062 | Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, |
2063 | AliTPCFastMatrix *m1, AliTPCFastMatrix *m2,Int_t *indexRange) | |
8c555625 | 2064 | { |
2065 | ||
2066 | //--------------------------------------------------------------- | |
2067 | // Calculates 2-D signal (pad,time) for a single track, | |
2068 | // returns a pointer to the signal matrix and the track label | |
2069 | // No digitization is performed at this level!!! | |
2070 | //--------------------------------------------------------------- | |
2071 | ||
2072 | //----------------------------------------------------------------- | |
2073 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
cc80f89e | 2074 | // Modified: Marian Ivanov |
8c555625 | 2075 | //----------------------------------------------------------------- |
2076 | ||
de61d5d5 | 2077 | AliTPCFastVector *tv; |
2078 | ||
2079 | tv = (AliTPCFastVector*)p1->At(ntr); // pointer to a track | |
2080 | AliTPCFastVector &v = *tv; | |
8c555625 | 2081 | |
2082 | Float_t label = v(0); | |
b584c7dd | 2083 | Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]-1)-1)/2; |
8c555625 | 2084 | |
8c555625 | 2085 | Int_t nElectrons = (tv->GetNrows()-1)/4; |
73042f01 | 2086 | indexRange[0]=9999; // min pad |
2087 | indexRange[1]=-1; // max pad | |
2088 | indexRange[2]=9999; //min time | |
2089 | indexRange[3]=-1; // max time | |
8c555625 | 2090 | |
de61d5d5 | 2091 | AliTPCFastMatrix &signal = *m1; |
2092 | AliTPCFastMatrix &total = *m2; | |
8c555625 | 2093 | // |
2094 | // Loop over all electrons | |
2095 | // | |
8c555625 | 2096 | for(Int_t nel=0; nel<nElectrons; nel++){ |
cc80f89e | 2097 | Int_t idx=nel*4; |
2098 | Float_t aval = v(idx+4); | |
2099 | Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac(); | |
2100 | Float_t xyz[3]={v(idx+1),v(idx+2),v(idx+3)}; | |
de61d5d5 | 2101 | Int_t n = ((AliTPCParamSR*)fTPCParam)->CalcResponseFast(xyz,fCurrentIndex,fCurrentIndex[3]); |
2102 | ||
2103 | Int_t *index = fTPCParam->GetResBin(0); | |
2104 | Float_t *weight = & (fTPCParam->GetResWeight(0)); | |
2105 | ||
2106 | if (n>0) for (Int_t i =0; i<n; i++){ | |
73042f01 | 2107 | Int_t pad=index[1]+centralPad; //in digit coordinates central pad has coordinate 0 |
de61d5d5 | 2108 | |
2109 | if (pad>=0){ | |
cc80f89e | 2110 | Int_t time=index[2]; |
de61d5d5 | 2111 | Float_t qweight = *(weight)*eltoadcfac; |
cc80f89e | 2112 | |
de61d5d5 | 2113 | if (m1!=0) signal.UncheckedAt(pad,time)+=qweight; |
2114 | total.UncheckedAt(pad,time)+=qweight; | |
2115 | if (indexRange[0]>pad) indexRange[0]=pad; | |
2116 | if (indexRange[1]<pad) indexRange[1]=pad; | |
2117 | if (indexRange[2]>time) indexRange[2]=time; | |
2118 | if (indexRange[3]<time) indexRange[3]=time; | |
2119 | ||
2120 | index+=3; | |
2121 | weight++; | |
2122 | ||
cc80f89e | 2123 | } |
2124 | } | |
8c555625 | 2125 | } // end of loop over electrons |
cc80f89e | 2126 | |
8c555625 | 2127 | return label; // returns track label when finished |
2128 | } | |
2129 | ||
2130 | //_____________________________________________________________________________ | |
de61d5d5 | 2131 | void AliTPC::GetList(Float_t label,Int_t np,AliTPCFastMatrix *m, |
2132 | Int_t *indexRange, Float_t **pList) | |
8c555625 | 2133 | { |
2134 | //---------------------------------------------------------------------- | |
2135 | // Updates the list of tracks contributing to digits for a given row | |
2136 | //---------------------------------------------------------------------- | |
2137 | ||
2138 | //----------------------------------------------------------------- | |
2139 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2140 | //----------------------------------------------------------------- | |
2141 | ||
de61d5d5 | 2142 | AliTPCFastMatrix &signal = *m; |
8c555625 | 2143 | |
2144 | // lop over nonzero digits | |
2145 | ||
73042f01 | 2146 | for(Int_t it=indexRange[2];it<indexRange[3]+1;it++){ |
2147 | for(Int_t ip=indexRange[0];ip<indexRange[1]+1;ip++){ | |
8c555625 | 2148 | |
2149 | ||
921bf71a | 2150 | // accept only the contribution larger than 500 electrons (1/2 s_noise) |
2151 | ||
cc80f89e | 2152 | if(signal(ip,it)<0.5) continue; |
921bf71a | 2153 | |
2154 | ||
73042f01 | 2155 | Int_t globalIndex = it*np+ip; // globalIndex starts from 0! |
8c555625 | 2156 | |
73042f01 | 2157 | if(!pList[globalIndex]){ |
8c555625 | 2158 | |
2159 | // | |
2160 | // Create new list (6 elements - 3 signals and 3 labels), | |
8c555625 | 2161 | // |
2162 | ||
73042f01 | 2163 | pList[globalIndex] = new Float_t [6]; |
8c555625 | 2164 | |
2165 | // set list to -1 | |
2166 | ||
73042f01 | 2167 | *pList[globalIndex] = -1.; |
2168 | *(pList[globalIndex]+1) = -1.; | |
2169 | *(pList[globalIndex]+2) = -1.; | |
2170 | *(pList[globalIndex]+3) = -1.; | |
2171 | *(pList[globalIndex]+4) = -1.; | |
2172 | *(pList[globalIndex]+5) = -1.; | |
8c555625 | 2173 | |
2174 | ||
73042f01 | 2175 | *pList[globalIndex] = label; |
2176 | *(pList[globalIndex]+3) = signal(ip,it); | |
8c555625 | 2177 | } |
2178 | else{ | |
2179 | ||
2180 | // check the signal magnitude | |
2181 | ||
73042f01 | 2182 | Float_t highest = *(pList[globalIndex]+3); |
2183 | Float_t middle = *(pList[globalIndex]+4); | |
2184 | Float_t lowest = *(pList[globalIndex]+5); | |
8c555625 | 2185 | |
2186 | // | |
2187 | // compare the new signal with already existing list | |
2188 | // | |
2189 | ||
2190 | if(signal(ip,it)<lowest) continue; // neglect this track | |
2191 | ||
2192 | // | |
2193 | ||
2194 | if (signal(ip,it)>highest){ | |
73042f01 | 2195 | *(pList[globalIndex]+5) = middle; |
2196 | *(pList[globalIndex]+4) = highest; | |
2197 | *(pList[globalIndex]+3) = signal(ip,it); | |
8c555625 | 2198 | |
73042f01 | 2199 | *(pList[globalIndex]+2) = *(pList[globalIndex]+1); |
2200 | *(pList[globalIndex]+1) = *pList[globalIndex]; | |
2201 | *pList[globalIndex] = label; | |
8c555625 | 2202 | } |
2203 | else if (signal(ip,it)>middle){ | |
73042f01 | 2204 | *(pList[globalIndex]+5) = middle; |
2205 | *(pList[globalIndex]+4) = signal(ip,it); | |
8c555625 | 2206 | |
73042f01 | 2207 | *(pList[globalIndex]+2) = *(pList[globalIndex]+1); |
2208 | *(pList[globalIndex]+1) = label; | |
8c555625 | 2209 | } |
2210 | else{ | |
73042f01 | 2211 | *(pList[globalIndex]+5) = signal(ip,it); |
2212 | *(pList[globalIndex]+2) = label; | |
8c555625 | 2213 | } |
2214 | } | |
2215 | ||
2216 | } // end of loop over pads | |
2217 | } // end of loop over time bins | |
2218 | ||
2219 | ||
2220 | ||
8c555625 | 2221 | }//end of GetList |
2222 | //___________________________________________________________________ | |
2223 | void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH, | |
2224 | Stat_t ntracks,TObjArray **row) | |
2225 | { | |
2226 | ||
2227 | //----------------------------------------------------------------- | |
2228 | // Prepares the sector digitization, creates the vectors of | |
2229 | // tracks for each row of this sector. The track vector | |
2230 | // contains the track label and the position of electrons. | |
2231 | //----------------------------------------------------------------- | |
2232 | ||
2233 | //----------------------------------------------------------------- | |
2234 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2235 | //----------------------------------------------------------------- | |
2236 | ||
cc80f89e | 2237 | Float_t gasgain = fTPCParam->GetGasGain(); |
8c555625 | 2238 | Int_t i; |
cc80f89e | 2239 | Float_t xyz[4]; |
8c555625 | 2240 | |
2241 | AliTPChit *tpcHit; // pointer to a sigle TPC hit | |
39c8eb58 | 2242 | //MI change |
2243 | TBranch * branch=0; | |
792bb11c | 2244 | if (fHitType>1) branch = TH->GetBranch("TPC2"); |
39c8eb58 | 2245 | else branch = TH->GetBranch("TPC"); |
2246 | ||
8c555625 | 2247 | |
2248 | //---------------------------------------------- | |
2249 | // Create TObjArray-s, one for each row, | |
de61d5d5 | 2250 | // each TObjArray will store the AliTPCFastVectors |
2251 | // of electrons, one AliTPCFastVectors per each track. | |
8c555625 | 2252 | //---------------------------------------------- |
2253 | ||
b584c7dd | 2254 | Int_t *nofElectrons = new Int_t [nrows+2]; // electron counter for each row |
2255 | AliTPCFastVector **tracks = new AliTPCFastVector* [nrows+2]; //pointers to the track vectors | |
de61d5d5 | 2256 | |
b584c7dd | 2257 | for(i=0; i<nrows+2; i++){ |
8c555625 | 2258 | row[i] = new TObjArray; |
f74bb6f5 | 2259 | nofElectrons[i]=0; |
2260 | tracks[i]=0; | |
8c555625 | 2261 | } |
8c555625 | 2262 | |
37831078 | 2263 | |
2264 | ||
8c555625 | 2265 | //-------------------------------------------------------------------- |
2266 | // Loop over tracks, the "track" contains the full history | |
2267 | //-------------------------------------------------------------------- | |
2268 | ||
2269 | Int_t previousTrack,currentTrack; | |
2270 | previousTrack = -1; // nothing to store so far! | |
2271 | ||
2272 | for(Int_t track=0;track<ntracks;track++){ | |
39c8eb58 | 2273 | Bool_t isInSector=kTRUE; |
8c555625 | 2274 | ResetHits(); |
792bb11c | 2275 | isInSector = TrackInVolume(isec,track); |
39c8eb58 | 2276 | if (!isInSector) continue; |
2277 | //MI change | |
2278 | branch->GetEntry(track); // get next track | |
2279 | ||
2280 | //M.I. changes | |
8c555625 | 2281 | |
39c8eb58 | 2282 | tpcHit = (AliTPChit*)FirstHit(-1); |
8c555625 | 2283 | |
2284 | //-------------------------------------------------------------- | |
2285 | // Loop over hits | |
2286 | //-------------------------------------------------------------- | |
2287 | ||
8c555625 | 2288 | |
39c8eb58 | 2289 | while(tpcHit){ |
8c555625 | 2290 | |
2291 | Int_t sector=tpcHit->fSector; // sector number | |
39c8eb58 | 2292 | if(sector != isec){ |
2293 | tpcHit = (AliTPChit*) NextHit(); | |
2294 | continue; | |
2295 | } | |
8c555625 | 2296 | |
94de3818 | 2297 | currentTrack = tpcHit->Track(); // track number |
39c8eb58 | 2298 | |
2299 | ||
8c555625 | 2300 | if(currentTrack != previousTrack){ |
2301 | ||
2302 | // store already filled fTrack | |
2303 | ||
b584c7dd | 2304 | for(i=0;i<nrows+2;i++){ |
8c555625 | 2305 | if(previousTrack != -1){ |
73042f01 | 2306 | if(nofElectrons[i]>0){ |
de61d5d5 | 2307 | AliTPCFastVector &v = *tracks[i]; |
8c555625 | 2308 | v(0) = previousTrack; |
73042f01 | 2309 | tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary |
cc80f89e | 2310 | row[i]->Add(tracks[i]); |
8c555625 | 2311 | } |
2312 | else{ | |
de61d5d5 | 2313 | delete tracks[i]; // delete empty AliTPCFastVector |
cc80f89e | 2314 | tracks[i]=0; |
8c555625 | 2315 | } |
2316 | } | |
2317 | ||
73042f01 | 2318 | nofElectrons[i]=0; |
de61d5d5 | 2319 | tracks[i] = new AliTPCFastVector(481); // AliTPCFastVectors for the next fTrack |
8c555625 | 2320 | |
2321 | } // end of loop over rows | |
2322 | ||
2323 | previousTrack=currentTrack; // update track label | |
2324 | } | |
2325 | ||
73042f01 | 2326 | Int_t qI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons) |
8c555625 | 2327 | |
2328 | //--------------------------------------------------- | |
2329 | // Calculate the electron attachment probability | |
2330 | //--------------------------------------------------- | |
2331 | ||
cc80f89e | 2332 | |
94de3818 | 2333 | Float_t time = 1.e6*(fTPCParam->GetZLength()-TMath::Abs(tpcHit->Z())) |
cc80f89e | 2334 | /fTPCParam->GetDriftV(); |
8c555625 | 2335 | // in microseconds! |
73042f01 | 2336 | Float_t attProb = fTPCParam->GetAttCoef()* |
8c555625 | 2337 | fTPCParam->GetOxyCont()*time; // fraction! |
2338 | ||
2339 | //----------------------------------------------- | |
2340 | // Loop over electrons | |
2341 | //----------------------------------------------- | |
cc80f89e | 2342 | Int_t index[3]; |
2343 | index[1]=isec; | |
73042f01 | 2344 | for(Int_t nel=0;nel<qI;nel++){ |
8c555625 | 2345 | // skip if electron lost due to the attachment |
73042f01 | 2346 | if((gRandom->Rndm(0)) < attProb) continue; // electron lost! |
94de3818 | 2347 | xyz[0]=tpcHit->X(); |
2348 | xyz[1]=tpcHit->Y(); | |
1705494b | 2349 | xyz[2]=tpcHit->Z(); |
2350 | // | |
2351 | // protection for the nonphysical avalanche size (10**6 maximum) | |
2352 | // | |
710dacf5 | 2353 | Double_t rn=TMath::Max(gRandom->Rndm(0),1.93e-22); |
2354 | xyz[3]= (Float_t) (-gasgain*TMath::Log(rn)); | |
cc80f89e | 2355 | index[0]=1; |
2356 | ||
b584c7dd | 2357 | TransportElectron(xyz,index); |
73042f01 | 2358 | Int_t rowNumber; |
b584c7dd | 2359 | fTPCParam->GetPadRow(xyz,index); |
2360 | // row 0 - cross talk from the innermost row | |
2361 | // row fNRow+1 cross talk from the outermost row | |
2362 | rowNumber = index[2]+1; | |
cc80f89e | 2363 | //transform position to local digit coordinates |
2364 | //relative to nearest pad row | |
b584c7dd | 2365 | if ((rowNumber<0)||rowNumber>fTPCParam->GetNRow(isec)+1) continue; |
2366 | Float_t x1,y1; | |
f03e3423 | 2367 | if (isec <fTPCParam->GetNInnerSector()) { |
2368 | x1 = xyz[1]*fTPCParam->GetInnerPadPitchWidth(); | |
2369 | y1 = fTPCParam->GetYInner(rowNumber); | |
2370 | } | |
2371 | else{ | |
2372 | x1=xyz[1]*fTPCParam->GetOuterPadPitchWidth(); | |
2373 | y1 = fTPCParam->GetYOuter(rowNumber); | |
2374 | } | |
e8f678d7 | 2375 | // gain inefficiency at the wires edges - linear |
f03e3423 | 2376 | x1=TMath::Abs(x1); |
e8f678d7 | 2377 | y1-=1.; |
2378 | if(x1>y1) xyz[3]*=TMath::Max(1.e-6,(y1-x1+1.)); | |
2379 | ||
73042f01 | 2380 | nofElectrons[rowNumber]++; |
8c555625 | 2381 | //---------------------------------- |
2382 | // Expand vector if necessary | |
2383 | //---------------------------------- | |
73042f01 | 2384 | if(nofElectrons[rowNumber]>120){ |
2385 | Int_t range = tracks[rowNumber]->GetNrows(); | |
2386 | if((nofElectrons[rowNumber])>(range-1)/4){ | |
cc80f89e | 2387 | |
73042f01 | 2388 | tracks[rowNumber]->ResizeTo(range+400); // Add 100 electrons |
fe4da5cc | 2389 | } |
2390 | } | |
2391 | ||
de61d5d5 | 2392 | AliTPCFastVector &v = *tracks[rowNumber]; |
73042f01 | 2393 | Int_t idx = 4*nofElectrons[rowNumber]-3; |
de61d5d5 | 2394 | Real_t * position = &(((AliTPCFastVector&)v).UncheckedAt(idx)); //make code faster |
2395 | memcpy(position,xyz,4*sizeof(Float_t)); | |
2396 | ||
8c555625 | 2397 | } // end of loop over electrons |
39c8eb58 | 2398 | |
2399 | tpcHit = (AliTPChit*)NextHit(); | |
8c555625 | 2400 | |
2401 | } // end of loop over hits | |
2402 | } // end of loop over tracks | |
2403 | ||
2404 | // | |
2405 | // store remaining track (the last one) if not empty | |
2406 | // | |
2407 | ||
b584c7dd | 2408 | for(i=0;i<nrows+2;i++){ |
73042f01 | 2409 | if(nofElectrons[i]>0){ |
de61d5d5 | 2410 | AliTPCFastVector &v = *tracks[i]; |
8c555625 | 2411 | v(0) = previousTrack; |
73042f01 | 2412 | tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary |
cc80f89e | 2413 | row[i]->Add(tracks[i]); |
fe4da5cc | 2414 | } |
2415 | else{ | |
cc80f89e | 2416 | delete tracks[i]; |
2417 | tracks[i]=0; | |
8c555625 | 2418 | } |
2419 | } | |
2420 | ||
cc80f89e | 2421 | delete [] tracks; |
73042f01 | 2422 | delete [] nofElectrons; |
8c555625 | 2423 | |
8c555625 | 2424 | |
cc80f89e | 2425 | } // end of MakeSector |
8c555625 | 2426 | |
fe4da5cc | 2427 | |
2428 | //_____________________________________________________________________________ | |
2429 | void AliTPC::Init() | |
2430 | { | |
2431 | // | |
2432 | // Initialise TPC detector after definition of geometry | |
2433 | // | |
2434 | Int_t i; | |
2435 | // | |
9e1a0ddb | 2436 | if(fDebug) { |
2437 | printf("\n%s: ",ClassName()); | |
2438 | for(i=0;i<35;i++) printf("*"); | |
2439 | printf(" TPC_INIT "); | |
2440 | for(i=0;i<35;i++) printf("*"); | |
2441 | printf("\n%s: ",ClassName()); | |
2442 | // | |
2443 | for(i=0;i<80;i++) printf("*"); | |
2444 | printf("\n"); | |
2445 | } | |
fe4da5cc | 2446 | } |
2447 | ||
2448 | //_____________________________________________________________________________ | |
9e1a0ddb | 2449 | void AliTPC::MakeBranch(Option_t* option, const char *file) |
fe4da5cc | 2450 | { |
2451 | // | |
2452 | // Create Tree branches for the TPC. | |
2453 | // | |
2454 | Int_t buffersize = 4000; | |
2455 | char branchname[10]; | |
2456 | sprintf(branchname,"%s",GetName()); | |
2457 | ||
2ab0c725 | 2458 | AliDetector::MakeBranch(option,file); |
fe4da5cc | 2459 | |
5cf7bbad | 2460 | const char *d = strstr(option,"D"); |
fe4da5cc | 2461 | |
73042f01 | 2462 | if (fDigits && gAlice->TreeD() && d) { |
9e1a0ddb | 2463 | MakeBranchInTree(gAlice->TreeD(), |
2464 | branchname, &fDigits, buffersize, file); | |
fe4da5cc | 2465 | } |
39c8eb58 | 2466 | |
792bb11c | 2467 | if (fHitType>1) MakeBranch2(option,file); // MI change 14.09.2000 |
fe4da5cc | 2468 | } |
2469 | ||
2470 | //_____________________________________________________________________________ | |
2471 | void AliTPC::ResetDigits() | |
2472 | { | |
2473 | // | |
2474 | // Reset number of digits and the digits array for this detector | |
fe4da5cc | 2475 | // |
2476 | fNdigits = 0; | |
cc80f89e | 2477 | if (fDigits) fDigits->Clear(); |
fe4da5cc | 2478 | } |
2479 | ||
2480 | //_____________________________________________________________________________ | |
2481 | void AliTPC::SetSecAL(Int_t sec) | |
2482 | { | |
8c555625 | 2483 | //--------------------------------------------------- |
fe4da5cc | 2484 | // Activate/deactivate selection for lower sectors |
8c555625 | 2485 | //--------------------------------------------------- |
2486 | ||
2487 | //----------------------------------------------------------------- | |
2488 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2489 | //----------------------------------------------------------------- | |
2490 | ||
fe4da5cc | 2491 | fSecAL = sec; |
2492 | } | |
2493 | ||
2494 | //_____________________________________________________________________________ | |
2495 | void AliTPC::SetSecAU(Int_t sec) | |
2496 | { | |
8c555625 | 2497 | //---------------------------------------------------- |
fe4da5cc | 2498 | // Activate/deactivate selection for upper sectors |
8c555625 | 2499 | //--------------------------------------------------- |
2500 | ||
2501 | //----------------------------------------------------------------- | |
2502 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2503 | //----------------------------------------------------------------- | |
2504 | ||
fe4da5cc | 2505 | fSecAU = sec; |
2506 | } | |
2507 | ||
2508 | //_____________________________________________________________________________ | |
2509 | void AliTPC::SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6) | |
2510 | { | |
8c555625 | 2511 | //---------------------------------------- |
fe4da5cc | 2512 | // Select active lower sectors |
8c555625 | 2513 | //---------------------------------------- |
2514 | ||
2515 | //----------------------------------------------------------------- | |
2516 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2517 | //----------------------------------------------------------------- | |
2518 | ||
fe4da5cc | 2519 | fSecLows[0] = s1; |
2520 | fSecLows[1] = s2; | |
2521 | fSecLows[2] = s3; | |
2522 | fSecLows[3] = s4; | |
2523 | fSecLows[4] = s5; | |
2524 | fSecLows[5] = s6; | |
2525 | } | |
2526 | ||
2527 | //_____________________________________________________________________________ | |
2528 | void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6, | |
2529 | Int_t s7, Int_t s8 ,Int_t s9 ,Int_t s10, | |
2530 | Int_t s11 , Int_t s12) | |
2531 | { | |
8c555625 | 2532 | //-------------------------------- |
fe4da5cc | 2533 | // Select active upper sectors |
8c555625 | 2534 | //-------------------------------- |
2535 | ||
2536 | //----------------------------------------------------------------- | |
2537 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2538 | //----------------------------------------------------------------- | |
2539 | ||
fe4da5cc | 2540 | fSecUps[0] = s1; |
2541 | fSecUps[1] = s2; | |
2542 | fSecUps[2] = s3; | |
2543 | fSecUps[3] = s4; | |
2544 | fSecUps[4] = s5; | |
2545 | fSecUps[5] = s6; | |
2546 | fSecUps[6] = s7; | |
2547 | fSecUps[7] = s8; | |
2548 | fSecUps[8] = s9; | |
2549 | fSecUps[9] = s10; | |
2550 | fSecUps[10] = s11; | |
2551 | fSecUps[11] = s12; | |
2552 | } | |
2553 | ||
2554 | //_____________________________________________________________________________ | |
2555 | void AliTPC::SetSens(Int_t sens) | |
2556 | { | |
8c555625 | 2557 | |
2558 | //------------------------------------------------------------- | |
2559 | // Activates/deactivates the sensitive strips at the center of | |
2560 | // the pad row -- this is for the space-point resolution calculations | |
2561 | //------------------------------------------------------------- | |
2562 | ||
2563 | //----------------------------------------------------------------- | |
2564 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
2565 | //----------------------------------------------------------------- | |
2566 | ||
fe4da5cc | 2567 | fSens = sens; |
2568 | } | |
2b06d5c3 | 2569 | |
4b0fdcad | 2570 | |
73042f01 | 2571 | void AliTPC::SetSide(Float_t side=0.) |
4b0fdcad | 2572 | { |
73042f01 | 2573 | // choice of the TPC side |
2574 | ||
4b0fdcad | 2575 | fSide = side; |
2576 | ||
2577 | } | |
1283eee5 | 2578 | //____________________________________________________________________________ |
2579 | void AliTPC::SetGasMixt(Int_t nc,Int_t c1,Int_t c2,Int_t c3,Float_t p1, | |
2580 | Float_t p2,Float_t p3) | |
2581 | { | |
fe4da5cc | 2582 | |
73042f01 | 2583 | // gax mixture definition |
2584 | ||
1283eee5 | 2585 | fNoComp = nc; |
2586 | ||
2587 | fMixtComp[0]=c1; | |
2588 | fMixtComp[1]=c2; | |
2589 | fMixtComp[2]=c3; | |
2590 | ||
2591 | fMixtProp[0]=p1; | |
2592 | fMixtProp[1]=p2; | |
2593 | fMixtProp[2]=p3; | |
2594 | ||
2595 | ||
cc80f89e | 2596 | } |
2597 | //_____________________________________________________________________________ | |
2598 | ||
2599 | void AliTPC::TransportElectron(Float_t *xyz, Int_t *index) | |
2600 | { | |
2601 | // | |
2602 | // electron transport taking into account: | |
2603 | // 1. diffusion, | |
2604 | // 2.ExB at the wires | |
2605 | // 3. nonisochronity | |
2606 | // | |
2607 | // xyz and index must be already transformed to system 1 | |
2608 | // | |
2609 | ||
2610 | fTPCParam->Transform1to2(xyz,index); | |
2611 | ||
2612 | //add diffusion | |
2613 | Float_t driftl=xyz[2]; | |
2614 | if(driftl<0.01) driftl=0.01; | |
2615 | driftl=TMath::Sqrt(driftl); | |
73042f01 | 2616 | Float_t sigT = driftl*(fTPCParam->GetDiffT()); |
2617 | Float_t sigL = driftl*(fTPCParam->GetDiffL()); | |
2618 | xyz[0]=gRandom->Gaus(xyz[0],sigT); | |
2619 | xyz[1]=gRandom->Gaus(xyz[1],sigT); | |
2620 | xyz[2]=gRandom->Gaus(xyz[2],sigL); | |
cc80f89e | 2621 | |
2622 | // ExB | |
2623 | ||
2624 | if (fTPCParam->GetMWPCReadout()==kTRUE){ | |
b584c7dd | 2625 | Float_t dx = fTPCParam->Transform2to2NearestWire(xyz,index); |
cc80f89e | 2626 | xyz[1]+=dx*(fTPCParam->GetOmegaTau()); |
2627 | } | |
b584c7dd | 2628 | //add nonisochronity (not implemented yet) |
1283eee5 | 2629 | } |
fe4da5cc | 2630 | |
fe4da5cc | 2631 | ClassImp(AliTPCdigit) |
2632 | ||
2633 | //_____________________________________________________________________________ | |
2634 | AliTPCdigit::AliTPCdigit(Int_t *tracks, Int_t *digits): | |
2635 | AliDigit(tracks) | |
2636 | { | |
2637 | // | |
2638 | // Creates a TPC digit object | |
2639 | // | |
2640 | fSector = digits[0]; | |
2641 | fPadRow = digits[1]; | |
2642 | fPad = digits[2]; | |
2643 | fTime = digits[3]; | |
2644 | fSignal = digits[4]; | |
2645 | } | |
2646 | ||
2647 | ||
2648 | ClassImp(AliTPChit) | |
2649 | ||
2650 | //_____________________________________________________________________________ | |
2651 | AliTPChit::AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits): | |
2652 | AliHit(shunt,track) | |
2653 | { | |
2654 | // | |
2655 | // Creates a TPC hit object | |
2656 | // | |
2657 | fSector = vol[0]; | |
2658 | fPadRow = vol[1]; | |
2659 | fX = hits[0]; | |
2660 | fY = hits[1]; | |
2661 | fZ = hits[2]; | |
2662 | fQ = hits[3]; | |
2663 | } | |
2664 | ||
8c555625 | 2665 | |
39c8eb58 | 2666 | //________________________________________________________________________ |
792bb11c | 2667 | // Additional code because of the AliTPCTrackHitsV2 |
39c8eb58 | 2668 | |
9e1a0ddb | 2669 | void AliTPC::MakeBranch2(Option_t *option,const char *file) |
39c8eb58 | 2670 | { |
2671 | // | |
2672 | // Create a new branch in the current Root Tree | |
2673 | // The branch of fHits is automatically split | |
2674 | // MI change 14.09.2000 | |
792bb11c | 2675 | if (fHitType<2) return; |
39c8eb58 | 2676 | char branchname[10]; |
2677 | sprintf(branchname,"%s2",GetName()); | |
2678 | // | |
2679 | // Get the pointer to the header | |
5cf7bbad | 2680 | const char *cH = strstr(option,"H"); |
39c8eb58 | 2681 | // |
792bb11c | 2682 | if (fTrackHits && gAlice->TreeH() && cH && fHitType&4) { |
2683 | // AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHitsV2",&fTrackHits, | |
2684 | // gAlice->TreeH(),fBufferSize,99); | |
2685 | //TBranch * branch = | |
2686 | gAlice->TreeH()->Branch(branchname,"AliTPCTrackHitsV2",&fTrackHits, | |
2687 | fBufferSize,99); | |
2688 | ||
2689 | // gAlice->TreeH()->GetListOfBranches()->Add(branch); | |
9e1a0ddb | 2690 | if (GetDebug()>1) |
2691 | printf("* AliDetector::MakeBranch * Making Branch %s for trackhits\n",branchname); | |
2692 | const char folder [] = "RunMC/Event/Data"; | |
2693 | if (GetDebug()) | |
2694 | printf("%15s: Publishing %s to %s\n",ClassName(),branchname,folder); | |
2695 | Publish(folder,&fTrackHits,branchname); | |
2ab0c725 | 2696 | if (file) { |
2697 | TBranch *b = gAlice->TreeH()->GetBranch(branchname); | |
2698 | TDirectory *wd = gDirectory; | |
2699 | b->SetFile(file); | |
2700 | TIter next( b->GetListOfBranches()); | |
2701 | while ((b=(TBranch*)next())) { | |
9e1a0ddb | 2702 | b->SetFile(file); |
2ab0c725 | 2703 | } |
2704 | wd->cd(); | |
9e1a0ddb | 2705 | if (GetDebug()>1) |
2706 | cout << "Diverting branch " << branchname << " to file " << file << endl; | |
2ab0c725 | 2707 | } |
39c8eb58 | 2708 | } |
792bb11c | 2709 | |
2710 | if (fTrackHitsOld && gAlice->TreeH() && cH && fHitType&2) { | |
2711 | AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHitsOld, | |
2712 | gAlice->TreeH(),fBufferSize,99); | |
2713 | //TBranch * branch = gAlice->TreeH()->Branch(branchname,"AliTPCTrackHitsV2",&fTrackHits, | |
2714 | // fBufferSize,99); | |
2715 | ||
2716 | gAlice->TreeH()->GetListOfBranches()->Add(branch); | |
2717 | if (GetDebug()>1) | |
2718 | printf("* AliDetector::MakeBranch * Making Branch %s for trackhits\n",branchname); | |
2719 | const char folder [] = "RunMC/Event/Data"; | |
2720 | if (GetDebug()) | |
2721 | printf("%15s: Publishing %s to %s\n",ClassName(),branchname,folder); | |
2722 | Publish(folder,&fTrackHitsOld,branchname); | |
2723 | if (file) { | |
2724 | TBranch *b = gAlice->TreeH()->GetBranch(branchname); | |
2725 | TDirectory *wd = gDirectory; | |
2726 | b->SetFile(file); | |
2727 | TIter next( b->GetListOfBranches()); | |
2728 | while ((b=(TBranch*)next())) { | |
2729 | b->SetFile(file); | |
2730 | } | |
2731 | wd->cd(); | |
2732 | if (GetDebug()>1) | |
2733 | cout << "Diverting branch " << branchname << " to file " << file << endl; | |
2734 | } | |
2735 | } | |
39c8eb58 | 2736 | } |
2737 | ||
2738 | void AliTPC::SetTreeAddress() | |
2739 | { | |
792bb11c | 2740 | if (fHitType<=1) AliDetector::SetTreeAddress(); |
2741 | if (fHitType>1) SetTreeAddress2(); | |
39c8eb58 | 2742 | } |
2743 | ||
2744 | void AliTPC::SetTreeAddress2() | |
2745 | { | |
2746 | // | |
2747 | // Set branch address for the TrackHits Tree | |
2748 | // | |
2749 | TBranch *branch; | |
2750 | char branchname[20]; | |
2751 | sprintf(branchname,"%s2",GetName()); | |
2752 | // | |
2753 | // Branch address for hit tree | |
2754 | TTree *treeH = gAlice->TreeH(); | |
792bb11c | 2755 | if ((treeH)&&(fHitType&4)) { |
39c8eb58 | 2756 | branch = treeH->GetBranch(branchname); |
2757 | if (branch) branch->SetAddress(&fTrackHits); | |
2758 | } | |
792bb11c | 2759 | if ((treeH)&&(fHitType&2)) { |
2760 | branch = treeH->GetBranch(branchname); | |
2761 | if (branch) branch->SetAddress(&fTrackHitsOld); | |
2762 | } | |
b6e0d3fe | 2763 | //set address to TREETR |
2764 | TTree *treeTR = gAlice->TreeTR(); | |
2765 | if (treeTR && fTrackReferences) { | |
2766 | branch = treeTR->GetBranch(GetName()); | |
2767 | if (branch) branch->SetAddress(&fTrackReferences); | |
2768 | } | |
2769 | ||
792bb11c | 2770 | |
39c8eb58 | 2771 | } |
2772 | ||
2773 | void AliTPC::FinishPrimary() | |
2774 | { | |
792bb11c | 2775 | if (fTrackHits &&fHitType&4) fTrackHits->FlushHitStack(); |
2776 | if (fTrackHitsOld && fHitType&2) fTrackHitsOld->FlushHitStack(); | |
39c8eb58 | 2777 | } |
2778 | ||
2779 | ||
2780 | void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits) | |
2781 | { | |
2782 | // | |
2783 | // add hit to the list | |
39c8eb58 | 2784 | Int_t rtrack; |
2785 | if (fIshunt) { | |
2786 | int primary = gAlice->GetPrimary(track); | |
2ab0c725 | 2787 | gAlice->Particle(primary)->SetBit(kKeepBit); |
39c8eb58 | 2788 | rtrack=primary; |
2789 | } else { | |
2790 | rtrack=track; | |
2791 | gAlice->FlagTrack(track); | |
2792 | } | |
2793 | //AliTPChit *hit = (AliTPChit*)fHits->UncheckedAt(fNhits-1); | |
2794 | //if (hit->fTrack!=rtrack) | |
2795 | // cout<<"bad track number\n"; | |
792bb11c | 2796 | if (fTrackHits && fHitType&4) |
39c8eb58 | 2797 | fTrackHits->AddHitKartez(vol[0],rtrack, hits[0], |
2798 | hits[1],hits[2],(Int_t)hits[3]); | |
792bb11c | 2799 | if (fTrackHitsOld &&fHitType&2 ) |
2800 | fTrackHitsOld->AddHitKartez(vol[0],rtrack, hits[0], | |
2801 | hits[1],hits[2],(Int_t)hits[3]); | |
2802 | ||
39c8eb58 | 2803 | } |
2804 | ||
2805 | void AliTPC::ResetHits() | |
2806 | { | |
2807 | if (fHitType&1) AliDetector::ResetHits(); | |
792bb11c | 2808 | if (fHitType>1) ResetHits2(); |
39c8eb58 | 2809 | } |
2810 | ||
2811 | void AliTPC::ResetHits2() | |
2812 | { | |
2813 | // | |
2814 | //reset hits | |
792bb11c | 2815 | if (fTrackHits && fHitType&4) fTrackHits->Clear(); |
2816 | if (fTrackHitsOld && fHitType&2) fTrackHitsOld->Clear(); | |
2817 | ||
39c8eb58 | 2818 | } |
2819 | ||
2820 | AliHit* AliTPC::FirstHit(Int_t track) | |
2821 | { | |
792bb11c | 2822 | if (fHitType>1) return FirstHit2(track); |
39c8eb58 | 2823 | return AliDetector::FirstHit(track); |
2824 | } | |
2825 | AliHit* AliTPC::NextHit() | |
2826 | { | |
792bb11c | 2827 | if (fHitType>1) return NextHit2(); |
2828 | ||
39c8eb58 | 2829 | return AliDetector::NextHit(); |
2830 | } | |
2831 | ||
2832 | AliHit* AliTPC::FirstHit2(Int_t track) | |
2833 | { | |
2834 | // | |
2835 | // Initialise the hit iterator | |
2836 | // Return the address of the first hit for track | |
2837 | // If track>=0 the track is read from disk | |
2838 | // while if track<0 the first hit of the current | |
2839 | // track is returned | |
2840 | // | |
2841 | if(track>=0) { | |
2842 | gAlice->ResetHits(); | |
2843 | gAlice->TreeH()->GetEvent(track); | |
2844 | } | |
2845 | // | |
792bb11c | 2846 | if (fTrackHits && fHitType&4) { |
39c8eb58 | 2847 | fTrackHits->First(); |
2848 | return fTrackHits->GetHit(); | |
2849 | } | |
792bb11c | 2850 | if (fTrackHitsOld && fHitType&2) { |
2851 | fTrackHitsOld->First(); | |
2852 | return fTrackHitsOld->GetHit(); | |
2853 | } | |
2854 | ||
39c8eb58 | 2855 | else return 0; |
2856 | } | |
2857 | ||
2858 | AliHit* AliTPC::NextHit2() | |
2859 | { | |
2860 | // | |
2861 | //Return the next hit for the current track | |
2862 | ||
792bb11c | 2863 | |
2864 | if (fTrackHitsOld && fHitType&2) { | |
2865 | fTrackHitsOld->Next(); | |
2866 | return fTrackHitsOld->GetHit(); | |
2867 | } | |
39c8eb58 | 2868 | if (fTrackHits) { |
2869 | fTrackHits->Next(); | |
2870 | return fTrackHits->GetHit(); | |
2871 | } | |
2872 | else | |
2873 | return 0; | |
2874 | } | |
2875 | ||
2876 | void AliTPC::LoadPoints(Int_t) | |
2877 | { | |
2878 | // | |
2879 | Int_t a = 0; | |
f2e8b846 | 2880 | /* if(fHitType==1) return AliDetector::LoadPoints(a); |
39c8eb58 | 2881 | LoadPoints2(a); |
f2e8b846 | 2882 | */ |
2883 | if(fHitType==1) AliDetector::LoadPoints(a); | |
2884 | else LoadPoints2(a); | |
2885 | ||
39c8eb58 | 2886 | // LoadPoints3(a); |
2887 | ||
2888 | } | |
2889 | ||
2890 | ||
2891 | void AliTPC::RemapTrackHitIDs(Int_t *map) | |
2892 | { | |
2893 | if (!fTrackHits) return; | |
39c8eb58 | 2894 | |
792bb11c | 2895 | if (fTrackHitsOld && fHitType&2){ |
2896 | AliObjectArray * arr = fTrackHitsOld->fTrackHitsInfo; | |
2897 | for (UInt_t i=0;i<arr->GetSize();i++){ | |
2898 | AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i)); | |
2899 | info->fTrackID = map[info->fTrackID]; | |
2900 | } | |
2901 | } | |
2902 | if (fTrackHitsOld && fHitType&4){ | |
2903 | TClonesArray * arr = fTrackHits->GetArray();; | |
2904 | for (Int_t i=0;i<arr->GetEntriesFast();i++){ | |
2905 | AliTrackHitsParamV2 * info = (AliTrackHitsParamV2 *)(arr->At(i)); | |
2906 | info->fTrackID = map[info->fTrackID]; | |
2907 | } | |
2908 | } | |
39c8eb58 | 2909 | } |
2910 | ||
792bb11c | 2911 | Bool_t AliTPC::TrackInVolume(Int_t id,Int_t track) |
2912 | { | |
2913 | //return bool information - is track in given volume | |
2914 | //load only part of the track information | |
2915 | //return true if current track is in volume | |
2916 | // | |
2917 | // return kTRUE; | |
2918 | if (fTrackHitsOld && fHitType&2) { | |
2919 | TBranch * br = gAlice->TreeH()->GetBranch("fTrackHitsInfo"); | |
2920 | br->GetEvent(track); | |
2921 | AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo; | |
2922 | for (UInt_t j=0;j<ar->GetSize();j++){ | |
2923 | if ( ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==id) return kTRUE; | |
2924 | } | |
2925 | } | |
2926 | ||
2927 | if (fTrackHits && fHitType&4) { | |
2928 | TBranch * br1 = gAlice->TreeH()->GetBranch("fVolumes"); | |
2929 | TBranch * br2 = gAlice->TreeH()->GetBranch("fNVolumes"); | |
2930 | br2->GetEvent(track); | |
2931 | br1->GetEvent(track); | |
2932 | Int_t *volumes = fTrackHits->GetVolumes(); | |
2933 | Int_t nvolumes = fTrackHits->GetNVolumes(); | |
2934 | if (!volumes && nvolumes>0) { | |
2935 | printf("Problematic track\t%d\t%d",track,nvolumes); | |
2936 | return kFALSE; | |
2937 | } | |
2938 | for (Int_t j=0;j<nvolumes; j++) | |
2939 | if (volumes[j]==id) return kTRUE; | |
2940 | } | |
2941 | ||
2942 | if (fHitType&1) { | |
2943 | TBranch * br = gAlice->TreeH()->GetBranch("fSector"); | |
2944 | br->GetEvent(track); | |
2945 | for (Int_t j=0;j<fHits->GetEntriesFast();j++){ | |
2946 | if ( ((AliTPChit*)fHits->At(j))->fSector==id) return kTRUE; | |
2947 | } | |
2948 | } | |
2949 | return kFALSE; | |
2950 | ||
2951 | } | |
39c8eb58 | 2952 | |
2953 | //_____________________________________________________________________________ | |
2954 | void AliTPC::LoadPoints2(Int_t) | |
2955 | { | |
2956 | // | |
2957 | // Store x, y, z of all hits in memory | |
2958 | // | |
792bb11c | 2959 | if (fTrackHits == 0 && fTrackHitsOld==0) return; |
39c8eb58 | 2960 | // |
792bb11c | 2961 | Int_t nhits =0; |
2962 | if (fHitType&4) nhits = fTrackHits->GetEntriesFast(); | |
2963 | if (fHitType&2) nhits = fTrackHitsOld->GetEntriesFast(); | |
2964 | ||
39c8eb58 | 2965 | if (nhits == 0) return; |
2966 | Int_t tracks = gAlice->GetNtrack(); | |
2967 | if (fPoints == 0) fPoints = new TObjArray(tracks); | |
2968 | AliHit *ahit; | |
2969 | // | |
2970 | Int_t *ntrk=new Int_t[tracks]; | |
2971 | Int_t *limi=new Int_t[tracks]; | |
2972 | Float_t **coor=new Float_t*[tracks]; | |
2973 | for(Int_t i=0;i<tracks;i++) { | |
2974 | ntrk[i]=0; | |
2975 | coor[i]=0; | |
2976 | limi[i]=0; | |
2977 | } | |
2978 | // | |
2979 | AliPoints *points = 0; | |
2980 | Float_t *fp=0; | |
2981 | Int_t trk; | |
2982 | Int_t chunk=nhits/4+1; | |
2983 | // | |
2984 | // Loop over all the hits and store their position | |
2985 | // | |
2986 | ahit = FirstHit2(-1); | |
39c8eb58 | 2987 | while (ahit){ |
39c8eb58 | 2988 | trk=ahit->GetTrack(); |
2989 | if(ntrk[trk]==limi[trk]) { | |
2990 | // | |
2991 | // Initialise a new track | |
2992 | fp=new Float_t[3*(limi[trk]+chunk)]; | |
2993 | if(coor[trk]) { | |
2994 | memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]); | |
2995 | delete [] coor[trk]; | |
2996 | } | |
2997 | limi[trk]+=chunk; | |
2998 | coor[trk] = fp; | |
2999 | } else { | |
3000 | fp = coor[trk]; | |
3001 | } | |
3002 | fp[3*ntrk[trk] ] = ahit->X(); | |
3003 | fp[3*ntrk[trk]+1] = ahit->Y(); | |
3004 | fp[3*ntrk[trk]+2] = ahit->Z(); | |
3005 | ntrk[trk]++; | |
3006 | ahit = NextHit2(); | |
3007 | } | |
792bb11c | 3008 | |
3009 | ||
3010 | ||
39c8eb58 | 3011 | // |
3012 | for(trk=0; trk<tracks; ++trk) { | |
3013 | if(ntrk[trk]) { | |
3014 | points = new AliPoints(); | |
3015 | points->SetMarkerColor(GetMarkerColor()); | |
3016 | points->SetMarkerSize(GetMarkerSize()); | |
3017 | points->SetDetector(this); | |
3018 | points->SetParticle(trk); | |
3019 | points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle()); | |
3020 | fPoints->AddAt(points,trk); | |
3021 | delete [] coor[trk]; | |
3022 | coor[trk]=0; | |
3023 | } | |
3024 | } | |
3025 | delete [] coor; | |
3026 | delete [] ntrk; | |
3027 | delete [] limi; | |
3028 | } | |
3029 | ||
3030 | ||
3031 | //_____________________________________________________________________________ | |
3032 | void AliTPC::LoadPoints3(Int_t) | |
3033 | { | |
3034 | // | |
3035 | // Store x, y, z of all hits in memory | |
3036 | // - only intersection point with pad row | |
3037 | if (fTrackHits == 0) return; | |
3038 | // | |
3039 | Int_t nhits = fTrackHits->GetEntriesFast(); | |
3040 | if (nhits == 0) return; | |
3041 | Int_t tracks = gAlice->GetNtrack(); | |
3042 | if (fPoints == 0) fPoints = new TObjArray(2*tracks); | |
3043 | fPoints->Expand(2*tracks); | |
3044 | AliHit *ahit; | |
3045 | // | |
3046 | Int_t *ntrk=new Int_t[tracks]; | |
3047 | Int_t *limi=new Int_t[tracks]; | |
3048 | Float_t **coor=new Float_t*[tracks]; | |
3049 | for(Int_t i=0;i<tracks;i++) { | |
3050 | ntrk[i]=0; | |
3051 | coor[i]=0; | |
3052 | limi[i]=0; | |
3053 | } | |
3054 | // | |
3055 | AliPoints *points = 0; | |
3056 | Float_t *fp=0; | |
3057 | Int_t trk; | |
3058 | Int_t chunk=nhits/4+1; | |
3059 | // | |
3060 | // Loop over all the hits and store their position | |
3061 | // | |
3062 | ahit = FirstHit2(-1); | |
3063 | //for (Int_t hit=0;hit<nhits;hit++) { | |
3064 | ||
3065 | Int_t lastrow = -1; | |
3066 | while (ahit){ | |
3067 | // ahit = (AliHit*)fHits->UncheckedAt(hit); | |
3068 | trk=ahit->GetTrack(); | |
3069 | Float_t x[3]={ahit->X(),ahit->Y(),ahit->Z()}; | |
3070 | Int_t index[3]={1,((AliTPChit*)ahit)->fSector,0}; | |
3071 | Int_t currentrow = fTPCParam->GetPadRow(x,index) ; | |
3072 | if (currentrow!=lastrow){ | |
3073 | lastrow = currentrow; | |
3074 | //later calculate intersection point | |
3075 | if(ntrk[trk]==limi[trk]) { | |
3076 | // | |
3077 | // Initialise a new track | |
3078 | fp=new Float_t[3*(limi[trk]+chunk)]; | |
3079 | if(coor[trk]) { | |
3080 | memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]); | |
3081 | delete [] coor[trk]; | |
3082 | } | |
3083 | limi[trk]+=chunk; | |
3084 | coor[trk] = fp; | |
3085 | } else { | |
3086 | fp = coor[trk]; | |
3087 | } | |
3088 | fp[3*ntrk[trk] ] = ahit->X(); | |
3089 | fp[3*ntrk[trk]+1] = ahit->Y(); | |
3090 | fp[3*ntrk[trk]+2] = ahit->Z(); | |
3091 | ntrk[trk]++; | |
3092 | } | |
3093 | ahit = NextHit2(); | |
3094 | } | |
3095 | ||
3096 | // | |
3097 | for(trk=0; trk<tracks; ++trk) { | |
3098 | if(ntrk[trk]) { | |
3099 | points = new AliPoints(); | |
3100 | points->SetMarkerColor(GetMarkerColor()+1); | |
3101 | points->SetMarkerStyle(5); | |
3102 | points->SetMarkerSize(0.2); | |
3103 | points->SetDetector(this); | |
3104 | points->SetParticle(trk); | |
3105 | // points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle()20); | |
3106 | points->SetPolyMarker(ntrk[trk],coor[trk],30); | |
3107 | fPoints->AddAt(points,tracks+trk); | |
3108 | delete [] coor[trk]; | |
3109 | coor[trk]=0; | |
3110 | } | |
3111 | } | |
3112 | delete [] coor; | |
3113 | delete [] ntrk; | |
3114 | delete [] limi; | |
3115 | } | |
3116 | ||
3117 | ||
3118 | ||
3119 | void AliTPC::FindTrackHitsIntersection(TClonesArray * arr) | |
3120 | { | |
3121 | ||
3122 | // | |
3123 | //fill clones array with intersection of current point with the | |
3124 | //middle of the row | |
3125 | Int_t sector; | |
3126 | Int_t ipart; | |
3127 | ||
3128 | const Int_t kcmaxhits=30000; | |
de61d5d5 | 3129 | AliTPCFastVector * xxxx = new AliTPCFastVector(kcmaxhits*4); |
3130 | AliTPCFastVector & xxx = *xxxx; | |
39c8eb58 | 3131 | Int_t maxhits = kcmaxhits; |
3132 | ||
3133 | // | |
3134 | AliTPChit * tpcHit=0; | |
3135 | tpcHit = (AliTPChit*)FirstHit2(-1); | |
3136 | Int_t currentIndex=0; | |
3137 | Int_t lastrow=-1; //last writen row | |
3138 | ||
3139 | while (tpcHit){ | |
3140 | if (tpcHit==0) continue; | |
3141 | sector=tpcHit->fSector; // sector number | |
3142 | ipart=tpcHit->Track(); | |
3143 | ||
3144 | //find row number | |
3145 | ||
3146 | Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()}; | |
3147 | Int_t index[3]={1,sector,0}; | |
3148 | Int_t currentrow = fTPCParam->GetPadRow(x,index) ; | |
3149 | if (currentrow<0) continue; | |
3150 | if (lastrow<0) lastrow=currentrow; | |
3151 | if (currentrow==lastrow){ | |
3152 | if ( currentIndex>=maxhits){ | |
3153 | maxhits+=kcmaxhits; | |
3154 | xxx.ResizeTo(4*maxhits); | |
3155 | } | |
3156 | xxx(currentIndex*4)=x[0]; | |
3157 | xxx(currentIndex*4+1)=x[1]; | |
3158 | xxx(currentIndex*4+2)=x[2]; | |
3159 | xxx(currentIndex*4+3)=tpcHit->fQ; | |
3160 | currentIndex++; | |
3161 | } | |
3162 | else | |
3163 | if (currentIndex>2){ | |
3164 | Float_t sumx=0; | |
3165 | Float_t sumx2=0; | |
3166 | Float_t sumx3=0; | |
3167 | Float_t sumx4=0; | |
3168 | Float_t sumy=0; | |
3169 | Float_t sumxy=0; | |
3170 | Float_t sumx2y=0; | |
3171 | Float_t sumz=0; | |
3172 | Float_t sumxz=0; | |
3173 | Float_t sumx2z=0; | |
3174 | Float_t sumq=0; | |
3175 | for (Int_t index=0;index<currentIndex;index++){ | |
3176 | Float_t x,x2,x3,x4; | |
3177 | x=x2=x3=x4=xxx(index*4); | |
3178 | x2*=x; | |
3179 | x3*=x2; | |
3180 | x4*=x3; | |
3181 | sumx+=x; | |
3182 | sumx2+=x2; | |
3183 | sumx3+=x3; | |
3184 | sumx4+=x4; | |
3185 | sumy+=xxx(index*4+1); | |
3186 | sumxy+=xxx(index*4+1)*x; | |
3187 | sumx2y+=xxx(index*4+1)*x2; | |
3188 | sumz+=xxx(index*4+2); | |
3189 | sumxz+=xxx(index*4+2)*x; | |
3190 | sumx2z+=xxx(index*4+2)*x2; | |
3191 | sumq+=xxx(index*4+3); | |
3192 | } | |
3193 | Float_t centralPad = (fTPCParam->GetNPads(sector,lastrow)-1)/2; | |
3194 | Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+ | |
3195 | sumx2*(sumx*sumx3-sumx2*sumx2); | |
3196 | ||
3197 | Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+ | |
3198 | sumx2*(sumxy*sumx3-sumx2y*sumx2); | |
3199 | Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+ | |
3200 | sumx2*(sumxz*sumx3-sumx2z*sumx2); | |
3201 | ||
3202 | Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+ | |
3203 | sumx2*(sumx*sumx2y-sumx2*sumxy); | |
3204 | Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+ | |
3205 | sumx2*(sumx*sumx2z-sumx2*sumxz); | |
3206 | ||
3207 | Float_t y=detay/det+centralPad; | |
3208 | Float_t z=detaz/det; | |
3209 | Float_t by=detby/det; //y angle | |
3210 | Float_t bz=detbz/det; //z angle | |
3211 | sumy/=Float_t(currentIndex); | |
3212 | sumz/=Float_t(currentIndex); | |
3213 | ||
3214 | AliComplexCluster cl; | |
3215 | cl.fX=z; | |
3216 | cl.fY=y; | |
3217 | cl.fQ=sumq; | |
3218 | cl.fSigmaX2=bz; | |
3219 | cl.fSigmaY2=by; | |
3220 | cl.fTracks[0]=ipart; | |
3221 | ||
3222 | AliTPCClustersRow * row = (fClustersArray->GetRow(sector,lastrow)); | |
3223 | if (row!=0) row->InsertCluster(&cl); | |
3224 | currentIndex=0; | |
3225 | lastrow=currentrow; | |
3226 | } //end of calculating cluster for given row | |
3227 | ||
3228 | } // end of loop over hits | |
3229 | xxxx->Delete(); | |
39c8eb58 | 3230 | |
3231 | } | |
afc42102 | 3232 | //_______________________________________________________________________________ |
a62d28a2 | 3233 | void AliTPC::Digits2Reco(Int_t firstevent,Int_t lastevent) |
afc42102 | 3234 | { |
a62d28a2 | 3235 | // produces rec points from digits and writes them on the root file |
3236 | // AliTPCclusters.root | |
3237 | ||
3238 | TDirectory *cwd = gDirectory; | |
3239 | ||
3240 | ||
7a09f434 | 3241 | AliTPCParamSR *dig=(AliTPCParamSR *)gDirectory->Get("75x40_100x60"); |
3242 | if(dig){ | |
3243 | printf("You are running 2 pad-length geom hits with 3 pad-length geom digits\n"); | |
3244 | delete dig; | |
3245 | dig = new AliTPCParamSR(); | |
3246 | } | |
3247 | else | |
3248 | { | |
3249 | dig=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60"); | |
3250 | } | |
3251 | if(!dig){ | |
3252 | printf("No TPC parameters found\n"); | |
3253 | exit(3); | |
3254 | } | |
3255 | ||
a62d28a2 | 3256 | SetParam(dig); |
3257 | cout<<"AliTPC::Digits2Reco: TPC parameteres have been set"<<endl; | |
3258 | TFile *out; | |
3259 | if(!gSystem->Getenv("CONFIG_FILE")){ | |
3260 | out=TFile::Open("AliTPCclusters.root","recreate"); | |
3261 | } | |
3262 | else { | |
3263 | const char *tmp1; | |
3264 | const char *tmp2; | |
3265 | char tmp3[80]; | |
3266 | tmp1=gSystem->Getenv("CONFIG_FILE_PREFIX"); | |
3267 | tmp2=gSystem->Getenv("CONFIG_OUTDIR"); | |
3268 | sprintf(tmp3,"%s%s/AliTPCclusters.root",tmp1,tmp2); | |
3269 | out=TFile::Open(tmp3,"recreate"); | |
3270 | } | |
3271 | ||
3272 | TStopwatch timer; | |
3273 | cout<<"AliTPC::Digits2Reco - determination of rec points begins"<<endl; | |
3274 | timer.Start(); | |
3275 | cwd->cd(); | |
3276 | for(Int_t iev=firstevent;iev<lastevent+1;iev++){ | |
3277 | ||
3278 | printf("Processing event %d\n",iev); | |
3279 | Digits2Clusters(out,iev); | |
3280 | } | |
3281 | cout<<"AliTPC::Digits2Reco - determination of rec points ended"<<endl; | |
3282 | timer.Stop(); | |
3283 | timer.Print(); | |
3284 | out->Close(); | |
3285 | cwd->cd(); | |
3286 | ||
3287 | ||
afc42102 | 3288 | } |
42157e55 | 3289 | |
3290 | //////////////////////////////////////////////////////////////////////// | |
3291 | AliTPCParam* AliTPC::LoadTPCParam(TFile *file) { | |
3292 | // | |
3293 | // load TPC paarmeters from a given file or create new if the object | |
3294 | // is not found there | |
3295 | // | |
3296 | char paramName[50]; | |
3297 | sprintf(paramName,"75x40_100x60_150x60"); | |
3298 | AliTPCParam *paramTPC=(AliTPCParam*)file->Get(paramName); | |
3299 | if (paramTPC) { | |
3300 | cout<<"TPC parameters "<<paramName<<" found."<<endl; | |
3301 | } else { | |
3302 | cerr<<"TPC parameters not found. Create new (they may be incorrect)." | |
3303 | <<endl; | |
3304 | paramTPC = new AliTPCParamSR; | |
3305 | } | |
3306 | return paramTPC; | |
3307 | ||
3308 | // the older version of parameters can be accessed with this code. | |
3309 | // In some cases, we have old parameters saved in the file but | |
3310 | // digits were created with new parameters, it can be distinguish | |
3311 | // by the name of TPC TreeD. The code here is just for the case | |
3312 | // we would need to compare with old data, uncomment it if needed. | |
3313 | // | |
3314 | // char paramName[50]; | |
3315 | // sprintf(paramName,"75x40_100x60"); | |
3316 | // AliTPCParam *paramTPC=(AliTPCParam*)in->Get(paramName); | |
3317 | // if (paramTPC) { | |
3318 | // cout<<"TPC parameters "<<paramName<<" found."<<endl; | |
3319 | // } else { | |
3320 | // sprintf(paramName,"75x40_100x60_150x60"); | |
3321 | // paramTPC=(AliTPCParam*)in->Get(paramName); | |
3322 | // if (paramTPC) { | |
3323 | // cout<<"TPC parameters "<<paramName<<" found."<<endl; | |
3324 | // } else { | |
3325 | // cerr<<"TPC parameters not found. Create new (they may be incorrect)." | |
3326 | // <<endl; | |
3327 | // paramTPC = new AliTPCParamSR; | |
3328 | // } | |
3329 | // } | |
3330 | // return paramTPC; | |
3331 | ||
3332 | } | |
3333 |