LCOV - code coverage report
Current view: top level - MUON/MUONraw - AliMUONBusStruct.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 19 94 20.2 %
Date: 2016-06-14 17:26:59 Functions: 7 20 35.0 %

          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             : #include "AliMUONBusStruct.h"
      19             : 
      20             : #include "AliLog.h"
      21             : #include <Riostream.h>
      22             : #include <string.h>
      23             : 
      24             : //-----------------------------------------------------------------------------
      25             : /// \class AliMUONBusStruct
      26             : /// Bus patch structure for tracker raw data
      27             : /// each Dsp contains at most 5 bus patch structure
      28             : /// Beside the total length and length of the below data
      29             : /// the header of the block contains the bus patch id, trigger words 
      30             : /// and data structure itself (11bits for manu id, 6 bits for channel id and
      31             : /// 12 bits for charge)
      32             : ///
      33             : /// \author Christian Finck
      34             : //-----------------------------------------------------------------------------
      35             : 
      36             : using std::cout;
      37             : using std::endl;
      38             : /// \cond CLASSIMP
      39          18 : ClassImp(AliMUONBusStruct)
      40             : /// \endcond
      41             : 
      42             : const Int_t  AliMUONBusStruct::fgkHeaderLength = 4;
      43             : const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
      44             : const Int_t  AliMUONBusStruct::fgkManuNofChannels(64);
      45             : 
      46             : //___________________________________________
      47             : AliMUONBusStruct::AliMUONBusStruct()
      48         128 :   :  TObject(),
      49         128 :      fDataKey(0),
      50         128 :      fTotalLength(0),
      51         128 :      fLength(0),
      52         128 :      fBusPatchId(0),
      53         128 : fBufSize(43*fgkManuNofChannels), 
      54             :   /* assuming 43 manus max per bustpatch.
      55             :   Anyway fData is resized where needed (though it makes it slower) */
      56         256 :      fData(new UInt_t[fBufSize]),
      57         128 :      fDspId(0),
      58         128 :      fBlkId(0)
      59         640 : {
      60             :   ///
      61             :   /// ctor
      62             :   /// 
      63             : 
      64         256 : }
      65             : //___________________________________________
      66             : AliMUONBusStruct::~AliMUONBusStruct()
      67         768 : {
      68             :   ///
      69             :   /// dtor
      70             :   ///
      71         256 :   delete[] fData;
      72         384 : }
      73             : 
      74             : //___________________________________________
      75             : void AliMUONBusStruct::SetAlloc(Int_t size)
      76             : {
      77             :   ///
      78             :   /// Allocate size 
      79             :   /// return if size < fBufSize 
      80             :   ///
      81           0 :   if (size < fBufSize) 
      82             :     return;
      83             :   else 
      84           0 :     ResizeData(size);
      85           0 : }
      86             : //___________________________________________
      87             : void AliMUONBusStruct::AddData(UInt_t data)
      88             : {
      89             :   /// could have used class from ROOT
      90             :   /// but the structure must be as simple as possible
      91             :   /// to be written on disc blockwise, not so sure ?
      92        1416 :   if (fLength == fBufSize) 
      93           0 :     ResizeData();
      94         708 :   fData[fLength++] = data;
      95         708 :   fTotalLength = fLength + fgkHeaderLength;
      96         708 : }
      97             : 
      98             : //___________________________________________
      99             : void AliMUONBusStruct::ResizeData(Int_t size)
     100             : {
     101             :   /// In case of resizing the vector
     102             :   /// the most simplest way to do it
     103             :   ///
     104           0 :   if (size == 0)
     105           0 :     fBufSize *= 2;
     106             :   else
     107           0 :     fBufSize = size;
     108           0 :   UInt_t* newData = new UInt_t[fBufSize];
     109           0 :   for (Int_t i = 0; i < fLength; i++)
     110           0 :     newData[i] = fData[i];
     111           0 :   delete[] fData;
     112           0 :   fData = newData;
     113           0 : }
     114             : //___________________________________________
     115             : AliMUONBusStruct::
     116             : AliMUONBusStruct(const AliMUONBusStruct& event)
     117           0 :   : TObject(event),
     118           0 :     fDataKey(event.fDataKey),
     119           0 :     fTotalLength(event.fTotalLength),
     120           0 :     fLength(event.fLength),
     121           0 :     fBusPatchId(event.fBusPatchId),
     122           0 :     fBufSize(event.fBufSize),
     123           0 :     fData(new UInt_t[event.fBufSize]),
     124           0 :     fDspId(event.fDspId),
     125           0 :     fBlkId(event.fBlkId)
     126           0 : {
     127             :   ///
     128             :   /// copy ctor
     129             :   ///
     130             : 
     131           0 :   for (int i = 0; i < event.fBufSize; i++)
     132           0 :     fData[i] = event.fData[i];
     133           0 : }
     134             : //___________________________________________
     135             : AliMUONBusStruct&
     136             : AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
     137             : {
     138             :   ///
     139             :   /// assignment operator
     140             :   ///
     141           0 :   if (this == &event) return *this;
     142           0 :   fDataKey     = event.fDataKey;
     143           0 :   fTotalLength = event.fTotalLength;
     144           0 :   fLength      = event.fLength;
     145           0 :   fBusPatchId  = event.fBusPatchId;
     146           0 :   fBufSize     = event.fBufSize;
     147             : 
     148           0 :   fBlkId = event.fBlkId;
     149           0 :   fDspId = event.fDspId;
     150             : 
     151           0 :   delete [] fData;  
     152           0 :   fData =  new UInt_t[event.fBufSize];
     153           0 :   for (int i = 0; i < event.fLength; i++)
     154           0 :     fData[i] = event.fData[i];
     155             : 
     156           0 :   return *this;
     157           0 : }
     158             : //___________________________________________
     159             : Int_t AliMUONBusStruct::Compare(const TObject *obj) const
     160             : {
     161             :   /// 
     162             :   /// sort bus patch by bus patch number
     163             :   /// important for AliMUONRawWriter
     164             :   ///
     165           0 :   AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
     166           0 :   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
     167             : }
     168             : 
     169             : //___________________________________________
     170             : void AliMUONBusStruct::Clear(Option_t *)
     171             : {
     172             :   /// clear
     173             :   /// delete the allocated memory 
     174             :   ///
     175           0 :   delete[] fData;
     176           0 : }
     177             : //___________________________________________
     178             : UInt_t AliMUONBusStruct::GetData(Int_t n) const 
     179             : {
     180             :   ///
     181             :   /// get data
     182             :   ///
     183           0 :   if ( n>=0 && n<fLength ) return fData[n];
     184             : 
     185           0 :   AliError("Index outside limits."); 
     186           0 :   return 0; 
     187           0 : }
     188             : 
     189             : //___________________________________________
     190             : Char_t AliMUONBusStruct::GetParity(Int_t n) const   
     191             : {
     192             :   ///
     193             :   /// get parity
     194             :   ///
     195           0 :   if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) &  0x1;
     196             : 
     197           0 :   AliError("Index outside limits."); 
     198           0 :   return 0; 
     199           0 : }
     200             : 
     201             : //___________________________________________
     202             : UShort_t AliMUONBusStruct::GetManuId(Int_t n) const     
     203             : {
     204             :   ///
     205             :   /// get manu Id
     206             :   ///
     207           0 :   if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) &  0x7FF;
     208             : 
     209           0 :   AliError("Index outside limits."); 
     210           0 :   return 0; 
     211           0 : }
     212             : 
     213             : //___________________________________________
     214             : UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const  
     215             : {
     216             :   /// 
     217             :   /// get channel Id
     218             :   ///
     219           0 :   if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
     220             : 
     221           0 :   AliError("Index outside limits."); 
     222           0 :   return 0; 
     223           0 : }
     224             : 
     225             : //___________________________________________
     226             : UShort_t AliMUONBusStruct::GetCharge(Int_t n) const     
     227             : {
     228             :   ///
     229             :   /// get charge (in ADC)
     230             :   ///
     231           0 :   if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
     232             : 
     233           0 :   AliError("Index outside limits."); 
     234           0 :   return 0; 
     235           0 : }
     236             : 
     237             : //___________________________________________
     238             : void AliMUONBusStruct::Print(Option_t* opt) const
     239             : {
     240             :   /// print out
     241             : 
     242           0 :   cout << "Bus patch info" << endl;
     243           0 :   cout << "DataKey: "      << fDataKey << endl;
     244           0 :   cout << "fTotalLength: " << fTotalLength << endl;
     245           0 :   cout << "fLength: "      << fLength << endl;
     246           0 :   cout << "fBusPatchId: "  << fBusPatchId << endl;
     247           0 :   cout << "fBufSize: "     << fBufSize << endl;
     248             : 
     249           0 :   if (strstr(opt, "all")) {
     250           0 :   for (Int_t i = 0; i <fLength; ++i)
     251           0 :       cout << "Data["<< i << "] = " << fData[i] << endl;
     252           0 :   }
     253           0 : }
     254             : 
     255             : 

Generated by: LCOV version 1.11