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