Some additional protections
[u/mrichter/AliRoot.git] / TRD / AliTRDtrigger.cxx
CommitLineData
0ee00e25 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// //
e3b2b5e5 18// //
0ee00e25 19// TRD trigger class //
20// //
e3b2b5e5 21// //
0ee00e25 22///////////////////////////////////////////////////////////////////////////////
23
24#include <TTree.h>
25#include <TBranch.h>
26#include <TMatrixD.h>
27
28#include "AliLog.h"
29#include "AliRun.h"
0ee00e25 30#include "AliLoader.h"
0ee00e25 31
32#include "AliTRDdigitsManager.h"
33#include "AliTRDgeometry.h"
34#include "AliTRDdataArrayI.h"
35#include "AliTRDcalibDB.h"
36#include "AliTRDCommonParam.h"
37#include "Cal/AliTRDCalPIDLQ.h"
38#include "AliTRDrawData.h"
39
40#include "AliTRDtrigger.h"
e3b2b5e5 41#include "AliTRDmodule.h"
0ee00e25 42#include "AliTRDmcmTracklet.h"
43#include "AliTRDtrigParam.h"
44#include "AliTRDmcm.h"
e3b2b5e5 45#include "AliTRDzmaps.h"
0ee00e25 46
e3b2b5e5 47//#include "AliHeader.h"
0ee00e25 48
e3b2b5e5 49ClassImp(AliTRDtrigger)
0ee00e25 50
51//_____________________________________________________________________________
52AliTRDtrigger::AliTRDtrigger():
53 TNamed(),
54 fTracks("AliTRDgtuTrack",0)
55{
56 //
57 // AliTRDtrigger default constructor
58 //
59
60 fDigitsManager = NULL;
61 fTrackletTree = NULL;
62 fTracklets = NULL;
63
64 fNROB = 0;
65 fTrigParam = NULL;
66 fMCM = NULL;
67 fTrk = NULL;
3fcb9908 68 fTrkTest = NULL;
0ee00e25 69 fGTUtrk = NULL;
70
71 fNtracklets = 0;
72
73 fDigits = NULL;
74 fTrack0 = NULL;
75 fTrack1 = NULL;
76 fTrack2 = NULL;
77
78 fModule = NULL;
79
80 fNPrimary = 0;
81
3fcb9908 82 fField = 0.0;
83 fGeo = NULL;
84 fCalib = NULL;
85 fCParam = NULL;
86
0ee00e25 87}
88
89//_____________________________________________________________________________
90AliTRDtrigger::AliTRDtrigger(const Text_t *name, const Text_t *title):
91 TNamed(name,title),
92 fTracks("AliTRDgtuTrack",1000)
93{
94 //
95 // AliTRDtrigger constructor
96 //
97
98 fDigitsManager = new AliTRDdigitsManager();
99 fTrackletTree = NULL;
100 fTracklets = new TObjArray(400);
101
102 fNROB = 0;
103 fTrigParam = NULL;
104 fMCM = NULL;
105 fTrk = NULL;
3fcb9908 106 fTrkTest = NULL;
0ee00e25 107 fGTUtrk = NULL;
108
109 fNtracklets = 0;
110
111 fDigits = NULL;
112 fTrack0 = NULL;
113 fTrack1 = NULL;
114 fTrack2 = NULL;
115
116 fModule = NULL;
117
118 fNPrimary = 0;
119
3fcb9908 120 fField = 0.0;
121 fGeo = NULL;
122 fCalib = NULL;
123 fCParam = NULL;
124
0ee00e25 125}
126
127//_____________________________________________________________________________
128AliTRDtrigger::AliTRDtrigger(const AliTRDtrigger &p):TNamed(p)
129{
130 //
131 // AliTRDtrigger copy constructor
132 //
133
134 ((AliTRDtrigger &) p).Copy(*this);
135
136}
137
138///_____________________________________________________________________________
139AliTRDtrigger::~AliTRDtrigger()
140{
141 //
142 // AliTRDtrigger destructor
143 //
144
145 if (fTracklets) {
146 fTracklets->Delete();
147 delete fTracklets;
148 }
149
150 fTracks.Delete();
151
152}
153
154//_____________________________________________________________________________
155AliTRDtrigger &AliTRDtrigger::operator=(const AliTRDtrigger &p)
156{
157 //
158 // Assignment operator
159 //
160
161 if (this != &p) ((AliTRDtrigger &) p).Copy(*this);
162 return *this;
163
164}
165
166//_____________________________________________________________________________
167void AliTRDtrigger::Copy(TObject &) const
168{
169 //
170 // Copy function
171 //
172
173 AliFatal("Not implemented");
174
175}
176
177//_____________________________________________________________________________
178void AliTRDtrigger::Init()
179{
180
181 fModule = new AliTRDmodule(fTrigParam);
182 /*
183 AliHeader *header = fRunLoader->GetHeader();
184 fNPrimary = header->GetNprimary();
185 */
186 fTracks.Clear();
187
3fcb9908 188 fField = fTrigParam->GetField();
189 fGeo = (AliTRDgeometry*)AliTRDgeometry::GetGeometry(fRunLoader);
190
191 fCalib = AliTRDcalibDB::Instance();
192 if (!fCalib)
193 {
194 Error("Init","No instance of AliTRDcalibDB.");
195 return;
196 }
197
198 fCParam = AliTRDCommonParam::Instance();
199 if (!fCParam)
200 {
201 Error("Init","No common params.");
202 return;
203 }
204
0ee00e25 205}
206
207//_____________________________________________________________________________
208Bool_t AliTRDtrigger::Open(const Char_t *name, Int_t nEvent)
209{
210 //
211 // Opens the AliROOT file.
212 //
213
214 TString evfoldname = AliConfig::GetDefaultEventFolderName();
215 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
216
217 if (!fRunLoader)
218 fRunLoader = AliRunLoader::Open(name);
219
220 if (!fRunLoader) {
221 Error("Open","Can not open session for file %s.",name);
222 return kFALSE;
223 }
224
225 // Open input
226
227 if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice();
228 gAlice = fRunLoader->GetAliRun();
229
230 if (!(gAlice)) {
231 fRunLoader->LoadgAlice();
232 gAlice = fRunLoader->GetAliRun();
233 if (!(gAlice)) {
234 Error("Open","Could not find AliRun object.");
235 return kFALSE;
236 }
237 }
238
239 // Import the Trees for the event nEvent in the file
240 fRunLoader->GetEvent(nEvent);
241
242 // Open output
243
244 TObjArray *ioArray = 0;
245
246 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
247 loader->MakeTree("T");
248 fTrackletTree = loader->TreeT();
249 fTrackletTree->Branch("TRDmcmTracklet","TObjArray",&ioArray,32000,0);
e3b2b5e5 250 /*
0ee00e25 251 fRunLoader->LoadHeader();
e3b2b5e5 252 */
0ee00e25 253 Init();
254
255 return kTRUE;
256
257}
258
259
260//_____________________________________________________________________________
261Bool_t AliTRDtrigger::ReadDigits()
262{
263 //
264 // Reads the digits arrays from the input aliroot file
265 //
266
267 if (!fRunLoader) {
268 Error("ReadDigits","Can not find the Run Loader");
269 return kFALSE;
270 }
271
272 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
273 if (!loader->TreeD()) loader->LoadDigits();
274
698b2e52 275 if (!loader->TreeD()) return kFALSE;
276
0ee00e25 277 return (fDigitsManager->ReadDigits(loader->TreeD()));
278
279}
280
281//_____________________________________________________________________________
282Bool_t AliTRDtrigger::ReadDigits(AliRawReader* rawReader)
283{
284 //
285 // Reads the digits arrays from the ddl file
286 //
287
288 AliTRDrawData *raw = new AliTRDrawData();
289 raw->SetDebug(1);
290
291 fDigitsManager = raw->Raw2Digits(rawReader);
292
293 return kTRUE;
294
295}
296
297//_____________________________________________________________________________
298Bool_t AliTRDtrigger::ReadTracklets(AliRunLoader *rl)
299{
300 //
301 // Reads the tracklets find the tracks
302 //
303
304 Int_t idet;
305
306 AliLoader *loader = rl->GetLoader("TRDLoader");
307 loader->LoadTracks();
308 fTrackletTree = loader->TreeT();
309
310 TBranch *branch = fTrackletTree->GetBranch("TRDmcmTracklet");
311 if (!branch) {
312 Error("ReadTracklets","Can't get the branch !");
313 return kFALSE;
314 }
315 TObjArray *tracklets = new TObjArray(400);
316 branch->SetAddress(&tracklets);
317
318 Int_t nEntries = (Int_t) fTrackletTree->GetEntries();
319 Int_t iEntry, itrk;
320 Int_t iStack, iStackPrev = -1;
321
322 for (iEntry = 0; iEntry < nEntries; iEntry++) {
323 fTrackletTree->GetEvent(iEntry);
324
325 for (itrk = 0; itrk < tracklets->GetEntriesFast(); itrk++){
326
327 fTrk = (AliTRDmcmTracklet*)tracklets->UncheckedAt(itrk);
328
329 idet = fTrk->GetDetector();
330
331 iStack = idet / (AliTRDgeometry::Nplan());
332 if (iStackPrev != iStack) {
333 if (iStackPrev == -1) {
334 iStackPrev = iStack;
335 } else {
336 MakeTracks(idet-AliTRDgeometry::Nplan());
337 ResetTracklets();
338 iStackPrev = iStack;
339 }
340 }
341
342 Tracklets()->Add(fTrk);
343
344 if (iEntry == (nEntries-1) && itrk == (tracklets->GetEntriesFast()-1)) {
345 idet++;
346 MakeTracks(idet-AliTRDgeometry::Nplan());
347 ResetTracklets();
348 }
349
350 }
351
352 }
353
354 loader->UnloadTracks();
355
356 return kTRUE;
357
358}
359
360//_____________________________________________________________________________
e3b2b5e5 361Bool_t AliTRDtrigger::MakeTracklets(Bool_t makeTracks)
0ee00e25 362{
3fcb9908 363 //
364 // Create tracklets from digits
365 //
0ee00e25 366
367 Int_t chamBeg = 0;
368 Int_t chamEnd = AliTRDgeometry::Ncham();
369 Int_t planBeg = 0;
370 Int_t planEnd = AliTRDgeometry::Nplan();
371 Int_t sectBeg = 0;
372 Int_t sectEnd = AliTRDgeometry::Nsect();
373
3fcb9908 374 fTrkTest = new AliTRDmcmTracklet(0,0,0);
375
0ee00e25 376 fMCM = new AliTRDmcm(fTrigParam,0);
377
378 Int_t time, col, row, col1, col2;
379 Float_t amp;
380 Int_t idet, iStack, iStackPrev;
3fcb9908 381 idet = -1;
0ee00e25 382 iStack = -1;
383 iStackPrev = -1;
384 for (Int_t isect = sectBeg; isect < sectEnd; isect++) {
385
386 for (Int_t icham = chamBeg; icham < chamEnd; icham++) {
387
388 // number of ROBs in the chamber
389 if( icham == 2 ) {
390 fNROB = 6;
391 } else {
392 fNROB = 8;
393 }
394
395 for (Int_t iplan = planBeg; iplan < planEnd; iplan++) {
396
3fcb9908 397 idet = fGeo->GetDetector(iplan,icham,isect);
0ee00e25 398 ResetTracklets();
e3b2b5e5 399
400 if (makeTracks) {
401 iStack = idet / (AliTRDgeometry::Nplan());
402 if (iStackPrev != iStack) {
403 if (iStackPrev == -1) {
404 iStackPrev = iStack;
405 } else {
406 MakeTracks(idet-AliTRDgeometry::Nplan());
407 ResetTracklets();
408 iStackPrev = iStack;
409 }
0ee00e25 410 }
411 }
e3b2b5e5 412
3fcb9908 413 Int_t nRowMax = fCParam->GetRowMax(iplan,icham,isect);
414 Int_t nColMax = fCParam->GetColMax(iplan);
415 Int_t nTimeTotal = fCalib->GetNumberOfTimeBins();
0ee00e25 416
417 // Get the digits
418 fDigits = fDigitsManager->GetDigits(idet);
698b2e52 419 if (!fDigits) return kFALSE;
0ee00e25 420 fDigits->Expand();
421 fTrack0 = fDigitsManager->GetDictionary(idet,0);
698b2e52 422 if (!fTrack0) return kFALSE;
0ee00e25 423 fTrack0->Expand();
424 fTrack1 = fDigitsManager->GetDictionary(idet,1);
698b2e52 425 if (!fTrack1) return kFALSE;
0ee00e25 426 fTrack1->Expand();
427 fTrack2 = fDigitsManager->GetDictionary(idet,2);
698b2e52 428 if (!fTrack2) return kFALSE;
0ee00e25 429 fTrack2->Expand();
430
0ee00e25 431 for (Int_t iRob = 0; iRob < fNROB; iRob++) {
432
433 for (Int_t iMcm = 0; iMcm < kNMCM; iMcm++) {
434
435 fMCM->Reset();
436
437 fMCM->SetRobId(iRob);
438 fMCM->SetChaId(idet);
439
440 SetMCMcoordinates(iMcm);
441
442 row = fMCM->GetRow();
443
9e79a757 444 if (row < 0 || row >= nRowMax) {
0ee00e25 445 Error("MakeTracklets","MCM row number out of range.");
9e79a757 446 continue;
0ee00e25 447 }
448
449 fMCM->GetColRange(col1,col2);
450
451 for (time = 0; time < nTimeTotal; time++) {
452 for (col = col1; col < col2; col++) {
453 if (col >= 0 && col < nColMax) {
454 amp = TMath::Abs(fDigits->GetDataUnchecked(row,col,time));
455 } else {
456 amp = 0.0;
457 }
458 fMCM->SetADC(col-col1,time,amp);
459
460 }
461 }
462
463 if (fTrigParam->GetTailCancelation()) {
464 fMCM->Filter(fTrigParam->GetNexponential(),fTrigParam->GetFilterType());
465 }
466
467 if (fMCM->Run()) {
468
469 for (Int_t iSeed = 0; iSeed < kMaxTrackletsPerMCM; iSeed++) {
470
471 if (fMCM->GetSeedCol()[iSeed] < 0) continue;
472
473 if ( fTrigParam->GetDebugLevel() > 1 )
474 printf("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]);
475
476 if ( fTrigParam->GetDebugLevel() == -1 ) {
477 printf("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]);
478 for (time = 0; time < nTimeTotal; time++) {
479 for (col = 0; col < kMcmCol; col++) {
480 printf("%03.0f ",fMCM->GetADC(col,time));
481 }
482 printf("\n");
483 }
484 }
485
3fcb9908 486 if (TestTracklet(idet,row,iSeed,0)) {
487 AddTracklet(idet,row,iSeed,fNtracklets++);
488 }
0ee00e25 489
490 }
491
492 }
493
494 }
495
496
497 }
498
499 // Compress the arrays
500 fDigits->Compress(1,0);
501 fTrack0->Compress(1,0);
502 fTrack1->Compress(1,0);
503 fTrack2->Compress(1,0);
504
505 WriteTracklets(idet);
506
507 }
508 }
509 }
e3b2b5e5 510
511 if (makeTracks) {
512 idet++;
513 MakeTracks(idet-AliTRDgeometry::Nplan());
514 ResetTracklets();
515 }
516
0ee00e25 517 return kTRUE;
518
519}
520
521//_____________________________________________________________________________
522void AliTRDtrigger::SetMCMcoordinates(Int_t imcm)
523{
3fcb9908 524 //
525 // Configure MCM position in the pad plane
526 //
0ee00e25 527
528 Int_t robid = fMCM->GetRobId();
529
530 // setting the Row and Col range
531
532 const Int_t kNcolRob = 2; // number of ROBs per chamber in column direction
533 const Int_t kNmcmRob = 4; // number of MCMs per ROB in column/row direction
534
535 Int_t mcmid = imcm%(kNmcmRob*kNmcmRob);
536
537 if (robid%kNcolRob == 0) {
538
539 if ( mcmid%kNmcmRob == 0 ) {
540 fMCM->SetColRange(18*0-1,18*1-1+2+1);
541 }
542 if ( mcmid%kNmcmRob == 1 ) {
543 fMCM->SetColRange(18*1-1,18*2-1+2+1);
544 }
545 if ( mcmid%kNmcmRob == 2 ) {
546 fMCM->SetColRange(18*2-1,18*3-1+2+1);
547 }
548 if ( mcmid%kNmcmRob == 3 ) {
549 fMCM->SetColRange(18*3-1,18*4-1+2+1);
550 }
551
552 } else {
553
554 if ( mcmid%kNmcmRob == 0 ) {
555 fMCM->SetColRange(18*4-1,18*5-1+2+1);
556 }
557 if ( mcmid%kNmcmRob == 1 ) {
558 fMCM->SetColRange(18*5-1,18*6-1+2+1);
559 }
560 if ( mcmid%kNmcmRob == 2 ) {
561 fMCM->SetColRange(18*6-1,18*7-1+2+1);
562 }
563 if ( mcmid%kNmcmRob == 3 ) {
564 fMCM->SetColRange(18*7-1,18*8-1+2+1);
565 }
566
567 }
568
569 fMCM->SetRow(kNmcmRob*(robid/kNcolRob)+mcmid/kNmcmRob);
570
571}
572
573//_____________________________________________________________________________
3fcb9908 574Bool_t AliTRDtrigger::TestTracklet(Int_t det, Int_t row, Int_t seed, Int_t n)
0ee00e25 575{
3fcb9908 576 //
577 // Check first the tracklet pt
578 //
0ee00e25 579
3fcb9908 580 Int_t nTimeTotal = fCalib->GetNumberOfTimeBins();
581
582 fTrkTest->Reset();
583
584 fTrkTest->SetDetector(det);
585 fTrkTest->SetRow(row);
586 fTrkTest->SetN(n);
587
588 Int_t iCol, iCol1, iCol2, track[3];
589 iCol = fMCM->GetSeedCol()[seed]; // 0....20 (MCM)
590 fMCM->GetColRange(iCol1,iCol2); // range in the pad plane
591
592 Float_t amp[3];
593 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
594
595 amp[0] = fMCM->GetADC(iCol-1,iTime);
596 amp[1] = fMCM->GetADC(iCol ,iTime);
597 amp[2] = fMCM->GetADC(iCol+1,iTime);
598
599 // extract track contribution only from the central pad
600 track[0] = fTrack0->GetDataUnchecked(row,iCol+iCol1,iTime);
601 track[1] = fTrack1->GetDataUnchecked(row,iCol+iCol1,iTime);
602 track[2] = fTrack2->GetDataUnchecked(row,iCol+iCol1,iTime);
603
604 if (fMCM->IsCluster(iCol,iTime)) {
605
606 fTrkTest->AddCluster(iCol+iCol1,iTime,amp,track);
607
608 } else if ((iCol+1+1) < kMcmCol) {
609
610 amp[0] = fMCM->GetADC(iCol-1+1,iTime);
611 amp[1] = fMCM->GetADC(iCol +1,iTime);
612 amp[2] = fMCM->GetADC(iCol+1+1,iTime);
613
614 if (fMCM->IsCluster(iCol+1,iTime)) {
615
616 // extract track contribution only from the central pad
617 track[0] = fTrack0->GetDataUnchecked(row,iCol+1+iCol1,iTime);
618 track[1] = fTrack1->GetDataUnchecked(row,iCol+1+iCol1,iTime);
619 track[2] = fTrack2->GetDataUnchecked(row,iCol+1+iCol1,iTime);
620
621 fTrkTest->AddCluster(iCol+1+iCol1,iTime,amp,track);
622
623 }
624
625 } else {
626 }
0ee00e25 627
3fcb9908 628 }
629
630 fTrkTest->CookLabel(0.8);
631 /*
632 if (fTrkTest->GetLabel() >= fNPrimary) {
633 Info("AddTracklet","Only primaries are stored!");
634 return;
635 }
636 */
637 // LTU Pt cut
638
639 fTrkTest->MakeTrackletGraph(fGeo,fField);
640 fTrkTest->MakeClusAmpGraph();
641 if (TMath::Abs(fTrkTest->GetPt()) < fTrigParam->GetLtuPtCut()) {
642 return kFALSE;
0ee00e25 643 }
644
3fcb9908 645 return kTRUE;
646
647}
648
649//_____________________________________________________________________________
650void AliTRDtrigger::AddTracklet(Int_t det, Int_t row, Int_t seed, Int_t n)
651{
652 //
653 // Add a found tracklet
654 //
655
656 Int_t nTimeTotal = fCalib->GetNumberOfTimeBins();
0ee00e25 657
658 fTrk = new AliTRDmcmTracklet(det,row,n);
659
660 Int_t iCol, iCol1, iCol2, track[3];
661 iCol = fMCM->GetSeedCol()[seed]; // 0....20 (MCM)
662 fMCM->GetColRange(iCol1,iCol2); // range in the pad plane
663
e3b2b5e5 664 Float_t amp[3];
0ee00e25 665 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
666
e3b2b5e5 667 amp[0] = fMCM->GetADC(iCol-1,iTime);
668 amp[1] = fMCM->GetADC(iCol ,iTime);
669 amp[2] = fMCM->GetADC(iCol+1,iTime);
0ee00e25 670
671 // extract track contribution only from the central pad
672 track[0] = fTrack0->GetDataUnchecked(row,iCol+iCol1,iTime);
673 track[1] = fTrack1->GetDataUnchecked(row,iCol+iCol1,iTime);
674 track[2] = fTrack2->GetDataUnchecked(row,iCol+iCol1,iTime);
675
676 if (fMCM->IsCluster(iCol,iTime)) {
677
e3b2b5e5 678 fTrk->AddCluster(iCol+iCol1,iTime,amp,track);
0ee00e25 679
680 } else if ((iCol+1+1) < kMcmCol) {
681
e3b2b5e5 682 amp[0] = fMCM->GetADC(iCol-1+1,iTime);
683 amp[1] = fMCM->GetADC(iCol +1,iTime);
684 amp[2] = fMCM->GetADC(iCol+1+1,iTime);
0ee00e25 685
686 if (fMCM->IsCluster(iCol+1,iTime)) {
687
688 // extract track contribution only from the central pad
689 track[0] = fTrack0->GetDataUnchecked(row,iCol+1+iCol1,iTime);
690 track[1] = fTrack1->GetDataUnchecked(row,iCol+1+iCol1,iTime);
691 track[2] = fTrack2->GetDataUnchecked(row,iCol+1+iCol1,iTime);
692
e3b2b5e5 693 fTrk->AddCluster(iCol+1+iCol1,iTime,amp,track);
0ee00e25 694
695 }
696
697 } else {
698 }
699
700 }
701
702 fTrk->CookLabel(0.8);
703 /*
704 if (fTrk->GetLabel() >= fNPrimary) {
705 Info("AddTracklet","Only primaries are stored!");
706 return;
707 }
708 */
709 // LTU Pt cut
3fcb9908 710 fTrk->MakeTrackletGraph(fGeo,fField);
0ee00e25 711 fTrk->MakeClusAmpGraph();
e3b2b5e5 712 if (TMath::Abs(fTrk->GetPt()) < fTrigParam->GetLtuPtCut()) {
713 return;
714 }
0ee00e25 715
716 Tracklets()->Add(fTrk);
717
718}
719
720//_____________________________________________________________________________
721Bool_t AliTRDtrigger::WriteTracklets(Int_t det)
722{
723 //
724 // Fills TRDmcmTracklet branch in the tree with the Tracklets
725 // found in detector = det. For det=-1 writes the tree.
726 //
727
728 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
729 Error("WriteTracklets","Unexpected detector index %d.",det);
730 return kFALSE;
731 }
732
733 TBranch *branch = fTrackletTree->GetBranch("TRDmcmTracklet");
734 if (!branch) {
735 TObjArray *ioArray = 0;
736 branch = fTrackletTree->Branch("TRDmcmTracklet","TObjArray",&ioArray,32000,0);
737 }
738
739 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
740
741 Int_t nTracklets = Tracklets()->GetEntriesFast();
742 TObjArray *detTracklets = new TObjArray(400);
743
744 for (Int_t i = 0; i < nTracklets; i++) {
745 AliTRDmcmTracklet *trk = (AliTRDmcmTracklet *) Tracklets()->UncheckedAt(i);
746
747 if (det == trk->GetDetector()) {
748 detTracklets->AddLast(trk);
749 }
750 else {
751 }
752 }
753
754 branch->SetAddress(&detTracklets);
755 fTrackletTree->Fill();
756
757 delete detTracklets;
758
759 return kTRUE;
760
761 }
762
763 if (det == -1) {
764
765 Info("WriteTracklets","Writing the Tracklet tree %s for event %d."
766 ,fTrackletTree->GetName(),fRunLoader->GetEventNumber());
767
768 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
769 loader->WriteTracks("OVERWRITE");
770
771 return kTRUE;
772
773 }
774
775 return kFALSE;
776
777}
778
779//_____________________________________________________________________________
780void AliTRDtrigger::MakeTracks(Int_t det)
781{
782 //
783 // Create GTU tracks per module (stack of 6 chambers)
784 //
785
786 fModule->Reset();
787
0ee00e25 788 Int_t nRowMax, iplan, icham, isect, row;
789
0ee00e25 790 if ((det < 0) || (det >= AliTRDgeometry::Ndet())) {
791 Error("MakeTracks","Unexpected detector index %d.",det);
792 return;
793 }
794
795 Int_t nTracklets = Tracklets()->GetEntriesFast();
796
797 AliTRDmcmTracklet *trk;
798 for (Int_t i = 0; i < nTracklets; i++) {
799
800 trk = (AliTRDmcmTracklet *) Tracklets()->UncheckedAt(i);
801
3fcb9908 802 iplan = fGeo->GetPlane(trk->GetDetector());
803 icham = fGeo->GetChamber(trk->GetDetector());
804 isect = fGeo->GetSector(trk->GetDetector());
0ee00e25 805
3fcb9908 806 nRowMax = fCParam->GetRowMax(iplan,icham,isect);
0ee00e25 807 row = trk->GetRow();
808
809 fModule->AddTracklet(trk->GetDetector(),
810 row,
811 trk->GetRowz(),
812 trk->GetSlope(),
813 trk->GetOffset(),
814 trk->GetTime0(),
815 trk->GetNclusters(),
816 trk->GetLabel(),
817 trk->GetdQdl());
818
819 }
820
821 fModule->SortTracklets();
822 fModule->RemoveMultipleTracklets();
3fcb9908 823 fModule->SortZ((Int_t)fGeo->GetChamber(det));
0ee00e25 824 fModule->FindTracks();
825 fModule->SortTracks();
826 fModule->RemoveMultipleTracks();
827
828 Int_t nModTracks = fModule->GetNtracks();
829 AliTRDgtuTrack *gtutrk;
830 for (Int_t i = 0; i < nModTracks; i++) {
831 gtutrk = (AliTRDgtuTrack*)fModule->GetTrack(i);
832 if (TMath::Abs(gtutrk->GetPt()) < fTrigParam->GetGtuPtCut()) continue;
833 gtutrk->CookLabel();
834 gtutrk->MakePID();
835 AddTrack(gtutrk,det);
836 }
837
838}
839
840