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