]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Update of raw data simulation by WooJin
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Jan 2009 14:44:09 +0000 (14:44 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Jan 2009 14:44:09 +0000 (14:44 +0000)
TRD/AliTRDmcmSim.cxx
TRD/AliTRDmcmSim.h
TRD/AliTRDrawData.cxx
TRD/AliTRDrawData.h
TRD/AliTRDrawStream.cxx
TRD/AliTRDrawStream.h
TRD/AliTRDrawStreamBase.cxx

index 17c403e29618d1916544ddbc2366a23ba251b507..264efaa6c031e8da57b8465f1cc0265fd6c4d3d5 100644 (file)
@@ -610,7 +610,7 @@ Int_t AliTRDmcmSim::ProduceRawStream( UInt_t *buf, Int_t maxSize )
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDmcmSim::ProduceRawStreamV2( UInt_t *buf, Int_t maxSize )
+Int_t AliTRDmcmSim::ProduceRawStreamV2( UInt_t *buf, Int_t maxSize, UInt_t iEv )
 {
   //
   // Produce raw data stream from this MCM and put in buf
@@ -619,7 +619,7 @@ Int_t AliTRDmcmSim::ProduceRawStreamV2( UInt_t *buf, Int_t maxSize )
   //
 
   UInt_t  x;
-  UInt_t  iEv = 0;
+  //UInt_t  iEv = 0;
   Int_t   nw  = 0;  // Number of written words
   Int_t   of  = 0;  // Number of overflowed words
   Int_t   rawVer   = fFeeParam->GetRAWversion();
@@ -634,8 +634,13 @@ Int_t AliTRDmcmSim::ProduceRawStreamV2( UInt_t *buf, Int_t maxSize )
     adc = fADCF;
   }
 
-  // Produce MCM header
-  x = (1<<31) | ((fRobPos * fFeeParam->GetNmcmRob() + fMcmPos) << 24) | ((iEv % 0x100000) << 4) | 0xC;
+  // Produce MCM header : xrrr mmmm eeee eeee eeee eeee eeee 1100
+  //                      x : 0 before , 1 since 10.2007
+  //                      r : Readout board position (Alice numbering)
+  //                      m : MCM posi
+  //                      e : Event counter from 1
+  //x = (1<<31) | ((fRobPos * fFeeParam->GetNmcmRob() + fMcmPos) << 24) | ((iEv % 0x100000) << 4) | 0xC;
+  x = (1<<31) | (fRobPos << 28) | (fMcmPos << 24) | ((iEv % 0x100000) << 4) | 0xC;
   if (nw < maxSize) {
     buf[nw++] = x;
        //printf("\nMCM header: %X ",x);
@@ -673,7 +678,7 @@ Int_t AliTRDmcmSim::ProduceRawStreamV2( UInt_t *buf, Int_t maxSize )
 
   for (Int_t iAdc = 0; iAdc < 21; iAdc++ ) {
     if( rawVer>= 3 && fZSM1Dim[iAdc] != 0 ) continue; // Zero Suppression, 0 means not suppressed
-    aa = !(iAdc & 1) + 2;
+    aa = !(iAdc & 1) + 2;      // 3 for the even ADC channel , 2 for the odd ADC channel
     for (Int_t iT = 0; iT < fNTimeBin; iT+=3 ) {
       a1 = ((iT    ) < fNTimeBin ) ? adc[iAdc][iT  ] : 0;
       a2 = ((iT + 1) < fNTimeBin ) ? adc[iAdc][iT+1] : 0;
index 1994e8dd89d081a5addc491350bc73b7916c187f..5422768dc4991fa2ac427edf64fc86c286e2cfc3 100644 (file)
@@ -48,7 +48,7 @@ class AliTRDmcmSim : public TObject {
          Int_t*    GetPosLUT();
 
          Int_t     ProduceRawStream( UInt_t *buf, Int_t bufsize );   // Produce raw data stream from this MCM - old
-         Int_t     ProduceRawStreamV2( UInt_t *buf, Int_t bufsize ); // Produce raw data stream - Read data format
+         Int_t     ProduceRawStreamV2( UInt_t *buf, Int_t bufsize, UInt_t iEv ); // Produce raw data stream - Read data format
          Int_t     ProduceTrackletStream( UInt_t *buf, Int_t bufsize ); // produce the tracklet stream for this MCM
          void      Filter();                                  // Apply digital filters for existing data
          void      ZSMapping();                               // Do ZS mapping for existing data
index caeaf9f9fb08a1be39291d8d17cafd1bc1fa20dd..90096fdd88e4b46f564db64c9593f0fb2ba35172 100644 (file)
@@ -45,7 +45,8 @@
 
 ClassImp(AliTRDrawData)
 
-Int_t AliTRDrawData::fgRawFormatVersion = AliTRDrawData::kRawOldFormat;
+Int_t AliTRDrawData::fgRawFormatVersion = AliTRDrawData::kRawNewFormat;
+Int_t AliTRDrawData::fgDataSuppressionLevel = 1;
 
 //_____________________________________________________________________________
 AliTRDrawData::AliTRDrawData()
@@ -53,6 +54,9 @@ AliTRDrawData::AliTRDrawData()
   ,fGeo(NULL)
   ,fFee(NULL)
   ,fNumberOfDDLs(0)
+  ,fSMindexPos(0)
+  ,fStackindexPos(0)
+  ,fEventCounter(0)
 {
   //
   // Default constructor
@@ -69,6 +73,9 @@ AliTRDrawData::AliTRDrawData(const AliTRDrawData &r)
   ,fGeo(NULL)
   ,fFee(NULL)
   ,fNumberOfDDLs(0)
+  ,fSMindexPos(0)
+  ,fStackindexPos(0)
+  ,fEventCounter(0)
 {
   //
   // Copy constructor
@@ -157,6 +164,8 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
   UInt_t     *hcBuffer    = new UInt_t[kMaxHcWords];
   
   Bool_t newEvent = kFALSE;  // only for correct readout tree
+  Bool_t newSM    = kFALSE;  // new SM flag, for writing SM index words
+  Bool_t newStack = kFALSE;  // new stack flag, for writing stack index words
 
   // sect is same as iDDL, so I use only sect here.
   for (Int_t sect = 0; sect < fGeo->Nsector(); sect++) { 
@@ -166,7 +175,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
 
     AliFstream* of = new AliFstream(name);
 
-    // Write a dummy data header
+           // Write a dummy data header
     AliRawDataHeaderSim  header;  // the event header
     UInt_t hpos = of->Tellp();
     of->WriteBuffer((char *) (& header), sizeof(header));
@@ -174,38 +183,93 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
     // Reset payload byte size (payload does not include header).
     Int_t npayloadbyte = 0;
 
-    
-       if ( fgRawFormatVersion == 0 ){
+
+    if ( fgRawFormatVersion == 0 ){
     // GTU common data header (5x4 bytes per super module, shows link mask)
     for( Int_t stack = 0; stack < fGeo->Nstack(); stack++ ) {
       UInt_t gtuCdh = (UInt_t)(0xe << 28);
       for( Int_t layer = 0; layer < fGeo->Nlayer(); layer++) {
-       Int_t iDet = fGeo->GetDetector(layer, stack, sect);
-       
-       // If chamber status is ok, we assume that the optical link is also OK.
+    Int_t iDet = fGeo->GetDetector(layer, stack, sect);
+
+    // If chamber status is ok, we assume that the optical link is also OK.
         // This is shown in the GTU link mask.
-       if ( AliTRDcalibDB::Instance()->GetChamberStatus(iDet) )
-         gtuCdh = gtuCdh | (3 << (2*layer));
+    if ( AliTRDcalibDB::Instance()->GetChamberStatus(iDet) )
+      gtuCdh = gtuCdh | (3 << (2*layer));
       }
       of->WriteBuffer((char *) (& gtuCdh), sizeof(gtuCdh));
       npayloadbyte += 4;
     }
-       }
+    }
+
+
+    // check the existance of the data
+    // SM index word and Stack index word
+   if ( fgRawFormatVersion == 1 ){
+    UInt_t *iwbuffer = new UInt_t[42]; // index word buffer; max 42 = 2 SM headers + 5*8 stack headers
+    Int_t nheader = 0;
+    UInt_t StackMask = 0x0;
+    Bool_t StackHasData = kFALSE;
+    Bool_t SMHasData = kFALSE;
+    iwbuffer[nheader++] = 0x0001a020;   // SM index words 
+    iwbuffer[nheader++] = 0x10404071;   // SM header
+
+    for ( Int_t stack= 0; stack < fGeo->Nstack(); stack++) {
+        UInt_t LinkMask = 0x0;
+        for( Int_t layer = 0; layer < fGeo->Nlayer(); layer++) {
+            Int_t iDet = fGeo->GetDetector(layer,stack,sect);
+                       AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(iDet);
+            if ( digits->HasData() ) {
+                StackMask = StackMask | ( 1 << stack ); // active stack mask for new stack
+                LinkMask = LinkMask | ( 3 << (2*layer) );    // 3 = 0011
+                StackHasData = kTRUE;
+                SMHasData = kTRUE;
+            } // has data
+        } // loop over layer
+
+        if ( fgDataSuppressionLevel==0 || StackHasData ){
+        //if ( StackHasData ){
+            iwbuffer[nheader++] = 0x0007a000 | LinkMask;    // stack index word + link masks
+            //if (fgDataSuppressionLevel==0) iwbuffer[nheader-1] = 0x0007afff;  // no suppression
+            iwbuffer[nheader++] = 0x04045b01;               // stack header
+            for (Int_t i=0;i<6;i++) iwbuffer[nheader++] = 0x00000000; // 6 dummy words
+            StackHasData = kFALSE;
+        }
+    } // loop over stack
+
+    if ( fgDataSuppressionLevel==0 || SMHasData ){
+        iwbuffer[0] = iwbuffer[0] | StackMask;  // add stack masks to SM index word
+        if (fgDataSuppressionLevel==0) iwbuffer[0] = 0x0001a03f;    // no suppression
+        of->WriteBuffer((char *) iwbuffer, nheader*4);
+        AliDebug(11, Form("SM %d index word: %08x", iwbuffer[0]));
+        AliDebug(11, Form("SM %d header: %08x", iwbuffer[1]));
+    }
+   }
+    // end of SM & stack header ------------------------------------------------------------------------
+    // -------------------------------------------------------------------------------------------------
 
     // Prepare chamber data
     for( Int_t stack = 0; stack < fGeo->Nstack(); stack++) {
       for( Int_t layer = 0; layer < fGeo->Nlayer(); layer++) {
 
         Int_t iDet = fGeo->GetDetector(layer,stack,sect);
-       if (iDet == 0) newEvent = kTRUE; // it is expected that each event has at least one tracklet; this is only needed for correct readout tree
-       // Get the digits array
-       AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(iDet);
-        if (digits->HasData() ) {  // second part is new!! and is for indicating a new event
+        if (iDet == 0){
+            newEvent = kTRUE; // it is expected that each event has at least one tracklet; 
+                                         // this is only needed for correct readout tree
+            fEventCounter++;
+            AliDebug(11, Form("New event!! Event counter: %d",fEventCounter));
+        }
 
-          digits->Expand();
+        if ( stack==0 && layer==0 ) newSM = kTRUE;  // new SM flag
+        if ( layer==0 ) newStack = kTRUE;           // new stack flag
+        AliDebug(15, Form("stack : %d, layer : %d, iDec : %d\n",stack,layer,iDet));
+        // Get the digits array
+               AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(iDet);
+        if (fgDataSuppressionLevel==0 || digits->HasData() ) {  // second part is new!! and is for indicating a new event
 
-          Int_t hcwords = 0;
-         Int_t rv = fFee->GetRAWversion();
+               if (digits->HasData()) digits->Expand();
+
+                       Int_t hcwords = 0;
+                       Int_t rv = fFee->GetRAWversion();
 
 
        if ( fgRawFormatVersion == 0 ){
@@ -236,25 +300,57 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
           of->WriteBuffer((char *) hcBuffer, hcwords*4);
           npayloadbyte += hcwords*4;
 
-       } else { // real data format
-               // Process A side of the chamber
-               hcwords = ProduceHcData(digits,0,iDet,hcBuffer,kMaxHcWords,newEvent);
-               if(newEvent == kTRUE) newEvent = kFALSE;
+    } else { // real data format
+
+       if (digits->HasData()){
+        // Process A side of the chamber
+        hcwords = ProduceHcData(digits,0,iDet,hcBuffer,kMaxHcWords,newEvent,newSM);
+        //if ( newStack ){
+        //  AssignStackMask(hcBuffer, stack);   // active stack mask for this stack
+        //  hcwords += AddStackIndexWords(hcBuffer, stack, hcwords);
+        //  newStack = kFALSE;
+        //}
+        //if ( newSM ) newSM = kFALSE;
+        if ( newEvent ) newEvent = kFALSE;
+        //AssignLinkMask(hcBuffer, layer);  // active link mask for this layer(2*HC)
         of->WriteBuffer((char *) hcBuffer, hcwords*4);
         npayloadbyte += hcwords*4;
-               //for ( Int_t i=0; i<hcwords; i++ ) AliInfo(Form("Buf : %X",hcBuffer[i]));
+        //for ( Int_t i=0; i<hcwords; i++ ) AliInfo(Form("Buf : %X",hcBuffer[i]));
 
-               // Process B side of the chamber
-               hcwords = ProduceHcData(digits,1,iDet,hcBuffer,kMaxHcWords,newEvent);
+        // Process B side of the chamber
+        hcwords = ProduceHcData(digits,1,iDet,hcBuffer,kMaxHcWords,newEvent,newSM);
         of->WriteBuffer((char *) hcBuffer, hcwords*4);
         npayloadbyte += hcwords*4;
-       }
+       } else {
+        hcBuffer[hcwords++] = fgkEndOfTrackletMarker;
+        hcBuffer[hcwords++] = fgkEndOfTrackletMarker;
+        hcBuffer[hcwords++] = (1<<31) | (0<<24) | (0<<17) | (1<<14) | (sect<<9) | (layer<<6) | (stack<<3) | (0<<2) | 1;
+        hcBuffer[hcwords++] = (24<<26) | (99<<10) | (15<<6) | (11<<2) | 1;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        npayloadbyte += hcwords*4;
 
-       }
+        hcBuffer[hcwords++] = fgkEndOfTrackletMarker;
+        hcBuffer[hcwords++] = fgkEndOfTrackletMarker;
+        hcBuffer[hcwords++] = (1<<31) | (0<<24) | (0<<17) | (1<<14) | (sect<<9) | (layer<<6) | (stack<<3) | (1<<2) | 1;
+        hcBuffer[hcwords++] = (24<<26) | (99<<10) | (15<<6) | (11<<2) | 1;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        hcBuffer[hcwords++] = kEndofrawdatamarker;
+        npayloadbyte += hcwords*4;
 
-      }
+        of->WriteBuffer((char *) hcBuffer, hcwords*4);
+       }
     }
 
+    } // has data
+
+      } // loop over layer
+    } // loop over stack
+
     // Complete header
     header.fSize = UInt_t(of->Tellp()) - hpos;
     header.SetAttribute(0);  // Valid data
@@ -302,19 +398,89 @@ void AliTRDrawData::ProduceSMIndexData(UInt_t *buf, Int_t& nw){
        //       and 6 dummy words(0x00000000)
        //
        
-       buf[nw++] = 0x0001a03f; // SM index words
-       buf[nw++] = 0x10404071; // SM header
+    //buf[nw++] = 0x0001a03f;   // SM index words
+    fSMindexPos = nw;       // memorize position of the SM index word for re-allocating stack mask
+    buf[nw++] = 0x0001a020; // SM index words
+    buf[nw++] = 0x10404071; // SM header
+
+    fStackindexPos = nw;    // memorize position of the stack index word for future adding
+       /*  
+    for (Int_t istack=0; istack<5; istack++){
+        buf[nw++] = 0x0007afff; // stack index words
+        buf[nw++] = 0x04045b01; // stack header
+        for (Int_t i=0;i<6;i++) buf[nw++] = 0x00000000; // 6 dummy words
+    } // loop over 5 stacks
+       */
+}
 
-       for (Int_t istack=0; istack<5; istack++){
-               buf[nw++] = 0x0007afff; // stack index words
-               buf[nw++] = 0x04045b01; // stack header
-               for (Int_t i=0;i<6;i++) buf[nw++] = 0x00000000; // 6 dummy words
-       } // loop over 5 stacks
+//_____________________________________________________________________________
+void AliTRDrawData::AssignStackMask(UInt_t *buf, Int_t nStack){
+    //
+    // This function re-assign stack mask active(from 0 to 1) in the SM index word
+    //   
+    buf[fSMindexPos] = buf[fSMindexPos] | ( 1 << nStack );
+}
+
+//_____________________________________________________________________________  
+Int_t AliTRDrawData::AddStackIndexWords(UInt_t *buf, Int_t nStack, Int_t nMax){
+    // 
+    // This function add stack index words and stack header when there is data for the stack
+    //
+    //   1) stack index words : ssssssss ssssssss vvvv mmmm mmmmmmmm 
+    //      - s : size of stack header (number of header, (default = 0x0007)       
+    //      - v : header version (default = 0xa)
+    //      - m : link mask (default = 0xfff)
+    //      - m : link mask (starting value = 0x000)
+    //
+    //   2) stack header : vvvvvvvv vvvvvvvv bbbbbbbb rrrr rrr c
+    //      - v : hardware design revision (default = 0x0404)
+    //      - b : physical board ID (default = 0x5b)
+    //      - r : reserved for future use (default = 0000 000)
+    //      - c : clean checkout flag (default = 1)
+    //  
+    //   and 6 dummy words(0x00000000)
+    //
+
+    Int_t nAddedWords = 0;  // Number of added words
+    if ( ShiftWords(buf, fStackindexPos, 8, nMax)== kFALSE ){
+        AliError("Adding stack header failed.");
+        return 0;
+    }
+
+    buf[fStackindexPos++] = 0x0007a000; // stack index words
+    buf[fStackindexPos++] = 0x04045b01; // stack header
+    for (Int_t i=0;i<6;i++) buf[fStackindexPos++] = 0x00000000; // 6 dummy words 
+    nAddedWords += 8;
 
+    return nAddedWords;
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize, Bool_t newEvent = kFALSE){
+void AliTRDrawData::AssignLinkMask(UInt_t *buf, Int_t nLayer){
+    //
+    // This function re-assign link mask active(from 0 to 1) in the stack index word
+    //   
+    buf[fStackindexPos-8] = buf[fStackindexPos-8] | ( 3 << (2*nLayer) );    // 3 = 0011 
+}
+
+//_____________________________________________________________________________ 
+Bool_t AliTRDrawData::ShiftWords(UInt_t *buf, Int_t nStart, Int_t nWords, Int_t nMax){
+    //  
+    // This function shifts n words
+    //
+    //if ( nStart+nWords > sizeof(buf)/sizeof(UInt_t) ){
+    //  AliError("Words shift failed. No more buffer space.");
+    //  return kFALSE;
+    //}
+
+    for ( Int_t iw=nMax; iw>nStart-1; iw--){
+        buf[iw+nWords] = buf[iw];
+    }
+    return kTRUE;
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize, Bool_t newEvent = kFALSE, Bool_t newSM = kFALSE){
        //
        // This function can be used for both ZS and NZS data
        //
@@ -343,14 +509,15 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det
 
        AliTRDmcmSim** mcm = new AliTRDmcmSim*[(kCtype + 3)*(fGeo->MCMmax())];
 
-       if (newEvent) ProduceSMIndexData(buf, nw);              // SM index words , Stack index words
+       //if (newEvent) ProduceSMIndexData(buf, nw);            // SM index words , Stack index words
 
        if (!tracklet_on) WriteIntermediateWordsV2(buf,nw,of,maxSize,det,side); // no tracklet or NZS
  
        
        // scanning direction such, that tracklet-words are sorted in ascending z and then in ascending y order
        // ROB numbering on chamber and MCM numbering on ROB increase with decreasing z and increasing y
-       for (Int_t iRobRow =  (kCtype + 3)-1; iRobRow >= 0; iRobRow-- ) {
+       //for (Int_t iRobRow =  (kCtype + 3)-1; iRobRow >= 0; iRobRow-- ) {
+       for (Int_t iRobRow = 0; iRobRow <= (kCtype + 3)-1; iRobRow++ ) {        // ROB number should be increasing
        Int_t iRob = iRobRow * 2 + side;
        // MCM on one ROB
        for (Int_t iMcmRB = 0; iMcmRB < fGeo->MCMmax(); iMcmRB++ ) {
@@ -396,7 +563,7 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det
                    }
                } else { // no tracklets: write raw-data already in this loop 
                    // Write MCM data to buffer
-                   Int_t tempNw =  mcm[entry]->ProduceRawStreamV2( &buf[nw], maxSize - nw );
+                   Int_t tempNw =  mcm[entry]->ProduceRawStreamV2( &buf[nw], maxSize - nw, fEventCounter );
                    if( tempNw < 0 ) {
                                of += tempNw;
                                nw += maxSize - nw;
@@ -426,7 +593,7 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det
                        Int_t entry = iRobRow*(fGeo->MCMmax()) + iMcm; 
                      
                        // Write MCM data to buffer
-                       Int_t tempNw =  mcm[entry]->ProduceRawStreamV2( &buf[nw], maxSize - nw );
+                       Int_t tempNw =  mcm[entry]->ProduceRawStreamV2( &buf[nw], maxSize - nw, fEventCounter );
                        if( tempNw < 0 ) {
                                        of += tempNw;
                                        nw += maxSize - nw;
@@ -444,7 +611,10 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det
        delete [] mcm;
   
        // Write end of raw data marker
-       if (nw < maxSize) {
+       if (nw+3 < maxSize) {
+       buf[nw++] = kEndofrawdatamarker; 
+       buf[nw++] = kEndofrawdatamarker; 
+       buf[nw++] = kEndofrawdatamarker; 
        buf[nw++] = kEndofrawdatamarker; 
        } else {
        of++;
@@ -588,7 +758,7 @@ Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDarrayADC *digits, Int_t side
       // ADC data
       for (Int_t iAdc = 0; iAdc < 21; iAdc++ ) {
        Int_t padcol = fFee->GetPadColFromADC(iRob, iMcm, iAdc);
-       UInt_t aa = !(iAdc & 1) + 2;
+       UInt_t aa = !(iAdc & 1) + 2;    // 3 for the even ADC channel , 2 for the odd ADC channel
         UInt_t *a = new UInt_t[kNTBin+2];
         // 3 timebins are packed into one 32 bits word
         for (Int_t iT = 0; iT < kNTBin; iT+=3) { 
@@ -935,7 +1105,14 @@ void AliTRDrawData::WriteIntermediateWordsV2(UInt_t* buf, Int_t& nw, Int_t& of,
     UInt_t           x = 0;
 
     // Write end of tracklet marker
-    if (nw < maxSize) buf[nw++] = fgkEndOfTrackletMarker; else of++;
+       if (nw < maxSize){
+        buf[nw++] = fgkEndOfTrackletMarker;
+        buf[nw++] = fgkEndOfTrackletMarker;     // the number of tracklet end marker should be more than 2
+    }
+    else {
+        of++;
+    }
+
    
        // Half Chamber header
        // h[0] (there are 2 HC headers) xmmm mmmm nnnn nnnq qqss sssp ppcc ci01
@@ -968,7 +1145,7 @@ void AliTRDrawData::WriteIntermediateWordsV2(UInt_t* buf, Int_t& nw, Int_t& of,
     Int_t ptCtr   = 15; // pretrigger counter. Here it is set to 15 always for no reason
     Int_t ptPhase = 11; // pretrigger phase. Here it is set to 11 always for no reason
     //x = (bcCtr<<16) | (ptCtr<<12) | (ptPhase<<8) | ((kNTBin-1)<<2) | 1;      // old format
-    x = ((kNTBin-1)<<26) | (bcCtr<<10) | (ptCtr<<6) | (ptPhase<<2) | 1;
+    x = ((kNTBin)<<26) | (bcCtr<<10) | (ptCtr<<6) | (ptPhase<<2) | 1;
     if (nw < maxSize) buf[nw++] = x; else of++;
   
 }
index fe8bb14e4738ef1701568812c4f55f0bd95768fd..01bd9acae5ad7bec7adc81300e9b0768fbfe7131 100644 (file)
@@ -37,6 +37,7 @@ class AliTRDrawData : public TObject {
   virtual AliTRDdigitsManager *Raw2Digits(AliRawReader *rawReader);
   virtual AliTRDdigitsManager *Raw2DigitsOLD(AliRawReader *rawReader);
   static void SetRawFormatVersion(Int_t iver){ fgRawFormatVersion=iver; };
+  static void SetSuppressionLevel(Int_t ilevel){ fgDataSuppressionLevel=ilevel; };
 
   enum FORMATTYPE
     {
@@ -47,13 +48,17 @@ class AliTRDrawData : public TObject {
  protected:
 
   virtual Bool_t       Digits2Raw(AliTRDdigitsManager* digitsManager); // for fRawVersion > 0
-  virtual Int_t        ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize, Bool_t newEvent);
+  virtual Int_t        ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize, Bool_t newEvent, Bool_t newSM);
   virtual Int_t        ProduceHcDataV1andV2(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize);
   virtual Int_t        ProduceHcDataV3(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize, Bool_t newEvent);
   //virtual Int_t      ProduceHcDataV3(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize);
                  void         ProduceSMIndexData(UInt_t *buf, Int_t& nw);                              // SM index words and header - real data format
           void         WriteIntermediateWords(UInt_t *buf, Int_t& nw, Int_t& of, const Int_t& maxSize, const Int_t& det, const Int_t& side); // writes tracklet-endmarker and additional words between tracklet and raw-data
           void            WriteIntermediateWordsV2(UInt_t *buf, Int_t& nw, Int_t& of, const Int_t& maxSize, const Int_t& det, const Int_t& side); // real data format
+                 void         AssignStackMask(UInt_t *buf, Int_t nStack);  // re-assignment of stack mask in the SM index word
+          void         AssignLinkMask(UInt_t *buf, Int_t nLayer);   // re-assignment of link mask in the stack index word
+          Int_t        AddStackIndexWords(UInt_t *buf, Int_t nStack, Int_t nMax);   // add stack index words and stack header when there is no data for the stack 
+          Bool_t       ShiftWords(UInt_t *buf, Int_t nStart, Int_t nWords, Int_t nMax); // shifts n words
   
   AliTRDgeometry      *fGeo;            //! Geometry
   AliTRDfeeParam      *fFee;            //! Fee Parameters
@@ -64,8 +69,14 @@ class AliTRDrawData : public TObject {
  private:
 
        static       Int_t  fgRawFormatVersion;                   // simulation raw data version - 0:old , 1:new(real data format)
+       static       Int_t  fgDataSuppressionLevel;                 // Data suppression level - 0:no su, 1: su, 2: deep suppression 
        static const UInt_t fgkEndOfTrackletMarker  = 0x10001000; // This marks the end of tracklet data words
 
+       Int_t   fSMindexPos;                // Position of SM index word
+    Int_t   fStackindexPos;             // Position of SM index word
+    UInt_t  fEventCounter;              // Event counter(starting from 1)
+
+
 
 
 };
index 9ab8f5455e07c3b4843534026c9edd36b8003436..1298e510f23ef832d22be29488f988d22a4c2c31 100644 (file)
@@ -120,7 +120,7 @@ Bool_t AliTRDrawStream::fgEnableMemoryReset = kTRUE;
 Bool_t AliTRDrawStream::fgStackNumberChecker = kTRUE;\r
 Bool_t AliTRDrawStream::fgStackLinkNumberChecker = kTRUE;\r
 Bool_t AliTRDrawStream::fgSkipData = kTRUE;\r
-UInt_t AliTRDrawStream::fgDumpHead = 0;\r
+Int_t AliTRDrawStream::fgDumpHead = -1;\r
 Int_t  AliTRDrawStream::fgCommonAdditive = 0;\r
 Int_t AliTRDrawStream::fgEmptySignals[] = \r
   {\r
@@ -331,22 +331,21 @@ AliTRDrawStream::SwapOnEndian()
 }\r
 \r
 //------------------------------------------------------------\r
-Bool_t \r
+Bool_t\r
 AliTRDrawStream::DumpWords(UInt_t *px, UInt_t iw, UInt_t marker)\r
 {\r
+    //UInt_t iEnd = iw;\r
+    //if ( iw ==0 ) iEnd = (fpEnd - px)/sizeof(UInt_t); // if iw is 0, dump all words\r
 \r
   TString tsreturn = Form("\n[ Dump Sequence at 0x%08x ] : ", px);\r
   for (UInt_t i = 0; i < iw; i++)\r
+  //for (UInt_t i = 0; i < iEnd; i++)\r
     {\r
-      if (px + iw >= fpEnd)\r
-  return kFALSE;\r
+      if ( iw != 0 && px + iw > fpEnd) return kFALSE;\r
 \r
-      if (i % 8 == 0)\r
-  tsreturn += "\n                              ";\r
-      if (marker != 0 && marker == px[i])\r
-  tsreturn += Form(" *>0x%08x<* ", px[i]);\r
-      else\r
-  tsreturn += Form("0x%08x ", px[i]);\r
+      if (i % 8 == 0) tsreturn += "\n                              ";\r
+      if (marker != 0 && marker == px[i]) tsreturn += Form(" *>0x%08x<* ", px[i]);\r
+      else tsreturn += Form("0x%08x ", px[i]);\r
     }\r
   tsreturn += "\n";\r
 \r
@@ -949,15 +948,16 @@ AliTRDrawStream::InitBuffer(void *buffer, UInt_t length)
 \r
   SwapOnEndian();\r
 \r
-  if (fgDumpHead > 0)\r
-    {\r
-      AliInfo(Form("---------- Dumping %u words from the beginnig of the buffer ----------",fgDumpHead));\r
-      if (DumpWords(fpBegin, fgDumpHead) == kFALSE)\r
-  {\r
-    AliError("Dump failed. Not enough data.");   \r
-  }\r
-      AliInfo(Form("---------- Dumping ended ----------------------------------------------"));\r
+  if (fgDumpHead >= 0){\r
+    if ( fgDumpHead == 0 ){ // dump all words\r
+        AliInfo(Form("---------- Dumping all words from the beginnig of the buffer ----------"));\r
+        if (DumpWords(fpBegin, fWordLength) == kFALSE) AliError("Dump failed. Not enough data.");\r
+    } else {\r
+        AliInfo(Form("---------- Dumping %u words from the beginnig of the buffer ----------",fgDumpHead));\r
+        if (DumpWords(fpBegin, fgDumpHead) == kFALSE) AliError("Dump failed. Not enough data.");\r
     }\r
+    AliInfo(Form("---------- Dumping ended ----------------------------------------------"));\r
+  }\r
 \r
   return kTRUE;\r
 }\r
index b20a17d84840d507cecfbca9c59c6804a285c0e6..f9d6d17f0b8ed75e6de6f54452f8ddcd23ea1ac1 100644 (file)
@@ -522,7 +522,7 @@ class AliTRDrawStream : public AliTRDrawStreamBase
 
   static void    SetExtraWordsFix() {fgExtraSkip = kTRUE;} // extra skip of 24 32-bit words 
   static void    SetSkipCDH() {fgSkipCDH = kTRUE;} // skip of 8 32-bit words 
-  static void    SetDumpHead(UInt_t iv) {fgDumpHead = iv;}
+  static void    SetDumpHead(Int_t iv) {fgDumpHead = iv;}
   static void    DisableStackNumberChecker() {fgStackNumberChecker = kFALSE;}  // set false to cleanroom data 
   static void    DisableStackLinkNumberChecker() {fgStackLinkNumberChecker = kFALSE;}  
   static void    DisableSkipData() {fgSkipData = kFALSE;} // keep reading next words even previous words were corrupted - debugging purpose  
@@ -642,7 +642,7 @@ class AliTRDrawStream : public AliTRDrawStreamBase
   static Bool_t fgStackNumberChecker; // decide if we check stack number insanity - set false to cleanroom data
   static Bool_t fgStackLinkNumberChecker; // decide if we check stack link number insanity - debuging purpose
   static Bool_t fgSkipData; // decide if we skip corrupted data of given HC
-  static UInt_t fgDumpHead; // number of words to dump (from the start of the buffer) on each Init
+  static Int_t fgDumpHead; // number of words to dump (from the start of the buffer) on each Init
   static Int_t  fgEmptySignals[30]; // empty signals in case of ADC pointer = NULL
   static Short_t  fgMCMordering[16]; // mcm number odering for mcm header corruption check
   static Short_t  fgROBordering[16]; // mcm number odering for mcm header corruption check
index 2a9708a82b5f88a079ac98e0d3e531831f526489..38e7af33546c70d89e28d37597eb1abf961c9afe 100644 (file)
@@ -39,7 +39,7 @@
 //--------------------------------------------------------
 ClassImp(AliTRDrawStreamBase)
 
-Int_t AliTRDrawStreamBase::fgRawStreamVersion = AliTRDrawStreamBase::kTRDsimStream;
+Int_t AliTRDrawStreamBase::fgRawStreamVersion = AliTRDrawStreamBase::kTRDrealStream;
 
 //_____________________________________________________________________________
 AliTRDrawStreamBase::AliTRDrawStreamBase()