LCOV - code coverage report
Current view: top level - PMD/PMDbase - AliPMDRawStream.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 249 311 80.1 %
Date: 2016-06-14 17:26:59 Functions: 16 22 72.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             : ///
      20             : /// This class provides access to PMD digits in raw data.
      21             : ///
      22             : /// It loops over all PMD digits in the raw data given by the AliRawReader.
      23             : /// The Next method goes to the next digit. If there are no digits left
      24             : /// it returns kFALSE.
      25             : /// Several getters provide information about the current digit.
      26             : ///
      27             : ///////////////////////////////////////////////////////////////////////////////
      28             : 
      29             : #include <Riostream.h>
      30             : #include <TObjArray.h>
      31             : #include <TString.h>
      32             : #include <TSystem.h>
      33             : 
      34             : #include "AliLog.h"
      35             : #include "AliPMDBlockHeader.h"
      36             : #include "AliPMDDspHeader.h"
      37             : #include "AliPMDPatchBusHeader.h"
      38             : #include "AliPMDddldata.h"
      39             : #include "AliPMDRawStream.h"
      40             : #include "AliPMDMappingData.h"
      41             : #include "AliRawReader.h"
      42             : #include "AliCDBManager.h"
      43             : #include "AliCDBStorage.h"
      44             : #include "AliCDBEntry.h"
      45             : 
      46          12 : ClassImp(AliPMDRawStream)
      47             : 
      48             : 
      49             : //_____________________________________________________________________________
      50           4 : AliPMDRawStream::AliPMDRawStream(AliRawReader* rawReader) :
      51           4 :     fRawReader(rawReader),
      52           4 :     fData(NULL),
      53           4 :     fPosition(-1),
      54           8 :     fMapData(GetMappingData())
      55          20 : {
      56             : // create an object to read PMD raw digits
      57             : 
      58           4 :   fRawReader->Reset();
      59           4 :   fRawReader->Select("PMD");
      60           8 : }
      61             : 
      62             : //_____________________________________________________________________________
      63             : AliPMDRawStream::AliPMDRawStream(const AliPMDRawStream& stream) :
      64           0 :   TObject(stream),
      65           0 :   fRawReader(NULL),
      66           0 :   fData(NULL),
      67           0 :   fPosition(-1),
      68           0 :   fMapData(GetMappingData())
      69           0 : {
      70             : // copy constructor
      71             : 
      72           0 :   AliFatal("Copy constructor not implemented");
      73           0 : }
      74             : 
      75             : //_____________________________________________________________________________
      76             : AliPMDRawStream& AliPMDRawStream::operator = (const AliPMDRawStream& 
      77             :                                               /* stream */)
      78             : {
      79             : // assignment operator
      80             : 
      81           0 :   AliFatal("operator = assignment operator not implemented");
      82           0 :   return *this;
      83             : }
      84             : 
      85             : //_____________________________________________________________________________
      86             : AliPMDRawStream::~AliPMDRawStream()
      87           8 : {
      88             : // destructor
      89             : 
      90          12 : }
      91             : 
      92             : 
      93             : //_____________________________________________________________________________
      94             : 
      95             : Int_t AliPMDRawStream::DdlData(TObjArray *pmdddlcont)
      96             : {
      97             :   // read the next raw digit
      98             :   // returns kFALSE if there is no digit left
      99             :   
     100             :   Int_t iddl = -1;
     101             : 
     102             :   AliPMDddldata *pmdddldata;
     103             : 
     104          44 :   if (!fRawReader->ReadHeader()) return -1;
     105             : 
     106          16 :   iddl           = fRawReader->GetDDLID();
     107          16 :   Int_t dataSize = fRawReader->GetDataSize();
     108          16 :   Int_t totaldataword = dataSize/4;
     109             : 
     110          16 :   if (dataSize <= 0) return -1;
     111             : 
     112             :   UInt_t data = 0;
     113             : 
     114             :  // PMD raw data does not contain CDH
     115             : 
     116          16 :   if (!fRawReader->ReadNextData(fData))
     117             :     {
     118           0 :       return kFALSE;
     119             :     }
     120             : 
     121             : 
     122          16 :   fPosition = 0;
     123             : 
     124             :   Int_t ibus = 0;
     125             : 
     126             :   const Int_t kNPatchBus = 51;
     127             : 
     128          16 :   Int_t moduleNo[kNPatchBus], mcmperBus[kNPatchBus];
     129          16 :   Int_t startRowBus[kNPatchBus], endRowBus[kNPatchBus];
     130          16 :   Int_t startColBus[kNPatchBus], endColBus[kNPatchBus];
     131             : 
     132        1664 :   for (ibus = 0; ibus < kNPatchBus; ibus++)
     133             :     {
     134         816 :       moduleNo[ibus]    = -1;
     135         816 :       mcmperBus[ibus]   = -1;
     136         816 :       startRowBus[ibus] = -1;
     137         816 :       endRowBus[ibus]   = -1;
     138         816 :       startColBus[ibus] = -1;
     139         816 :       endColBus[ibus]   = -1;
     140             :     }
     141             :   
     142          16 :   if (iddl == 0)
     143             :     {
     144           8 :       Ddl0Mapping(moduleNo, mcmperBus, startRowBus, 
     145           4 :                   endRowBus, startColBus, endColBus);
     146             : 
     147           4 :     }
     148          12 :   else if (iddl == 1)
     149             :     {
     150           8 :       Ddl1Mapping(moduleNo, mcmperBus, startRowBus, 
     151           4 :                   endRowBus, startColBus, endColBus);
     152             :       
     153           4 :     }
     154           8 :   else if (iddl == 2)
     155             :     {
     156           0 :       Ddl2Mapping(moduleNo, mcmperBus, startRowBus, 
     157           0 :                   endRowBus, startColBus, endColBus);
     158           0 :     }
     159           8 :   else if (iddl == 3)
     160             :     {
     161           0 :       Ddl3Mapping(moduleNo, mcmperBus, startRowBus, 
     162           0 :                   endRowBus, startColBus, endColBus);
     163           0 :     }
     164           8 :   else if (iddl == 4)
     165             :     {
     166           8 :       Ddl4Mapping(moduleNo, mcmperBus, startRowBus, 
     167           4 :                   endRowBus, startColBus, endColBus);
     168           4 :     }
     169           4 :   else if (iddl == 5)
     170             :     {
     171           8 :       Ddl5Mapping(moduleNo, mcmperBus, startRowBus, 
     172           4 :                   endRowBus, startColBus, endColBus);
     173           4 :   }
     174             : 
     175             : 
     176          16 :   AliPMDBlockHeader    blockHeader;
     177          16 :   AliPMDDspHeader      dspHeader;
     178          16 :   AliPMDPatchBusHeader pbusHeader;
     179             : 
     180          16 :   const Int_t kblHLen   = blockHeader.GetHeaderLength();
     181          16 :   const Int_t kdspHLen  = dspHeader.GetHeaderLength();
     182          16 :   const Int_t kpbusHLen = pbusHeader.GetHeaderLength();
     183             :   
     184             :   Int_t parity = 0;
     185          16 :   Int_t idet = 0, ismn = 0;
     186          16 :   Int_t irow = -1;
     187          16 :   Int_t icol = -1;
     188             : 
     189          16 :   Int_t blHeaderWord[8]={0};
     190          16 :   Int_t dspHeaderWord[10]={0};
     191          16 :   Int_t pbusHeaderWord[4]={0};
     192             : 
     193             :   Int_t blRawDataLength  = 0;
     194             :   Int_t dspRawDataLength = 0;
     195             :   Int_t iwordddl         = 2;
     196             : 
     197             : 
     198             : 
     199          64 :   for (Int_t iblock = 0; iblock < 2; iblock++)
     200             :     {
     201         576 :       for (Int_t i = 0; i < kblHLen; i++)
     202             :         {
     203         256 :             iwordddl++;
     204         512 :             blHeaderWord[i] = (Int_t) GetNextWord();
     205             :         }
     206             : 
     207          32 :       blockHeader.SetHeader(blHeaderWord);
     208          32 :       blRawDataLength = blockHeader.GetRawDataLength();
     209             : 
     210          32 :       if (iwordddl == totaldataword) break;
     211             : 
     212             :       Int_t iwordblk = 0;
     213             : 
     214         320 :       for (Int_t idsp = 0; idsp < 5; idsp++)
     215             :         {
     216        3520 :           for (Int_t i = 0; i < kdspHLen; i++)
     217             :             {
     218        1600 :                 iwordddl++;
     219        1600 :                 iwordblk++;
     220        3200 :                 dspHeaderWord[i] = (Int_t) GetNextWord();
     221             :             }
     222         160 :           dspHeader.SetHeader(dspHeaderWord);
     223         160 :           dspRawDataLength = dspHeader.GetRawDataLength();
     224             : 
     225         160 :           if (iwordddl == totaldataword) break;
     226             : 
     227             :           Int_t iworddsp = 0;
     228             : 
     229        1600 :           for (ibus = 0; ibus < 5; ibus++)
     230             :             {
     231        8000 :               for (Int_t i = 0; i < kpbusHLen; i++)
     232             :                 {
     233        3200 :                     iwordddl++;
     234        3200 :                     iwordblk++;
     235        3200 :                     iworddsp++;
     236        6400 :                     pbusHeaderWord[i] = (Int_t) GetNextWord();
     237             :                 }
     238             : 
     239         800 :               pbusHeader.SetHeader(pbusHeaderWord);
     240         800 :               Int_t rawdatalength = pbusHeader.GetRawDataLength();
     241         800 :               Int_t pbusid = pbusHeader.GetPatchBusId();
     242             : 
     243         800 :               if (pbusid < 0 || pbusid > 50) return -1;
     244             : 
     245         800 :               Int_t imodule = moduleNo[pbusid];
     246             : 
     247         814 :               if (iwordddl == totaldataword) break;
     248             : 
     249        2718 :               for (Int_t iword = 0; iword < rawdatalength; iword++)
     250             :                 {
     251         180 :                     iwordddl++;
     252         180 :                     iwordblk++;
     253         180 :                     iworddsp++;
     254             :                     data = 0;
     255         180 :                     data = GetNextWord();
     256             : 
     257         180 :                   Int_t isig =  data & 0x0FFF;
     258         180 :                   Int_t ich  = (data >> 12) & 0x003F;
     259         180 :                   Int_t imcm = (data >> 18) & 0x07FF;
     260         180 :                   Int_t ibit = (data >> 31) & 0x0001;
     261         180 :                   if (imcm == 0)
     262             :                     {
     263           0 :                       AliWarning(Form("FEE address WRONG:: Module %d Patch Bus %d MCM %d",imodule,pbusid,imcm));
     264           0 :                       return -1;
     265             :                     }
     266             : 
     267         180 :                   parity = ComputeParity(data);
     268             : 
     269         180 :                   if (ibit != parity)
     270             :                     {
     271           0 :                       AliWarning(Form("Parity Error:: Patch Bus %d Module %d",pbusid,imodule));
     272           0 :                       fRawReader->AddMajorErrorLog(kParityError);
     273           0 :                       return -1;
     274             :                     }
     275             : 
     276         180 :                   ConvertDDL2SMN(iddl, imodule, ismn, idet);
     277             : 
     278         180 :                   GetRowCol(imodule, pbusid, imcm, ich, 
     279         180 :                             startRowBus, endRowBus,
     280         180 :                             startColBus, endColBus,
     281             :                             irow, icol);
     282             : 
     283             : 
     284         180 :                   TransformH2S(ismn, irow, icol);
     285             : 
     286         360 :                   pmdddldata = new AliPMDddldata();
     287             : 
     288         180 :                   pmdddldata->SetDetector(idet);
     289         180 :                   pmdddldata->SetSMN(ismn);
     290         180 :                   pmdddldata->SetModule(imodule);
     291         180 :                   pmdddldata->SetPatchBusId(pbusid);
     292         180 :                   pmdddldata->SetMCM(imcm);
     293         180 :                   pmdddldata->SetChannel(ich);
     294         180 :                   pmdddldata->SetRow(irow);
     295         180 :                   pmdddldata->SetColumn(icol);
     296         180 :                   pmdddldata->SetSignal(isig);
     297         180 :                   pmdddldata->SetParityBit(ibit);
     298             :                   
     299         180 :                   pmdddlcont->Add(pmdddldata);
     300             : 
     301         180 :                 } // data word loop
     302             : 
     303             : 
     304         786 :               if (iwordddl == totaldataword) break;
     305             : 
     306         786 :               if (dspHeader.GetPaddingWord() == 1)
     307             :               {
     308         168 :                   if (iworddsp == dspRawDataLength-1) break; // raw data
     309             :               }
     310             :               else
     311             :               {
     312         764 :                   if (iworddsp == dspRawDataLength) break; // raw data
     313             :               }
     314             : 
     315             : 
     316         640 :             } // patch bus loop
     317             : 
     318             : //SKP added break next line (Reqd. if only one patch Bus)
     319         174 :           if (iwordddl == totaldataword) break;
     320             : 
     321         146 :           if (dspHeader.GetPaddingWord() == 1)
     322             :           {
     323          28 :               iwordddl++;
     324          28 :               iwordblk++;
     325             :               iworddsp++;
     326          28 :               data = GetNextWord();
     327          28 :           }
     328         148 :           if (iwordddl == totaldataword) break;
     329             : 
     330         160 :           if (iwordblk == blRawDataLength) break; // for raw data
     331             : 
     332             : 
     333         128 :         } // end of DSP
     334             : //SKP added break next line (Reqd. if only one patch Bus)
     335          48 :           if (iwordddl == totaldataword) break;
     336             : 
     337          16 :     } // end of BLOCK
     338             :  
     339          16 :  return iddl;
     340          36 : }
     341             : //_____________________________________________________________________________
     342             : void AliPMDRawStream::GetRowCol(Int_t imodule, Int_t pbusid,
     343             :                                 UInt_t mcmno, UInt_t chno,
     344             :                                 Int_t startRowBus[], Int_t endRowBus[],
     345             :                                 Int_t startColBus[], Int_t endColBus[],
     346             :                                 Int_t &row, Int_t &col) const
     347             : {
     348             :   // decode: ddlno, patchbusid, mcmno, chno -> um, row, col
     349             : 
     350         360 :   UInt_t iCh[64];
     351             : 
     352             :   static const UInt_t kChDdl01[64] = { 9, 6, 5, 10, 1, 2, 0, 3,
     353             :                                        13, 7, 4, 11, 8, 14, 12, 15,
     354             :                                        16, 19, 17, 23, 20, 27, 24, 18,
     355             :                                        28, 31, 29, 30, 21, 26, 25, 22,
     356             :                                        41, 38, 37, 42, 33, 34, 32, 35,
     357             :                                        45, 39, 36, 43, 40, 46, 44, 47,
     358             :                                        48, 51, 49, 55, 52, 59, 56, 50,
     359             :                                        60, 63, 61, 62, 53, 58, 57, 54 };
     360             :     
     361             :   static const UInt_t kChDdl23[64] = { 54, 57, 58, 53, 62, 61, 63, 60,
     362             :                                        50, 56, 59, 52, 55, 49, 51, 48,
     363             :                                        47, 44, 46, 40, 43, 36, 39, 45,
     364             :                                        35, 32, 34, 33, 42, 37, 38, 41,
     365             :                                        22, 25, 26, 21, 30, 29, 31, 28,
     366             :                                        18, 24, 27, 20, 23, 17, 19, 16,
     367             :                                        15, 12, 14, 8, 11, 4, 7, 13,
     368             :                                        3, 0, 2, 1, 10, 5, 6, 9 };
     369             :   
     370             :   static const UInt_t kChDdl41[64] = { 53, 58, 57, 54, 61, 62, 60, 63,
     371             :                                        49, 59, 56, 55, 52, 50, 48, 51,
     372             :                                        44, 47, 45, 43, 40, 39, 36, 46,
     373             :                                        32, 35, 33, 34, 41, 38, 37, 42,
     374             :                                        21, 26, 25, 22, 29, 30, 28, 31,
     375             :                                        17, 27, 24, 23, 20, 18, 16, 19,
     376             :                                        12, 15, 13, 11, 8, 7, 4, 14,
     377             :                                        0, 3, 1, 2, 9, 6, 5, 10 };
     378             :   
     379             :   static const UInt_t kChDdl42[64] = { 10, 5, 6, 9, 2, 1, 3, 0,
     380             :                                        14, 4, 7, 8, 11, 13, 15, 12,
     381             :                                        19, 16, 18, 20, 23, 24, 27, 17,
     382             :                                        31, 28, 30, 29, 22, 25, 26, 21,
     383             :                                        42, 37, 38, 41, 34, 33, 35, 32,
     384             :                                        46, 36, 39, 40, 43, 45, 47, 44,
     385             :                                        51, 48, 50, 52, 55, 56, 59, 49,
     386             :                                        63, 60, 62, 61, 54, 57, 58, 53 };
     387             :   
     388             :   static const UInt_t kChDdl51[64] = { 10, 5, 6, 9, 2, 1, 3, 0,
     389             :                                        14, 4, 7, 8, 11, 13, 15, 12,
     390             :                                        19, 16, 18, 20, 23, 24, 27, 17,
     391             :                                        31, 28, 30, 29, 22, 25, 26, 21,
     392             :                                        42, 37, 38, 41, 34, 33, 35, 32,
     393             :                                        46, 36, 39, 40, 43, 45, 47, 44,
     394             :                                        51, 48, 50, 52, 55, 56, 59, 49,
     395             :                                        63, 60, 62, 61, 54, 57, 58, 53 };
     396             :   
     397             :   static const UInt_t kChDdl52[64] = { 53, 58, 57, 54, 61, 62, 60, 63,
     398             :                                        49, 59, 56, 55, 52, 50, 48, 51,
     399             :                                        44, 47, 45, 43, 40, 39, 36, 46,
     400             :                                        32, 35, 33, 34, 41, 38, 37, 42,
     401             :                                        21, 26, 25, 22, 29, 30, 28, 31,
     402             :                                        17, 27, 24, 23, 20, 18, 16, 19,
     403             :                                        12, 15, 13, 11, 8, 7, 4, 14,
     404             :                                        0, 3, 1, 2, 9, 6, 5, 10 };
     405             :   
     406       23400 :   for (Int_t i = 0; i < 64; i++)
     407             :     {
     408       16896 :       if(imodule < 6)                    iCh[i] = kChDdl01[i];
     409       12096 :       if(imodule >= 6 && imodule <= 11)  iCh[i] = kChDdl01[i];
     410       11840 :       if(imodule >= 12 && imodule <= 17) iCh[i] = kChDdl23[i];
     411       12928 :       if(imodule >= 18 && imodule <= 23) iCh[i] = kChDdl23[i];
     412       13696 :       if(imodule >= 24 && imodule <= 29) iCh[i] = kChDdl41[i];
     413       11520 :       if(imodule >= 42 && imodule <= 47) iCh[i] = kChDdl42[i];
     414       12416 :       if(imodule >= 36 && imodule <= 41) iCh[i] = kChDdl51[i];
     415       12288 :       if(imodule >= 30 && imodule <= 35) iCh[i] = kChDdl52[i];
     416             :     }
     417             :   
     418             :   
     419         180 :   Int_t rowcol  = iCh[chno];
     420         180 :   Int_t irownew = rowcol/4;
     421         180 :   Int_t icolnew = rowcol%4;
     422             : 
     423             : 
     424         180 :   if (imodule < 6 )
     425             :     {
     426          84 :       row = startRowBus[pbusid] + irownew;
     427          84 :       col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
     428          84 :     }
     429          96 :   else if (imodule >= 6 && imodule < 12)
     430             :     {
     431           9 :       row = endRowBus[pbusid] - (15 - irownew);
     432           9 :       col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
     433             :       
     434           9 :     }
     435          87 :   else if (imodule >= 12 && imodule < 18 )
     436             :     {
     437           5 :       row = startRowBus[pbusid] + irownew;
     438           5 :       col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew);
     439           5 :     }
     440          82 :   else if (imodule >= 18 && imodule < 24)
     441             :     {
     442          22 :       row = endRowBus[pbusid] - (15 - irownew);
     443          22 :       col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew);
     444          22 :     }
     445          60 :   else if (imodule >= 24 && imodule < 30)
     446             :     {
     447          34 :       Int_t rowdiff = endRowBus[pbusid] - startRowBus[pbusid];
     448          34 :       if(rowdiff > 16)
     449             :         {
     450           0 :           if (mcmno <= 12)
     451             :             {
     452             :               // Add 16 to skip the 1st 15 rows
     453           0 :               row = startRowBus[pbusid] + irownew + 16;
     454           0 :               col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
     455           0 :             }
     456           0 :           else if(mcmno > 12)
     457             :             {
     458           0 :               row = startRowBus[pbusid] + irownew;
     459           0 :               col = startColBus[pbusid] + (mcmno-12-1)*4 + icolnew;
     460           0 :             }
     461             :         }
     462          34 :       else if (rowdiff < 16)
     463             :         {
     464          34 :           row = startRowBus[pbusid] + irownew;
     465          34 :           col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
     466          34 :         }
     467          34 :     }
     468          26 :   else if (imodule >= 42 && imodule < 48)
     469             :     {
     470           0 :       Int_t rowdiff = endRowBus[pbusid] - startRowBus[pbusid];
     471             : 
     472           0 :       if (mcmno <= 12)
     473             :         {
     474           0 :           col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew); 
     475             :           
     476           0 :           if(rowdiff > 16)
     477           0 :             row = endRowBus[pbusid] - (15 - irownew) - 16 ;
     478             :           else
     479           0 :             row = endRowBus[pbusid] - (15 - irownew) ;
     480             :         }
     481           0 :       else if(mcmno > 12)
     482             :         {
     483           0 :           row = endRowBus[pbusid] - (15 - irownew)  ;
     484           0 :           col = endColBus[pbusid] - (mcmno - 12 - 1)*4 - (3 - icolnew);
     485           0 :         }
     486           0 :     }
     487             : 
     488             : 
     489             : 
     490          26 :   else if (imodule >= 30 && imodule < 36)
     491             :     {
     492          24 :       if (mcmno > 12)
     493             :         {
     494             :           // Subtract 16 to skip the 1st 15 rows
     495          12 :           row = endRowBus[pbusid] - 16 -(15 - irownew);
     496           0 :           col = startColBus[pbusid] + (mcmno-12 -1)*4 + icolnew;
     497           0 :         }
     498             :       else
     499             :         {
     500          12 :           row = endRowBus[pbusid]  - (15 - irownew) ;
     501          12 :           col = startColBus[pbusid] + (mcmno -1)*4 + icolnew;
     502             :         }
     503             : 
     504             :     }
     505             :       
     506          14 :   else if (imodule >= 36 && imodule < 42)
     507             :     {
     508          28 :       if(mcmno > 12)
     509             :         {
     510             :           // Add 16 to skip the 1st 15 rows
     511          14 :           row = startRowBus[pbusid] + irownew + 16;
     512           0 :           col = endColBus[pbusid] - (mcmno - 12 - 1)*4 - (3 - icolnew);
     513           0 :         }
     514             :       else 
     515             :         {
     516          14 :           row = startRowBus[pbusid] + irownew ;
     517          14 :           col = endColBus[pbusid] - (mcmno - 1)*4 - (3 - icolnew); 
     518             :         }
     519             :     }
     520             : 
     521             : 
     522         180 : }
     523             : //_____________________________________________________________________________
     524             : void AliPMDRawStream::ConvertDDL2SMN(Int_t iddl, Int_t imodule,
     525             :                                      Int_t &smn, Int_t &detector) const
     526             : {
     527             :   // This converts the DDL number (0 to 5), Module Number (0-47)
     528             :   // to Serial module number in one detector (SMN : 0-23) and
     529             :   // detector number (0:PRE plane, 1:CPV plane)
     530         360 :   if (iddl < 4)
     531             :     {
     532         120 :       smn = imodule;
     533         120 :       detector = 0;
     534         120 :     }
     535             :   else
     536             :     {
     537          60 :       smn = imodule - 24;
     538          60 :       detector = 1;
     539             :     }
     540         180 : }
     541             : //_____________________________________________________________________________
     542             : 
     543             : void AliPMDRawStream::TransformH2S(Int_t smn, Int_t &row, Int_t &col) const
     544             : {
     545             :   // This does the transformation of the hardware coordinate to
     546             :   // software 
     547             :   // i.e., For SuperModule 0 &1, instead of 96x48(hardware),
     548             :   // it is 48x96 (software)
     549             :   // For Supermodule 3 & 4, 48x96
     550             : 
     551             :   Int_t irownew  = 0;
     552             :   Int_t icolnew  = 0;
     553             : 
     554         360 :   if(smn < 12)
     555             :     {
     556         139 :       irownew = col;
     557         139 :       icolnew = row;
     558         139 :     }
     559          41 :   else if(smn >= 12 && smn < 24)
     560             :     {
     561          41 :       irownew = row;
     562          41 :       icolnew = col;
     563          41 :     }
     564             : 
     565         180 :   row = irownew;
     566         180 :   col = icolnew;
     567         180 : }
     568             : //_____________________________________________________________________________
     569             : Int_t AliPMDRawStream::ComputeParity(UInt_t data)
     570             : {
     571             : // Calculate the parity bit
     572             : 
     573             :   Int_t count = 0;
     574       10980 :   for(Int_t j = 0; j<29; j++)
     575             :     {
     576        6833 :       if (data & 0x01 ) count++;
     577        5220 :       data >>= 1;
     578             :     }
     579             :   
     580         180 :   Int_t parity = count%2;
     581             : 
     582         180 :   return parity;
     583             : }
     584             : 
     585             : //_____________________________________________________________________________
     586             : UInt_t AliPMDRawStream::GetNextWord()
     587             : {
     588             :     // Returns the next 32 bit word
     589             :     // inside the raw data payload.
     590             : 
     591       15792 :     if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
     592             : 
     593             :     UInt_t word = 0;
     594        5264 :     word |= fData[fPosition++];
     595        5264 :     word |= fData[fPosition++] << 8;
     596        5264 :     word |= fData[fPosition++] << 16;
     597        5264 :     word |= fData[fPosition++] << 24;
     598             : 
     599        5264 :     return word;
     600             : }
     601             : 
     602             : //_____________________________________________________________________________
     603             : void AliPMDRawStream::Ddl0Mapping(Int_t moduleNo[],    Int_t mcmperBus[],
     604             :                                   Int_t startRowBus[], Int_t endRowBus[],
     605             :                                   Int_t startColBus[], Int_t endColBus[])
     606             : {
     607             :   // DDL0 Mapping 
     608             : 
     609             :   Int_t iddl = 0;
     610             : 
     611         412 :   for(Int_t ibus = 1; ibus < 51; ibus++)
     612             :     {
     613         200 :       moduleNo[ibus]     = fMapData->GetModuleNo(iddl,ibus);
     614         200 :       mcmperBus[ibus]    = fMapData->GetMcmperBus(iddl,ibus);
     615         200 :       startRowBus[ibus]  = fMapData->GetStartRowBus(iddl,ibus);
     616         200 :       startColBus[ibus]  = fMapData->GetStartColBus(iddl,ibus);
     617         200 :       endRowBus[ibus]    = fMapData->GetEndRowBus(iddl,ibus);
     618         200 :       endColBus[ibus]    = fMapData->GetEndColBus(iddl,ibus);
     619             :     }
     620             : 
     621           4 : }
     622             : 
     623             : //_____________________________________________________________________________
     624             : void AliPMDRawStream::Ddl1Mapping(Int_t moduleNo[],    Int_t mcmperBus[],
     625             :                                   Int_t startRowBus[], Int_t endRowBus[],
     626             :                                   Int_t startColBus[], Int_t endColBus[])
     627             : {
     628             :   // DDL1 Mapping 
     629             : 
     630             :   Int_t iddl = 1;
     631             : 
     632         412 :   for(Int_t ibus = 1; ibus < 51; ibus++)
     633             :     {
     634         200 :       moduleNo[ibus]     = fMapData->GetModuleNo(iddl,ibus);
     635         200 :       mcmperBus[ibus]    = fMapData->GetMcmperBus(iddl,ibus);
     636         200 :       startRowBus[ibus]  = fMapData->GetStartRowBus(iddl,ibus);
     637         200 :       startColBus[ibus]  = fMapData->GetStartColBus(iddl,ibus);
     638         200 :       endRowBus[ibus]    = fMapData->GetEndRowBus(iddl,ibus);
     639         200 :       endColBus[ibus]    = fMapData->GetEndColBus(iddl,ibus);
     640             :           
     641             :     }
     642             : 
     643             : 
     644           4 : }
     645             : 
     646             : //_____________________________________________________________________________
     647             : void AliPMDRawStream::Ddl2Mapping(Int_t moduleNo[],    Int_t mcmperBus[],
     648             :                                   Int_t startRowBus[], Int_t endRowBus[],
     649             :                                   Int_t startColBus[], Int_t endColBus[])
     650             : {
     651             :   // DDL2 Mapping 
     652             : 
     653             :   Int_t iddl = 2;
     654             : 
     655           0 :   for(Int_t ibus = 1; ibus < 51; ibus++)
     656             :     {
     657           0 :       moduleNo[ibus]     = fMapData->GetModuleNo(iddl,ibus);
     658           0 :       mcmperBus[ibus]    = fMapData->GetMcmperBus(iddl,ibus);
     659           0 :       startRowBus[ibus]  = fMapData->GetStartRowBus(iddl,ibus);
     660           0 :       startColBus[ibus]  = fMapData->GetStartColBus(iddl,ibus);
     661           0 :       endRowBus[ibus]    = fMapData->GetEndRowBus(iddl,ibus);
     662           0 :       endColBus[ibus]    = fMapData->GetEndColBus(iddl,ibus);
     663             :           
     664             :     }
     665             : 
     666           0 : }
     667             : 
     668             : //_____________________________________________________________________________
     669             : void AliPMDRawStream::Ddl3Mapping(Int_t moduleNo[],    Int_t mcmperBus[],
     670             :                                   Int_t startRowBus[], Int_t endRowBus[],
     671             :                                   Int_t startColBus[], Int_t endColBus[])
     672             : {
     673             :   // DDL3 Mapping 
     674             : 
     675             :   Int_t iddl = 3;
     676             : 
     677           0 :   for(Int_t ibus = 1; ibus < 51; ibus++)
     678             :     {
     679           0 :       moduleNo[ibus]     = fMapData->GetModuleNo(iddl,ibus);
     680           0 :       mcmperBus[ibus]    = fMapData->GetMcmperBus(iddl,ibus);
     681           0 :       startRowBus[ibus]  = fMapData->GetStartRowBus(iddl,ibus);
     682           0 :       startColBus[ibus]  = fMapData->GetStartColBus(iddl,ibus);
     683           0 :       endRowBus[ibus]    = fMapData->GetEndRowBus(iddl,ibus);
     684           0 :       endColBus[ibus]    = fMapData->GetEndColBus(iddl,ibus);
     685             :           
     686             :     }
     687             : 
     688           0 : }
     689             : 
     690             : //_____________________________________________________________________________
     691             : void AliPMDRawStream::Ddl4Mapping(Int_t moduleNo[],    Int_t mcmperBus[],
     692             :                                   Int_t startRowBus[], Int_t endRowBus[],
     693             :                                   Int_t startColBus[], Int_t endColBus[])
     694             : {
     695             :   // DDL4 Mapping 
     696             : 
     697             :   Int_t iddl = 4;
     698             : 
     699         412 :   for(Int_t ibus = 1; ibus < 51; ibus++)
     700             :     {
     701         200 :       moduleNo[ibus]     = fMapData->GetModuleNo(iddl,ibus);
     702         200 :       mcmperBus[ibus]    = fMapData->GetMcmperBus(iddl,ibus);
     703         200 :       startRowBus[ibus]  = fMapData->GetStartRowBus(iddl,ibus);
     704         200 :       startColBus[ibus]  = fMapData->GetStartColBus(iddl,ibus);
     705         200 :       endRowBus[ibus]    = fMapData->GetEndRowBus(iddl,ibus);
     706         200 :       endColBus[ibus]    = fMapData->GetEndColBus(iddl,ibus);
     707             :           
     708             :     }
     709             : 
     710             :   
     711           4 : }
     712             : 
     713             : //_____________________________________________________________________________
     714             : void AliPMDRawStream::Ddl5Mapping(Int_t moduleNo[],    Int_t mcmperBus[],
     715             :                                   Int_t startRowBus[], Int_t endRowBus[],
     716             :                                   Int_t startColBus[], Int_t endColBus[])
     717             : {
     718             :   // DDL5 Mapping 
     719             : 
     720             :   Int_t iddl = 5;
     721             : 
     722         412 :   for(Int_t ibus = 1; ibus < 51; ibus++)
     723             :     {
     724         200 :       moduleNo[ibus]     = fMapData->GetModuleNo(iddl,ibus);
     725         200 :       mcmperBus[ibus]    = fMapData->GetMcmperBus(iddl,ibus);
     726         200 :       startRowBus[ibus]  = fMapData->GetStartRowBus(iddl,ibus);
     727         200 :       startColBus[ibus]  = fMapData->GetStartColBus(iddl,ibus);
     728         200 :       endRowBus[ibus]    = fMapData->GetEndRowBus(iddl,ibus);
     729         200 :       endColBus[ibus]    = fMapData->GetEndColBus(iddl,ibus);
     730             :           
     731             :     }
     732             : 
     733           4 : }
     734             : //_____________________________________________________________________________
     735             : 
     736             : AliPMDMappingData* AliPMDRawStream::GetMappingData() const
     737             : {
     738             :   // Fetching the mapping data from CDB
     739             : 
     740          12 :   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Mapping");
     741             :   
     742           4 :   if(!entry) AliFatal("Mapping object retrieval failed!");
     743             :   
     744             :   AliPMDMappingData *mapdata=0;
     745           8 :   if (entry) mapdata = (AliPMDMappingData*) entry->GetObject();
     746             :   
     747           4 :   if (!mapdata)  AliFatal("No Mapping data from CDB !");
     748             :   
     749           4 :   return mapdata;
     750           0 : }
     751             : 
     752             : 
     753             : 
     754             : //_____________________________________________________________________________
     755             : 

Generated by: LCOV version 1.11