Interfaced with new mapping for copy cards & cleaning (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
fd19a819 21//* Debugged by Ph. Crochet & Ch. Finck
22//* Interfaced with new mapping Ch. Finck
f4678817 23//*
516d3280 24
257091b1 25#include "AliLoader.h"
26#include "AliLog.h"
27#include "AliMUON.h"
28#include "AliMUONCalibrationData.h"
29#include "AliMUONVDigit.h"
30#include "AliMUONVDigitStore.h"
31#include "AliMUONGlobalTrigger.h"
516d3280 32#include "AliMUONGlobalTriggerBoard.h"
33#include "AliMUONLocalTrigger.h"
257091b1 34#include "AliMUONLocalTriggerBoard.h"
47dc4ee7 35#include "AliMUONRegionalTrigger.h"
257091b1 36#include "AliMUONRegionalTriggerBoard.h"
37#include "AliMUONTriggerCrate.h"
38#include "AliMUONTriggerCrateStore.h"
39#include "AliMUONTriggerElectronics.h"
40#include "AliMUONVTriggerStore.h"
4c0f0f5d 41#include "AliMUONVCalibParam.h"
257091b1 42#include "AliMpCathodType.h"
43#include "AliMpDEManager.h"
666ada1e 44#include "AliMpSegmentation.h"
f4678817 45#include "AliMpVSegmentation.h"
866c3232 46#include "AliMpCathodType.h"
fd19a819 47#include "AliMpTriggerCrate.h"
48#include "AliMpLocalBoard.h"
49#include "AliMpDDLStore.h"
50#include "AliMpExMap.h"
51#include "AliMpIntPair.h"
f4678817 52
53#include "AliLog.h"
54#include "AliLoader.h"
55#include "AliRun.h"
257091b1 56#include <TBits.h>
57#include <TSystem.h>
f4678817 58
516d3280 59
6014107b 60/// \cond CLASSIMP
63ed9c6b 61ClassImp(AliMUONTriggerElectronics)
6014107b 62/// \endcond
63ed9c6b 63
516d3280 64//___________________________________________
257091b1 65AliMUONTriggerElectronics::AliMUONTriggerElectronics(AliMUONCalibrationData* calibData)
66: TObject(),
f1e8d46c 67 fCrates(new AliMUONTriggerCrateStore),
257091b1 68 fGlobalTriggerBoard(new AliMUONGlobalTriggerBoard)
516d3280 69{
257091b1 70 /// CONSTRUCTOR
6014107b 71///
fd19a819 72
73 for (Int_t i = 0; i < 2; ++i) {
74 fCopyXInput[i] = new TList();
75 fCopyXInput[i]->SetOwner();
76 fCopyYInput[i] = new TList();
77 fCopyYInput[i]->SetOwner();
78 }
79
80 SetCopyInput();
f1e8d46c 81 Factory(calibData);
82 LoadMasks(calibData);
516d3280 83}
84
85//___________________________________________
86AliMUONTriggerElectronics::~AliMUONTriggerElectronics()
87{
6014107b 88/// DESTRUCTOR
89///
516d3280 90 delete fGlobalTriggerBoard;
91 delete fCrates;
fd19a819 92 for (Int_t i = 0; i < 2; ++i) {
93 delete fCopyXInput[i];
94 delete fCopyYInput[i];
95 }
96
97}
98//___________________________________________
99void AliMUONTriggerElectronics::SetCopyInput()
100{
101/// set list of copy input
102
103 for (Int_t iDDL = 0; iDDL < 2; ++iDDL) {
104
105 for(Int_t iReg = 0; iReg < 8; ++iReg){ //reg loop
106
107 AliMpTriggerCrate* crateMapping = AliMpDDLStore::Instance()->GetTriggerCrate(iDDL, iReg);
108
109 for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) {
110
111 Int_t localBoardFromId = crateMapping->GetLocalBoardId(iLocal);
112 if (!localBoardFromId) continue; //empty slot, should not happen
113
114 AliMpLocalBoard* localBoardFrom = AliMpDDLStore::Instance()->GetLocalBoard(localBoardFromId);
115 Int_t localBoardToId;
116 if ((localBoardToId = localBoardFrom->GetInputXto())) {
117 AliMpLocalBoard* localBoardTo = AliMpDDLStore::Instance()->GetLocalBoard(localBoardToId);
118 TString crateFrom = localBoardFrom->GetCrate();
119 Int_t slotFrom = localBoardFrom->GetSlot();
120 TString crateTo = localBoardTo->GetCrate();
121 Int_t slotTo = localBoardTo->GetSlot();
122
123 fCopyXInput[0]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateFrom), slotFrom));
124 fCopyXInput[1]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateTo), slotTo));
125 AliDebug(3, Form("copy xInputs from local %s_%d to %s_%d\n", crateFrom.Data(), slotFrom,
126 crateTo.Data(), slotTo));
127 }
128
129 if ((localBoardToId = localBoardFrom->GetInputYto())) {
130 AliMpLocalBoard* localBoardTo = AliMpDDLStore::Instance()->GetLocalBoard(localBoardToId);
131 TString crateFrom = localBoardFrom->GetCrate();
132 Int_t slotFrom = localBoardFrom->GetSlot();
133 TString crateTo = localBoardTo->GetCrate();
134 Int_t slotTo = localBoardTo->GetSlot();
135
136 fCopyYInput[0]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateFrom), slotFrom));
137 fCopyYInput[1]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateTo), slotTo));
138 AliDebug(3, Form("copy yInputs from local %s_%d to %s_%d\n", crateFrom.Data(), slotFrom,
139 crateTo.Data(), slotTo));
140
141 }
142
143 }
144 }
145 }
516d3280 146}
147
148//___________________________________________
4c0f0f5d 149void AliMUONTriggerElectronics::Factory(AliMUONCalibrationData* calibData)
516d3280 150{
6014107b 151 /// BUILD ALL ELECTRONICS
152 ///
e93b11d0 153
154// get coinc44 from AliMUON (added 12/09/06)
155 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
156 Int_t coinc44 = pMUON->GetTriggerCoinc44();
157 if (coinc44 != 0 && coinc44 != 1) {
158 AliFatal("Coinc 44 should be equal to 0 or 1");
159 return;
160 }
161
fd19a819 162 fCrates->ReadFromFile();
f1e8d46c 163
164 if ( !calibData ) return;
165
166 AliMUONTriggerLut* lut = calibData->TriggerLut();
167
168 if (!lut) return;
169
170 AliMUONLocalTriggerBoard* localBoard;
171
172 fCrates->FirstLocalBoard();
173
174 while ( (localBoard=fCrates->NextLocalBoard()) )
175 {
176 localBoard->SetLUT(lut);
e93b11d0 177 localBoard->SetCoinc44(coinc44);
f1e8d46c 178 }
8af755f4 179}
516d3280 180
8af755f4 181//___________________________________________
257091b1 182void AliMUONTriggerElectronics::Feed(const AliMUONVDigitStore& digitStore)
8af755f4 183{
257091b1 184 /// FILL INPUTS
185 ///
186
187 TIter next(digitStore.CreateTriggerIterator());
188 AliMUONVDigit* mdig;
189
190 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) )
191 {
192 // CHECKME ! The TrackCharge is not ok with new digitizerV3 !
193 // for (Int_t ichg=0; ichg<10; ichg++) schg += mdig->TrackCharge(ichg);
194 Int_t ichamber = AliMpDEManager::GetChamberId(mdig->DetElemId());
195 Int_t schg = (Int_t)(mdig->Charge() + 0.5);
196
197 // APPLY CONDITION ON SOFT BACKGROUND
198 Int_t tchg = schg - (Int_t(schg/10))*10;
199
200 if (schg<=10 || tchg>0)
43368512 201 {
257091b1 202 Int_t detElemId = mdig->DetElemId();
203 Int_t cathode = mdig->Cathode();
fd19a819 204
205 const AliMpVSegmentation* seg =
206 AliMpSegmentation::Instance()
207 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
208
257091b1 209 Int_t ix = mdig->PadX(), iy = mdig->PadY();
210
211 AliDebug(3,Form("cathode %d ix %d iy %d ",cathode,ix,iy));
fd19a819 212
257091b1 213 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
214
215 for (Int_t i=0; i<pad.GetNofLocations(); i++)
43368512 216 {
257091b1 217 AliMpIntPair location = pad.GetLocation(i);
218
219 Int_t nboard = location.GetFirst();
220
221 Int_t ibitxy = location.GetSecond();
222
223 AliMUONLocalTriggerBoard *b = fCrates->LocalBoard(nboard);
224
225 if (b)
226 {
227 if (cathode && b->GetSwitch(6)) ibitxy += 8;
228
229 b->SetbitM(ibitxy,cathode,ichamber-10);
230 }
231 else
232 {
233 AliError(Form("Could not get local board number %d",b->GetNumber()));
234 }
43368512 235 }
257091b1 236 }
237 }
fd19a819 238
43368512 239 // Particular case of the columns with 22 local boards (2R(L) 3R(L))
fd19a819 240 // fill copy input from mapping instead of hardcoded valued (Ch.F)
43368512 241 AliMUONTriggerCrate *crate = 0x0; TObjArray *bs = 0x0;
fd19a819 242
243 for (Int_t i = 0; i < fCopyXInput[0]->GetEntries(); ++i)
43368512 244 {
fd19a819 245 AliMpIntPair* pair = (AliMpIntPair*)fCopyXInput[0]->At(i);
246 TString crateFrom = AliMpExMap::GetString(pair->GetFirst());
247 Int_t slotFrom = pair->GetSecond();
248
249 pair = (AliMpIntPair*)fCopyXInput[1]->At(i);
250 TString crateTo = AliMpExMap::GetString(pair->GetFirst());
251 Int_t slotTo = pair->GetSecond();
252
253 AliDebug(3, Form("copy xInputs from local %s_%d to %s_%d\n", crateFrom.Data(), slotFrom,
254 crateTo.Data(), slotTo));
255
256 UShort_t cX[2];
257 crate = fCrates->Crate(crateFrom);
257091b1 258 bs = crate->Boards();
fd19a819 259 AliMUONLocalTriggerBoard *fromxb = (AliMUONLocalTriggerBoard*)bs->At(slotFrom);
260 crate = fCrates->Crate(crateTo);
257091b1 261 bs = crate->Boards();
fd19a819 262 AliMUONLocalTriggerBoard *desxb = (AliMUONLocalTriggerBoard*)bs->At(slotTo);
263 fromxb->GetX34(cX); desxb->SetX34(cX);
264
265
266 }
267
268 for (Int_t i = 0; i < fCopyYInput[0]->GetEntries(); ++i)
269 {
270 AliMpIntPair* pair = (AliMpIntPair*)fCopyYInput[0]->At(i);
271 TString crateFrom = AliMpExMap::GetString(pair->GetFirst());
272 Int_t slotFrom = pair->GetSecond();
273
274 pair = (AliMpIntPair*)fCopyYInput[1]->At(i);
275 TString crateTo = AliMpExMap::GetString(pair->GetFirst());
276 Int_t slotTo = pair->GetSecond();
277
278 AliDebug(3, Form("copy yInputs from local %s_%d to %s_%d\n", crateFrom.Data(), slotFrom,
279 crateTo.Data(), slotTo));
280
257091b1 281 UShort_t cY[4];
fd19a819 282 crate = fCrates->Crate(crateFrom);
283 bs = crate->Boards();
284 AliMUONLocalTriggerBoard *fromyb = (AliMUONLocalTriggerBoard*)bs->At(slotFrom);
285 crate = fCrates->Crate(crateTo);
286 bs = crate->Boards();
287 AliMUONLocalTriggerBoard *desyb = (AliMUONLocalTriggerBoard*)bs->At(slotTo);
288 fromyb->GetY(cY); desyb->SetY(cY);
43368512 289 }
257091b1 290
43368512 291 // FILL UP/DOWN OF CURRENT BOARD (DONE VIA J3 BUS IN REAL LIFE)
292 AliMUONTriggerCrate* cr;
257091b1 293
43368512 294 fCrates->FirstCrate();
257091b1 295
43368512 296 while ( ( cr = fCrates->NextCrate() ) )
297 {
257091b1 298 TObjArray *boards = cr->Boards();
299
300 for (Int_t j = 1; j < boards->GetEntries()-1; j++)
301 {
302 TObject *o = boards->At(j);
8af755f4 303
257091b1 304 if (!o) break;
8af755f4 305
257091b1 306 AliMUONLocalTriggerBoard *currboard = (AliMUONLocalTriggerBoard*)o;
8af755f4 307
257091b1 308 AliMUONLocalTriggerBoard *neighbour = (AliMUONLocalTriggerBoard*)boards->At(j+1);
1fe8c19b 309
257091b1 310 UShort_t cXY[2][4];
8af755f4 311
257091b1 312 if (j==1) {neighbour->GetXY(cXY); currboard->SetXYU(cXY);}
8af755f4 313
257091b1 314 // LAST BOARD IN THE CRATE HAS NO UP EXCEPT FOR CRATES 2 & 3
315 if (j < boards->GetEntries()-2)
316 {
43368512 317 AliMUONLocalTriggerBoard *nextboard = (AliMUONLocalTriggerBoard*)boards->At(j+2);
8af755f4 318
43368512 319 currboard->GetXY(cXY); neighbour->SetXYD(cXY);
320 nextboard->GetXY(cXY); neighbour->SetXYU(cXY);
8af755f4 321
1fe8c19b 322 if (j==boards->GetEntries()-3) {neighbour->GetXY(cXY); nextboard->SetXYD(cXY);}
43368512 323 }
257091b1 324 }
43368512 325 }
fd19a819 326
257091b1 327}
1fe8c19b 328
516d3280 329
330//___________________________________________
331void AliMUONTriggerElectronics::Feed(UShort_t pattern[2][4])
332{
6014107b 333 /// FILL INPUTS
334 ///
f1e8d46c 335 AliMUONTriggerCrate* cr;
336
337 fCrates->FirstCrate();
338
339 while ( ( cr = fCrates->NextCrate() ) )
340 {
341 TObjArray *boards = cr->Boards();
342
43368512 343 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 344 {
345 TObject *o = boards->At(j);
346
347 if (!o) break;
348
349 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
350
351 board->SetXY(pattern);
352 }
516d3280 353 }
354}
355
356//___________________________________________
357void AliMUONTriggerElectronics::DumpOS()
358{
6014107b 359/// DUMP IN THE OLD WAY
360///
43368512 361 for (Int_t i= 0; i < 234;i++)
516d3280 362 {
f1e8d46c 363 AliMUONLocalTriggerBoard *board = fCrates->LocalBoard(i);
516d3280 364
43368512 365 if (board) board->Scan("ALL");
516d3280 366 }
367}
368
369//___________________________________________
370void AliMUONTriggerElectronics::Scan(Option_t *option)
371{
6014107b 372 /// SCAN
373 ///
516d3280 374
f1e8d46c 375 AliMUONTriggerCrate* cr;
376
377 fCrates->FirstCrate();
378
379 while ( ( cr = fCrates->NextCrate() ) )
43368512 380 {
f1e8d46c 381 TObjArray *boards = cr->Boards();
382
43368512 383 for (Int_t j = 0; j < boards->GetEntries(); j++)
f1e8d46c 384 {
385 TObject *o = boards->At(j);
386
387 TString op = option;
388
389 Bool_t cdtion = kFALSE;
390
391 if (op.Contains("LOCAL")) cdtion = o->IsA() == AliMUONLocalTriggerBoard::Class();
392 if (op.Contains("REGIONAL")) cdtion = o->IsA() == AliMUONRegionalTriggerBoard::Class();
393 if (op.Contains("GLOBAL")) cdtion = o->IsA() == AliMUONGlobalTriggerBoard::Class();
394
395 if (!o || !cdtion) continue;
396
397 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
398
399 board->Scan();
400 }
401 }
516d3280 402}
403
404//___________________________________________
405void AliMUONTriggerElectronics::Reset()
406{
6014107b 407 /// RESET
408 ///
f1e8d46c 409
410 AliMUONTriggerCrate* cr;
411
412 fCrates->FirstCrate();
413
414 while ( ( cr = fCrates->NextCrate() ) )
516d3280 415 {
516d3280 416 TObjArray *boards = cr->Boards();
417
418 for (Int_t j=0; j<boards->GetEntries(); j++)
419 {
420 AliMUONTriggerBoard *b = (AliMUONTriggerBoard*)boards->At(j);
421
422 if (b) b->Reset();
423 }
424 }
425}
426
4c0f0f5d 427//_______________________________________________________________________
428void AliMUONTriggerElectronics::LoadMasks(AliMUONCalibrationData* calibData)
429{
71a2d3aa 430 /// LOAD MASKS FROM CDB
4c0f0f5d 431
432
433 // SET MASKS
f1e8d46c 434
435 AliMUONTriggerCrate* cr;
436
437 fCrates->FirstCrate();
438
439 Int_t irb(0);
440
441 while ( ( cr = fCrates->NextCrate() ) )
43368512 442 {
4c0f0f5d 443 TObjArray *boards = cr->Boards();
444
445 AliMUONRegionalTriggerBoard *regb =
446 (AliMUONRegionalTriggerBoard*)boards->At(0);
447
f1e8d46c 448 AliMUONVCalibParam* regionalBoardMasks = calibData->RegionalTriggerBoardMasks(irb);
4c0f0f5d 449
450 for ( Int_t i = 0; i < regionalBoardMasks->Size(); ++i )
451 {
452 UShort_t rmask = static_cast<UShort_t>(regionalBoardMasks->ValueAsInt(i) & 0x3F);
453 regb->Mask(i,rmask);
454 }
455
43368512 456 for (Int_t j = 1; j < boards->GetEntries(); j++)
4c0f0f5d 457 {
458 AliMUONLocalTriggerBoard *b = (AliMUONLocalTriggerBoard*)boards->At(j);
459
460 Int_t cardNumber = b->GetNumber();
461
462 if (cardNumber) // interface board are not interested
463 {
464 AliMUONVCalibParam* localBoardMasks = calibData->LocalTriggerBoardMasks(cardNumber);
465 for ( Int_t i = 0; i < localBoardMasks->Size(); ++i )
466 {
467 UShort_t lmask = static_cast<UShort_t>(localBoardMasks->ValueAsInt(i) & 0xFFFF);
468 b->Mask(i,lmask);
469 }
470 }
471 }
f1e8d46c 472 ++irb;
4c0f0f5d 473 }
474
475 AliMUONVCalibParam* globalBoardMasks = calibData->GlobalTriggerBoardMasks();
476 for ( Int_t i = 0; i < globalBoardMasks->Size(); ++i )
477 {
478 UShort_t gmask = static_cast<UShort_t>(globalBoardMasks->ValueAsInt(i) & 0xFFF);
479 fGlobalTriggerBoard->Mask(i,gmask);
480 }
481}
482
483
516d3280 484//___________________________________________
485void AliMUONTriggerElectronics::LocalResponse()
486{
6014107b 487/// \todo add comment
516d3280 488
f1e8d46c 489 AliMUONTriggerCrate* cr;
490
491 fCrates->FirstCrate();
492
493 while ( ( cr = fCrates->NextCrate() ) )
43368512 494 {
f1e8d46c 495
496 TObjArray *boards = cr->Boards();
497
498 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
499
500 UShort_t thisl[16]; for (Int_t j=0; j<16; j++) thisl[j] = 0;
29e3f51e 501
502 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 503 {
43368512 504 TObject *o = boards->At(j);
f1e8d46c 505
43368512 506 if (!o) break;
f1e8d46c 507
43368512 508 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
f1e8d46c 509
29e3f51e 510 if (board) // check if empty slot
43368512 511 {
512 board->Response();
516d3280 513
29e3f51e 514 UShort_t response = board->GetResponse();
f1e8d46c 515
29e3f51e 516 // CRATE CONTAINING INTERFACE BOARD
517 if (board->GetNumber() == 0) // copy boards
518 {
519 if ( response != 0 )
520 AliWarning(Form("Interface board %s in slot %d of crate %s has a non zero response",
43368512 521 board->GetName(),j,cr->GetName()));
29e3f51e 522 AliDebug(1, Form("local slot %d, number %d in crate %s\n", j, board->GetNumber(), cr->GetName()));
523
524 }
f1e8d46c 525
29e3f51e 526 thisl[j-1] = response;
43368512 527 }
516d3280 528 }
f1e8d46c 529
530 regb->SetLocalResponse(thisl);
531 }
516d3280 532}
533
534//___________________________________________
535void AliMUONTriggerElectronics::RegionalResponse()
536{
f1e8d46c 537 /// Compute the response for all regional cards.
538 AliMUONTriggerCrate* cr;
539
540 fCrates->FirstCrate();
541
542 while ( ( cr = fCrates->NextCrate() ) )
43368512 543 {
516d3280 544 TObjArray *boards = cr->Boards();
545
546 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
547
548 if (regb)
549 {
550 regb->Response();
516d3280 551 }
552 }
553}
554
555//___________________________________________
556void AliMUONTriggerElectronics::GlobalResponse()
557{
f1e8d46c 558 /// Compute the global response
516d3280 559
f1e8d46c 560 UShort_t regional[16];
561
562 AliMUONTriggerCrate* cr;
563
564 fCrates->FirstCrate();
565 Int_t irb(0);
566
567 if ( !fCrates->NumberOfCrates() >= 16 )
568 {
569 AliFatal(Form("Something is wrong : too many crates %d",
570 fCrates->NumberOfCrates()));
571 }
572
573 while ( ( cr = fCrates->NextCrate() ) )
43368512 574 {
f1e8d46c 575 AliMUONTriggerBoard* rb =
576 static_cast<AliMUONTriggerBoard*>(cr->Boards()->At(0));
577 regional[irb] = rb->GetResponse();
578 ++irb;
579 }
580
581 fGlobalTriggerBoard->SetRegionalResponse(regional);
582 fGlobalTriggerBoard->Response();
516d3280 583}
584
516d3280 585//_______________________________________________________________________
257091b1 586void AliMUONTriggerElectronics::Digits2Trigger(const AliMUONVDigitStore& digitStore,
587 AliMUONVTriggerStore& triggerStore)
516d3280 588{
f1e8d46c 589 /// Main method to go from digits to trigger decision
257091b1 590 AliMUONRegionalTrigger pRegTrig;
591
592 triggerStore.Clear();
593
f1e8d46c 594 // RUN THE FULL BEE CHAIN
257091b1 595 Feed(digitStore);
596 LocalResponse();
597 RegionalResponse();
598 GlobalResponse();
599 // DumpOS();
8af755f4 600
f1e8d46c 601 AliMUONTriggerCrate* cr;
257091b1 602 AliMUONLocalTrigger localTrigger;
603
6a6a56b4 604 // stored in right order
605 // do not used iterator order
257091b1 606
6a6a56b4 607 for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
f1e8d46c 608 {
6a6a56b4 609 for (Int_t iReg = 0; iReg < 8; iReg++) // 8 crates/regional boards for each side.
610 {
611 cr = fCrates->Crate(iSide, iReg);
612 TObjArray *boards = cr->Boards();
257091b1 613
6a6a56b4 614 UInt_t regInpLpt = 0;
615 UInt_t regInpHpt = 0;
257091b1 616
6a6a56b4 617 AliMUONRegionalTriggerBoard *regBoard = (AliMUONRegionalTriggerBoard*)boards->At(0);
257091b1 618
6a6a56b4 619 for (Int_t j = 1; j < boards->GetEntries(); j++)
620 {
257091b1 621 TObject *o = boards->At(j);
622
623 if (!o) break;
624
625 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
626
627 if (board)
628 {
629 // L0 TRIGGER
630 // pcrochet 181206: MOOD needs ALL boards
631 // if (board->Triggered())
632 // {
f1e8d46c 633
257091b1 634 Int_t icirc = board->GetNumber();
635 if (icirc != 0) { // pcrochet 181206: MOOD needs ALL boards
636
637 localTrigger.SetLoCircuit(icirc);
638 localTrigger.SetLoStripX(board->GetStripX11());
639 localTrigger.SetLoDev(board->GetDev());
640 localTrigger.SetLoSdev(board->GetSdev());
641 localTrigger.SetLoTrigY(board->GetTrigY());
642 localTrigger.SetLoStripY(board->GetStripY11());
643
644 // SAVE LUT OUTPUT
645 UShort_t response = board->GetResponse();
646 localTrigger.SetLoHpt((response & 12) >> 2);
647 localTrigger.SetLoLpt(response & 3);
648
649 // calculates regional inputs from local for the moment
650 UInt_t hPt = (response >> 2) & 0x3;
651 UInt_t lPt = response & 0x3;
652
653 regInpHpt |= hPt << (30 - (j-1)*2);
654 regInpLpt |= lPt << (30 - (j-1)*2);
655
656 TBits rrr;
657 rrr.Set(6,&response);
658
659 // SAVE BIT PATTERN
660 localTrigger.SetX1Pattern(board->GetXY(0,0));
661 localTrigger.SetX2Pattern(board->GetXY(0,1));
662 localTrigger.SetX3Pattern(board->GetXY(0,2));
663 localTrigger.SetX4Pattern(board->GetXY(0,3));
664
665 localTrigger.SetY1Pattern(board->GetXY(1,0));
666 localTrigger.SetY2Pattern(board->GetXY(1,1));
667 localTrigger.SetY3Pattern(board->GetXY(1,2));
668 localTrigger.SetY4Pattern(board->GetXY(1,3));
669
670 // ADD A NEW LOCAL TRIGGER
671 triggerStore.Add(localTrigger);
672
673 }
674 }
675 }
676 pRegTrig.SetId(iReg + 8*iSide);
677 pRegTrig.SetLocalOutput(regInpLpt, 0);
678 pRegTrig.SetLocalOutput(regInpHpt, 1);
679 pRegTrig.SetOutput(regBoard->GetResponse());
680
681 triggerStore.Add(pRegTrig);
516d3280 682 }
6a6a56b4 683 }
f1e8d46c 684
1908473e 685 // GLOBAL TRIGGER INFORMATION
f1e8d46c 686 UShort_t global = fGlobalTriggerBoard->GetResponse();
f1e8d46c 687
257091b1 688 AliMUONGlobalTrigger globalTrigger;
689
690 globalTrigger.SetFromGlobalResponse(global);
f1e8d46c 691 // ADD A LOCAL TRIGGER IN THE LIST
257091b1 692 triggerStore.SetGlobal(globalTrigger);
693
f1e8d46c 694 // NOW RESET ELECTRONICS
695 Reset();
516d3280 696}