]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtrigger.cxx
First implementation of neural network PID
[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"
720a0a16 48#include "Cal/AliTRDCalPID.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
c0ab62ff 165 delete fDigitsManager;
166 delete fModule;
167 delete fTrkTest;
168 delete fMCM;
aec56b0b 169 // delete fTrk;
c0ab62ff 170
0ee00e25 171}
172
173//_____________________________________________________________________________
174AliTRDtrigger &AliTRDtrigger::operator=(const AliTRDtrigger &p)
175{
176 //
177 // Assignment operator
178 //
179
180 if (this != &p) ((AliTRDtrigger &) p).Copy(*this);
181 return *this;
182
183}
184
185//_____________________________________________________________________________
186void AliTRDtrigger::Copy(TObject &) const
187{
188 //
189 // Copy function
190 //
191
192 AliFatal("Not implemented");
193
194}
195
196//_____________________________________________________________________________
197void AliTRDtrigger::Init()
198{
199
f162af62 200 fModule = new AliTRDmodule();
6d50f529 201 fTracks->Clear();
0ee00e25 202
f162af62 203 // The magnetic field strength
204 Double_t x[3] = { 0.0, 0.0, 0.0 };
205 Double_t b[3];
206 gAlice->Field(x,b); // b[] is in kilo Gauss
207 fField = b[2] * 0.1; // Tesla
208
209 fGeo = new AliTRDgeometry();
3fcb9908 210
f162af62 211 if (!AliTRDcalibDB::Instance()) {
6d50f529 212 AliError("No instance of AliTRDcalibDB.");
3fcb9908 213 return;
214 }
215
0ee00e25 216}
217
218//_____________________________________________________________________________
219Bool_t AliTRDtrigger::Open(const Char_t *name, Int_t nEvent)
220{
221 //
222 // Opens the AliROOT file.
223 //
224
225 TString evfoldname = AliConfig::GetDefaultEventFolderName();
6d50f529 226 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
0ee00e25 227
6d50f529 228 if (!fRunLoader) {
0ee00e25 229 fRunLoader = AliRunLoader::Open(name);
6d50f529 230 }
0ee00e25 231 if (!fRunLoader) {
6d50f529 232 AliError(Form("Can not open session for file %s.",name));
0ee00e25 233 return kFALSE;
234 }
235
0ee00e25 236 // Import the Trees for the event nEvent in the file
237 fRunLoader->GetEvent(nEvent);
238
239 // Open output
0ee00e25 240 TObjArray *ioArray = 0;
6d50f529 241 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
0ee00e25 242 loader->MakeTree("T");
243 fTrackletTree = loader->TreeT();
244 fTrackletTree->Branch("TRDmcmTracklet","TObjArray",&ioArray,32000,0);
0ee00e25 245 Init();
246
247 return kTRUE;
248
249}
250
0ee00e25 251//_____________________________________________________________________________
252Bool_t AliTRDtrigger::ReadDigits()
253{
254 //
255 // Reads the digits arrays from the input aliroot file
256 //
257
258 if (!fRunLoader) {
6d50f529 259 AliError("Can not find the Run Loader");
0ee00e25 260 return kFALSE;
261 }
262
263 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
6d50f529 264 if (!loader->TreeD()) {
265 loader->LoadDigits();
266 }
267 if (!loader->TreeD()) {
268 return kFALSE;
269 }
698b2e52 270
0ee00e25 271 return (fDigitsManager->ReadDigits(loader->TreeD()));
272
273}
274
275//_____________________________________________________________________________
276Bool_t AliTRDtrigger::ReadDigits(AliRawReader* rawReader)
277{
278 //
279 // Reads the digits arrays from the ddl file
280 //
281
282 AliTRDrawData *raw = new AliTRDrawData();
6d50f529 283 fDigitsManager = raw->Raw2Digits(rawReader);
0ee00e25 284
285 return kTRUE;
286
287}
288
25ca55ce 289//_____________________________________________________________________________
290Bool_t AliTRDtrigger::ReadDigits(TTree *digitsTree)
291{
292 //
293 // Reads the digits arrays from the input tree
294 //
295
296 return (fDigitsManager->ReadDigits(digitsTree));
297
298}
299
0ee00e25 300//_____________________________________________________________________________
301Bool_t AliTRDtrigger::ReadTracklets(AliRunLoader *rl)
302{
303 //
304 // Reads the tracklets find the tracks
305 //
306
307 Int_t idet;
308
309 AliLoader *loader = rl->GetLoader("TRDLoader");
310 loader->LoadTracks();
6d50f529 311 fTrackletTree = loader->TreeT();
0ee00e25 312
6d50f529 313 TBranch *branch = fTrackletTree->GetBranch("TRDmcmTracklet");
0ee00e25 314 if (!branch) {
6d50f529 315 AliError("Can't get the branch !");
0ee00e25 316 return kFALSE;
317 }
318 TObjArray *tracklets = new TObjArray(400);
319 branch->SetAddress(&tracklets);
320
6d50f529 321 Int_t nEntries = (Int_t) fTrackletTree->GetEntries();
322 Int_t iEntry;
323 Int_t itrk;
324 Int_t iStack;
325 Int_t iStackPrev = -1;
0ee00e25 326
327 for (iEntry = 0; iEntry < nEntries; iEntry++) {
6d50f529 328
0ee00e25 329 fTrackletTree->GetEvent(iEntry);
330
6d50f529 331 for (itrk = 0; itrk < tracklets->GetEntriesFast(); itrk++) {
0ee00e25 332
f162af62 333 fTrk = (AliTRDmcmTracklet *) tracklets->UncheckedAt(itrk);
6d50f529 334 idet = fTrk->GetDetector();
0ee00e25 335 iStack = idet / (AliTRDgeometry::Nplan());
6d50f529 336
0ee00e25 337 if (iStackPrev != iStack) {
338 if (iStackPrev == -1) {
339 iStackPrev = iStack;
6d50f529 340 }
341 else {
342 MakeTracks(idet - AliTRDgeometry::Nplan());
0ee00e25 343 ResetTracklets();
344 iStackPrev = iStack;
345 }
346 }
347
348 Tracklets()->Add(fTrk);
349
6d50f529 350 if ((iEntry == (nEntries-1)) &&
351 (itrk == (tracklets->GetEntriesFast() - 1))) {
0ee00e25 352 idet++;
353 MakeTracks(idet-AliTRDgeometry::Nplan());
354 ResetTracklets();
355 }
356
357 }
358
359 }
360
361 loader->UnloadTracks();
362
363 return kTRUE;
364
365}
366
367//_____________________________________________________________________________
e3b2b5e5 368Bool_t AliTRDtrigger::MakeTracklets(Bool_t makeTracks)
0ee00e25 369{
3fcb9908 370 //
371 // Create tracklets from digits
372 //
0ee00e25 373
6d50f529 374 Int_t chamBeg = 0;
375 Int_t chamEnd = AliTRDgeometry::Ncham();
376 Int_t planBeg = 0;
377 Int_t planEnd = AliTRDgeometry::Nplan();
378 Int_t sectBeg = 0;
379 Int_t sectEnd = AliTRDgeometry::Nsect();
0ee00e25 380
3fcb9908 381 fTrkTest = new AliTRDmcmTracklet(0,0,0);
f162af62 382 fMCM = new AliTRDmcm(0);
6d50f529 383
384 Int_t time;
385 Int_t col;
386 Int_t row;
387 Int_t col1;
388 Int_t col2;
389 Int_t idet = -1;
390 Int_t iStack = -1;
391 Int_t iStackPrev = -1;
0ee00e25 392 Float_t amp;
6d50f529 393
0ee00e25 394 for (Int_t isect = sectBeg; isect < sectEnd; isect++) {
395
396 for (Int_t icham = chamBeg; icham < chamEnd; icham++) {
397
6d50f529 398 // Number of ROBs in the chamber
399 if(icham == 2) {
0ee00e25 400 fNROB = 6;
6d50f529 401 }
402 else {
0ee00e25 403 fNROB = 8;
404 }
405
406 for (Int_t iplan = planBeg; iplan < planEnd; iplan++) {
407
3fcb9908 408 idet = fGeo->GetDetector(iplan,icham,isect);
0ee00e25 409 ResetTracklets();
e3b2b5e5 410
411 if (makeTracks) {
412 iStack = idet / (AliTRDgeometry::Nplan());
413 if (iStackPrev != iStack) {
414 if (iStackPrev == -1) {
415 iStackPrev = iStack;
6d50f529 416 }
417 else {
e3b2b5e5 418 MakeTracks(idet-AliTRDgeometry::Nplan());
419 ResetTracklets();
420 iStackPrev = iStack;
421 }
0ee00e25 422 }
423 }
e3b2b5e5 424
f162af62 425 Int_t nRowMax = fGeo->GetRowMax(iplan,icham,isect);
426 Int_t nColMax = fGeo->GetColMax(iplan);
427 Int_t nTimeTotal = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
0ee00e25 428
429 // Get the digits
430 fDigits = fDigitsManager->GetDigits(idet);
698b2e52 431 if (!fDigits) return kFALSE;
559d92d4 432 // This is to take care of switched off super modules
433 if (fDigits->GetNtime() == 0) {
434 continue;
435 }
0ee00e25 436 fDigits->Expand();
437 fTrack0 = fDigitsManager->GetDictionary(idet,0);
698b2e52 438 if (!fTrack0) return kFALSE;
0ee00e25 439 fTrack0->Expand();
440 fTrack1 = fDigitsManager->GetDictionary(idet,1);
698b2e52 441 if (!fTrack1) return kFALSE;
0ee00e25 442 fTrack1->Expand();
443 fTrack2 = fDigitsManager->GetDictionary(idet,2);
698b2e52 444 if (!fTrack2) return kFALSE;
0ee00e25 445 fTrack2->Expand();
446
0ee00e25 447 for (Int_t iRob = 0; iRob < fNROB; iRob++) {
448
449 for (Int_t iMcm = 0; iMcm < kNMCM; iMcm++) {
450
451 fMCM->Reset();
0ee00e25 452 fMCM->SetRobId(iRob);
453 fMCM->SetChaId(idet);
454
455 SetMCMcoordinates(iMcm);
456
457 row = fMCM->GetRow();
458
6d50f529 459 if ((row < 0) || (row >= nRowMax)) {
460 AliError("MCM row number out of range.");
9e79a757 461 continue;
0ee00e25 462 }
463
464 fMCM->GetColRange(col1,col2);
465
466 for (time = 0; time < nTimeTotal; time++) {
467 for (col = col1; col < col2; col++) {
6d50f529 468 if ((col >= 0) && (col < nColMax)) {
0ee00e25 469 amp = TMath::Abs(fDigits->GetDataUnchecked(row,col,time));
6d50f529 470 }
471 else {
0ee00e25 472 amp = 0.0;
473 }
474 fMCM->SetADC(col-col1,time,amp);
0ee00e25 475 }
476 }
477
f162af62 478 if (AliTRDtrigParam::Instance()->GetTailCancelation()) {
479 fMCM->Filter(AliTRDtrigParam::Instance()->GetNexponential()
480 ,AliTRDtrigParam::Instance()->GetFilterType());
0ee00e25 481 }
482
483 if (fMCM->Run()) {
484
485 for (Int_t iSeed = 0; iSeed < kMaxTrackletsPerMCM; iSeed++) {
486
6d50f529 487 if (fMCM->GetSeedCol()[iSeed] < 0) {
488 continue;
489 }
0ee00e25 490
f162af62 491 AliDebug(2,Form("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
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
f162af62 588 Int_t nTimeTotal = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
3fcb9908 589
77566f2a 590 // Calibration fill 2D
082a2283 591 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
77566f2a 592 if (!calibra) {
593 AliInfo("Could not get Calibra instance\n");
594 }
595
3fcb9908 596 fTrkTest->Reset();
597
598 fTrkTest->SetDetector(det);
599 fTrkTest->SetRow(row);
600 fTrkTest->SetN(n);
601
602 Int_t iCol, iCol1, iCol2, track[3];
603 iCol = fMCM->GetSeedCol()[seed]; // 0....20 (MCM)
604 fMCM->GetColRange(iCol1,iCol2); // range in the pad plane
605
606 Float_t amp[3];
607 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
608
609 amp[0] = fMCM->GetADC(iCol-1,iTime);
610 amp[1] = fMCM->GetADC(iCol ,iTime);
611 amp[2] = fMCM->GetADC(iCol+1,iTime);
612
613 // extract track contribution only from the central pad
614 track[0] = fTrack0->GetDataUnchecked(row,iCol+iCol1,iTime);
615 track[1] = fTrack1->GetDataUnchecked(row,iCol+iCol1,iTime);
616 track[2] = fTrack2->GetDataUnchecked(row,iCol+iCol1,iTime);
617
6d50f529 618 if (fMCM->IsCluster(iCol,iTime)) {
3fcb9908 619
620 fTrkTest->AddCluster(iCol+iCol1,iTime,amp,track);
621
6d50f529 622 }
623 else if ((iCol+1+1) < kMcmCol) {
3fcb9908 624
625 amp[0] = fMCM->GetADC(iCol-1+1,iTime);
626 amp[1] = fMCM->GetADC(iCol +1,iTime);
627 amp[2] = fMCM->GetADC(iCol+1+1,iTime);
628
629 if (fMCM->IsCluster(iCol+1,iTime)) {
630
631 // extract track contribution only from the central pad
632 track[0] = fTrack0->GetDataUnchecked(row,iCol+1+iCol1,iTime);
633 track[1] = fTrack1->GetDataUnchecked(row,iCol+1+iCol1,iTime);
634 track[2] = fTrack2->GetDataUnchecked(row,iCol+1+iCol1,iTime);
635
636 fTrkTest->AddCluster(iCol+1+iCol1,iTime,amp,track);
637
638 }
639
6d50f529 640 }
0ee00e25 641
3fcb9908 642 }
643
644 fTrkTest->CookLabel(0.8);
645 /*
646 if (fTrkTest->GetLabel() >= fNPrimary) {
647 Info("AddTracklet","Only primaries are stored!");
648 return;
649 }
650 */
651 // LTU Pt cut
3fcb9908 652 fTrkTest->MakeTrackletGraph(fGeo,fField);
77566f2a 653
654 // TRD Online calibration
8ec526a4 655 if (calibra->GetMcmTracking()) {
77566f2a 656 calibra->UpdateHistogramcm(fTrkTest);
657 }
658
3fcb9908 659 fTrkTest->MakeClusAmpGraph();
77566f2a 660
f162af62 661 if (TMath::Abs(fTrkTest->GetPt()) < AliTRDtrigParam::Instance()->GetLtuPtCut()) {
3fcb9908 662 return kFALSE;
0ee00e25 663 }
664
3fcb9908 665 return kTRUE;
666
667}
668
669//_____________________________________________________________________________
670void AliTRDtrigger::AddTracklet(Int_t det, Int_t row, Int_t seed, Int_t n)
671{
672 //
673 // Add a found tracklet
674 //
675
f162af62 676 Int_t nTimeTotal = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
0ee00e25 677
678 fTrk = new AliTRDmcmTracklet(det,row,n);
679
680 Int_t iCol, iCol1, iCol2, track[3];
681 iCol = fMCM->GetSeedCol()[seed]; // 0....20 (MCM)
682 fMCM->GetColRange(iCol1,iCol2); // range in the pad plane
683
e3b2b5e5 684 Float_t amp[3];
0ee00e25 685 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
686
e3b2b5e5 687 amp[0] = fMCM->GetADC(iCol-1,iTime);
688 amp[1] = fMCM->GetADC(iCol ,iTime);
689 amp[2] = fMCM->GetADC(iCol+1,iTime);
0ee00e25 690
691 // extract track contribution only from the central pad
692 track[0] = fTrack0->GetDataUnchecked(row,iCol+iCol1,iTime);
693 track[1] = fTrack1->GetDataUnchecked(row,iCol+iCol1,iTime);
694 track[2] = fTrack2->GetDataUnchecked(row,iCol+iCol1,iTime);
695
6d50f529 696 if (fMCM->IsCluster(iCol,iTime)) {
0ee00e25 697
e3b2b5e5 698 fTrk->AddCluster(iCol+iCol1,iTime,amp,track);
0ee00e25 699
6d50f529 700 }
701 else if ((iCol+1+1) < kMcmCol) {
0ee00e25 702
e3b2b5e5 703 amp[0] = fMCM->GetADC(iCol-1+1,iTime);
704 amp[1] = fMCM->GetADC(iCol +1,iTime);
705 amp[2] = fMCM->GetADC(iCol+1+1,iTime);
0ee00e25 706
707 if (fMCM->IsCluster(iCol+1,iTime)) {
708
709 // extract track contribution only from the central pad
710 track[0] = fTrack0->GetDataUnchecked(row,iCol+1+iCol1,iTime);
711 track[1] = fTrack1->GetDataUnchecked(row,iCol+1+iCol1,iTime);
712 track[2] = fTrack2->GetDataUnchecked(row,iCol+1+iCol1,iTime);
713
e3b2b5e5 714 fTrk->AddCluster(iCol+1+iCol1,iTime,amp,track);
0ee00e25 715
716 }
717
0ee00e25 718 }
719
720 }
721
722 fTrk->CookLabel(0.8);
723 /*
724 if (fTrk->GetLabel() >= fNPrimary) {
725 Info("AddTracklet","Only primaries are stored!");
726 return;
727 }
728 */
729 // LTU Pt cut
3fcb9908 730 fTrk->MakeTrackletGraph(fGeo,fField);
0ee00e25 731 fTrk->MakeClusAmpGraph();
f162af62 732 if (TMath::Abs(fTrk->GetPt()) < AliTRDtrigParam::Instance()->GetLtuPtCut()) {
e3b2b5e5 733 return;
734 }
0ee00e25 735
736 Tracklets()->Add(fTrk);
737
738}
739
740//_____________________________________________________________________________
741Bool_t AliTRDtrigger::WriteTracklets(Int_t det)
742{
743 //
744 // Fills TRDmcmTracklet branch in the tree with the Tracklets
745 // found in detector = det. For det=-1 writes the tree.
746 //
747
748 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
6d50f529 749 AliError(Form("Unexpected detector index %d.",det));
0ee00e25 750 return kFALSE;
751 }
752
753 TBranch *branch = fTrackletTree->GetBranch("TRDmcmTracklet");
754 if (!branch) {
755 TObjArray *ioArray = 0;
756 branch = fTrackletTree->Branch("TRDmcmTracklet","TObjArray",&ioArray,32000,0);
757 }
758
759 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
760
761 Int_t nTracklets = Tracklets()->GetEntriesFast();
762 TObjArray *detTracklets = new TObjArray(400);
763
764 for (Int_t i = 0; i < nTracklets; i++) {
6d50f529 765
0ee00e25 766 AliTRDmcmTracklet *trk = (AliTRDmcmTracklet *) Tracklets()->UncheckedAt(i);
767
768 if (det == trk->GetDetector()) {
769 detTracklets->AddLast(trk);
770 }
6d50f529 771
0ee00e25 772 }
773
774 branch->SetAddress(&detTracklets);
775 fTrackletTree->Fill();
776
777 delete detTracklets;
778
779 return kTRUE;
780
781 }
782
783 if (det == -1) {
784
6d50f529 785 AliInfo(Form("Writing the Tracklet tree %s for event %d."
786 ,fTrackletTree->GetName(),fRunLoader->GetEventNumber()));
0ee00e25 787
788 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
789 loader->WriteTracks("OVERWRITE");
790
791 return kTRUE;
792
793 }
794
795 return kFALSE;
796
797}
798
799//_____________________________________________________________________________
800void AliTRDtrigger::MakeTracks(Int_t det)
801{
802 //
803 // Create GTU tracks per module (stack of 6 chambers)
804 //
805
806 fModule->Reset();
807
0ee00e25 808 Int_t nRowMax, iplan, icham, isect, row;
809
0ee00e25 810 if ((det < 0) || (det >= AliTRDgeometry::Ndet())) {
6d50f529 811 AliError(Form("Unexpected detector index %d.",det));
0ee00e25 812 return;
813 }
814
815 Int_t nTracklets = Tracklets()->GetEntriesFast();
816
817 AliTRDmcmTracklet *trk;
818 for (Int_t i = 0; i < nTracklets; i++) {
819
820 trk = (AliTRDmcmTracklet *) Tracklets()->UncheckedAt(i);
821
3fcb9908 822 iplan = fGeo->GetPlane(trk->GetDetector());
823 icham = fGeo->GetChamber(trk->GetDetector());
824 isect = fGeo->GetSector(trk->GetDetector());
0ee00e25 825
f162af62 826 nRowMax = fGeo->GetRowMax(iplan,icham,isect);
0ee00e25 827 row = trk->GetRow();
828
829 fModule->AddTracklet(trk->GetDetector(),
830 row,
831 trk->GetRowz(),
832 trk->GetSlope(),
833 trk->GetOffset(),
834 trk->GetTime0(),
835 trk->GetNclusters(),
836 trk->GetLabel(),
837 trk->GetdQdl());
838
839 }
840
841 fModule->SortTracklets();
842 fModule->RemoveMultipleTracklets();
3fcb9908 843 fModule->SortZ((Int_t)fGeo->GetChamber(det));
0ee00e25 844 fModule->FindTracks();
845 fModule->SortTracks();
846 fModule->RemoveMultipleTracks();
847
848 Int_t nModTracks = fModule->GetNtracks();
849 AliTRDgtuTrack *gtutrk;
850 for (Int_t i = 0; i < nModTracks; i++) {
851 gtutrk = (AliTRDgtuTrack*)fModule->GetTrack(i);
f162af62 852 if (TMath::Abs(gtutrk->GetPt()) < AliTRDtrigParam::Instance()->GetGtuPtCut()) continue;
0ee00e25 853 gtutrk->CookLabel();
854 gtutrk->MakePID();
855 AddTrack(gtutrk,det);
856 }
857
858}
859
6d50f529 860//_____________________________________________________________________________
861void AliTRDtrigger::AddTrack(const AliTRDgtuTrack *t, Int_t det)
862{
863 //
864 // Add a track to the list
865 //
866
867 AliTRDgtuTrack *track = new(fTracks->operator[](fTracks->GetEntriesFast()))
868 AliTRDgtuTrack(*t);
869 track->SetDetector(det);
870
871}
872
873//_____________________________________________________________________________
874TObjArray* AliTRDtrigger::Tracklets()
875{
876 //
877 // Returns list of tracklets
878 //
879
880 if (!fTracklets) {
881 fTracklets = new TObjArray(400);
882 }
883 return fTracklets;
0ee00e25 884
6d50f529 885}
886
887//_____________________________________________________________________________
888void AliTRDtrigger::ResetTracklets()
889{
890 //
891 // Resets the list of tracklets
892 //
893
894 if (fTracklets) {
895 fTracklets->Delete();
896 }
897
898}
899
900//_____________________________________________________________________________
901Int_t AliTRDtrigger::GetNumberOfTracks() const
902{
903 //
904 // Returns number of tracks
905 //
906
907 return fTracks->GetEntriesFast();
908
909}
910
911//_____________________________________________________________________________
912AliTRDgtuTrack* AliTRDtrigger::GetTrack(Int_t i) const
913{
914 //
915 // Returns a given track from the list
916 //
917
918 return (AliTRDgtuTrack *) fTracks->UncheckedAt(i);
919
920}