]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerElectronics.cxx
added a new analysis task
[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 "AliMUONLocalTriggerBoard.h"
28#include "AliMUONRegionalTriggerBoard.h"
29#include "AliMUONGlobalTriggerBoard.h"
30#include "AliMUONLocalTrigger.h"
47dc4ee7 31#include "AliMUONRegionalTrigger.h"
516d3280 32#include "AliMUONGlobalTrigger.h"
8af755f4 33#include "AliMUON.h"
516d3280 34#include "AliMUONData.h"
35#include "AliMUONDigit.h"
8af755f4 36#include "AliMUONSegmentation.h"
4c0f0f5d 37#include "AliMUONCalibrationData.h"
38#include "AliMUONVCalibParam.h"
516d3280 39
666ada1e 40#include "AliMpSegmentation.h"
f4678817 41#include "AliMpVSegmentation.h"
866c3232 42#include "AliMpCathodType.h"
f4678817 43
07f2614d 44#include "AliMUONTriggerGUIboard.h"
45
f4678817 46#include "AliLog.h"
47#include "AliLoader.h"
48#include "AliRun.h"
49
50//#include "Riostream.h"
51#include "TBits.h"
516d3280 52#include "TSystem.h"
53
6014107b 54/// \cond CLASSIMP
63ed9c6b 55ClassImp(AliMUONTriggerElectronics)
6014107b 56/// \endcond
63ed9c6b 57
516d3280 58//___________________________________________
4c0f0f5d 59AliMUONTriggerElectronics::AliMUONTriggerElectronics(AliMUONData *Data, AliMUONCalibrationData* calibData)
516d3280 60: TTask("AliMUONTriggerElectronics",
61 "From trigger digits to Local and Global Trigger objects"),
43368512 62 fSourceFileName(),
f1e8d46c 63 fCrates(new AliMUONTriggerCrateStore),
516d3280 64 fGlobalTriggerBoard(new AliMUONGlobalTriggerBoard),
1908473e 65 fMUONData(Data),
66 fLocalTrigger(new AliMUONLocalTrigger()),
67 fGlobalTrigger(new AliMUONGlobalTrigger())
68
516d3280 69{
6014107b 70/// CONSTRUCTOR
71///
516d3280 72 if (!fMUONData)
73 {
64860867 74 AliWarning("NO MUON TRIGGER DATA");
516d3280 75 }
76
f1e8d46c 77 SetDataSource();
78 Factory(calibData);
79 LoadMasks(calibData);
516d3280 80}
81
82//___________________________________________
83AliMUONTriggerElectronics::~AliMUONTriggerElectronics()
84{
6014107b 85/// DESTRUCTOR
86///
516d3280 87 delete fGlobalTriggerBoard;
88 delete fCrates;
1908473e 89 delete fLocalTrigger;
90 delete fGlobalTrigger;
91
516d3280 92}
93
94//___________________________________________
4c0f0f5d 95void AliMUONTriggerElectronics::Factory(AliMUONCalibrationData* calibData)
516d3280 96{
6014107b 97 /// BUILD ALL ELECTRONICS
98 ///
e93b11d0 99
100// get coinc44 from AliMUON (added 12/09/06)
101 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
102 Int_t coinc44 = pMUON->GetTriggerCoinc44();
103 if (coinc44 != 0 && coinc44 != 1) {
104 AliFatal("Coinc 44 should be equal to 0 or 1");
105 return;
106 }
107
f1e8d46c 108 fCrates->ReadFromFile(gSystem->ExpandPathName(fSourceFileName.Data()));
109
110 if ( !calibData ) return;
111
112 AliMUONTriggerLut* lut = calibData->TriggerLut();
113
114 if (!lut) return;
115
116 AliMUONLocalTriggerBoard* localBoard;
117
118 fCrates->FirstLocalBoard();
119
120 while ( (localBoard=fCrates->NextLocalBoard()) )
121 {
122 localBoard->SetLUT(lut);
e93b11d0 123 localBoard->SetCoinc44(coinc44);
f1e8d46c 124 }
8af755f4 125}
516d3280 126
8af755f4 127//___________________________________________
128void AliMUONTriggerElectronics::FeedM()
129{
6014107b 130/// FILL INPUTS
131///
43368512 132 for (Int_t ichamber=10; ichamber<14; ichamber++)
133 {
f4678817 134 TClonesArray *muonDigits = fMUONData->Digits(ichamber);
135 Int_t ndigits = muonDigits->GetEntriesFast();
8af755f4 136
8af755f4 137 for (Int_t digit=0; digit<ndigits; digit++)
43368512 138 {
139 AliMUONDigit *mdig = static_cast<AliMUONDigit*>(muonDigits->UncheckedAt(digit));
8af755f4 140
43368512 141 // CHECKME ! The TrackCharge is not ok with new digitizerV3 !
142 // for (Int_t ichg=0; ichg<10; ichg++) schg += mdig->TrackCharge(ichg);
8d4fefab 143 Int_t schg = (Int_t)(mdig->Signal() + 0.5);
516d3280 144
43368512 145 // APPLY CONDITION ON SOFT BACKGROUND
146 Int_t tchg = schg - (Int_t(schg/10))*10;
516d3280 147
43368512 148 if (schg<=10 || tchg>0)
149 {
150 // mdig->Print();
516d3280 151
43368512 152 Int_t detElemId = mdig->DetElemId();
153 Int_t cathode = mdig->Cathode();
8af755f4 154
43368512 155 const AliMpVSegmentation *seg =
866c3232 156 AliMpSegmentation::Instance()
157 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
8af755f4 158
43368512 159 Int_t ix = mdig->PadX(), iy = mdig->PadY();
8af755f4 160
43368512 161 AliDebug(3,Form("cathode %d ix %d iy %d ",cathode,ix,iy));
8af755f4 162
43368512 163 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
8af755f4 164
43368512 165 for (Int_t i=0; i<pad.GetNofLocations(); i++)
166 {
167 AliMpIntPair location = pad.GetLocation(i);
8af755f4 168
43368512 169 Int_t nboard = location.GetFirst();
8af755f4 170
43368512 171 Int_t ibitxy = location.GetSecond();
8af755f4 172
43368512 173 AliMUONLocalTriggerBoard *b = fCrates->LocalBoard(nboard);
8af755f4 174
43368512 175 if (b)
176 {
177 if (cathode && b->GetSwitch(6)) ibitxy += 8;
8af755f4 178
43368512 179 b->SetbitM(ibitxy,cathode,ichamber-10);
8af755f4 180
43368512 181 }
182 else
183 {
184 AliError(Form("Could not get local board number %d",b->GetNumber()));
185 }
186 }
187 }
188 }
189 }
8af755f4 190
43368512 191 // Particular case of the columns with 22 local boards (2R(L) 3R(L))
192 AliMUONTriggerCrate *crate = 0x0; TObjArray *bs = 0x0;
8af755f4 193
43368512 194 char *scratess[4] = { "2R", "2L", "3L", "3R"};
195 char *scratesd[4] = {"2-3R", "2-3L", "2-3L", "2-3R"};
196 Int_t slotf[4] = { 2, 2, 10, 10};
197 Int_t slotd[4] = { 1, 1, 9, 9};
8af755f4 198
43368512 199 for (Int_t i = 0; i < 4; i++)
200 {
f1e8d46c 201 crate = fCrates->Crate(scratess[i]);
8af755f4 202 bs = crate->Boards();
203 AliMUONLocalTriggerBoard *desybb = (AliMUONLocalTriggerBoard*)bs->At(14);
204 AliMUONLocalTriggerBoard *fromcb = (AliMUONLocalTriggerBoard*)bs->At(15);
205 AliMUONLocalTriggerBoard *desxbb = (AliMUONLocalTriggerBoard*)bs->At(16);
206
f1e8d46c 207 crate = fCrates->Crate(scratesd[i]);
8af755f4 208 bs = crate->Boards();
209 AliMUONLocalTriggerBoard *frombb = (AliMUONLocalTriggerBoard*)bs->At(slotf[i]);
210 AliMUONLocalTriggerBoard *desycb = (AliMUONLocalTriggerBoard*)bs->At(slotd[i]);
211
212 UShort_t cX[2];
213
43368512 214 // COPY X3-4 FROM BOARD 2 OF CRATE 2-3 TO BOARD 16 OF CRATE 2
215 // COPY X3-4 FROM BOARD 10 OF CRATE 2-3 TO BOARD 16 OF CRATE 3
8af755f4 216 frombb->GetX34(cX); desxbb->SetX34(cX);
217
43368512 218 // COPY X3-4 FROM BOARD 15 OF CRATE 2 TO BOARD 1 OF CRATE 2-3
219 // COPY X3-4 FROM BOARD 15 OF CRATE 3 TO BOARD 9 OF CRATE 2-3
8af755f4 220 fromcb->GetX34(cX); desycb->SetX34(cX);
221
222 UShort_t cY[4];
223
224 desybb->GetY(cY); frombb->SetY(cY);
225
226 frombb->GetY(cY); desxbb->SetY(cY);
227 fromcb->GetY(cY); desycb->SetY(cY);
43368512 228 }
8af755f4 229
43368512 230 // FILL UP/DOWN OF CURRENT BOARD (DONE VIA J3 BUS IN REAL LIFE)
231 AliMUONTriggerCrate* cr;
f1e8d46c 232
43368512 233 fCrates->FirstCrate();
f1e8d46c 234
43368512 235 while ( ( cr = fCrates->NextCrate() ) )
236 {
237 TObjArray *boards = cr->Boards();
8af755f4 238
43368512 239 for (Int_t j = 1; j < boards->GetEntries()-1; j++)
240 {
241 TObject *o = boards->At(j);
8af755f4 242
43368512 243 if (!o) break;
8af755f4 244
43368512 245 AliMUONLocalTriggerBoard *currboard = (AliMUONLocalTriggerBoard*)o;
8af755f4 246
43368512 247 AliMUONLocalTriggerBoard *neighbour = (AliMUONLocalTriggerBoard*)boards->At(j+1);
07f2614d 248
249/*
250 cout << j << " "
251 << boards->GetEntries()-2 << " "
252 << boards->GetEntries()-3 << " "
253 << cr->GetName() << " "
254 << currboard->GetName() << " "
255 << neighbour->GetName() << " "
256 << currboard->GetNumber() << " "
257 << currboard->GetSwitch(7) << currboard->GetSwitch(8)
258 << currboard->GetSwitch(9) << "\n";;
259*/
260
43368512 261 UShort_t cXY[2][4];
8af755f4 262
43368512 263 if (j==1) {neighbour->GetXY(cXY); currboard->SetXYU(cXY);}
8af755f4 264
43368512 265 // LAST BOARD IN THE CRATE HAS NO UP EXCEPT FOR CRATES 2 & 3
266 if (j < boards->GetEntries()-2)
267 {
07f2614d 268 cout << " here000 " << j << " "
269 << boards->GetEntries()-2 << " "
270 << boards->GetEntries()-3 << " "
271 << cr->GetName() << " "
272 << currboard->GetName() << " "
273 << neighbour->GetName() << " "
274 << currboard->GetNumber() << " "
275 << currboard->GetSwitch(7) << currboard->GetSwitch(8)
276 << currboard->GetSwitch(9) << "\n";;
277
43368512 278 AliMUONLocalTriggerBoard *nextboard = (AliMUONLocalTriggerBoard*)boards->At(j+2);
8af755f4 279
43368512 280 currboard->GetXY(cXY); neighbour->SetXYD(cXY);
281 nextboard->GetXY(cXY); neighbour->SetXYU(cXY);
8af755f4 282
07f2614d 283 if (j==boards->GetEntries()-3) {
284 cout << " here111 " << j << " "
285 << boards->GetEntries()-2 << " "
286 << boards->GetEntries()-3 << " "
287 << cr->GetName() << " "
288 << currboard->GetName() << " "
289 << neighbour->GetName() << " "
290 << currboard->GetNumber() << " "
291 << currboard->GetSwitch(7) << currboard->GetSwitch(8)
292 << currboard->GetSwitch(9) << "\n";;
293 neighbour->GetXY(cXY); nextboard->SetXYD(cXY);
294 }
43368512 295 }
296 }
297 }
516d3280 298}
516d3280 299
300//___________________________________________
301void AliMUONTriggerElectronics::Feed(UShort_t pattern[2][4])
302{
6014107b 303 /// FILL INPUTS
304 ///
f1e8d46c 305 AliMUONTriggerCrate* cr;
306
307 fCrates->FirstCrate();
308
309 while ( ( cr = fCrates->NextCrate() ) )
310 {
311 TObjArray *boards = cr->Boards();
312
43368512 313 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 314 {
315 TObject *o = boards->At(j);
316
317 if (!o) break;
318
319 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
320
321 board->SetXY(pattern);
322 }
516d3280 323 }
324}
325
326//___________________________________________
327void AliMUONTriggerElectronics::DumpOS()
328{
6014107b 329/// DUMP IN THE OLD WAY
330///
43368512 331 for (Int_t i= 0; i < 234;i++)
516d3280 332 {
f1e8d46c 333 AliMUONLocalTriggerBoard *board = fCrates->LocalBoard(i);
516d3280 334
43368512 335 if (board) board->Scan("ALL");
516d3280 336 }
337}
338
339//___________________________________________
340void AliMUONTriggerElectronics::Scan(Option_t *option)
341{
6014107b 342 /// SCAN
343 ///
516d3280 344
f1e8d46c 345 AliMUONTriggerCrate* cr;
346
347 fCrates->FirstCrate();
348
349 while ( ( cr = fCrates->NextCrate() ) )
43368512 350 {
f1e8d46c 351 TObjArray *boards = cr->Boards();
352
43368512 353 for (Int_t j = 0; j < boards->GetEntries(); j++)
f1e8d46c 354 {
355 TObject *o = boards->At(j);
356
357 TString op = option;
358
359 Bool_t cdtion = kFALSE;
360
361 if (op.Contains("LOCAL")) cdtion = o->IsA() == AliMUONLocalTriggerBoard::Class();
362 if (op.Contains("REGIONAL")) cdtion = o->IsA() == AliMUONRegionalTriggerBoard::Class();
363 if (op.Contains("GLOBAL")) cdtion = o->IsA() == AliMUONGlobalTriggerBoard::Class();
364
365 if (!o || !cdtion) continue;
366
367 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
368
369 board->Scan();
370 }
371 }
516d3280 372}
373
374//___________________________________________
375void AliMUONTriggerElectronics::Reset()
376{
6014107b 377 /// RESET
378 ///
f1e8d46c 379
380 AliMUONTriggerCrate* cr;
381
382 fCrates->FirstCrate();
383
384 while ( ( cr = fCrates->NextCrate() ) )
516d3280 385 {
516d3280 386 TObjArray *boards = cr->Boards();
387
388 for (Int_t j=0; j<boards->GetEntries(); j++)
389 {
390 AliMUONTriggerBoard *b = (AliMUONTriggerBoard*)boards->At(j);
391
392 if (b) b->Reset();
393 }
394 }
395}
396
4c0f0f5d 397//_______________________________________________________________________
398void AliMUONTriggerElectronics::LoadMasks(AliMUONCalibrationData* calibData)
399{
71a2d3aa 400 /// LOAD MASKS FROM CDB
4c0f0f5d 401
402
403 // SET MASKS
f1e8d46c 404
405 AliMUONTriggerCrate* cr;
406
407 fCrates->FirstCrate();
408
409 Int_t irb(0);
410
411 while ( ( cr = fCrates->NextCrate() ) )
43368512 412 {
4c0f0f5d 413 TObjArray *boards = cr->Boards();
414
415 AliMUONRegionalTriggerBoard *regb =
416 (AliMUONRegionalTriggerBoard*)boards->At(0);
417
f1e8d46c 418 AliMUONVCalibParam* regionalBoardMasks = calibData->RegionalTriggerBoardMasks(irb);
4c0f0f5d 419
420 for ( Int_t i = 0; i < regionalBoardMasks->Size(); ++i )
421 {
422 UShort_t rmask = static_cast<UShort_t>(regionalBoardMasks->ValueAsInt(i) & 0x3F);
423 regb->Mask(i,rmask);
424 }
425
43368512 426 for (Int_t j = 1; j < boards->GetEntries(); j++)
4c0f0f5d 427 {
428 AliMUONLocalTriggerBoard *b = (AliMUONLocalTriggerBoard*)boards->At(j);
429
430 Int_t cardNumber = b->GetNumber();
431
432 if (cardNumber) // interface board are not interested
433 {
434 AliMUONVCalibParam* localBoardMasks = calibData->LocalTriggerBoardMasks(cardNumber);
435 for ( Int_t i = 0; i < localBoardMasks->Size(); ++i )
436 {
437 UShort_t lmask = static_cast<UShort_t>(localBoardMasks->ValueAsInt(i) & 0xFFFF);
438 b->Mask(i,lmask);
439 }
440 }
441 }
f1e8d46c 442 ++irb;
4c0f0f5d 443 }
444
445 AliMUONVCalibParam* globalBoardMasks = calibData->GlobalTriggerBoardMasks();
446 for ( Int_t i = 0; i < globalBoardMasks->Size(); ++i )
447 {
448 UShort_t gmask = static_cast<UShort_t>(globalBoardMasks->ValueAsInt(i) & 0xFFF);
449 fGlobalTriggerBoard->Mask(i,gmask);
450 }
451}
452
453
516d3280 454//___________________________________________
455void AliMUONTriggerElectronics::LocalResponse()
456{
6014107b 457/// \todo add comment
516d3280 458
f1e8d46c 459 AliMUONTriggerCrate* cr;
460
461 fCrates->FirstCrate();
462
463 while ( ( cr = fCrates->NextCrate() ) )
43368512 464 {
f1e8d46c 465
466 TObjArray *boards = cr->Boards();
467
468 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
469
470 UShort_t thisl[16]; for (Int_t j=0; j<16; j++) thisl[j] = 0;
29e3f51e 471
472 for (Int_t j = 1; j < boards->GetEntries(); j++)
f1e8d46c 473 {
43368512 474 TObject *o = boards->At(j);
f1e8d46c 475
43368512 476 if (!o) break;
f1e8d46c 477
43368512 478 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
f1e8d46c 479
29e3f51e 480 if (board) // check if empty slot
43368512 481 {
482 board->Response();
516d3280 483
29e3f51e 484 UShort_t response = board->GetResponse();
f1e8d46c 485
29e3f51e 486 // CRATE CONTAINING INTERFACE BOARD
487 if (board->GetNumber() == 0) // copy boards
488 {
489 if ( response != 0 )
490 AliWarning(Form("Interface board %s in slot %d of crate %s has a non zero response",
43368512 491 board->GetName(),j,cr->GetName()));
29e3f51e 492 AliDebug(1, Form("local slot %d, number %d in crate %s\n", j, board->GetNumber(), cr->GetName()));
493
494 }
f1e8d46c 495
29e3f51e 496 thisl[j-1] = response;
43368512 497 }
516d3280 498 }
f1e8d46c 499
500 regb->SetLocalResponse(thisl);
501 }
516d3280 502}
503
504//___________________________________________
505void AliMUONTriggerElectronics::RegionalResponse()
506{
f1e8d46c 507 /// Compute the response for all regional cards.
508 AliMUONTriggerCrate* cr;
509
510 fCrates->FirstCrate();
511
512 while ( ( cr = fCrates->NextCrate() ) )
43368512 513 {
516d3280 514 TObjArray *boards = cr->Boards();
515
516 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
517
518 if (regb)
519 {
520 regb->Response();
516d3280 521 }
522 }
523}
524
525//___________________________________________
526void AliMUONTriggerElectronics::GlobalResponse()
527{
f1e8d46c 528 /// Compute the global response
516d3280 529
f1e8d46c 530 UShort_t regional[16];
531
532 AliMUONTriggerCrate* cr;
533
534 fCrates->FirstCrate();
535 Int_t irb(0);
536
537 if ( !fCrates->NumberOfCrates() >= 16 )
538 {
539 AliFatal(Form("Something is wrong : too many crates %d",
540 fCrates->NumberOfCrates()));
541 }
542
543 while ( ( cr = fCrates->NextCrate() ) )
43368512 544 {
f1e8d46c 545 AliMUONTriggerBoard* rb =
546 static_cast<AliMUONTriggerBoard*>(cr->Boards()->At(0));
547 regional[irb] = rb->GetResponse();
548 ++irb;
549 }
550
551 fGlobalTriggerBoard->SetRegionalResponse(regional);
552 fGlobalTriggerBoard->Response();
516d3280 553}
554
516d3280 555//_______________________________________________________________________
556void
557AliMUONTriggerElectronics::Exec(Option_t*)
558{
6014107b 559/// \todo add comment
560///
516d3280 561 Digits2Trigger();
562}
563
564//_______________________________________________________________________
565void AliMUONTriggerElectronics::Trigger()
566{
6014107b 567/// \todo add comment
568///
8af755f4 569 FeedM();
516d3280 570 LocalResponse();
571 RegionalResponse();
572 GlobalResponse();
573}
516d3280 574
516d3280 575//_______________________________________________________________________
576void AliMUONTriggerElectronics::Digits2Trigger()
577{
f1e8d46c 578 /// Main method to go from digits to trigger decision
47dc4ee7 579 AliMUONRegionalTrigger *pRegTrig = new AliMUONRegionalTrigger();
f1e8d46c 580 fMUONData->ResetTrigger();
f1e8d46c 581 // RUN THE FULL BEE CHAIN
582 Trigger();
68ee8c5e 583// DumpOS();
8af755f4 584
f1e8d46c 585 AliMUONTriggerCrate* cr;
6a6a56b4 586
587 // stored in right order
588 // do not used iterator order
68ee8c5e 589
6a6a56b4 590 for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
f1e8d46c 591 {
6a6a56b4 592 for (Int_t iReg = 0; iReg < 8; iReg++) // 8 crates/regional boards for each side.
593 {
594 cr = fCrates->Crate(iSide, iReg);
595 TObjArray *boards = cr->Boards();
47dc4ee7 596
6a6a56b4 597 UInt_t regInpLpt = 0;
598 UInt_t regInpHpt = 0;
47dc4ee7 599
6a6a56b4 600 AliMUONRegionalTriggerBoard *regBoard = (AliMUONRegionalTriggerBoard*)boards->At(0);
47dc4ee7 601
6a6a56b4 602 for (Int_t j = 1; j < boards->GetEntries(); j++)
603 {
604 TObject *o = boards->At(j);
f1e8d46c 605
6a6a56b4 606 if (!o) break;
f1e8d46c 607
6a6a56b4 608 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
f1e8d46c 609
6a6a56b4 610 if (board)
611 {
612 // L0 TRIGGER
55735acb 613// pcrochet 181206: MOOD needs ALL boards
614// if (board->Triggered())
615// {
f1e8d46c 616
6a6a56b4 617 Int_t icirc = board->GetNumber();
55735acb 618 if (icirc != 0) { // pcrochet 181206: MOOD needs ALL boards
68ee8c5e 619
6a6a56b4 620 fLocalTrigger->SetLoCircuit(icirc);
621 fLocalTrigger->SetLoStripX(board->GetStripX11());
622 fLocalTrigger->SetLoDev(board->GetDev());
8aac6cce 623 fLocalTrigger->SetLoSdev(board->GetSdev());
624 fLocalTrigger->SetLoTrigY(board->GetTrigY());
6a6a56b4 625 fLocalTrigger->SetLoStripY(board->GetStripY11());
f1e8d46c 626
6a6a56b4 627 // SAVE LUT OUTPUT
628 UShort_t response = board->GetResponse();
629 fLocalTrigger->SetLoHpt((response & 12) >> 2);
630 fLocalTrigger->SetLoLpt(response & 3);
631
632 // calculates regional inputs from local for the moment
4798d385 633 UInt_t hPt = (response >> 2) & 0x3;
634 UInt_t lPt = response & 0x3;
47dc4ee7 635
6a6a56b4 636 regInpHpt |= hPt << (30 - (j-1)*2);
637 regInpLpt |= lPt << (30 - (j-1)*2);
47dc4ee7 638
6a6a56b4 639 TBits rrr;
640 rrr.Set(6,&response);
f1e8d46c 641
6a6a56b4 642 // SAVE BIT PATTERN
643 fLocalTrigger->SetX1Pattern(board->GetXY(0,0));
644 fLocalTrigger->SetX2Pattern(board->GetXY(0,1));
645 fLocalTrigger->SetX3Pattern(board->GetXY(0,2));
646 fLocalTrigger->SetX4Pattern(board->GetXY(0,3));
f1e8d46c 647
6a6a56b4 648 fLocalTrigger->SetY1Pattern(board->GetXY(1,0));
649 fLocalTrigger->SetY2Pattern(board->GetXY(1,1));
650 fLocalTrigger->SetY3Pattern(board->GetXY(1,2));
651 fLocalTrigger->SetY4Pattern(board->GetXY(1,3));
f1e8d46c 652
6a6a56b4 653 // ADD A NEW LOCAL TRIGGER
654 fMUONData->AddLocalTrigger(*fLocalTrigger);
68ee8c5e 655
6a6a56b4 656 }
657 }
516d3280 658 }
4798d385 659 pRegTrig->SetId(iReg + 8*iSide);
6a6a56b4 660 pRegTrig->SetLocalOutput(regInpLpt, 0);
661 pRegTrig->SetLocalOutput(regInpHpt, 1);
4798d385 662 pRegTrig->SetOutput(regBoard->GetResponse());
47dc4ee7 663
6a6a56b4 664 fMUONData->AddRegionalTrigger(*pRegTrig);
665 }
f1e8d46c 666 }
47dc4ee7 667 delete pRegTrig;
f1e8d46c 668
1908473e 669 // GLOBAL TRIGGER INFORMATION
f1e8d46c 670 UShort_t global = fGlobalTriggerBoard->GetResponse();
8d4fefab 671 fGlobalTrigger->SetFromGlobalResponse(global);
672
f1e8d46c 673
674 // ADD A LOCAL TRIGGER IN THE LIST
1908473e 675 fMUONData->AddGlobalTrigger(*fGlobalTrigger);
47dc4ee7 676
f1e8d46c 677 // NOW RESET ELECTRONICS
678 Reset();
516d3280 679}
680
07f2614d 681//_______________________________________________________________________
682void AliMUONTriggerElectronics::FeedBoardsGUI(TObjArray *guibs)
683{
684 /// feed digits from board objects from the TriggerGUI, with values
685 /// read from a file or set interactively in the GUI
686 ///
687
688 // adaptated from FeedM()
689
690 AliMUONTriggerGUIboard* board;
691 Int_t cathode, nstripX, nstripY, ix, iy, detElemId0, detElemId, charge;
692 Int_t iX1, iY1, schg, tchg;
693 Bool_t triggerBgn;
694
695 for (Int_t ib = 0; ib < 234; ib++) {
696
697 board = (AliMUONTriggerGUIboard*)guibs->At(ib);
698 if (board == 0) continue;
699
700 detElemId0 = board->GetDetElemId();
701
702 nstripX = board->GetNStripX();
703 nstripY = board->GetNStripY();
704
705 for (Int_t ichamber = 11; ichamber <= 14; ichamber++) {
706
707 detElemId = ichamber * 100 + detElemId0;
708
709 // x strips
710 cathode = 0;
711 for (Int_t isx = 0; isx < nstripX; isx++) {
712
713 charge = (Int_t)board->GetXDig(ichamber-11,isx);
714 if (charge) {
715
716 triggerBgn = kFALSE;
717 schg = (Int_t)(charge + 0.5);
718 // APPLY CONDITION ON SOFT BACKGROUND
719 tchg = schg - (Int_t(schg/10))*10;
720 if (schg<=10 || tchg>0) {
721 triggerBgn = kFALSE;
722 } else {
723 triggerBgn = kTRUE;
724 }
725 if (triggerBgn) continue;
726
727 //printf("MT %2d SX %2d \n",ichamber,isx);
728
729 ix = board->GetXSix();
730 iY1 = board->GetXSiy1();
731 iy = isx + iY1;
732
733 //printf("X: CH %1d B %3d ID %4d ix %2d iy %2d \n",ichamber,ib,detElemId,ix,iy);
734
735 const AliMpVSegmentation* seg =
736 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
737
738 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
739
740 if (!pad.IsValid()) printf("Invalid pad! \n");
741
742 for (Int_t i=0; i<pad.GetNofLocations(); i++) {
743
744 AliMpIntPair location = pad.GetLocation(i);
745 Int_t nboard = location.GetFirst();
746 if (nboard != board->GetIdCircuit()) continue;
747 Int_t ibitxy = location.GetSecond();
748
749 //printf("FeedGUI x (%2d): ix %d iy %d detElemId %d \n",ichamber,ix,iy,detElemId);
750
751 AliMUONLocalTriggerBoard *b = fCrates->LocalBoard(nboard);
752
753 if (b) {
754 if (cathode && b->GetSwitch(6)) ibitxy += 8;
755
756 //printf("Feed x-digits in board: %d cha %d s %d \n",nboard,ichamber,isx);
757 b->SetbitM(ibitxy,cathode,ichamber-11);
758
759 } else {
760 AliError(Form("Could not get local board number %d",b->GetNumber()));
761 }
762
763 }
764
765 }
766
767 }
768
769 // y strips
770 cathode = 1;
771 for (Int_t isy = 0; isy < nstripY; isy++) {
772
773 charge = board->GetYDig(ichamber-11,isy);
774 if (charge) {
775
776 triggerBgn = kFALSE;
777 schg = (Int_t)(charge + 0.5);
778 // APPLY CONDITION ON SOFT BACKGROUND
779 tchg = schg - (Int_t(schg/10))*10;
780 if (schg<=10 || tchg>0) {
781 triggerBgn = kFALSE;
782 } else {
783 triggerBgn = kTRUE;
784 }
785 if (triggerBgn) continue;
786
787 //printf("MT %2d SY %2d \n",ichamber,isy);
788
789 iX1 = board->GetYSix1();
790 ix = isy + iX1;
791 iy = board->GetYSiy();
792
793 //printf("Y: CH %1d B %3d ID %4d ix %2d iy %2d \n",ichamber,ib,detElemId,ix,iy);
794
795 const AliMpVSegmentation* seg =
796 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
797
798 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
799
800 if (!pad.IsValid()) printf("Invalid pad! \n");;
801
802 for (Int_t i=0; i<pad.GetNofLocations(); i++) {
803
804 AliMpIntPair location = pad.GetLocation(i);
805 Int_t nboard = location.GetFirst();
806 if (nboard != board->GetIdCircuit()) continue;
807 Int_t ibitxy = location.GetSecond();
808
809 //printf("FeedGUI y (%2d): ix %d iy %d detElemId %d \n",ichamber,ix,iy,detElemId);
810
811 AliMUONLocalTriggerBoard *b = fCrates->LocalBoard(nboard);
812
813 if (b) {
814 if (cathode && b->GetSwitch(6)) ibitxy += 8;
815
816 //printf("Feed y-digits in board: %d cha %d s %d \n",nboard,ichamber,isy);
817 b->SetbitM(ibitxy,cathode,ichamber-11);
818
819 } else {
820 AliError(Form("Could not get local board number %d",b->GetNumber()));
821 }
822
823 }
824
825 }
826
827 }
828
829 }
830
831 }
832
833 // ... the rest from FeedM()
834
835 // Particular case of the columns with 22 local boards (2R(L) 3R(L))
836 AliMUONTriggerCrate *crate = 0x0; TObjArray *bs = 0x0;
837
838 char *scratess[4] = { "2R", "2L", "3L", "3R"};
839 char *scratesd[4] = {"2-3R", "2-3L", "2-3L", "2-3R"};
840 Int_t slotf[4] = { 2, 2, 10, 10};
841 Int_t slotd[4] = { 1, 1, 9, 9};
842
843 for (Int_t i = 0; i < 4; i++)
844 {
845 crate = fCrates->Crate(scratess[i]);
846 bs = crate->Boards();
847 AliMUONLocalTriggerBoard *desybb = (AliMUONLocalTriggerBoard*)bs->At(14);
848 AliMUONLocalTriggerBoard *fromcb = (AliMUONLocalTriggerBoard*)bs->At(15);
849 AliMUONLocalTriggerBoard *desxbb = (AliMUONLocalTriggerBoard*)bs->At(16);
850
851 crate = fCrates->Crate(scratesd[i]);
852 bs = crate->Boards();
853 AliMUONLocalTriggerBoard *frombb = (AliMUONLocalTriggerBoard*)bs->At(slotf[i]);
854 AliMUONLocalTriggerBoard *desycb = (AliMUONLocalTriggerBoard*)bs->At(slotd[i]);
855
856 UShort_t cX[2];
857
858 // COPY X3-4 FROM BOARD 2 OF CRATE 2-3 TO BOARD 16 OF CRATE 2
859 // COPY X3-4 FROM BOARD 10 OF CRATE 2-3 TO BOARD 16 OF CRATE 3
860 frombb->GetX34(cX); desxbb->SetX34(cX);
861
862 // COPY X3-4 FROM BOARD 15 OF CRATE 2 TO BOARD 1 OF CRATE 2-3
863 // COPY X3-4 FROM BOARD 15 OF CRATE 3 TO BOARD 9 OF CRATE 2-3
864 fromcb->GetX34(cX); desycb->SetX34(cX);
865
866 UShort_t cY[4];
867
868 desybb->GetY(cY); frombb->SetY(cY);
869
870 frombb->GetY(cY); desxbb->SetY(cY);
871 fromcb->GetY(cY); desycb->SetY(cY);
872 }
873
874 // FILL UP/DOWN OF CURRENT BOARD (DONE VIA J3 BUS IN REAL LIFE)
875 AliMUONTriggerCrate* cr;
876
877 fCrates->FirstCrate();
878
879 while ( ( cr = fCrates->NextCrate() ) )
880 {
881 TObjArray *boards = cr->Boards();
882
883 for (Int_t j = 1; j < boards->GetEntries()-1; j++)
884 {
885 TObject *o = boards->At(j);
886
887 if (!o) break;
888
889 AliMUONLocalTriggerBoard *currboard = (AliMUONLocalTriggerBoard*)o;
890
891 AliMUONLocalTriggerBoard *neighbour = (AliMUONLocalTriggerBoard*)boards->At(j+1);
892
893 UShort_t cXY[2][4];
894
895 if (j==1) {neighbour->GetXY(cXY); currboard->SetXYU(cXY);}
896
897 // LAST BOARD IN THE CRATE HAS NO UP EXCEPT FOR CRATES 2 & 3
898 if (j < boards->GetEntries()-2)
899 {
900 AliMUONLocalTriggerBoard *nextboard = (AliMUONLocalTriggerBoard*)boards->At(j+2);
901
902 currboard->GetXY(cXY); neighbour->SetXYD(cXY);
903 nextboard->GetXY(cXY); neighbour->SetXYU(cXY);
904
905 if (j==boards->GetEntries()-3) {neighbour->GetXY(cXY); nextboard->SetXYD(cXY);}
906 }
907 }
908 }
909
910}
911
912//_______________________________________________________________________
913Int_t AliMUONTriggerElectronics::TriggerGUI(Int_t *trigInfo, Bool_t patt)
914{
915 /// trigger with digits from TriggerGUI and return local trigger information
916 /// and optionally the strips pattern
917 ///
918
919 Int_t nlo = 0;
920
921 LocalResponse();
922 RegionalResponse();
923 GlobalResponse();
924
925 AliMUONTriggerCrate* cr;
926
927 // stored in right order
928 // do not used iterator order
929
930 for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
931 {
932 for (Int_t iReg = 0; iReg < 8; iReg++) // 8 crates/regional boards for each side.
933 {
934 cr = fCrates->Crate(iSide, iReg);
935 TObjArray *boards = cr->Boards();
936
937 for (Int_t j = 1; j < boards->GetEntries(); j++)
938 {
939 TObject *o = boards->At(j);
940
941 if (!o) break;
942
943 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
944
945 if (board)
946 {
947 // L0 TRIGGER
948 if (board->Triggered())
949 {
950
951 if (patt) {
952 cout << " " << endl;
953 cout << "Local trigger board P A T T E R N :" << endl;
954 cout << "-----------------------------------" << endl;
955 cout << " " << endl;
956 board->Pattern();
957 board->Scan("RESPF");
958 }
959
960 Int_t icirc = board->GetNumber();
961 Int_t loStripX = board->GetStripX11();
962 Int_t loStripY = board->GetStripY11();
963 Int_t loDev = board->GetDev();
964
965 UShort_t response = board->GetResponse();
966 Int_t loHpt = (response & 12) >> 2;
967 Int_t loLpt = response & 3;
968 /*
969 cout << "TriggerGUI done!" << endl;
970
971 cout << "Circuit = " << icirc << endl;
972 cout << "LoStripX = " << loStripX << endl;
973 cout << "LoStripY = " << loStripY << endl;
974 cout << "LoDev = " << loDev << endl;
975 cout << endl;
976 */
977 trigInfo[6*nlo+0] = icirc;
978 trigInfo[6*nlo+1] = loStripX;
979 trigInfo[6*nlo+2] = loStripY;
980 trigInfo[6*nlo+3] = loDev;
981
982 trigInfo[6*nlo+4] = loLpt;
983 trigInfo[6*nlo+5] = loHpt;
984
985 nlo++;
986
987 }
988 }
989 }
990 }
991 }
992
993 Reset();
994
995 return nlo;
996
997}
998