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