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