Remove dependence to RAW module in MUONraw library for online purpose (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerElectronics.cxx
CommitLineData
516d3280 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/* $Id$ */
17
18//*-- Author: Rachid Guernane (LPCCFd)
f4678817 19//* Manager class for muon trigger electronics
20//* Client of trigger board classes
21//*
22//*
516d3280 23
24#include "AliMUONTriggerElectronics.h"
25#include "AliMUONTriggerCrate.h"
f1e8d46c 26#include "AliMUONTriggerCrateStore.h"
516d3280 27#include "AliMUONConstants.h"
28#include "AliMUONLocalTriggerBoard.h"
29#include "AliMUONRegionalTriggerBoard.h"
30#include "AliMUONGlobalTriggerBoard.h"
31#include "AliMUONLocalTrigger.h"
47dc4ee7 32#include "AliMUONRegionalTrigger.h"
516d3280 33#include "AliMUONGlobalTrigger.h"
8af755f4 34#include "AliMUON.h"
516d3280 35#include "AliMUONData.h"
36#include "AliMUONDigit.h"
8af755f4 37#include "AliMUONSegmentation.h"
4c0f0f5d 38#include "AliMUONCalibrationData.h"
39#include "AliMUONVCalibParam.h"
516d3280 40
f4678817 41#include "AliMpVSegmentation.h"
42
43#include "AliLog.h"
44#include "AliLoader.h"
45#include "AliRun.h"
46
47//#include "Riostream.h"
48#include "TBits.h"
516d3280 49#include "TSystem.h"
50
63ed9c6b 51ClassImp(AliMUONTriggerElectronics)
52
516d3280 53//___________________________________________
4c0f0f5d 54AliMUONTriggerElectronics::AliMUONTriggerElectronics(AliMUONData *Data, AliMUONCalibrationData* calibData)
516d3280 55: TTask("AliMUONTriggerElectronics",
56 "From trigger digits to Local and Global Trigger objects"),
43368512 57 fSourceFileName(),
f1e8d46c 58 fCrates(new AliMUONTriggerCrateStore),
516d3280 59 fGlobalTriggerBoard(new AliMUONGlobalTriggerBoard),
516d3280 60 fMUONData(Data)
61{
f4678817 62//* CONSTRUCTOR
63//*
516d3280 64 if (!fMUONData)
65 {
66 AliFatal("NO MUON TRIGGER DATA");
67 }
68
f1e8d46c 69 SetDataSource();
70 Factory(calibData);
71 LoadMasks(calibData);
516d3280 72}
73
74//___________________________________________
75AliMUONTriggerElectronics::~AliMUONTriggerElectronics()
76{
f4678817 77//* DESTRUCTOR
78//*
516d3280 79 delete fGlobalTriggerBoard;
80 delete fCrates;
81}
82
83//___________________________________________
4c0f0f5d 84void AliMUONTriggerElectronics::Factory(AliMUONCalibrationData* calibData)
516d3280 85{
f1e8d46c 86 //* BUILD ALL ELECTRONICS
87 //*
e93b11d0 88
89// get coinc44 from AliMUON (added 12/09/06)
90 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
91 Int_t coinc44 = pMUON->GetTriggerCoinc44();
92 if (coinc44 != 0 && coinc44 != 1) {
93 AliFatal("Coinc 44 should be equal to 0 or 1");
94 return;
95 }
96
f1e8d46c 97 fCrates->ReadFromFile(gSystem->ExpandPathName(fSourceFileName.Data()));
98
99 if ( !calibData ) return;
100
101 AliMUONTriggerLut* lut = calibData->TriggerLut();
102
103 if (!lut) return;
104
105 AliMUONLocalTriggerBoard* localBoard;
106
107 fCrates->FirstLocalBoard();
108
109 while ( (localBoard=fCrates->NextLocalBoard()) )
110 {
111 localBoard->SetLUT(lut);
e93b11d0 112 localBoard->SetCoinc44(coinc44);
f1e8d46c 113 }
8af755f4 114}
516d3280 115
8af755f4 116//___________________________________________
117void AliMUONTriggerElectronics::FeedM()
118{
f4678817 119//* FILL INPUTS
120//*
43368512 121 for (Int_t ichamber=10; ichamber<14; ichamber++)
122 {
f4678817 123 TClonesArray *muonDigits = fMUONData->Digits(ichamber);
124 Int_t ndigits = muonDigits->GetEntriesFast();
8af755f4 125
8af755f4 126 for (Int_t digit=0; digit<ndigits; digit++)
43368512 127 {
128 AliMUONDigit *mdig = static_cast<AliMUONDigit*>(muonDigits->UncheckedAt(digit));
8af755f4 129
43368512 130 // CHECKME ! The TrackCharge is not ok with new digitizerV3 !
131 // for (Int_t ichg=0; ichg<10; ichg++) schg += mdig->TrackCharge(ichg);
132 // assert(schg==mdig->Signal());
133 Int_t schg = mdig->Signal();
516d3280 134
43368512 135 // APPLY CONDITION ON SOFT BACKGROUND
136 Int_t tchg = schg - (Int_t(schg/10))*10;
516d3280 137
43368512 138 if (schg<=10 || tchg>0)
139 {
140 // mdig->Print();
516d3280 141
43368512 142 Int_t digitindex = digit;
143 Int_t detElemId = mdig->DetElemId();
144 Int_t cathode = mdig->Cathode();
8af755f4 145
43368512 146 const AliMpVSegmentation *seg =
147 ((AliMUON*)gAlice->GetDetector("MUON"))->GetSegmentation()->GetMpSegmentation(detElemId,cathode);
8af755f4 148
43368512 149 Int_t ix = mdig->PadX(), iy = mdig->PadY();
8af755f4 150
43368512 151 AliDebug(3,Form("cathode %d ix %d iy %d ",cathode,ix,iy));
8af755f4 152
43368512 153 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
8af755f4 154
43368512 155 for (Int_t i=0; i<pad.GetNofLocations(); i++)
156 {
157 AliMpIntPair location = pad.GetLocation(i);
8af755f4 158
43368512 159 Int_t nboard = location.GetFirst();
8af755f4 160
43368512 161 Int_t ibitxy = location.GetSecond();
8af755f4 162
43368512 163 AliMUONLocalTriggerBoard *b = fCrates->LocalBoard(nboard);
8af755f4 164
43368512 165 if (b)
166 {
167 if (cathode && b->GetSwitch(6)) ibitxy += 8;
8af755f4 168
43368512 169 b->SetbitM(ibitxy,cathode,ichamber-10);
8af755f4 170
43368512 171 DigitFiredCircuit(b->GetI(), cathode, ichamber, digitindex);
172 }
173 else
174 {
175 AliError(Form("Could not get local board number %d",b->GetNumber()));
176 }
177 }
178 }
179 }
180 }
8af755f4 181
43368512 182 // Particular case of the columns with 22 local boards (2R(L) 3R(L))
183 AliMUONTriggerCrate *crate = 0x0; TObjArray *bs = 0x0;
8af755f4 184
43368512 185 char *scratess[4] = { "2R", "2L", "3L", "3R"};
186 char *scratesd[4] = {"2-3R", "2-3L", "2-3L", "2-3R"};
187 Int_t slotf[4] = { 2, 2, 10, 10};
188 Int_t slotd[4] = { 1, 1, 9, 9};
8af755f4 189
43368512 190 for (Int_t i = 0; i < 4; i++)
191 {
f1e8d46c 192 crate = fCrates->Crate(scratess[i]);
8af755f4 193 bs = crate->Boards();
194 AliMUONLocalTriggerBoard *desybb = (AliMUONLocalTriggerBoard*)bs->At(14);
195 AliMUONLocalTriggerBoard *fromcb = (AliMUONLocalTriggerBoard*)bs->At(15);
196 AliMUONLocalTriggerBoard *desxbb = (AliMUONLocalTriggerBoard*)bs->At(16);
197
f1e8d46c 198 crate = fCrates->Crate(scratesd[i]);
8af755f4 199 bs = crate->Boards();
200 AliMUONLocalTriggerBoard *frombb = (AliMUONLocalTriggerBoard*)bs->At(slotf[i]);
201 AliMUONLocalTriggerBoard *desycb = (AliMUONLocalTriggerBoard*)bs->At(slotd[i]);
202
203 UShort_t cX[2];
204
43368512 205 // COPY X3-4 FROM BOARD 2 OF CRATE 2-3 TO BOARD 16 OF CRATE 2
206 // COPY X3-4 FROM BOARD 10 OF CRATE 2-3 TO BOARD 16 OF CRATE 3
8af755f4 207 frombb->GetX34(cX); desxbb->SetX34(cX);
208
43368512 209 // COPY X3-4 FROM BOARD 15 OF CRATE 2 TO BOARD 1 OF CRATE 2-3
210 // COPY X3-4 FROM BOARD 15 OF CRATE 3 TO BOARD 9 OF CRATE 2-3
8af755f4 211 fromcb->GetX34(cX); desycb->SetX34(cX);
212
213 UShort_t cY[4];
214
215 desybb->GetY(cY); frombb->SetY(cY);
216
217 frombb->GetY(cY); desxbb->SetY(cY);
218 fromcb->GetY(cY); desycb->SetY(cY);
43368512 219 }
8af755f4 220
43368512 221 // FILL UP/DOWN OF CURRENT BOARD (DONE VIA J3 BUS IN REAL LIFE)
222 AliMUONTriggerCrate* cr;
f1e8d46c 223
43368512 224 fCrates->FirstCrate();
f1e8d46c 225
43368512 226 while ( ( cr = fCrates->NextCrate() ) )
227 {
228 TObjArray *boards = cr->Boards();
8af755f4 229
43368512 230 for (Int_t j = 1; j < boards->GetEntries()-1; j++)
231 {
232 TObject *o = boards->At(j);
8af755f4 233
43368512 234 if (!o) break;
8af755f4 235
43368512 236 AliMUONLocalTriggerBoard *currboard = (AliMUONLocalTriggerBoard*)o;
8af755f4 237
43368512 238 AliMUONLocalTriggerBoard *neighbour = (AliMUONLocalTriggerBoard*)boards->At(j+1);
8af755f4 239
43368512 240 UShort_t cXY[2][4];
8af755f4 241
43368512 242 if (j==1) {neighbour->GetXY(cXY); currboard->SetXYU(cXY);}
8af755f4 243
43368512 244 // LAST BOARD IN THE CRATE HAS NO UP EXCEPT FOR CRATES 2 & 3
245 if (j < boards->GetEntries()-2)
246 {
247 AliMUONLocalTriggerBoard *nextboard = (AliMUONLocalTriggerBoard*)boards->At(j+2);
8af755f4 248
43368512 249 currboard->GetXY(cXY); neighbour->SetXYD(cXY);
250 nextboard->GetXY(cXY); neighbour->SetXYU(cXY);
8af755f4 251
43368512 252 if (j==boards->GetEntries()-3) {neighbour->GetXY(cXY); nextboard->SetXYD(cXY);}
253 }
254 }
255 }
516d3280 256}
516d3280 257
258//___________________________________________
259void AliMUONTriggerElectronics::Feed(UShort_t pattern[2][4])
260{
f1e8d46c 261 //* FILL INPUTS
262 //*
263 AliMUONTriggerCrate* cr;
264
265 fCrates->FirstCrate();
266
267 while ( ( cr = fCrates->NextCrate() ) )
268 {
269 TObjArray *boards = cr->Boards();
270
43368512 271 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 272 {
273 TObject *o = boards->At(j);
274
275 if (!o) break;
276
277 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
278
279 board->SetXY(pattern);
280 }
516d3280 281 }
282}
283
284//___________________________________________
285void AliMUONTriggerElectronics::DumpOS()
286{
f4678817 287//* DUMP IN THE OLD WAY
288//*
43368512 289 for (Int_t i= 0; i < 234;i++)
516d3280 290 {
f1e8d46c 291 AliMUONLocalTriggerBoard *board = fCrates->LocalBoard(i);
516d3280 292
43368512 293 if (board) board->Scan("ALL");
516d3280 294 }
295}
296
297//___________________________________________
298void AliMUONTriggerElectronics::Scan(Option_t *option)
299{
f1e8d46c 300 //* SCAN
301 //*
516d3280 302
f1e8d46c 303 AliMUONTriggerCrate* cr;
304
305 fCrates->FirstCrate();
306
307 while ( ( cr = fCrates->NextCrate() ) )
43368512 308 {
f1e8d46c 309 TObjArray *boards = cr->Boards();
310
43368512 311 for (Int_t j = 0; j < boards->GetEntries(); j++)
f1e8d46c 312 {
313 TObject *o = boards->At(j);
314
315 TString op = option;
316
317 Bool_t cdtion = kFALSE;
318
319 if (op.Contains("LOCAL")) cdtion = o->IsA() == AliMUONLocalTriggerBoard::Class();
320 if (op.Contains("REGIONAL")) cdtion = o->IsA() == AliMUONRegionalTriggerBoard::Class();
321 if (op.Contains("GLOBAL")) cdtion = o->IsA() == AliMUONGlobalTriggerBoard::Class();
322
323 if (!o || !cdtion) continue;
324
325 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
326
327 board->Scan();
328 }
329 }
516d3280 330}
331
332//___________________________________________
333void AliMUONTriggerElectronics::Reset()
334{
f1e8d46c 335 //* RESET
336 //*
337
338 AliMUONTriggerCrate* cr;
339
340 fCrates->FirstCrate();
341
342 while ( ( cr = fCrates->NextCrate() ) )
516d3280 343 {
516d3280 344 TObjArray *boards = cr->Boards();
345
346 for (Int_t j=0; j<boards->GetEntries(); j++)
347 {
348 AliMUONTriggerBoard *b = (AliMUONTriggerBoard*)boards->At(j);
349
350 if (b) b->Reset();
351 }
352 }
353}
354
4c0f0f5d 355//_______________________________________________________________________
356void AliMUONTriggerElectronics::LoadMasks(AliMUONCalibrationData* calibData)
357{
358 // LOAD MASKS FROM CDB
359
360
361 // SET MASKS
f1e8d46c 362
363 AliMUONTriggerCrate* cr;
364
365 fCrates->FirstCrate();
366
367 Int_t irb(0);
368
369 while ( ( cr = fCrates->NextCrate() ) )
43368512 370 {
4c0f0f5d 371 TObjArray *boards = cr->Boards();
372
373 AliMUONRegionalTriggerBoard *regb =
374 (AliMUONRegionalTriggerBoard*)boards->At(0);
375
f1e8d46c 376 AliMUONVCalibParam* regionalBoardMasks = calibData->RegionalTriggerBoardMasks(irb);
4c0f0f5d 377
378 for ( Int_t i = 0; i < regionalBoardMasks->Size(); ++i )
379 {
380 UShort_t rmask = static_cast<UShort_t>(regionalBoardMasks->ValueAsInt(i) & 0x3F);
381 regb->Mask(i,rmask);
382 }
383
43368512 384 for (Int_t j = 1; j < boards->GetEntries(); j++)
4c0f0f5d 385 {
386 AliMUONLocalTriggerBoard *b = (AliMUONLocalTriggerBoard*)boards->At(j);
387
388 Int_t cardNumber = b->GetNumber();
389
390 if (cardNumber) // interface board are not interested
391 {
392 AliMUONVCalibParam* localBoardMasks = calibData->LocalTriggerBoardMasks(cardNumber);
393 for ( Int_t i = 0; i < localBoardMasks->Size(); ++i )
394 {
395 UShort_t lmask = static_cast<UShort_t>(localBoardMasks->ValueAsInt(i) & 0xFFFF);
396 b->Mask(i,lmask);
397 }
398 }
399 }
f1e8d46c 400 ++irb;
4c0f0f5d 401 }
402
403 AliMUONVCalibParam* globalBoardMasks = calibData->GlobalTriggerBoardMasks();
404 for ( Int_t i = 0; i < globalBoardMasks->Size(); ++i )
405 {
406 UShort_t gmask = static_cast<UShort_t>(globalBoardMasks->ValueAsInt(i) & 0xFFF);
407 fGlobalTriggerBoard->Mask(i,gmask);
408 }
409}
410
411
516d3280 412//___________________________________________
413void AliMUONTriggerElectronics::LocalResponse()
414{
516d3280 415
f1e8d46c 416 AliMUONTriggerCrate* cr;
417
418 fCrates->FirstCrate();
419
420 while ( ( cr = fCrates->NextCrate() ) )
43368512 421 {
f1e8d46c 422
423 TObjArray *boards = cr->Boards();
424
425 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
426
427 UShort_t thisl[16]; for (Int_t j=0; j<16; j++) thisl[j] = 0;
29e3f51e 428
429 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 430 {
43368512 431 TObject *o = boards->At(j);
f1e8d46c 432
43368512 433 if (!o) break;
f1e8d46c 434
43368512 435 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
f1e8d46c 436
29e3f51e 437 if (board) // check if empty slot
43368512 438 {
439 board->Response();
516d3280 440
29e3f51e 441 UShort_t response = board->GetResponse();
f1e8d46c 442
29e3f51e 443 // CRATE CONTAINING INTERFACE BOARD
444 if (board->GetNumber() == 0) // copy boards
445 {
446 if ( response != 0 )
447 AliWarning(Form("Interface board %s in slot %d of crate %s has a non zero response",
43368512 448 board->GetName(),j,cr->GetName()));
29e3f51e 449 AliDebug(1, Form("local slot %d, number %d in crate %s\n", j, board->GetNumber(), cr->GetName()));
450
451 }
f1e8d46c 452
29e3f51e 453 thisl[j-1] = response;
43368512 454 }
516d3280 455 }
f1e8d46c 456
457 regb->SetLocalResponse(thisl);
458 }
516d3280 459}
460
461//___________________________________________
462void AliMUONTriggerElectronics::RegionalResponse()
463{
f1e8d46c 464 /// Compute the response for all regional cards.
465 AliMUONTriggerCrate* cr;
466
467 fCrates->FirstCrate();
468
469 while ( ( cr = fCrates->NextCrate() ) )
43368512 470 {
516d3280 471 TObjArray *boards = cr->Boards();
472
473 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
474
475 if (regb)
476 {
477 regb->Response();
516d3280 478 }
479 }
480}
481
482//___________________________________________
483void AliMUONTriggerElectronics::GlobalResponse()
484{
f1e8d46c 485 /// Compute the global response
516d3280 486
f1e8d46c 487 UShort_t regional[16];
488
489 AliMUONTriggerCrate* cr;
490
491 fCrates->FirstCrate();
492 Int_t irb(0);
493
494 if ( !fCrates->NumberOfCrates() >= 16 )
495 {
496 AliFatal(Form("Something is wrong : too many crates %d",
497 fCrates->NumberOfCrates()));
498 }
499
500 while ( ( cr = fCrates->NextCrate() ) )
43368512 501 {
f1e8d46c 502 AliMUONTriggerBoard* rb =
503 static_cast<AliMUONTriggerBoard*>(cr->Boards()->At(0));
504 regional[irb] = rb->GetResponse();
505 ++irb;
506 }
507
508 fGlobalTriggerBoard->SetRegionalResponse(regional);
509 fGlobalTriggerBoard->Response();
516d3280 510}
511
512//___________________________________________
513void AliMUONTriggerElectronics::BoardName(Int_t ix, Int_t iy, char *name)
514{
f4678817 515//* BOARD NAME FROM PAD INFO (OLD MAPPING)
516//*
516d3280 517 TString s = (ix>0) ? "R" : "L";
518
519 Int_t board = iy / 16, bid[4] = {12,34,56,78};
520
521 ix = abs(ix);
522
523 Int_t line = ix / 10, column = ix - 10 * line;
524
525// old scheme: line==1 is line==9
526 line -= 9; line = TMath::Abs(line); line++;
527
528 sprintf(name,"%sC%dL%dB%d", s.Data(), column, line, bid[board]);
529
530 AliDebug(3, Form("Strip ( %d , %d ) connected to board %s ", ix, iy, name));
531}
532
516d3280 533//___________________________________________
534void AliMUONTriggerElectronics::BuildName(Int_t icirc, char name[20])
535{
f4678817 536//* GET BOARD NAME FROM OLD NUMBERING
537//*
538 const Int_t kCircuitId[234] =
516d3280 539 {
540 111, 121, 131, 141, 151, 161, 171,
541 211, 212, 221, 222, 231, 232, 241, 242, 251, 252, 261, 262, 271,
542 311, 312, 321, 322, 331, 332, 341, 342, 351, 352, 361, 362, 371,
543 411, 412, 413, 421, 422, 423, 424, 431, 432, 433, 434, 441, 442, 451, 452, 461, 462, 471,
544 521, 522, 523, 524, 531, 532, 533, 534, 541, 542, 551, 552, 561, 562, 571,
545 611, 612, 613, 621, 622, 623, 624, 631, 632, 633, 634, 641, 642, 651, 652, 661, 662, 671,
546 711, 712, 721, 722, 731, 732, 741, 742, 751, 752, 761, 762, 771,
547 811, 812, 821, 822, 831, 832, 841, 842, 851, 852, 861, 862, 871,
548 911, 921, 931, 941, 951, 961, 971,
549 -111, -121, -131, -141, -151, -161, -171,
550 -211, -212, -221, -222, -231, -232, -241, -242, -251, -252, -261, -262, -271,
551 -311, -312, -321, -322, -331, -332, -341, -342, -351, -352, -361, -362, -371,
552 -411, -412, -413, -421, -422, -423, -424, -431, -432, -433, -434, -441, -442, -451, -452, -461, -462, -471,
553 -521, -522, -523, -524, -531, -532, -533, -534, -541, -542, -551, -552, -561, -562, -571,
554 -611, -612, -613, -621, -622, -623, -624, -631, -632, -633, -634, -641, -642, -651, -652, -661, -662, -671,
555 -711, -712, -721, -722, -731, -732, -741, -742, -751, -752, -761, -762, -771,
556 -811, -812, -821, -822, -831, -832, -841, -842, -851, -852, -861, -862, -871,
557 -911, -921, -931, -941, -951, -961, -971
558 };
559
560 Int_t b[4] = {12, 34, 56, 78};
561
f4678817 562 Int_t code = TMath::Abs(kCircuitId[icirc]);
516d3280 563
f4678817 564 Int_t lL = code / 100;
516d3280 565
f4678817 566 Int_t cC = ( code - 100 * lL ) / 10;
516d3280 567
f4678817 568 Int_t bB = code - 100 * lL - 10 * cC;
516d3280 569
f4678817 570 const char *side = (kCircuitId[icirc]>0) ? "R" : "L";
516d3280 571
f4678817 572// lL=1 AT TOP
573 lL -= 9; lL = abs(lL); lL++;
516d3280 574
f4678817 575 sprintf(name,"%sC%dL%dB%d",side,cC,lL,b[bB-1]);
516d3280 576}
577
578//_______________________________________________________________________
579void
580AliMUONTriggerElectronics::Exec(Option_t*)
581{
f4678817 582//*
583//*
516d3280 584 Digits2Trigger();
585}
586
587//_______________________________________________________________________
588void AliMUONTriggerElectronics::Trigger()
589{
f4678817 590//*
591//*
8af755f4 592 FeedM();
516d3280 593 LocalResponse();
594 RegionalResponse();
595 GlobalResponse();
596}
516d3280 597
516d3280 598//_______________________________________________________________________
599void AliMUONTriggerElectronics::Digits2Trigger()
600{
f1e8d46c 601 /// Main method to go from digits to trigger decision
516d3280 602
47dc4ee7 603 AliMUONRegionalTrigger *pRegTrig = new AliMUONRegionalTrigger();
604
f1e8d46c 605 ClearDigitNumbers();
606
607 fMUONData->ResetTrigger();
608
609 // RUN THE FULL BEE CHAIN
610 Trigger();
611 // DumpOS();
8af755f4 612
f1e8d46c 613 AliMUONTriggerCrate* cr;
614
615 fCrates->FirstCrate();
616
617 while ( ( cr = fCrates->NextCrate() ) )
618 {
619 TObjArray *boards = cr->Boards();
47dc4ee7 620
621 UInt_t regInpLpt = 0;
622 UInt_t regInpHpt = 0;
623 UShort_t localMask = 0x0;
624
625 AliMUONRegionalTriggerBoard *regBoard = (AliMUONRegionalTriggerBoard*)boards->At(0);
626
627 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 628 {
629 TObject *o = boards->At(j);
630
631 if (!o) break;
632
633 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
634
635 if (board)
636 {
637 // L0 TRIGGER
638 if (board->Triggered())
639 {
640 Int_t localtr[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
641
642 Int_t icirc = board->GetNumber();
643
644 localtr[0] = icirc;
645 localtr[1] = board->GetStripX11();
646 localtr[2] = board->GetDev();
647 localtr[3] = board->GetStripY11();
648
649 // SAVE LUT OUTPUT
650 UShort_t response = board->GetResponse();
651 localtr[4] = (response & 12) >> 2;
652 localtr[5] = (response & 48) >> 4;
653 localtr[6] = (response & 3);
47dc4ee7 654
655 // calculates regional inputs from local for the moment
656 UInt_t hPt = (response >> 4) & 0x3;
657 UInt_t lPt = (response >> 2) & 0x3;
658
659 regInpHpt |= hPt << (30 - (j-1)*2);
660 regInpLpt |= lPt << (30 - (j-1)*2);
661 localMask |= (0x1 << (j-1)); // local mask
662
663
f1e8d46c 664 TBits rrr;
665 rrr.Set(6,&response);
666
667 // SAVE BIT PATTERN
668 localtr[7] = board->GetXY(0,0);
669 localtr[8] = board->GetXY(0,1);
670 localtr[9] = board->GetXY(0,2);
671 localtr[10] = board->GetXY(0,3);
672
673 localtr[11] = board->GetXY(1,0);
674 localtr[12] = board->GetXY(1,1);
675 localtr[13] = board->GetXY(1,2);
676 localtr[14] = board->GetXY(1,3);
677
678 // ADD A NEW LOCAL TRIGGER
679 AliMUONLocalTrigger *pLocTrig = new AliMUONLocalTrigger(localtr, fDigitNumbers[icirc]);
680
681 fMUONData->AddLocalTrigger(*pLocTrig);
47dc4ee7 682 delete pLocTrig;
f1e8d46c 683 }
516d3280 684 }
f1e8d46c 685 }
47dc4ee7 686 pRegTrig->SetLocalOutput(regInpLpt, 0);
687 pRegTrig->SetLocalOutput(regInpHpt, 1);
688 pRegTrig->SetLocalMask(localMask);
689 pRegTrig->SetOutput((regBoard->GetResponse() >> 4) & 0xF); // to be uniformized (oct06 ?)
690
691 fMUONData->AddRegionalTrigger(*pRegTrig);
692
f1e8d46c 693 }
47dc4ee7 694 delete pRegTrig;
f1e8d46c 695
696 // GLOBAL TRIGGER INFORMATION: [0] -> LOW PT
697 // [1] -> HIGH PT
698 // [2] -> ALL PT
699 Int_t globalSinglePlus[3], globalSingleMinus[3], globalSingleUndef[3];
700 Int_t globalPairUnlike[3], globalPairLike[3];
701
702 UShort_t global = fGlobalTriggerBoard->GetResponse();
703
704 globalPairUnlike[0] = (global & 16) >> 4;
705 globalPairUnlike[1] = (global & 256) >> 8;
706 globalPairUnlike[2] = (global & 1);
707
708 globalPairLike[0] = (global & 32) >> 5;
709 globalPairLike[1] = (global & 512) >> 9;
710 globalPairLike[2] = (global & 2) >> 1;
711
712 globalSinglePlus[0] = ((global & 192) >> 6) == 2;
713 globalSinglePlus[1] = ((global & 3072) >> 10) == 2;
714 globalSinglePlus[2] = ((global & 12) >> 2) == 2;
715
716 globalSingleMinus[0] = ((global & 192) >> 6) == 1;
717 globalSingleMinus[1] = ((global & 3072) >> 10) == 1;
718 globalSingleMinus[2] = ((global & 12) >> 2) == 1;
719
720 globalSingleUndef[0] = ((global & 192) >> 6) == 3;
721 globalSingleUndef[1] = ((global & 3072) >> 10) == 3;
722 globalSingleUndef[2] = ((global & 12) >> 2) == 3;
723
724 AliMUONGlobalTrigger *pGloTrig = new AliMUONGlobalTrigger(globalSinglePlus, globalSingleMinus,
725 globalSingleUndef, globalPairUnlike,
726 globalPairLike);
727
728 // ADD A LOCAL TRIGGER IN THE LIST
729 fMUONData->AddGlobalTrigger(*pGloTrig);
47dc4ee7 730 delete pGloTrig;
731
f1e8d46c 732 // NOW RESET ELECTRONICS
733 Reset();
516d3280 734}
735
736//_______________________________________________________________________
737void AliMUONTriggerElectronics::ClearDigitNumbers()
738{
739// RESET fDigitNumbers
740 for (Int_t i=0; i<AliMUONConstants::NTriggerCircuit(); i++) fDigitNumbers[i].Set(0);
741}
742
743//_______________________________________________________________________
744void AliMUONTriggerElectronics::DigitFiredCircuit(Int_t circuit, Int_t cathode,
745 Int_t chamber, Int_t digit)
746{
747// REGISTERS THAT THE SPECIFIED DIGIT FIRED THE SPECIFIED CIRCUIT
748// THIS DIGIT GETS ADDED TO AN ARRAY WHICH WILL BE COPIED TO
749// AliMUONLocalTrigger WHEN SUCH AN OBJECT IS CREATED FOR EACH CIRCUIT
750 Int_t digitnumber = AliMUONLocalTrigger::EncodeDigitNumber(chamber, cathode, digit);
751 Int_t last = fDigitNumbers[circuit].GetSize();
752 fDigitNumbers[circuit].Set(last + 1);
753 fDigitNumbers[circuit][last] = digitnumber;
754}
755