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