LCOV - code coverage report
Current view: top level - HMPID/HMPIDbase - AliHMPIDRawStream.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 89 123 72.4 %
Date: 2016-06-14 17:26:59 Functions: 12 32 37.5 %

          Line data    Source code
       1             : #ifndef ALIHMPIDRAWSTREAM_H
       2             : #define ALIHMPIDRAWSTREAM_H
       3             : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       4             :  * See cxx source for full Copyright notice                               */
       5             : 
       6             : ///////////////////////////////////////////////////////////////////////////////
       7             : ///
       8             : /// This is a class for reading raw data digits for HMPID.
       9             : /// The data format is taken from the document provided by Paolo Martinengo.
      10             : ///
      11             : /// cvetan.cheshkov@cern.ch 19/07/2007
      12             : ///
      13             : ///////////////////////////////////////////////////////////////////////////////
      14             : 
      15             : #include <TObject.h>
      16             : #include <TH1F.h>
      17             : #include <TH2F.h>
      18             : #include <TFile.h>
      19             : #include "AliHMPIDParam.h"
      20             : #include <AliBitPacking.h>
      21             : #include <AliFstream.h>
      22             : #include "AliHMPIDDigit.h"
      23             : #include "AliDAQ.h"
      24             : #include "AliRawDataHeaderSim.h"
      25             : 
      26             : class AliRawReader;
      27             : 
      28             : class AliHMPIDRawStream: public TObject {
      29             :   public :
      30             :     AliHMPIDRawStream(AliRawReader* rawReader);
      31             :     AliHMPIDRawStream();
      32             :     
      33             :     virtual ~AliHMPIDRawStream();
      34             : 
      35             :     virtual void     Reset();
      36             :     virtual Bool_t   Next();
      37             :             void     InitVars(Int_t n);
      38             :             void     DelVars();
      39             :     
      40             :    static  inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad);               //get absolute pad number
      41             :    static  inline Int_t GetFee(Int_t ddl,Int_t row);                                   //get the FEE number
      42           0 :    static  Int_t GetNDDL()     { return kNDDL;}                                        //return the number of max # of DDLs
      43           0 :    static  Int_t GetNErrors()  { return kSumErr;}                                      //return the number of max # of Error Types
      44             : 
      45        1174 :             Int_t   GetNPads()         const { return fNPads;}                         //Get number of pads present in the stream
      46        1062 :             Int_t*  GetPadArray()      const { return fPad;}                           //Get pad array from stream decoded
      47        1062 :             Int_t*  GetChargeArray()   const { return fCharge;}                        //Get the charge of the pads from dedcoded stream 
      48           0 :             Int_t*  GetnDDLInStream()  const { return fnDDLInStream;}                  //Get the DDL input check array
      49           0 :             Int_t*  GetnDDLOutStream() const { return fnDDLOutStream;}                 //Get the DDL output check array
      50           0 :             Int_t   Pc          ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2P(GetPad(ddl,row,dil,pad));}                                                 //PC position number
      51           0 :             Int_t   PadPcX      ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2X(GetPad(ddl,row,dil,pad));}                                                 //pad pc x # 0..79
      52           0 :             Int_t   PadPcY      ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2Y(GetPad(ddl,row,dil,pad));}                                                 //pad pc y # 0..47
      53             : 
      54             :     static inline const Char_t* GetErrName(Int_t eType);      
      55             :     inline  Bool_t SetZeroSup (Bool_t isSup);
      56             :     inline  Bool_t GetZeroSup()const; 
      57             :     inline  Int_t  GetErrors(Int_t ddl,Int_t eType)const;                                                                                   //Get errors and occurance
      58         112 :     Int_t  GetDDLNumber() const{ return fDDLNumber;} //return the number of DDL actually being decoded
      59           0 :     UInt_t GetLDCNumber() const{ return fLDCNumber;} //return the number of LDC actually being decoded
      60           0 :     UInt_t GetTimeStamp() const{ return fTimeStamp;} //return the time stamp of the event actually being decoded
      61             : 
      62           0 :     void   SetTurbo(Bool_t isTurbo){fTurbo=isTurbo;}     // Enable/Disable Turbo
      63           0 :     Bool_t GetTurbo(){ return fTurbo;}                   // Enable Turbo
      64             :     Bool_t Turbo();                                      // Read HMPID Raw data without error checks
      65             :     Bool_t ReadHMPIDRawData();                           // Read HMPID Raw data
      66             :     Bool_t ReadSegment(Int_t &cntSegment);               // Read Segment
      67             :     Bool_t ReadRow(Int_t &cntRow);                       // Read Row
      68             :     Bool_t ReadDilogic(Int_t &cntDilogic);               // Read Dilogic
      69             : 
      70             :     Bool_t CheckRow(UInt_t row);                         // Check Row
      71             :     Bool_t CheckDilogic(UInt_t dilogic);                 // Check Dilogic
      72             :     Bool_t CheckPad(UInt_t pad);                         // Check pad
      73             :     Bool_t CheckEoE(Int_t &nDil);                        // Check EoE
      74             :     Bool_t CheckRowMarker();                             // Check RowMarker
      75             :     Bool_t CheckSegment();                               // Check Segment
      76             :     void   DumpData(Int_t nw);                           // Dump Data
      77             :     void   StorePosition();                              //Debug purpose
      78             :     
      79           0 :     Double_t GetDdlDataSize()      { return 4.0*fRawDataSize;} //returns the data size for the DDL which is decoded in Next(); fRawDataSize = Bytes/4  
      80             :     
      81             : //    inline void    Raw            (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a);                                              //digit->(w32,ddl,r,d,a)
      82             : //    inline void    Raw            (Int_t ddl,Int_t r,Int_t d,Int_t a);                                                              //raw->abs pad number
      83             : //    inline Bool_t  Raw            (UInt_t  w32,Int_t  ddl,AliRawReader *pRR);                                                       //(w32,ddl)->digit
      84             : 
      85             :     inline void   WriteRaw       (TObjArray *pDigLst                             );                 //write as raw stream     
      86             :     inline void   WriteRowMarker  (AliFstream *ddl,UInt_t size);                                    //write row marker in simulation
      87             :     inline void   WriteEoE        (AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt);           //write Enf Of Event word in simulation
      88             :     inline void   WriteSegMarker  (AliFstream *ddl,UInt_t row, Int_t nwInSeg);                      //write Segment Marker word in simulation
      89             :     inline void   Write5FirmwareWords(AliFstream *ddl);                                             //write the firmware control words in simulation
      90             :     
      91             : //    inline TClonesArray  ReMap(TClonesArray *pDigIn);
      92             : enum EDirection {kFwd,kBwd};
      93             : 
      94             : enum Ebits {kbit0,kbit1 , kbit2, kbit3, kbit4, kbit5, kbit6, kbit7, kbit8,
      95             :                   kbit9 ,kbit10,kbit11,kbit12,kbit13,kbit14,kbit15,kbit16,
      96             :                   kbit17,kbit18,kbit19,kbit20,kbit21,kbit22,kbit23,kbit24,
      97             :                   kbit25,kbit26,kbit27,kbit28,kbit29,kbit30,kbit31,kbit32};
      98             :     
      99             :   enum EHMPIDRawStreamError { kRawDataSizeErr   = 0,  kRowMarkerErr     = 1,  kWrongRowErr      = 2,  kWrongDilogicErr  = 3,
     100             :                               kWrongPadErr      = 4,  kEoEFlagErr       = 5,  kEoESizeErr       = 6,  kEoEDILOGICErr    = 7,
     101             :                               kEoERowErr        = 8,  kBadSegWordErr    = 9,  kWrongSegErr      = 10, kRowMarkerSizeErr = 11,
     102             :                               kPedQZero         =12,  kSumErr           = 13  //This is always the last one, to retreive the number of errors
     103             :                             };                        //Always check the updated list of names in the .cxx file for print-out!
     104             :    
     105             :   enum {
     106             :       kNRows       = 24,                                    // Number of rows (starting from 1 !)//was25
     107             :       kNDILOGICAdd = 10,                                    // Number of DILOGIC addresses in a row (starting from 1 !) //was11
     108             :       kNPadAdd     = 48,                                    // Number of pad row
     109             :       kNRowsPerSegment = 8,                                 // Number of rows per segment
     110             :       kNDDL = 14
     111             :     };
     112             :  enum EHMPIDRawError {
     113             :     kInvalidRawDataWord = 1
     114             :   };
     115             : 
     116             :     
     117             :   private :
     118             : 
     119             :     AliHMPIDRawStream& operator = (const AliHMPIDRawStream& stream);
     120             :     AliHMPIDRawStream(const AliHMPIDRawStream& stream);
     121             : 
     122             :     Bool_t           GetWord(Int_t n=1,EDirection dir=kFwd);             // Get n-th word
     123             :     UInt_t           GetNextWord();                                      // Get next word
     124             :     Int_t            fNPads;                                             // counter of pads in one DDL
     125             :     Int_t           *fCharge;                                            // Array for charge values for all channels in one DDL
     126             :     Int_t           *fPad;                                               // Array for abs pad values for all channels in one DDL
     127             :     Int_t            fDDLNumber;                                         // index of current DDL number
     128             :     Int_t           *fnDDLInStream;                                      // if the DDL is in the raw data
     129             :     Int_t           *fnDDLOutStream;                                     // if the DDL is in the raw data
     130             :     UInt_t           fLDCNumber;                                         // index of current LDC number
     131             :     UInt_t           fTimeStamp;                                         // TimeStamp
     132             :     AliRawReader    *fRawReader;                                         // object for reading the raw data
     133             :     UChar_t         *fData;                                              // raw data
     134             :     Int_t          **fNumOfErr;                                          // Store the numner of errors for a given error type and a given DDL
     135             :     Int_t            fPosition;                                          // current word
     136             :     UInt_t           fWord;                                              // current position in fData
     137             :     Bool_t           fZeroSup;                                           // set if zero suppression is applied
     138             :     Int_t           *fPos;                                               // for debug purposes
     139             :     Int_t            fiPos;                                              // counter for debug
     140             :     Bool_t           fTurbo;                                             // kTRUE = Turbo decoding is called. DEFAULT: kFALSE = normal decoding is called
     141             :     Int_t            fRawDataSize;
     142         376 :     ClassDef(AliHMPIDRawStream, 4)                                       // base class for reading HMPID raw digits
     143             : };
     144             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     145             :     /*
     146             : void AliHMPIDRawStream::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)
     147             : {
     148             : // Convert raw stream word to raw word format
     149             : // Arguments: w32,ddl,r,d,a where to write the results
     150             : // Returns: none
     151             :   Int_t y2a[6]={5,3,1,0,2,4};
     152             :   
     153             :   ddl=2*Ch(ddl,r,d,a)+Pc(ddl,r,d,a)%2;                                                          //DDL# 0..13
     154             :   Int_t tmp=1+Pc(ddl,r,d,a)/2*8+PadPcY(ddl,r,d,a)/6;  r=(Pc(ddl,r,d,a)%2)? 25-tmp:tmp;              //row r=1..24
     155             :   d=1+PadPcX(ddl,r,d,a)/8;                                                                  //DILOGIC# 1..10
     156             :   a=y2a[PadPcY(ddl,r,d,a)%6]+6*(PadPcX(ddl,r,d,a)%8);                                           //ADDRESS 0..47        
     157             :   
     158             :   w32=0;    
     159             :   AliBitPacking::PackWord((fCharge[fNPads]>4095)?4095:(UInt_t)fCharge[fNPads],w32, 0,11);       // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq        Qdc               bits (00..11) counts (0..4095)
     160             :   //molnarl: Since in simulation the the charge can be > than 4095 but not in real life we need to protect. If fQ>4095 after packing we will get 0 for the charge! 
     161             :   assert(0<=a&&a<=47);AliBitPacking::PackWord(        a ,w32,12,17);  // 3322 2222 2222 1111 1111 1000 0000 0000        DILOGIC address   bits (12..17) counts (0..47)
     162             :   assert(1<=d&&d<=10);AliBitPacking::PackWord(        d ,w32,18,21);  // 1098 7654 3210 9876 5432 1098 7654 3210        DILOGIC number    bits (18..21) counts (1..10)
     163             :   assert(1<=r&&r<=24);AliBitPacking::PackWord(        r ,w32,22,26);  //                                                Row number        bits (22..26) counts (1..24)  
     164             : }
     165             : */
     166             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     167             :     /*
     168             : Int_t AliHMPIDRawStream::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
     169             : {
     170             :   //Assign absolute pad ID based on ddl,row,dil,pad
     171             :   //Arguments: DDL, row number, dilogic number, dilogic address(pad)
     172             :   //Returns  : nothing
     173             : 
     174             :   assert(0<=ddl&&ddl<=13); assert(1<=r&&r<=24); assert(1<=d&&d<=10);   assert(0<=a&&a<=47);  
     175             :   Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip)
     176             :                                   Int_t ch=ddl/2;
     177             :   Int_t tmp=(r-1)/8;              Int_t pc=(ddl%2)? 5-2*tmp:2*tmp; 
     178             :                                   Int_t px=(d-1)*8+a/6;
     179             :         tmp=(ddl%2)?(24-r):r-1;   Int_t py=6*(tmp%8)+a2y[a%6];
     180             :   return AliHMPIDParam::Abs(ch,pc,px,py);
     181             : }
     182             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     183             : Bool_t AliHMPIDRawStream::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR)
     184             : {
     185             : // Converts a given raw data word to a digit
     186             : // Arguments: w32 - 32 bits raw data word
     187             : //            ddl - DDL idx  0 1 2 3 4 ... 13
     188             : //   Returns: none
     189             :   Int_t r = AliBitPacking::UnpackWord(w32,22,26); assert(1<=r&&r<=24);   //                                         Row number      (1..24)    
     190             :   Int_t d = AliBitPacking::UnpackWord(w32,18,21); assert(1<=d&&d<=10);   // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC number  (1..10)
     191             :   Int_t a = AliBitPacking::UnpackWord(w32,12,17); assert(0<=a&&a<=47);   // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC address (0..47)  
     192             :   Int_t q = AliBitPacking::UnpackWord(w32, 0,11); assert(0<=q&&q<=4095); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc             (0..4095) 
     193             :   if (r<1 || r>24 || d<1 || d>10 || a<0 || a>47 || q<0 || q>4095) {
     194             :     AliWarning(Form("Invalid raw data word %x",w32));
     195             :     pRR->AddMajorErrorLog(kInvalidRawDataWord,Form("w=%x",w32));
     196             :     return kFALSE;
     197             :   }
     198             :   Raw(ddl,r,d,a);
     199             :   fCharge[ddl][r][d][a]=q;
     200             :   return kTRUE;
     201             : }
     202             : */
     203             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     204             : Int_t AliHMPIDRawStream::GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad)
     205             : {
     206             :   // The method returns the absolute pad number or -1 
     207             :   // in case the charge from the channels
     208             :   // has not been read or invalid arguments
     209             :  
     210             :  
     211        2124 :   if(ddl<0 || ddl >13 || row<1 || row >25 || dil<1 || dil >10 || pad<0 || pad >47 ) return -1;
     212        1062 :   Int_t a2y[6]={3,2,4,1,5,0};     //pady for a given padress (for single DILOGIC chip)
     213        1062 :   Int_t ch=ddl/2;
     214        1062 :   Int_t tmp=(24-row)/8;
     215        1062 :   Int_t pc=(ddl%2)?5-2*tmp:2*tmp;
     216        1062 :   Int_t px=(kNDILOGICAdd+1 - dil)*8-pad/6-1;  //flip according to Paolo (2-9-2008)
     217             : 
     218        1062 :   tmp=(ddl%2)?row-1:(24-row);
     219        1062 :   Int_t py=6*(tmp%8)+a2y[pad%6];
     220             : 
     221        1062 :   return AliHMPIDParam::Abs(ch,pc,px,py);
     222        2124 : }//GetPad()
     223             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     224             : Int_t AliHMPIDRawStream::GetFee(Int_t ddl,Int_t row)
     225             : {
     226             :    // The method returns the FEE number or -1 
     227             :    // in case of invalid argument(s)
     228             :  
     229           0 :    if(ddl<0 || ddl >13 || row<1 || row >25  ) return -1;
     230             :    Int_t fee=-1, kLeft=0, kRight=0;
     231           0 :    if(ddl%2==0) {kLeft=1;kRight=0;}
     232           0 :    if(ddl%2!=0) {kLeft=0;kRight=1;}
     233           0 :    if((kLeft==1 && row<=24 && row>=21) || (kRight==1 && row<=4  && row>=1)) fee=0;    //calculation of FEE values based on Giacomos pedestal macro
     234           0 :    if((kLeft==1 && row<=20 && row>=17) || (kRight==1 && row<=8  && row>=5)) fee=1;
     235           0 :    if((kLeft==1 && row<=16 && row>=13) || (kRight==1 && row<=12 && row>=9)) fee=2;
     236           0 :    if((kLeft==1 && row<=12 && row>=9)  || (kRight==1 && row<=16 && row>=13))fee=3;
     237           0 :    if((kLeft==1 && row<=8  && row>=5)  || (kRight==1 && row<=20 && row>=17))fee=4;
     238           0 :    if((kLeft==1 && row<=4  && row>=1)  || (kRight==1 && row<=24 && row>=21))fee=5;
     239             :    return fee;
     240           0 : }
     241             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     242             : void AliHMPIDRawStream::WriteRowMarker(AliFstream *ddl,UInt_t size)
     243             : {
     244             :   //Writes the row marker for real data and pedestal into the ddl stream
     245             :   //Arguments: ddl stream and the size of the block of the given row, the siye is at least the 10 EoE words!
     246             :   //Returns:   nothing
     247        5376 :   UInt_t w32=0;
     248             :   UInt_t marker=13992;                                   //for pedestal=12968  ==  32a8 for zero suppressed 36a8
     249        2688 :   AliBitPacking::PackWord(size,  w32, 16,31);            //number of roaw written after row marker (digits and EoE)
     250        2688 :   AliBitPacking::PackWord(marker,w32,0,15);              //the marker word
     251        2688 :   ddl->WriteBuffer((char*)&w32,sizeof(w32));              
     252        2688 : }
     253             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     254             : void AliHMPIDRawStream::WriteEoE(AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt  )
     255             : {
     256             :   //Writes the EoE word from real data and pedestals into the ddl stream
     257             :   //Arguments:  ddl stream, row number, dilogic number and the number of words before the EoE
     258             :   //Retursns:   nothing
     259             :   UInt_t e=1;
     260       26880 :   UInt_t w32=0;
     261       26880 :   assert(1<=row&&row<=24);      AliBitPacking::PackWord((UInt_t)row     ,w32,22,26);    // row number (1...24)
     262       26880 :   assert(1<=dil&&dil<=10);      AliBitPacking::PackWord((UInt_t)dil     ,w32,18,21);    // DILOGIC number (1...10)
     263       13440 :                                 AliBitPacking::PackWord(          e     ,w32, 7,17);   // event number -- not used
     264       13440 :                                 AliBitPacking::PackWord((UInt_t)wordCnt ,w32, 0, 6);  // word counter (0...47)                                                                  AliBitPacking::PackWord((UInt_t)1       ,w32,27,27);  // bit 27 is always 1 by definition of EoE
     265       13440 :                                 AliBitPacking::PackWord((UInt_t)1       ,w32,27,27);  // bit 27 is always 1 by definition of EoE    
     266       13440 :   ddl->WriteBuffer((char*)&w32,sizeof(w32));      
     267       13440 : } 
     268             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     269             : void AliHMPIDRawStream::WriteSegMarker(AliFstream *ddl,UInt_t row, Int_t nwInSeg)
     270             : {
     271             :   //Writes the segment marker (after 8 rows) into the ddl stream
     272             :   //Arguments: ddl stream and the segment: row 8 -> 0x5800, row 16 -> 5801, row 24 -> 5802 for pedestal
     273             :   //Retruns:   nothing
     274         336 :     UInt_t w32=0;
     275             : 
     276             :       //Segment marker: 2736 == ab0
     277             :       //AliBitPacking::PackWord((UInt_t)0   ,w32,27,31);          //zero out the rest of the bits, since they are not needed
     278         168 :       AliBitPacking::PackWord((UInt_t)2736   ,w32,20,31);       //ab0 the segment marker word
     279         168 :       AliBitPacking::PackWord((UInt_t)nwInSeg,w32, 8,19);       //number of words in the segment
     280         168 :       AliBitPacking::PackWord((UInt_t)(row/8),w32, 0, 7);       //segment 0,1,2    
     281         168 :       ddl->WriteBuffer((char*)&w32,sizeof(w32)); 
     282             :       //Printf("Segment word created is: %x",w32);
     283         168 : }      
     284             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     285             : void AliHMPIDRawStream::Write5FirmwareWords(AliFstream *ddl)
     286             : {
     287             :   //Before each DDL payload 5 words are written: 
     288             :   // 1.) Firmware version,              for sim = 999
     289             :   // 2.) Status and error bits from CD, for sim = 0
     290             :   // 3.) # FEE RESET received         , for sim = 0
     291             :   // 4.) # TTC READY                  , for sim = 0  
     292             :   // 5.) Spare/Reserved               , for sim = 0
     293             :   //Returns:   nothing
     294         112 :   UInt_t w32=0;
     295          56 :   AliBitPacking::PackWord((UInt_t)999,w32,0,31); ddl->WriteBuffer((char*)&w32,sizeof(w32));              
     296          56 :   AliBitPacking::PackWord((UInt_t) 10,w32,0,31); ddl->WriteBuffer((char*)&w32,sizeof(w32));              
     297          56 :   AliBitPacking::PackWord((UInt_t) 11,w32,0,31); ddl->WriteBuffer((char*)&w32,sizeof(w32));              
     298          56 :   AliBitPacking::PackWord((UInt_t) 12,w32,0,31); ddl->WriteBuffer((char*)&w32,sizeof(w32));              
     299          56 :   AliBitPacking::PackWord((UInt_t) 13,w32,0,31); ddl->WriteBuffer((char*)&w32,sizeof(w32));              
     300             :   
     301          56 : }
     302             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     303             : Bool_t AliHMPIDRawStream::SetZeroSup (Bool_t isSup)
     304             : {
     305             :   //Prevision to turn OFF zero suppression
     306             :   //Arguments: setter
     307             :   //Returns:   switch
     308           0 :   fZeroSup=isSup;
     309           0 :   return fZeroSup;
     310             : }
     311             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     312             : Bool_t AliHMPIDRawStream::GetZeroSup()const
     313             : {
     314           0 :   if(fZeroSup==kTRUE) return kTRUE;
     315           0 :   else                return kFALSE;
     316           0 : }
     317             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     318             : void AliHMPIDRawStream::WriteRaw(TObjArray *pDigAll)
     319             : {
     320             : // Write a list of digits for a given chamber in raw data stream
     321             : // Arguments: pDigAll- list of digits 
     322             : //   Returns: none      
     323           8 :   Int_t  ddl,r,d,a;            //32 bits data word 
     324             :   Int_t  cntLpad,cntRpad;
     325             :   Int_t  cntLrow,cntRrow;
     326             :   Int_t  cntL=0,cntR=0;                           //data words counters for DDLs
     327             :   Int_t  cntLeoe,cntReoe;
     328             :   UInt_t posL,posR;
     329             :   UInt_t cntLseg,cntRseg;
     330             :   UInt_t cntwInLseg=0,cntwInRseg=0;
     331             :   Int_t  cntRdig=0,cntLdig=0;
     332             :   
     333             :   UInt_t posLmarker,posRmarker;
     334             :   //  Int_t digcnt=0;
     335             : 
     336           4 :   Int_t isDigThere[14][25][11][48];
     337             :   
     338          64 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
     339             :     cntL=0;cntR=0;   
     340         840 :     for(Int_t iddl=0;iddl<14;iddl++){
     341       19600 :       for(Int_t irow=1;irow<=24;irow++){
     342      206976 :         for(Int_t idil=1;idil<=10;idil++){
     343     9219840 :           for(Int_t ipad=0;ipad<48;ipad++){
     344     4515840 :             isDigThere[iddl][irow][idil][ipad]=-1;
     345             :           }
     346             :         }
     347             :       }
     348             :     }
     349             :     
     350             :     AliFstream* ddlL;                                 //output streams, 2 per chamber
     351             :     AliFstream* ddlR;                          
     352             :     
     353          28 :     AliRawDataHeaderSim header; header.SetAttribute(0);  //empty DDL header
     354             :     
     355          56 :     ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1)); //left and right looking at the IP
     356          56 :     ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh));   //open both DDL of this chamber in parallel
     357             :     
     358          28 :     ddlL->WriteBuffer((char*)&header,sizeof(header));            //write dummy header as place holder, actual 
     359          28 :     ddlR->WriteBuffer((char*)&header,sizeof(header));            //will be rewritten later when total size of DDL is known
     360             :     
     361          28 :     UInt_t w32=0;                 //32 bits data word 
     362             :     //    digcnt=0;
     363             :     
     364             :     //added frimware control words
     365          28 :     Write5FirmwareWords(ddlL);  cntL+=5;
     366          28 :     Write5FirmwareWords(ddlR);  cntR+=5;
     367             :    
     368             :     
     369          28 :     TClonesArray *pDigCh=(TClonesArray *)pDigAll->At(iCh); //list of digits for current chamber 
     370             :    
     371        1118 :     for(Int_t iDig=0;iDig<pDigCh->GetEntriesFast();iDig++){//digits loop
     372         531 :       AliHMPIDDigit *pDig1=(AliHMPIDDigit*)pDigCh->At(iDig);
     373         531 :       pDig1->Raw(w32,ddl,r,d,a);  //??????????
     374         531 :       isDigThere[ddl][r][d][a]=iDig;
     375             :     }  
     376             :     
     377        1400 :     for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){ //AliHMPIDRawStream::kNRows=25!
     378             :       cntRrow=0;cntLrow=0;cntLseg=0;cntRseg=0;// 
     379             :       cntLeoe=0;cntReoe=0;
     380         672 :       posLmarker=ddlL->Tellp(); WriteRowMarker(ddlL,(UInt_t)1);   cntL++; cntRrow++; cntwInRseg++;
     381         672 :       posRmarker=ddlR->Tellp(); WriteRowMarker(ddlR,(UInt_t)1);   cntR++; cntLrow++; cntwInLseg++;
     382       14784 :       for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){ //AliHMPIDRawStream::kNDILOGICAdd = 11!
     383             :         cntLpad=0;cntRpad=0;
     384      658560 :         for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){   //AliHMPIDRawStream::kNPadAdd     = 48
     385     1935360 :           for ( Int_t iddl=2*iCh; iddl<=2*iCh+1;iddl++){
     386      645120 :             if (isDigThere[iddl][row][dil][pad]!=-1) {
     387         531 :               AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCh->At(isDigThere[iddl][row][dil][pad]);             
     388         531 :               pDig->Raw(w32,ddl,r,d,a);  
     389         531 :               if(pDig->Q() < 0 ) continue;                                                 //We can turn of the zero sup for pedestal simulation
     390         531 :                 if(ddl%2){                                                                               //write raw digit selecting on DDL
     391         131 :                 ddlL->WriteBuffer((char*)&w32,sizeof(w32));   cntL++; cntLpad++; cntLrow++;  cntLdig++; cntwInLseg++;//Printf(" WL: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]);
     392         131 :               }else{
     393         400 :                 ddlR->WriteBuffer((char*)&w32,sizeof(w32));   cntR++; cntRpad++; cntRrow++;   cntRdig++;cntwInRseg++;//Printf(" WR: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]);
     394             :               }
     395         531 :             }//ddl 
     396             :           }//isDig
     397             :         }//pad
     398        6720 :         WriteEoE(ddlL,row,dil,cntLpad); cntL++;  cntLrow++;    cntLeoe++;   cntwInLseg++;                              //molnarl: write EoE markers
     399        6720 :         WriteEoE(ddlR,row,dil,cntRpad); cntR++;  cntRrow++;    cntReoe++;   cntwInRseg++;
     400             :       }//dil
     401         672 :       if(row%8==0){                                               
     402          84 :         WriteSegMarker(ddlL,row,cntwInLseg); cntL++;  cntLseg++; cntwInLseg=0;
     403          84 :         WriteSegMarker(ddlR,row,cntwInRseg); cntR++;  cntRseg++;  cntwInRseg=0; 
     404          84 :       }
     405         672 :       posL=ddlL->Tellp();   ddlL->Seekp(posLmarker);    WriteRowMarker(ddlL,(UInt_t)(cntLrow-1)); ddlL->Seekp(posL);      //find the marker position write and  go back to the actual position to continue writing                    
     406         672 :       posR=ddlR->Tellp();   ddlR->Seekp(posRmarker);    WriteRowMarker(ddlR,(UInt_t)(cntRrow-1)); ddlR->Seekp(posR);                           
     407             :     }//row
     408          56 :     header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL->Seekp(0); ddlL->WriteBuffer((char*)&header,sizeof(header)); delete ddlL; //rewrite header with size set to
     409          56 :     header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR->Seekp(0); ddlR->WriteBuffer((char*)&header,sizeof(header)); delete ddlR; //number of bytes and close file
     410             :     
     411             :     //Printf("In Ch %d # digits written to LDD %d RDDL %d",iCh,cntLdig,cntRdig);
     412             :     
     413          28 :   }//chambers loop
     414           4 : }//WriteRaw()
     415             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     416             : Int_t AliHMPIDRawStream::GetErrors(Int_t ddl,Int_t eType)const
     417             : {
     418             : // Return the number of errors for a given error tye during raw data reading
     419             : // Arguments: errorType
     420             : // Returns: error or -999 if error Type does not exist
     421             :   
     422           0 :   if(eType < 0 || eType> kSumErr ||  ddl < 0 || ddl > kNDDL-1 ) return -999;
     423           0 :   else return fNumOfErr[ddl][eType];
     424           0 : } //GetErrors()     
     425             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     426             : const Char_t* AliHMPIDRawStream::GetErrName(Int_t eType)
     427             : {
     428             :   // Return the name of the error for a given error tye during raw data reading
     429             :   // Arguments: errorType
     430             :   // Returns: error or -999 if error Type does not exist
     431           0 :   const Char_t *eName[]={ "kRawDataSizeErr",  "kRowMarkerErr" , "kWrongRowErr" , "kWrongDilogicErr",
     432             :                     "kWrongPadErr"   ,  "kEoEFlagErr"   , "kEoESizeErr"  , "kEoEDILOGICErr",
     433             :                     "kEoERowErr"     ,  "kBadSegWordErr", "kWrongSegErr" , "kRowMarkerSizeErr",
     434             :                     "kPedQZero"      ,  "kSumErr"        };                       
     435             :   const Char_t *eNoErr="NotDefinedErrorType";
     436           0 :   if(eType<0 || eType>kSumErr) return eNoErr;
     437           0 :   else                         return eName[eType];
     438           0 : }//GetErrName()
     439             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     440             :     
     441             :     
     442             :     
     443             : #endif

Generated by: LCOV version 1.11