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