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