LCOV - code coverage report
Current view: top level - MUON/MUONraw - AliMUONPayloadTrigger.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 121 0.8 %
Date: 2016-06-14 17:26:59 Functions: 1 11 9.1 %

          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 AliMUONPayloadTrigger
      20             : /// Class Payload
      21             : ///
      22             : /// Decodes rawdata from buffer and stores in TClonesArray.
      23             : /// 
      24             : /// First version implement for Trigger
      25             : ///
      26             : /// \author Christian Finck
      27             : //-----------------------------------------------------------------------------
      28             : 
      29             : #include "AliMUONPayloadTrigger.h"
      30             : 
      31             : #include "AliMUONDarcHeader.h"
      32             : #include "AliMUONRegHeader.h"
      33             : #include "AliMUONLocalStruct.h"
      34             : #include "AliMUONDDLTrigger.h"
      35             : #include "AliMUONLogger.h"
      36             : 
      37             : #include "AliLog.h"
      38             : 
      39             : /// \cond CLASSIMP
      40          18 : ClassImp(AliMUONPayloadTrigger)
      41             : /// \endcond
      42             : 
      43             : AliMUONPayloadTrigger::AliMUONPayloadTrigger()
      44           0 :   : TObject(),
      45           0 :     fMaxReg(8),
      46           0 :     fMaxLoc(16),
      47           0 :     fDDLTrigger(new AliMUONDDLTrigger()),
      48           0 :     fRegHeader(new AliMUONRegHeader()), 
      49           0 :     fLocalStruct(new AliMUONLocalStruct()),
      50           0 :     fLog(new AliMUONLogger(1000)),
      51           0 :     fDarcEoWErrors(0),
      52           0 :     fGlobalEoWErrors(0),
      53           0 :     fRegEoWErrors(0),
      54           0 :     fLocalEoWErrors(0),
      55           0 :     fWarnings(kTRUE),
      56           0 :     fNofRegSet(kFALSE)
      57           0 : {
      58             :   ///
      59             :   /// create an object to read MUON raw digits
      60             :   /// Default ctor for monitoring purposes
      61             :   ///
      62             : 
      63           0 : }
      64             : 
      65             : //___________________________________
      66             : AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
      67           0 : {
      68             :   ///
      69             :   /// clean up
      70             :   ///
      71           0 :   delete fDDLTrigger;
      72           0 :   delete fLocalStruct;
      73           0 :   delete fRegHeader;
      74           0 :   delete fLog;
      75           0 : }
      76             : 
      77             : 
      78             : //______________________________________________________
      79             : Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer, Bool_t scalerEvent)
      80             : {
      81             :   /// decode trigger DDL
      82             :   /// store only notified cards
      83             : 
      84             :  // reading DDL for trigger
      85             : 
      86           0 :   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
      87             : 
      88           0 :   static Int_t kGlobalHeaderSize   = darcHeader->GetGlobalHeaderLength(); 
      89           0 :   static Int_t kDarcHeaderSize     = darcHeader->GetDarcHeaderLength(); 
      90           0 :   static Int_t kRegHeaderSize      = fRegHeader->GetHeaderLength();
      91           0 :   static Int_t kRegEmptySize       = fRegHeader->GetHeaderLength()+1 + 16*(fLocalStruct->GetLength()+1);
      92           0 :   static Int_t kRegEmptyScalerSize = fRegHeader->GetHeaderLength() + fRegHeader->GetScalerLength() + 1 +
      93           0 :                                       16*(fLocalStruct->GetLength() + fLocalStruct->GetScalerLength() + 1);
      94             : 
      95             :   Int_t index = 0;
      96             : 
      97           0 :   memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4); 
      98           0 :   index += kDarcHeaderSize;
      99             : 
     100             : 
     101             :   // darc type vadorh
     102           0 :   if (darcHeader->GetDarcType() == darcHeader->GetDarcVadohrType())
     103           0 :       fMaxReg = 1;
     104             :     
     105             :   // darc type def.
     106           0 :   if (darcHeader->GetDarcType() == darcHeader->GetDarcDefaultType())
     107           0 :       fMaxReg = 8;
     108             :       
     109           0 :   if(darcHeader->GetEventType() == scalerEvent) 
     110           0 :       if (fWarnings) AliWarning("Wrong event type obtained from the Darc header, take the one of CDH");
     111             : 
     112             : 
     113           0 :   if(scalerEvent) {
     114             :     // 6 DARC scaler words
     115           0 :     memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
     116           0 :     index += darcHeader->GetDarcScalerLength();
     117           0 :   }
     118             : 
     119           0 :   if (buffer[index++] != darcHeader->GetEndOfDarc()) {
     120             : 
     121           0 :       const Char_t* msg = Form("Wrong end of Darc word %x instead of %x\n",
     122           0 :                     buffer[index-1], darcHeader->GetEndOfDarc());
     123           0 :       if (fWarnings) AliWarning(msg);
     124           0 :       AddErrorMessage(msg);
     125           0 :       fDarcEoWErrors++;
     126           0 :   }
     127             :   // 4 words of global board input + Global board output
     128           0 :   memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4); 
     129           0 :   index += kGlobalHeaderSize; 
     130             : 
     131           0 :   if(scalerEvent) {
     132             :     // 10 Global scaler words
     133           0 :     memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
     134           0 :     index += darcHeader->GetGlobalScalerLength();
     135           0 :   }
     136             : 
     137           0 :   if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
     138             : 
     139           0 :       const Char_t* msg = Form("Wrong end of Global word %x instead of %x\n",
     140           0 :                       buffer[index-1], darcHeader->GetEndOfGlobal());
     141           0 :       if (fWarnings) AliWarning(msg);
     142           0 :       AddErrorMessage(msg);
     143           0 :       fGlobalEoWErrors++;
     144           0 :   }
     145             :   // 8 regional boards
     146           0 :   for (Int_t iReg = 0; iReg < fMaxReg; iReg++) {           //loop over regeonal card
     147             : 
     148             :     // skip empty regaional board (not connected or with error reading)
     149           0 :     if (buffer[index] == fRegHeader->GetErrorWord()) {
     150           0 :       fDDLTrigger->AddRegHeader(*fRegHeader);
     151           0 :       if (scalerEvent)
     152           0 :         index += kRegEmptyScalerSize;
     153             :       else 
     154           0 :         index += kRegEmptySize;
     155             :       continue;
     156             :     }
     157           0 :     memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
     158           0 :     index += kRegHeaderSize;
     159             : 
     160           0 :     fDDLTrigger->AddRegHeader(*fRegHeader);
     161             :     // 11 regional scaler word
     162           0 :     if(scalerEvent) {
     163           0 :       memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
     164           0 :       index += fRegHeader->GetScalerLength();
     165           0 :     }
     166             : 
     167           0 :     if (buffer[index++] != fRegHeader->GetEndOfReg()) {
     168             : 
     169           0 :       const Char_t* msg = Form("Wrong end of Regional word %x instead of %x\n",
     170           0 :                     buffer[index-1], fRegHeader->GetEndOfReg());
     171           0 :       if (fWarnings) AliWarning(msg);
     172           0 :       AddErrorMessage(msg);
     173           0 :       fRegEoWErrors++;
     174           0 :     }
     175             :     // 16 local cards per regional board
     176           0 :     for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) {         //loop over local card
     177             :           
     178           0 :       Int_t dataSize = fLocalStruct->GetLength();;
     179             : 
     180             :       // 5 word trigger information
     181           0 :       memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4); 
     182           0 :       index += dataSize;         
     183             : 
     184             :       // 45 regional scaler word
     185           0 :       if(scalerEvent) {
     186           0 :         memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
     187           0 :         index += fLocalStruct->GetScalerLength();
     188           0 :       }
     189             : 
     190           0 :       if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
     191             : 
     192           0 :         const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
     193           0 :                                  buffer[index-1], fLocalStruct->GetEndOfLocal());
     194             :         
     195           0 :         if (fWarnings) AliWarning(msg);
     196           0 :         AddErrorMessage(msg);
     197           0 :         fLocalEoWErrors++;
     198           0 :       }
     199             :       // fill only if card notified
     200           0 :       if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
     201           0 :           continue;
     202             : 
     203           0 :       fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
     204             : 
     205           0 :     } // local card loop
     206             :         
     207           0 :   } // regional card loop
     208             :       
     209             : 
     210           0 :   return kTRUE;
     211             : }
     212             : 
     213             : //______________________________________________________
     214             : void AliMUONPayloadTrigger::ResetDDL()
     215             : {
     216             :   /// reseting TClonesArray
     217             :   /// after each DDL
     218             :   ///
     219           0 :   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
     220           0 :   darcHeader->GetRegHeaderArray()->Delete();
     221           0 :   fDarcEoWErrors   = 0;
     222           0 :   fGlobalEoWErrors = 0;
     223           0 :   fRegEoWErrors    = 0;
     224           0 :   fLocalEoWErrors  = 0;
     225           0 : }
     226             : 
     227             : //______________________________________________________
     228             : void AliMUONPayloadTrigger::SetMaxReg(Int_t reg) 
     229             : {
     230             :   /// set regional card number
     231           0 :   if (reg > 8) reg = 8;
     232           0 :    fMaxReg = reg;
     233             :    
     234           0 :   fNofRegSet = kTRUE;
     235           0 : }
     236             : 
     237             : //______________________________________________________
     238             : void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc) 
     239             : {
     240             :   /// set local card number
     241           0 :   if (loc > 16) loc = 16;
     242           0 :   fMaxLoc = loc;
     243           0 : }
     244             : 
     245             : //______________________________________________________
     246             : void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
     247             : {
     248             : /// adding message to logger
     249             :  
     250           0 :   TString tmp(msg);
     251             :   
     252           0 :   Int_t pos = tmp.First("\n");
     253           0 :   tmp[pos] = 0;
     254             :     
     255           0 :   fLog->Log(tmp.Data());
     256           0 : }
     257             : 

Generated by: LCOV version 1.11