LCOV - code coverage report
Current view: top level - PHOS/PHOSbase - AliPHOSCpvRawStream.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 58 290 20.0 %
Date: 2016-06-14 17:26:59 Functions: 8 26 30.8 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 2007, 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             : #include "AliPHOSCpvRawStream.h"
      17             : #include "AliRawReader.h"
      18             : #include <stdio.h>
      19             : 
      20          22 : ClassImp(AliPHOSCpvRawStream);
      21             : using namespace std;
      22             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      23           4 : AliPHOSCpvRawStream::AliPHOSCpvRawStream(AliRawReader* rawReader) :
      24           4 :   fNPads(0),
      25           4 :   fCharge(0x0),
      26           4 :   fPad(0x0),
      27           4 :   fDDLNumber(-1),
      28           4 :   fnDDLInStream(0x0),
      29           4 :   fnDDLOutStream(0x0),
      30           4 :   fLDCNumber( 0),
      31           4 :   fTimeStamp( 0),
      32           4 :   fRawReader(rawReader),
      33           4 :   fData(0x0),
      34           4 :   fNumOfErr(0x0),
      35           4 :   fPosition(0),
      36           4 :   fWord(0),
      37           4 :   fZeroSup(kTRUE),
      38           4 :   fPos(0x0),
      39           4 :   fiPos(0),
      40           4 :   fTurbo(kFALSE),
      41           4 :   fRawDataSize(0)
      42          20 : {
      43             :   //
      44             :   // Constructor
      45             :   //
      46             :   Int_t kNDDL = AliPHOSCpvParam::kNDDL;
      47           8 :   fNumOfErr = new Int_t*[kNDDL];     // Store the number of errors for a given error type and a given DD
      48          48 :   for(Int_t iddl=0; iddl<kNDDL; iddl++) {
      49          40 :     fNumOfErr[iddl] = new Int_t [kSumErr];
      50         560 :     for(Int_t ierr=0; ierr < kSumErr; ierr++) {
      51         260 :       fNumOfErr[iddl][ierr]=0;       // reset errors
      52             :     }
      53             :   }
      54             :   
      55           8 :   fnDDLInStream  = new Int_t[kNDDL];
      56           8 :   fnDDLOutStream = new Int_t[kNDDL];
      57          48 :   for(Int_t i=0; i<kNDDL; i++) {
      58          20 :     fnDDLInStream [i] = -1;
      59          20 :     fnDDLOutStream[i] = -1;
      60             :   }
      61             :  
      62           4 :   fRawReader->Reset();
      63           4 :   fRawReader->Select("CPV");
      64           8 : } // Constructor
      65             : 
      66             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      67           0 : AliPHOSCpvRawStream::AliPHOSCpvRawStream() :
      68           0 :   fNPads(0),
      69           0 :   fCharge(0x0),
      70           0 :   fPad(0x0),
      71           0 :   fDDLNumber(-1),
      72           0 :   fnDDLInStream(0x0),
      73           0 :   fnDDLOutStream(0x0),
      74           0 :   fLDCNumber( 0),
      75           0 :   fTimeStamp( 0),
      76           0 :   fRawReader(0x0),
      77           0 :   fData(0x0),
      78           0 :   fNumOfErr(0x0),  
      79           0 :   fPosition(0),
      80           0 :   fWord(0),
      81           0 :   fZeroSup(kTRUE),
      82           0 :   fPos(0x0),
      83           0 :   fiPos(0),
      84           0 :   fTurbo(kFALSE) ,
      85           0 :   fRawDataSize(0)
      86           0 : {
      87             :   //
      88             :   // Default constructor
      89             :   //
      90             :   Int_t kNDDL = AliPHOSCpvParam::kNDDL;
      91           0 :   fNumOfErr = new Int_t*[kNDDL]; // Store the number of errors for a given error type and a given DDL
      92           0 :   for(Int_t iddl=0; iddl<kNDDL; iddl++) {
      93           0 :     fNumOfErr[iddl] = new Int_t [kSumErr];
      94           0 :     for(Int_t ierr=0; ierr < kSumErr; ierr++) {
      95           0 :       fNumOfErr[iddl][ierr]=0;   // reset errors
      96             :     }
      97             :   }
      98             : 
      99           0 :   fnDDLInStream  = new Int_t[kNDDL];
     100           0 :   fnDDLOutStream = new Int_t[kNDDL];
     101           0 :   for(Int_t i=0; i<kNDDL; i++) {
     102           0 :     fnDDLInStream [i] = -1;
     103           0 :     fnDDLOutStream[i] = -1;
     104             :   }
     105           0 : } // Default constructor
     106             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     107             : AliPHOSCpvRawStream::~AliPHOSCpvRawStream()
     108          24 : {
     109             :   //
     110             :   // destructor
     111             :   //
     112           4 :   DelVars();
     113             :     
     114           4 :   fDDLNumber=0;
     115           4 :   fLDCNumber=0;
     116           4 :   fTimeStamp=0;
     117           4 :   fPosition=0;
     118           4 :   fWord=0;
     119           4 :   fZeroSup=0;
     120           4 :   fTurbo=0;
     121           4 :   fRawDataSize=0;
     122          88 :   for(Int_t i=0; i<AliPHOSCpvParam::kNDDL; i++) delete [] fNumOfErr[i]; 
     123           8 :   delete [] fNumOfErr; 
     124           8 :   delete [] fnDDLInStream;
     125           8 :   delete [] fnDDLOutStream;
     126          12 : }
     127             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     128             : void AliPHOSCpvRawStream::Reset()
     129             : {
     130             :   // reset raw stream params
     131             :   // Reinitalize the containers
     132           0 :   fDDLNumber = -1;
     133           0 :   fLDCNumber =  0;
     134           0 :   fTimeStamp =  0;
     135           0 :   fPosition = 0;
     136           0 :   fData = NULL;
     137           0 :   if (fRawReader) fRawReader->Reset();
     138           0 : }
     139             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     140             : Bool_t AliPHOSCpvRawStream::Turbo()
     141             : {
     142             :   
     143             :   UInt_t row,_3G,pad;
     144           0 :   Int_t cntGlob = fRawReader->GetDataSize()/4;
     145           0 :   fPosition = 0;
     146           0 :   fNPads    = 0;
     147             : 
     148             :   //std::cout<<"words to be read: "<<cntGlob<<std::endl;
     149             : 
     150           0 :   for(Int_t i=1; i<cntGlob; i++) {
     151           0 :     if (!GetWord(1)) return kFALSE;
     152             :     //std::cout<<"i've passed getWord(1)"<<std::endl;
     153           0 :     if (fPosition/4 <= 5) continue; // Skip first 5 words 
     154             :     
     155           0 :     row = ((fWord >> kbit22) & 0x1f) - 1;
     156           0 :     _3G = ((fWord >> kbit18) & 0xf) - 1; // 3GASSIPLEX info in raw word is between bits: 18...21    
     157           0 :     pad = (fWord >> kbit12) & 0x3f;      // pad info in raw word is between bits: 12...17
     158             :     //std::cout<<"row = "<<row<<", 3Gassiplex = "<<_3G<<", pad info = "<<pad<<std::endl;
     159             :     
     160           0 :     Int_t charge, abs, eType;
     161           0 :     if(!AliPHOSCpvParam::DecodeRawWord(fDDLNumber,fWord,abs,charge,eType)) {
     162           0 :       if (eType > 0) {
     163           0 :         fNumOfErr[fDDLNumber][eType]++;
     164             :         //std::cout<<"AliPHOSCpvRawStream::Turbo(): I cannot decode word!"<<std::endl;
     165             :         //cout<<"DDL = "<<  fDDLNumber << "; word = "<< fWord <<"; abs = " << abs 
     166             :         //    <<"; charge = "<< charge <<"; etype = "<< eType << endl;
     167           0 :       }
     168           0 :       continue;
     169             :     }
     170             :     else {
     171           0 :       fPad   [fNPads] = abs;
     172           0 :       fCharge[fNPads] = charge;
     173           0 :       fNPads++;
     174           0 :       if(charge==0) fNumOfErr[fDDLNumber][kPedQZero]++;
     175             :       //Printf("Size: %i  DDL %i row %i 3G %i pad %i fPos %i fNPads: %i Charge: %d fWord %4.4x",cntGlob,fDDLNumber,row,_3G,pad,fPosition,fNPads,fCharge[fNPads-1],fWord);
     176             :     }
     177           0 :   }//word loop
     178           0 :   return kTRUE;
     179           0 : }//Turbo()
     180             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     181             : Bool_t AliPHOSCpvRawStream::Next()
     182             : {
     183             :   // read next DDL raw data from the CPV raw data stream
     184             :   // return kFALSE in case of error or no data left
     185             : 
     186          16 :   AliDebug(1,"Start.");
     187             :   do {
     188           8 :     if (!fRawReader->ReadNextData(fData)) return kFALSE;
     189           0 :   } while (fRawReader->GetDataSize() == 0);
     190             :  
     191             :   /*
     192             :   Event type is selected as in $ALICE_ROOT/RAW/event.h  
     193             :   #define START_OF_RUN                    ((eventTypeType) 1)
     194             :   #define END_OF_RUN                      ((eventTypeType) 2)
     195             :   #define START_OF_RUN_FILES              ((eventTypeType) 3)
     196             :   #define END_OF_RUN_FILES                ((eventTypeType) 4)
     197             :   #define START_OF_BURST                  ((eventTypeType) 5)
     198             :   #define END_OF_BURST                    ((eventTypeType) 6)
     199             :   #define PHYSICS_EVENT                   ((eventTypeType) 7) <<---------------  
     200             :   #define CALIBRATION_EVENT               ((eventTypeType) 8)
     201             :   #define EVENT_FORMAT_ERROR              ((eventTypeType) 9)
     202             :   #define START_OF_DATA                   ((eventTypeType)10)
     203             :   #define END_OF_DATA                     ((eventTypeType)11)
     204             :   #define SYSTEM_SOFTWARE_TRIGGER_EVENT   ((eventTypeType)12)
     205             :   #define DETECTOR_SOFTWARE_TRIGGER_EVENT ((eventTypeType)13)
     206             :   #define EVENT_TYPE_MIN                  1
     207             :   #define EVENT_TYPE_MAX                  13 
     208             :   */
     209             : 
     210           0 :   fPosition = 0;
     211             :   Bool_t status=kFALSE;
     212           0 :   fRawDataSize=0;        
     213           0 :   fDDLNumber = -1;
     214           0 :   if (fRawReader->GetDDLID()>=0)
     215           0 :     fDDLNumber = fRawReader->GetDDLID();
     216             : 
     217             :   //debug!!!
     218             :   //fDDLNumber=0;
     219             : 
     220           0 :   if(fDDLNumber<0) {
     221           0 :     AliWarning(Form("fDDLNumber not a acceptable value %i",fDDLNumber));
     222           0 :     return kFALSE;
     223             :   }
     224             :     
     225           0 :   if(fRawReader->GetType() == 7 || fRawReader->GetType() == 8 )  {  //New: Select Physics events, Old: Raw data size is not 0 and not 47148 (pedestal)
     226           0 :     fnDDLInStream[fDDLNumber]=1; 
     227           0 :     fnDDLOutStream[fDDLNumber]=0;
     228             :     
     229           0 :     fLDCNumber = fRawReader->GetLDCId();
     230           0 :     fTimeStamp = fRawReader->GetTimestamp();
     231             :     
     232           0 :     fRawDataSize=fRawReader->GetDataSize()/4;
     233           0 :     DelVars();                    //We have to delete the variables initialized in the InitVars before recall InitVars!!!
     234           0 :     InitVars(fRawDataSize);       //To read the charge and pads we cannot delete before the status return
     235             :   
     236           0 :     if(fTurbo==kTRUE) status=Turbo();
     237           0 :     else status = ReadCPVRawData(); // If there is any error in raw event, the whole event is thrown away
     238             :    
     239           0 :     if(status) AliDebug(1,Form("Event DDL %i successfully decoded!.",fDDLNumber));
     240           0 :     else       AliDebug(1,Form("Event DDL %i ERROR in decoding!.",fDDLNumber));
     241             :     //DumpData(fRawReader->GetDataSize());
     242             :   } // if(Select Physics events)
     243             : 
     244           0 :   if(status==kTRUE) fnDDLOutStream[fDDLNumber]++; //Count the number of events when the DDL was succesfully decoded
     245             :    
     246           0 :    return status;
     247           4 : } // Next()
     248             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     249             : void AliPHOSCpvRawStream::InitVars(Int_t n)
     250             : {
     251           0 :   fNPads = 0;
     252           0 :   fCharge = new Int_t[n]; 
     253           0 :   fPad = new Int_t[n];
     254           0 :   fPos = new Int_t[4*n];                 //reset debug 
     255           0 :   for(Int_t ie = 0 ; ie < 4*n; ie++) fPos[ie] = 0; //initialize for 0, otherwise the position is considered filled and will not be updated for the dump
     256           0 :   fiPos = 0;
     257           0 : } // InitVars()
     258             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     259             : void AliPHOSCpvRawStream::DelVars()
     260             : {
     261             :   //Clean the initvars!!!!!!!!
     262           8 :   fNPads = 0; 
     263           4 :   if (fCharge)     { delete [] fCharge;    fCharge = 0x0; }
     264           4 :   if (fPad)        { delete [] fPad;       fPad = 0x0;       }   
     265           4 :   if (fPos)        { delete [] fPos;       fPos = 0x0;       }     
     266             :  
     267           4 :   fiPos=0;
     268           4 : } // DelVars()
     269             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     270             : Bool_t AliPHOSCpvRawStream::ReadCPVRawData()
     271             : {
     272             :   //Here the loop on the decoding the raw bank 
     273             :   //for one ddl starts.
     274             :   //It returns: kFALSE if any error occurs
     275             :   //            kTRUE  if all OK
     276           0 :   Int_t cntGlob = fRawReader->GetDataSize()/4;
     277           0 :   if(cntGlob==0) {fNumOfErr[fDDLNumber][kRawDataSizeErr]++; return kFALSE; }
     278             :   
     279             :   Int_t cnt = cntGlob;
     280             :   Int_t nwSeg;
     281           0 :   Int_t cntSegment;
     282             : 
     283           0 :   if(!GetWord(cnt)) return kFALSE;
     284           0 :   cnt--;
     285             : 
     286           0 :   while (cnt>20) { //counter limit is changed from 0 to 20 to take into account (skip) the 5 extra words in the equipment header
     287           0 :     nwSeg = (fWord >> kbit8) & 0xfff;
     288           0 :     if(!CheckSegment()) return kFALSE; 
     289           0 :     if(!ReadSegment(cntSegment)) return kFALSE;
     290           0 :     AliDebug(1,"ReadCPVRawData(): ReadSegment() passed");
     291           0 :     if(nwSeg != cntSegment) return kFALSE;
     292           0 :     if(!GetWord(cntSegment+1,kBwd)) return kFALSE;
     293           0 :     cnt -= cntSegment+1;
     294             :   }
     295           0 :   return kTRUE;
     296           0 : } // ReadCPVRawData()
     297             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     298             : Bool_t AliPHOSCpvRawStream::ReadSegment(Int_t &cntSegment)
     299             : {
     300             :   //Read the segment
     301             :   //It returns: kFALSE if any error occurs
     302             :   //            kTRUE  if all OK
     303           0 :   cntSegment = (fWord >> kbit8) & 0xfff;
     304             :   Int_t cnt = cntSegment;
     305             :   Int_t cntRow;
     306           0 :   Int_t nwRow;
     307             : 
     308           0 :   if(!GetWord(cnt,kBwd)) return kFALSE;
     309             :   
     310           0 :   while (cnt>0) {
     311             :     //    cntRow  = (fWord >> kbit16) & 0xfff;
     312             :     cntRow = 490;
     313           0 :     if(!CheckRowMarker()) return kFALSE;
     314           0 :     if(!ReadRow(nwRow))   return kFALSE;
     315           0 :     if(nwRow != cntRow) {AliDebug(1,Form("Error in Row counters: %i different wrt %i",nwRow,cntRow)); return kFALSE;}
     316           0 :     if(!GetWord(cntRow+1)) return kFALSE;
     317           0 :     cnt -= cntRow+1;
     318             :   }
     319           0 :   cntSegment -= cnt;
     320           0 :   return kTRUE;
     321           0 : } // ReadSegment()    
     322             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     323             : Bool_t AliPHOSCpvRawStream::ReadRow(Int_t &cntRow)
     324             : {
     325             :   // Read the row
     326             :   //It returns: kFALSE if any error occurs
     327             :   //            kTRUE  if all OK
     328             : 
     329             :   // 3G = 3-gassiplex
     330             :   Int_t cnt;
     331           0 :   Int_t cnt3G;
     332           0 :   Int_t nw3G;
     333             :   
     334             :   //  cntRow  = (fWord >> kbit16) & 0xfff;
     335           0 :   cntRow = 490;
     336             :   cnt = cntRow;  
     337             :   
     338           0 :   if(!GetWord(cntRow)) return kFALSE;
     339             : 
     340           0 :   while (cnt>480) {
     341           0 :     if(!CheckEoE(nw3G)) return kFALSE;
     342           0 :     if(!Read3G(cnt3G)) return kFALSE;
     343           0 :     if(nw3G != cnt3G) {AliDebug(1,Form("Error in 3gassiplex counters: %i different wrt %i",nw3G,cnt3G));return kFALSE;}
     344           0 :     if(!GetWord(1,kBwd)) return kFALSE; // go to next 3gassiplex...
     345           0 :     cnt--;
     346             :   }
     347             :   
     348           0 :   cntRow -= cnt;  
     349           0 :   cntRow += 480;
     350           0 :   return kTRUE;
     351           0 : } // ReadRow()
     352             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     353             : Bool_t AliPHOSCpvRawStream::Read3G(Int_t &cnt3G)
     354             : {
     355             :   // Read the 3gassiplex
     356             :   //It returns: kFALSE if any error occurs
     357             :   //            kTRUE  if all OK
     358             : 
     359           0 :   cnt3G = fWord & 0x7f;
     360             :   
     361             :   Int_t cnt = cnt3G;
     362             : 
     363           0 :   for(Int_t i3G=0; i3G<cnt3G; i3G++) {
     364             :     UInt_t _3G = 0, row = 0;
     365           0 :     if(!GetWord(1,kBwd)) return kFALSE;
     366             :     //check on row number      
     367           0 :     cnt--;
     368           0 :     row = ((fWord >> kbit22) & 0x1f) - 1;
     369           0 :     if(!CheckRow(row)) continue;
     370             :     //check 3gassiplex number     
     371           0 :     _3G = ((fWord >> kbit18) & 0xf) - 1;     //3gassiplex info in raw word is between bits: 18...21
     372           0 :     if(!Check3G(_3G)) continue;
     373             :     //check pad number
     374           0 :     UInt_t pad = (fWord >> kbit12) & 0x3f; //pad info in raw word is between bits: 12...17
     375           0 :     if(!CheckPad(pad)) continue;
     376           0 :     Int_t charge = fWord & 0xfff;
     377           0 :     if(AliPHOSCpvParam::Abs(fDDLNumber,row,_3G,pad)<0) continue;
     378             : 
     379           0 :     fPad[fNPads] = AliPHOSCpvParam::Abs(fDDLNumber,row,_3G,pad);
     380           0 :     fCharge[fNPads] = charge; 
     381           0 :     fNPads++;
     382             :     
     383           0 :     if(charge==0) 
     384             :     {
     385           0 :       AliDebug(1,Form("If PEDESTAL run -> WARNING: ZERO charge is read from DDL: %d row: %d 3G: %d pad: %d",fDDLNumber,row,_3G,pad));
     386           0 :       fNumOfErr[fDDLNumber][kPedQZero]++;
     387           0 :     }
     388             :     
     389           0 :   }//i3G
     390             : 
     391           0 :   cnt3G -= cnt;  
     392           0 :   return kTRUE;  
     393           0 : } // ReadDilogic
     394             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     395             : Bool_t AliPHOSCpvRawStream::CheckSegment()
     396             : {
     397             :   // Check the segment marker
     398             :   // It returns: kFALSE if any error occurs
     399             :   //             kTRUE  if all OK
     400             : 
     401             :   UInt_t markSegment = 0xAB0;
     402           0 :   UInt_t segMarker = (fWord >> kbit20) & 0xfff;
     403             : 
     404           0 :   if (segMarker != markSegment ) {
     405           0 :     AliDebug(1,Form("Segment marker %X wrong (expected %0X)! at %i in word %0X!",segMarker,markSegment,fPosition,fWord));
     406           0 :     fNumOfErr[fDDLNumber][kWrongSegErr]++;
     407           0 :     return kFALSE;
     408             :   }
     409             :   
     410           0 :   UInt_t segAddress = fWord & 0xff;
     411           0 :   if (segAddress<1 ||segAddress>3) {
     412           0 :     AliDebug(1,Form("Segment address %d not in the valid range [1-3]",segAddress));
     413           0 :     fNumOfErr[fDDLNumber][kWrongSegErr]++;
     414           0 :     return kFALSE;
     415             :   }
     416           0 :   return kTRUE;
     417           0 : }
     418             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     419             : Bool_t AliPHOSCpvRawStream::CheckRow(UInt_t row)
     420             : {
     421             :   //check on row number      
     422             :   //It returns: kFALSE if any error occurs
     423             :   //            kTRUE  if all OK
     424           0 :   if(row>=0 && row <AliPHOSCpvParam::kNRows) return kTRUE;
     425           0 :   AliDebug(1,Form("Wrong row index: %d, expected (0 -> %d) word %0X at %i...",row,AliPHOSCpvParam::kNRows-1,fWord,fPosition));
     426           0 :   fNumOfErr[fDDLNumber][kWrongRowErr]++;
     427           0 :   return kFALSE;
     428           0 : }
     429             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     430             : Bool_t AliPHOSCpvRawStream::Check3G(UInt_t _3G)
     431             : {
     432             :   //check 3gassiplex number     
     433             :   //It returns: kFALSE if any error occurs
     434             :   //            kTRUE  if all OK
     435           0 :   if (_3G>= 0 && _3G <AliPHOSCpvParam::kN3GAdd) return kTRUE;
     436           0 :   AliDebug(1,Form("Wrong 3GASSIPLEX index: %d, expected (0 -> %d)!",_3G,AliPHOSCpvParam::kN3GAdd-1));
     437           0 :   fNumOfErr[fDDLNumber][kWrong3GErr]++;
     438           0 :   return kFALSE;
     439           0 : }      
     440             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     441             : Bool_t AliPHOSCpvRawStream::CheckPad(UInt_t pad)
     442             : {
     443             :   //check pad number     
     444             :   //It returns: kFALSE if any error occurs
     445             :   //            kTRUE  if all OK
     446           0 :   if (pad < AliPHOSCpvParam::kNPadAdd) return kTRUE;
     447           0 :   AliDebug(1,Form("Wrong pad index: %d, expected (0 -> %d)!",pad,AliPHOSCpvParam::kNPadAdd - 1));
     448           0 :   fNumOfErr[fDDLNumber][kWrongPadErr]++;
     449           0 :   return kFALSE;
     450           0 : }    
     451             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     452             : Bool_t AliPHOSCpvRawStream::CheckEoE(Int_t &nDil)
     453             : {
     454             :   //check the End of Event
     455             :   // "End of event" is not end of event. It checks subordinate words between 3gassiplex blocks
     456             :   //It returns: kFALSE if any error occurs
     457             :   //            kTRUE  if all OK
     458             : 
     459           0 :   if (!((fWord >> kbit27) & 0x1)) {      //check 27th bit in EoE. It must be 1!
     460           0 :     AliDebug(1,Form("Missing end-of-event flag! (%08X) at %i",fWord,fPosition/4));
     461           0 :     fNumOfErr[fDDLNumber][kEoEFlagErr]++;
     462           0 :     return kFALSE;
     463             :   }
     464           0 :   nDil = fWord & 0x7f;           //nDil=EoE word count
     465           0 :   if(nDil < 0 || nDil > 48 ) { 
     466           0 :     AliDebug(1,Form("Wrong end-of-event word-count: %08X",fWord));
     467           0 :     fNumOfErr[fDDLNumber][kEoESizeErr]++;
     468           0 :     return kFALSE;
     469             :   }
     470           0 :   return kTRUE;
     471           0 : }
     472             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     473             : Bool_t AliPHOSCpvRawStream::CheckRowMarker()
     474             : {
     475             :   //check the row marker
     476             :   //It returns: kFALSE if any error occurs
     477             :   //            kTRUE  if all OK
     478             :   UInt_t nMAXwordsInRow = 0x1EA;
     479             :   UInt_t statusControlRow = 0x32A8; // 0x36A8 for zero suppression
     480             : //First check on row marker    
     481           0 :   UInt_t rowControlWord = fWord >> kbit0 & 0xffff;
     482             : 
     483           0 :   if((fWord >> kbit27) & 0x1) return kTRUE;
     484             : 
     485           0 :   if(rowControlWord != statusControlRow) {
     486           0 :     AliDebug(1,Form("Wrong row marker %x expected 0x32a8!",rowControlWord));
     487           0 :     fNumOfErr[fDDLNumber][kRowMarkerErr]++;
     488           0 :     return kFALSE;
     489             :   }
     490             : 
     491             :   //Second check on row marker    
     492           0 :   UInt_t wordsInRow = fWord >> kbit16 & 0x0fff;    // Number of words after the row marker, bit 10 is skipped in this check
     493             :   
     494           0 :   if (wordsInRow > nMAXwordsInRow) {
     495           0 :     AliDebug(1,Form(" FATAL: Number of words %x in a row exceeds the expected value: 0x1EA !",wordsInRow));
     496           0 :     fNumOfErr[fDDLNumber][kRowMarkerSizeErr]++;
     497           0 :     return kFALSE;
     498             :   }
     499             :   
     500           0 :   return kTRUE;
     501           0 : }
     502             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     503             : Bool_t AliPHOSCpvRawStream::GetWord(Int_t n,EDirection dir)
     504             : {
     505             :   // This method returns the n-th 32 bit word
     506             :   // inside the raw data payload.
     507             :   // The method is supposed to be platform independent.
     508             :   
     509           0 :   fWord = 0;
     510           0 :   if (fPosition < 0) {
     511           0 :     AliError("fPosition < 0 !!! Event skipped.");
     512           0 :     fRawReader->AddMajorErrorLog(kRawDataSizeErr,"fPosition<0");
     513           0 :     return kFALSE;
     514             :   }
     515             : 
     516           0 :   if(dir==kBwd) n = -n; 
     517           0 :   fPosition += 4*n-4;
     518             : 
     519           0 :   if(fPosition == -4) return kTRUE;
     520             :   
     521           0 :   if(fPosition<0 || fPosition > fRawReader->GetDataSize()) {
     522           0 :     AliWarning(Form("fPosition out of boundaries %i",fPosition));
     523           0 :     return kFALSE;
     524             :   }
     525             :     
     526           0 :   StorePosition();
     527             :   
     528           0 :   fWord |= fData[fPosition++];
     529           0 :   fWord |= fData[fPosition++] << 8;
     530           0 :   fWord |= fData[fPosition++] << 16;
     531           0 :   fWord |= fData[fPosition++] << 24;
     532             : 
     533           0 :   return kTRUE;
     534           0 : }
     535             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     536             : void AliPHOSCpvRawStream::DumpData(Int_t nw)
     537             : {
     538             :   //just a simple raw data dump
     539             :   // in () is the position in bytes
     540             :   //--
     541           0 :    for(Int_t i=0;i<nw;i+=4) {
     542           0 :      if(!(i%16)) printf(" \n %8i) ",i);
     543           0 :      printf("%02X%02X%02X%02X [ %06i ] ",fData[i+3],fData[i+2],fData[i+1],fData[i+0],fPos[i]);
     544             :    }
     545           0 :    Printf(" \n -----end of dump ----------- ");
     546           0 : }
     547             : //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     548             : void AliPHOSCpvRawStream::StorePosition()
     549             : {
     550             :   //just for debug purpose
     551             :   // it stores the position
     552             :   //read for the first time
     553             : //  Printf("@@@@@@@@@ fPos: %x fPosition: %d",fPos,fPosition);
     554           0 :   if(fPos[fPosition]!=0) {
     555             : //    Printf("Position already stored!!! Value %i at address %i",fPos[fPosition],fPosition); 
     556             :     return;
     557             :   }
     558           0 :   fiPos++;
     559           0 :   fPos[fPosition] = fiPos;
     560             : //  if(stDeb)Printf("%i - Actual position %i",iPos,fPosition); 
     561           0 : }

Generated by: LCOV version 1.11