+ }
+
+
+ // 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 ------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------