]>
Commit | Line | Data |
---|---|---|
8e64dd77 | 1 | |
793ff80c | 2 | Int_t AliTRDtest() |
3 | { | |
4 | // | |
5 | // Test macro for the TRD code | |
6 | // | |
7 | ||
8 | Int_t rc = 0; | |
9 | ||
8e64dd77 | 10 | TFile *file; |
11 | ||
793ff80c | 12 | // Initialize the test setup |
5931c105 | 13 | gAlice->Init("$(ALICE_ROOT)/TRD/AliTRDconfig.C"); |
793ff80c | 14 | |
15 | // Run one event and create the hits | |
16 | gAlice->Run(1); | |
17 | ||
1f4ee546 | 18 | //if (gAlice) delete gAlice; |
19 | //file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); | |
20 | //gAlice = (AliRun *) file->Get("gAlice"); | |
6244debe | 21 | |
793ff80c | 22 | // Analyze the TRD hits |
793ff80c | 23 | if (rc = AliTRDanalyzeHits()) return rc; |
24 | ||
25 | // Run the digitization | |
793ff80c | 26 | if (rc = AliTRDcreateDigits()) return rc; |
27 | ||
1f4ee546 | 28 | // if (gAlice) delete gAlice; |
29 | // file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); | |
30 | // gAlice = (AliRun *) file->Get("gAlice"); | |
6244debe | 31 | |
a328fff9 | 32 | // Analyze the digits |
33 | if (rc = AliTRDanalyzeDigits()) return rc; | |
793ff80c | 34 | |
1f4ee546 | 35 | // // Create the cluster |
36 | // if (rc = AliTRDcreateCluster()) return rc; | |
4a0fe73c | 37 | |
1f4ee546 | 38 | // if (gAlice) delete gAlice; |
39 | // file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); | |
40 | // gAlice = (AliRun *) file->Get("gAlice"); | |
4a0fe73c | 41 | |
1f4ee546 | 42 | // // Analyze the cluster |
43 | // if (rc = AliTRDanalyzeCluster()) return rc; | |
4a0fe73c | 44 | |
8e64dd77 | 45 | //file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); |
46 | //file->Close(); | |
47 | ||
48 | // Find the tracks | |
49 | //if (rc = AliTRDcreateTracks()) return rc; | |
50 | ||
793ff80c | 51 | return rc; |
52 | ||
53 | } | |
fa148e6c | 54 | |
55 | //_____________________________________________________________________________ | |
56 | Int_t AliTRDanalyzeHits() | |
57 | { | |
58 | // | |
59 | // Analyzes the hits and fills QA-histograms | |
60 | // | |
61 | ||
62 | Int_t rc = 0; | |
63 | ||
1f4ee546 | 64 | AliRunLoader *rl = gAlice->GetRunLoader(); |
65 | if (!rl) { | |
66 | cout << "<AliTRDanalyzeHits> No RunLoader found" << endl; | |
fa148e6c | 67 | rc = 1; |
68 | return rc; | |
69 | } | |
1f4ee546 | 70 | |
71 | // Import the Trees for the event nEvent in the file | |
72 | rl->GetEvent(0); | |
73 | ||
74 | AliLoader* loader = rl->GetLoader("TRDLoader"); | |
75 | if (!loader) { | |
76 | cout << "<AliTRDanalyzeHits> No TRDLoader found" << endl; | |
77 | rc = 2; | |
78 | return rc; | |
79 | } | |
fa148e6c | 80 | |
81 | // Get the pointer to the TRD detector | |
82 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); | |
83 | if (!trd) { | |
84 | cout << "<AliTRDanalyzeHits> No TRD detector found" << endl; | |
85 | rc = 2; | |
86 | return rc; | |
87 | } | |
88 | ||
89 | // Get the pointer to the geometry object | |
90 | AliTRDgeometryFull *geo; | |
91 | if (trd) { | |
92 | geo = (AliTRDgeometryFull *) trd->GetGeometry(); | |
93 | } | |
94 | else { | |
95 | cout << "<AliTRDanalyzeHits> No TRD geometry found" << endl; | |
96 | rc = 3; | |
97 | return rc; | |
98 | } | |
99 | ||
3551db50 | 100 | AliTRDCommonParam *par = AliTRDCommonParam::Instance(); |
fa148e6c | 101 | |
102 | // Define the histograms | |
103 | TH1F *hQdedx = new TH1F("hQdedx","Charge dedx-hits",100,0.0,1000.0); | |
104 | TH1F *hQtr = new TH1F("hQtr" ,"Charge TR-hits" ,100,0.0,1000.0); | |
105 | ||
106 | Float_t rmin = geo->Rmin(); | |
107 | Float_t rmax = geo->Rmax(); | |
108 | Float_t length = geo->GetChamberLength(0,2); | |
109 | Float_t width = geo->GetChamberWidth(0); | |
110 | Int_t ncol = par->GetColMax(0); | |
111 | Int_t nrow = par->GetRowMax(0,2,13); | |
3551db50 | 112 | Int_t ntime = ((Int_t) (rmax - rmin) / 22.0); |
fa148e6c | 113 | |
114 | TH2F *hZY = new TH2F("hZY" ,"Y vs Z (chamber 0)", nrow,-length/2.,length/2. | |
115 | ,ntime, rmin, rmax); | |
116 | TH2F *hXZ = new TH2F("hXZ" ,"Z vs X (plane 0)" , ncol, -width/2., width/2. | |
117 | , nrow,-length/2.,length/2.); | |
118 | ||
fa148e6c | 119 | // Get the pointer hit tree |
1f4ee546 | 120 | TTree *hitTree = loader->TreeH(); |
fa148e6c | 121 | if (!hitTree) { |
122 | cout << "<AliTRDanalyzeHits> No hit tree found" << endl; | |
123 | rc = 4; | |
124 | return rc; | |
125 | } | |
126 | ||
127 | Int_t countHits = 0; | |
128 | Int_t nBytes = 0; | |
129 | ||
130 | // Get the number of entries in the hit tree | |
131 | // (Number of primary particles creating a hit somewhere) | |
132 | Int_t nTrack = (Int_t) hitTree->GetEntries(); | |
133 | cout << "<AliTRDanalyzeHits> Found " << nTrack | |
134 | << " primary particles with hits" << endl; | |
135 | ||
136 | // Loop through all entries in the tree | |
137 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
138 | ||
139 | gAlice->ResetHits(); | |
140 | nBytes += hitTree->GetEvent(iTrack); | |
141 | ||
fa148e6c | 142 | // Loop through the TRD hits |
143 | Int_t iHit = 0; | |
144 | AliTRDhit *hit = (AliTRDhit *) trd->FirstHit(-1); | |
145 | while (hit) { | |
146 | ||
147 | countHits++; | |
148 | iHit++; | |
149 | ||
150 | Float_t x = hit->X(); | |
151 | Float_t y = hit->Y(); | |
152 | Float_t z = hit->Z(); | |
153 | Float_t q = hit->GetCharge(); | |
154 | Int_t track = hit->Track(); | |
155 | Int_t det = hit->GetDetector(); | |
156 | Int_t plane = geo->GetPlane(det); | |
157 | ||
158 | if (q > 0) { | |
159 | hQdedx->Fill(q); | |
160 | hZY->Fill(z,y); | |
161 | if (plane == 0) { | |
162 | hXZ->Fill(x,z); | |
163 | } | |
164 | } | |
165 | else if (q < 0) { | |
166 | hQtr->Fill(TMath::Abs(q)); | |
167 | } | |
168 | ||
fa148e6c | 169 | hit = (AliTRDhit *) trd->NextHit(); |
170 | ||
171 | } | |
172 | ||
fa148e6c | 173 | } |
174 | ||
175 | cout << "<AliTRDanalyzeHits> Found " << countHits << " hits in total" << endl; | |
176 | ||
177 | TCanvas *cHits = new TCanvas("cHits","AliTRDanalyzeHits",50,50,600,600); | |
178 | cHits->Divide(2,2); | |
179 | cHits->cd(1); | |
180 | hXZ->Draw("COL"); | |
181 | cHits->cd(2); | |
182 | hZY->Draw("COL"); | |
183 | cHits->cd(3); | |
184 | gPad->SetLogy(); | |
185 | hQdedx->Draw(); | |
186 | cHits->cd(4); | |
187 | gPad->SetLogy(); | |
188 | hQtr->Draw(); | |
189 | ||
fa148e6c | 190 | return rc; |
191 | ||
192 | } | |
193 | ||
194 | //_____________________________________________________________________________ | |
195 | Int_t AliTRDcreateDigits() | |
196 | { | |
197 | // | |
198 | // Creates the digits from the hits of the slow simulator | |
199 | // | |
200 | ||
201 | Int_t rc = 0; | |
202 | ||
203 | if (!gAlice) { | |
204 | cout << "<AliTRDcreateDigits> No AliRun object found" << endl; | |
205 | rc = 1; | |
206 | return rc; | |
207 | } | |
208 | gAlice->GetEvent(0); | |
209 | ||
210 | // Create the TRD digitzer | |
211 | AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer" | |
212 | ,"TRD digitizer class"); | |
1f4ee546 | 213 | digitizer->Open("TRD_test.root"); |
fa148e6c | 214 | digitizer->InitDetector(); |
1f4ee546 | 215 | digitizer->InitOutput(0); |
fa148e6c | 216 | |
217 | // Set the parameter | |
218 | digitizer->SetDebug(1); | |
219 | ||
220 | // Define the parameter object | |
221 | // If no external parameter object is defined, | |
222 | // default parameter will be used | |
223 | AliTRDparameter *parameter = new AliTRDparameter("TRDparameter" | |
224 | ,"TRD parameter class"); | |
225 | digitizer->SetParameter(parameter); | |
226 | ||
227 | // Create the digits | |
228 | if (!(digitizer->MakeDigits())) { | |
229 | rc = 2; | |
230 | return rc; | |
231 | } | |
232 | ||
233 | // Write the digits into the input file | |
1f4ee546 | 234 | //if (!(digitizer->MakeBranch())) { |
235 | // rc = 3; | |
236 | // return rc; | |
237 | //} | |
fa148e6c | 238 | |
239 | // Write the digits into the input file | |
240 | if (!(digitizer->WriteDigits())) { | |
241 | rc = 4; | |
242 | return rc; | |
243 | } | |
244 | ||
245 | // Save the parameter object in the AliROOT file | |
246 | if (!(parameter->Write())) { | |
247 | rc = 4; | |
248 | return rc; | |
249 | } | |
250 | ||
251 | return rc; | |
252 | ||
253 | } | |
254 | ||
255 | //_____________________________________________________________________________ | |
256 | Int_t AliTRDanalyzeDigits() | |
257 | { | |
258 | // | |
259 | // Analyzes the digits | |
260 | // | |
261 | ||
262 | Int_t rc = 0; | |
263 | ||
264 | const Int_t kNpla = AliTRDgeometry::Nplan(); | |
265 | ||
266 | if (!gAlice) { | |
267 | cout << "<AliTRDanalyzeDigits> No AliRun object found" << endl; | |
268 | rc = 1; | |
269 | return rc; | |
270 | } | |
fa148e6c | 271 | |
a328fff9 | 272 | AliRunLoader *rl = gAlice->GetRunLoader(); |
273 | if (!rl) { | |
274 | cout << "<AliTRDanalyzeHits> No RunLoader found" << endl; | |
fa148e6c | 275 | rc = 2; |
276 | return rc; | |
277 | } | |
278 | ||
a328fff9 | 279 | // Import the Trees for the event nEvent in the file |
280 | rl->LoadKinematics(); | |
281 | rl->GetEvent(0); | |
282 | rl->GetHeader(); | |
283 | ||
284 | AliLoader* loader = rl->GetLoader("TRDLoader"); | |
285 | if (!loader) { | |
286 | cout << "<AliTRDanalyzeHits> No TRDLoader found" << endl; | |
fa148e6c | 287 | rc = 3; |
288 | return rc; | |
289 | } | |
290 | ||
a328fff9 | 291 | // Get the pointer to the TRD detector |
292 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); | |
293 | if (!trd) { | |
294 | cout << "<AliTRDanalyzeDigits> No TRD detector found" << endl; | |
295 | rc = 4; | |
296 | return rc; | |
297 | } | |
298 | ||
299 | // Get the parameter object | |
3551db50 | 300 | AliTRDSimParam *parSim = AliTRDSimParam::Instance(); |
301 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
302 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
a328fff9 | 303 | |
fa148e6c | 304 | // Define the histograms |
3551db50 | 305 | Int_t adcRange = ((Int_t) parSim->GetADCoutRange()); |
fa148e6c | 306 | TH1F *hAmpAll = new TH1F("hAmpAll" ,"Amplitude of the digits (all)" |
307 | ,adcRange+1,-0.5,((Float_t) adcRange)+0.5); | |
308 | TH1F *hAmpEl = new TH1F("hAmpEl" ,"Amplitude of the digits (electrons)" | |
309 | ,adcRange+1,-0.5,((Float_t) adcRange)+0.5); | |
310 | TH1F *hAmpPi = new TH1F("hAmpPi" ,"Amplitude of the digits (pions)" | |
311 | ,adcRange+1,-0.5,((Float_t) adcRange)+0.5); | |
312 | TH1F *hAmpNoise = new TH1F("hAmpNoise","Amplitude of the digits (noise)" | |
313 | ,5,-0.5,4.5); | |
314 | ||
315 | // Get the pointer to the geometry object | |
316 | AliTRDgeometry *geo; | |
317 | if (trd) { | |
318 | geo = trd->GetGeometry(); | |
319 | } | |
320 | else { | |
321 | cout << "<AliTRDanalyzeDigits> No TRD geometry found" << endl; | |
a328fff9 | 322 | rc = 5; |
fa148e6c | 323 | return rc; |
324 | } | |
325 | ||
326 | // Create the digits manager | |
327 | AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(); | |
8e64dd77 | 328 | digitsManager->SetDebug(1); |
fa148e6c | 329 | |
fa148e6c | 330 | // Read the digits from the file |
a328fff9 | 331 | if (!(digitsManager->ReadDigits(loader->TreeD()))) { |
fa148e6c | 332 | cout << "<AliTRDanalyzeDigits> Cannot read the digits" << endl; |
a328fff9 | 333 | rc = 6; |
334 | return rc; | |
335 | } | |
336 | ||
337 | // Get the particle stack | |
338 | AliStack *kineStack = rl->Stack(); | |
339 | if (!kineStack) { | |
340 | cout << "<AliTRDanalyzeDigits> Cannot find the KINE stack" << endl; | |
341 | rc = 7; | |
fa148e6c | 342 | return rc; |
343 | } | |
344 | ||
fa148e6c | 345 | Int_t countDigits = 0; |
346 | Int_t iSec = trd->GetSensSector(); | |
347 | Int_t iCha = trd->GetSensChamber(); | |
3551db50 | 348 | Int_t timeMax = cal->GetNumberOfTimeBins(); |
fa148e6c | 349 | |
350 | TProfile *hAmpTimeEl = new TProfile("hAmpTimeEl","Amplitude of the digits (electrons)" | |
351 | ,timeMax,-0.5,((Double_t) timeMax)-0.5); | |
352 | TProfile *hAmpTimePi = new TProfile("hAmpTimePi","Amplitude of the digits (pions)" | |
353 | ,timeMax,-0.5,((Double_t) timeMax)-0.5); | |
354 | ||
355 | // Loop over all planes | |
356 | for (Int_t iPla = 0; iPla < kNpla; iPla++) { | |
357 | ||
358 | Int_t iDet = geo->GetDetector(iPla,iCha,iSec); | |
3551db50 | 359 | Int_t rowMax = parCom->GetRowMax(iPla,iCha,iSec); |
360 | Int_t colMax = parCom->GetColMax(iPla); | |
fa148e6c | 361 | |
fa148e6c | 362 | // Loop through the detector pixel |
363 | for (Int_t time = 0; time < timeMax; time++) { | |
364 | for (Int_t col = 0; col < colMax; col++) { | |
365 | for (Int_t row = 0; row < rowMax; row++) { | |
366 | ||
367 | AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet); | |
368 | Int_t amp = digit->GetAmp(); | |
369 | Int_t track0 = digitsManager->GetTrack(0,row,col,time,iDet); | |
370 | Int_t track1 = digitsManager->GetTrack(1,row,col,time,iDet); | |
371 | TParticle *particle = 0; | |
372 | if (track0 > -1) { | |
a328fff9 | 373 | particle = (TParticle *) kineStack->Particle(track0); |
fa148e6c | 374 | } |
375 | ||
376 | if (amp > 0) { | |
377 | countDigits++; | |
fa148e6c | 378 | } |
379 | ||
380 | // Total spectrum | |
381 | hAmpAll->Fill(amp); | |
382 | ||
383 | // Noise spectrum | |
384 | if (track0 < 0) { | |
385 | hAmpNoise->Fill(amp); | |
386 | } | |
387 | ||
388 | // Electron digit | |
389 | if ((particle) && (particle->GetPdgCode() == 11) && (track1 < 0)) { | |
390 | hAmpEl->Fill(amp); | |
391 | hAmpTimeEl->Fill(time,amp); | |
392 | } | |
393 | ||
394 | // Pion digit | |
395 | if ((particle) && (particle->GetPdgCode() == -211) && (track1 < 0)) { | |
396 | hAmpPi->Fill(amp); | |
397 | hAmpTimePi->Fill(time,amp); | |
398 | } | |
399 | ||
400 | delete digit; | |
401 | ||
402 | } | |
403 | } | |
404 | } | |
405 | ||
406 | } | |
407 | ||
408 | cout << "<AliTRDanalyzeDigits> Found " << countDigits << " digits in total" << endl; | |
409 | ||
fa148e6c | 410 | TCanvas *cDigits = new TCanvas("cDigits","AliTRDanalyzeDigits",50,50,600,800); |
411 | cDigits->Divide(2,3); | |
412 | cDigits->cd(1); | |
413 | gPad->SetLogy(); | |
414 | hAmpAll->SetXTitle("Amplitude (ADC-channels)"); | |
415 | hAmpAll->SetYTitle("Entries"); | |
416 | hAmpAll->Draw(); | |
417 | cDigits->cd(2); | |
418 | gPad->SetLogy(); | |
419 | hAmpNoise->SetXTitle("Amplitude (ADC-channels)"); | |
420 | hAmpNoise->SetYTitle("Entries"); | |
421 | hAmpNoise->Draw(); | |
422 | cDigits->cd(3); | |
423 | gPad->SetLogy(); | |
424 | hAmpEl->SetXTitle("Amplitude (ADC-channels)"); | |
425 | hAmpEl->SetYTitle("Entries"); | |
426 | hAmpEl->Draw(); | |
427 | cDigits->cd(4); | |
428 | gPad->SetLogy(); | |
429 | hAmpPi->SetXTitle("Amplitude (ADC-channels)"); | |
430 | hAmpPi->SetYTitle("Entries"); | |
431 | hAmpPi->Draw(); | |
432 | cDigits->cd(5); | |
433 | hAmpTimeEl->SetXTitle("Timebin number"); | |
434 | hAmpTimeEl->SetYTitle("Mean amplitude"); | |
435 | hAmpTimeEl->Draw("HIST"); | |
436 | cDigits->cd(6); | |
437 | hAmpTimePi->SetXTitle("Timebin number"); | |
438 | hAmpTimePi->SetYTitle("Mean amplitude"); | |
439 | hAmpTimePi->Draw("HIST"); | |
440 | ||
fa148e6c | 441 | return rc; |
442 | ||
443 | } | |
444 | ||
445 | //_____________________________________________________________________________ | |
446 | Int_t AliTRDcreateCluster() | |
447 | { | |
448 | // | |
449 | // Creates the cluster from the digits | |
450 | // | |
451 | ||
452 | Int_t rc = 0; | |
453 | ||
454 | // Create the clusterizer | |
455 | AliTRDclusterizerV1 *clusterizer = new AliTRDclusterizerV1("TRDclusterizer" | |
456 | ,"TRD clusterizer class"); | |
457 | clusterizer->SetVerbose(1); | |
458 | ||
459 | // Define the parameter object | |
460 | // If no external parameter object is defined, | |
461 | // default parameter will be used | |
462 | AliTRDparameter *parameter = new AliTRDparameter("TRDparameter" | |
463 | ,"TRD parameter class"); | |
464 | parameter->SetClusMaxThresh(0); | |
465 | parameter->SetClusSigThresh(0); | |
466 | clusterizer->SetParameter(parameter); | |
467 | ||
468 | // Open the file | |
469 | if (!(clusterizer->Open("TRD_test.root",0))) { | |
470 | rc = 1; | |
471 | return rc; | |
472 | } | |
473 | ||
474 | // Load the digits | |
475 | if (!(clusterizer->ReadDigits())) { | |
476 | rc = 2; | |
477 | return rc; | |
478 | } | |
479 | ||
480 | // Find the cluster | |
481 | if (!(clusterizer->MakeClusters())) { | |
482 | rc = 3; | |
483 | return rc; | |
484 | } | |
485 | ||
486 | // Write the cluster tree into the file | |
487 | if (!(clusterizer->WriteClusters(-1))) { | |
488 | rc = 4; | |
489 | return rc; | |
490 | } | |
491 | ||
492 | // Save the clusterizer class in the file | |
493 | if (!(clusterizer->Write())) { | |
494 | rc = 5; | |
495 | return rc; | |
496 | } | |
497 | ||
498 | return rc; | |
499 | ||
500 | } | |
501 | ||
502 | //_____________________________________________________________________________ | |
503 | Int_t AliTRDanalyzeCluster() | |
504 | { | |
505 | // | |
506 | // Analyzes the cluster | |
507 | // | |
508 | ||
509 | Int_t rc = 0; | |
510 | ||
511 | if (!gAlice) { | |
512 | cout << "<AliTRDanalyzeCluster> No AliRun object found" << endl; | |
513 | rc = 1; | |
514 | return rc; | |
515 | } | |
516 | gAlice->GetEvent(0); | |
517 | ||
518 | // Get the pointer to the TRD detector | |
519 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); | |
520 | if (!trd) { | |
521 | cout << "<AliTRDanalyzeCluster> No TRD detector found" << endl; | |
522 | rc = 2; | |
523 | return rc; | |
524 | } | |
525 | ||
526 | // Define the histograms | |
527 | TH1F *hClusAll = new TH1F("hClusAll" ,"Amplitude of the cluster (all)" | |
528 | ,501,-0.5,500.5); | |
529 | TH1F *hClusNoise = new TH1F("hClusNoise","Amplitude of the cluster (noise)" | |
963b25ce | 530 | , 11,-0.5, 10.5); |
fa148e6c | 531 | TH1F *hClusEl = new TH1F("hClusEl" ,"Amplitude of the cluster (electron)" |
532 | ,501,-0.5,500.5); | |
533 | TH1F *hClusPi = new TH1F("hClusPi" ,"Amplitude of the cluster (pion)" | |
534 | ,501,-0.5,500.5); | |
535 | ||
536 | // Get the pointer to the geometry object | |
537 | AliTRDgeometry *geo; | |
538 | if (trd) { | |
539 | geo = trd->GetGeometry(); | |
540 | } | |
541 | else { | |
542 | cout << "<AliTRDanalyzeCluster> No TRD geometry found" << endl; | |
543 | rc = 3; | |
544 | return rc; | |
545 | } | |
546 | ||
547 | // Get the pointer to the hit-tree | |
548 | TFile *file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); | |
549 | TTree *clusterTree = (TTree *) file->Get("TreeR0_TRD"); | |
550 | if (!(clusterTree)) { | |
551 | cout << "<AliTRDanalyzeCluster> No tree with clusters found" << endl; | |
552 | rc = 4; | |
553 | return rc; | |
554 | } | |
555 | ||
556 | // Get the pointer to the hit container | |
557 | TObjArray *clusterArray = trd->RecPoints(); | |
558 | if (!(clusterArray)) { | |
559 | cout << "<AliTRDanalyzeCluster> No clusterArray found" << endl; | |
560 | rc = 5; | |
561 | return rc; | |
562 | } | |
563 | ||
564 | // Set the branch address | |
565 | clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray); | |
566 | Int_t nEntries = clusterTree->GetEntries(); | |
567 | cout << "<AliTRDanalyzeCluster> Number of entries in the cluster tree = " | |
568 | << nEntries | |
569 | << endl; | |
570 | ||
571 | Int_t countCluster = 0; | |
572 | Int_t countOverlap = 0; | |
573 | ||
574 | // Loop through all entries in the tree | |
575 | Int_t nbytes; | |
576 | for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { | |
577 | ||
578 | // Import the tree | |
579 | nbytes += clusterTree->GetEvent(iEntry); | |
580 | ||
581 | // Get the number of points in the detector | |
582 | Int_t nCluster = clusterArray->GetEntriesFast(); | |
583 | ||
584 | // Loop through all TRD digits | |
585 | for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { | |
586 | ||
587 | // Get the information for this digit | |
588 | AliTRDcluster *cluster = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster); | |
589 | Int_t detector = cluster->GetDetector(); | |
590 | Int_t sector = geo->GetSector(detector); | |
591 | Int_t plane = geo->GetPlane(detector); | |
592 | Int_t chamber = geo->GetChamber(detector); | |
593 | Float_t energy = cluster->GetQ(); | |
f6ff4cec | 594 | Int_t track0 = cluster->GetLabel(0); |
595 | Int_t track1 = cluster->GetLabel(1); | |
596 | Int_t track2 = cluster->GetLabel(2); | |
fa148e6c | 597 | TParticle *particle = 0; |
598 | if (track0 > -1) { | |
599 | particle = gAlice->Particle(track0); | |
600 | } | |
601 | ||
602 | countCluster++; | |
603 | if (!cluster->Isolated()) countOverlap++; | |
604 | ||
605 | // Total spectrum | |
606 | hClusAll->Fill(energy); | |
607 | ||
608 | if (cluster->Isolated()) { | |
609 | ||
610 | // Noise spectrum | |
611 | if (track0 < 0) { | |
612 | hClusNoise->Fill(energy); | |
613 | } | |
614 | ||
615 | // Electron cluster | |
616 | if ((particle) && (particle->GetPdgCode() == 11) && (track1 < 0)) { | |
617 | hClusEl->Fill(energy); | |
618 | } | |
619 | ||
620 | // Pion cluster | |
621 | if ((particle) && (particle->GetPdgCode() == -211) && (track1 < 0)) { | |
622 | hClusPi->Fill(energy); | |
623 | } | |
624 | ||
625 | } | |
626 | ||
627 | } | |
628 | ||
629 | } | |
630 | ||
631 | cout << "<AliTRDanalyzeCluster> Found " << countCluster << " cluster in total" << endl; | |
632 | cout << "<AliTRDanalyzeCluster> Found " << countOverlap << " overlapping cluster" << endl; | |
633 | cout << endl; | |
634 | ||
635 | TCanvas *cCluster = new TCanvas("cCluster","AliTRDanalyzeCluster",50,50,600,600); | |
636 | cCluster->Divide(2,2); | |
637 | ||
638 | TF1 *fun; | |
639 | cCluster->cd(1); | |
640 | gPad->SetLogy(); | |
641 | hClusAll->Fit("landau","0"); | |
642 | fun = (TF1 *) hClusAll->GetListOfFunctions()->First(); | |
643 | Float_t meanAll = fun->GetParameter(1); | |
644 | hClusAll->Draw(); | |
645 | fun->SetLineColor(2); | |
646 | fun->Draw("SAME"); | |
647 | ||
963b25ce | 648 | cCluster->cd(2); |
649 | gPad->SetLogy(); | |
fa148e6c | 650 | Float_t meanNoise = hClusNoise->GetMean(); |
963b25ce | 651 | hClusNoise->Draw(); |
fa148e6c | 652 | |
653 | cCluster->cd(3); | |
654 | gPad->SetLogy(); | |
655 | hClusEl->Fit("landau","0"); | |
656 | fun = (TF1 *) hClusEl->GetListOfFunctions()->First(); | |
657 | fun->SetLineColor(2); | |
658 | Float_t meanEl = fun->GetParameter(1); | |
659 | hClusEl->Draw(); | |
660 | fun->Draw("SAME"); | |
661 | ||
662 | cCluster->cd(4); | |
663 | gPad->SetLogy(); | |
664 | hClusPi->Fit("landau","0"); | |
665 | fun = (TF1 *) hClusPi->GetListOfFunctions()->First(); | |
666 | fun->SetLineColor(2); | |
667 | Float_t meanPi = fun->GetParameter(1); | |
668 | hClusPi->Draw(); | |
669 | fun->Draw("SAME"); | |
670 | ||
671 | cout << endl; | |
672 | cout << "##################################################################" << endl; | |
673 | cout << " Mean all = " << meanAll << endl; | |
674 | cout << " Mean noise = " << meanNoise << endl; | |
675 | cout << " Mean electrons = " << meanEl << endl; | |
676 | cout << " Mean pions = " << meanPi << endl; | |
677 | cout << "##################################################################" << endl; | |
678 | cout << endl; | |
679 | ||
680 | return rc; | |
681 | ||
682 | } | |
8e64dd77 | 683 | |
684 | //_____________________________________________________________________________ | |
685 | Int_t AliTRDcreateTracks() | |
686 | { | |
687 | // | |
688 | // Creates the tracks | |
689 | // | |
690 | ||
691 | Int_t rc = 0; | |
692 | ||
693 | // Create the tracker | |
694 | AliTRDtracker *tracker = new AliTRDtracker("TRDtracker","TRD tracker"); | |
695 | ||
696 | // Read in the kine tree and the cluster | |
697 | tracker->GetEvent("TRD_test.root","TRD_test.root"); | |
698 | ||
699 | // Find the tracks | |
700 | TH1F *hs = new TH1F("hs","hs",100,0.0,1.0); | |
701 | TH1F *hd = new TH1F("hd","hd",100,0.0,1.0); | |
702 | tracker->Clusters2Tracks(hs,hd); | |
703 | ||
704 | // Store the tracks | |
705 | tracker->WriteTracks("TRD_test.root"); | |
706 | ||
707 | return rc; | |
708 | ||
709 | } |