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