LCOV - code coverage report
Current view: top level - MUON/MUONbase - AliMUONTriggerElectronics.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 260 298 87.2 %
Date: 2016-06-14 17:26:59 Functions: 18 21 85.7 %

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

Generated by: LCOV version 1.11