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