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