]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Revised version of raw data v1 (bug fix and coding vios)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Feb 2007 14:17:47 +0000 (14:17 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Feb 2007 14:17:47 +0000 (14:17 +0000)
TRD/AliTRDRawStream.cxx
TRD/AliTRDRawStream.h
TRD/AliTRDrawData.cxx

index 67abbedf2775a81739cdd9e1dabdbb5b3ce34275..c4b3845d88652b722fe7efd7d1bf6d5df4e51560 100644 (file)
@@ -361,14 +361,6 @@ AliTRDRawStream::~AliTRDRawStream()
   // Destructor
   //
 
-  delete fGeo;
-  delete fRawReader;
-  //delete fDigitsManager;
-  delete fDigits;
-  delete fTrack0;
-  delete fTrack1;
-  delete fTrack2;
-
 }
 
 //_____________________________________________________________________________
@@ -532,7 +524,7 @@ Bool_t AliTRDRawStream::ReadAll()
 {
 
   //
-  // Read all TRD raw data word (32 bits). This is for all FrawVersion > 0.
+  // Read all TRD raw data word (32 bits). This is for all fRawVersion > 0.
   // Return kFALSE if something is not cool
   //
   // by C. Lippmann
@@ -558,9 +550,9 @@ Bool_t AliTRDRawStream::ReadAll()
 
   AliDebug(2, Form("Number of Timebins read from CDB: %d", timeTotal));
 
-  UInt_t TBswitch    = 3;
-  UInt_t TBswitchCtr = 0;
-  Int_t  WordCtr     = 0;
+  UInt_t tBswitch    = 3;
+  UInt_t tBswitchCtr = 0;
+  Int_t  wordCtr     = 0;
   Int_t  EqID        = 0;
   Int_t  datasize    = 0;
   Int_t  iDET        = 0;
@@ -572,7 +564,7 @@ Bool_t AliTRDRawStream::ReadAll()
 
   while ( 1 ) { // loop over all supermodules
 
-    WordCtr   = 0;
+    wordCtr   = 0;
     fHCHctr1  = 0;
     fMCMHctr1 = 0;
 
@@ -581,14 +573,42 @@ Bool_t AliTRDRawStream::ReadAll()
     //
     do {
 
-      if ( !fRawReader->ReadNextInt( fDataWord ) ) {
+      if ( !fRawReader->ReadNextInt( fDataWord ) ) {  // This is the standard exit point
+       // Compress also the digits from the last detector
+       if ( fChamberDone[iDET] == 2 ) {
+         //printf("Compressing data for det %d\n", iDET);
+         fDigits->Compress(1,0);
+         fTrack0->Compress(1,0);
+         fTrack1->Compress(1,0);
+         fTrack2->Compress(1,0);
+       }
        AliInfo(Form("Finished processing TRD raw data: Found %d Half-Chambers", fHCHctr2));
+       //
+       /*
+       fDigits = fDigitsManager->GetDigits(iDET+1);
+       fTrack0 = fDigitsManager->GetDictionary(iDET+1,0);
+       fTrack1 = fDigitsManager->GetDictionary(iDET+1,1);
+       fTrack2 = fDigitsManager->GetDictionary(iDET+1,2);
+       fDigits->Allocate(fRowMax,fColMax,timeTotal);
+       fTrack0->Allocate(fRowMax,fColMax,timeTotal);
+       fTrack1->Allocate(fRowMax,fColMax,timeTotal);
+       fTrack2->Allocate(fRowMax,fColMax,timeTotal);
+       fDigits->SetDataUnchecked(0, 0, 0, 50);
+       fTrack0->SetDataUnchecked(0, 0, 0, 0);
+       fTrack1->SetDataUnchecked(0, 0, 0, 0);
+       fTrack2->SetDataUnchecked(0, 0, 0, 0);  
+       fDigits->Compress(1,0);
+       fTrack0->Compress(1,0);
+       fTrack1->Compress(1,0);
+       fTrack2->Compress(1,0);
+       */
+       //
        return kTRUE;
       }
-      WordCtr++;
+      wordCtr++;
 
       // After reading the first word check for size of this data and get Eq. ID
-      if ( WordCtr == 1 ) {
+      if ( wordCtr == 1 ) {
        datasize = fRawReader->GetDataSize()/4;  // Size of this payload is in 32bit words
        EqID     = fRawReader->GetEquipmentId(); // Get Equipment ID
       }
@@ -605,23 +625,23 @@ Bool_t AliTRDRawStream::ReadAll()
       }
 
     } 
-    while ( WordCtr < datasize );
+    while ( wordCtr < datasize );
 
     //
     // loop over all half chambers in one supermodule
     //
-    while ( WordCtr < datasize ) {
+    while ( wordCtr < datasize ) {
 
       //
       // 1) Find end_of_tracklet_marker
       //
-      while ( WordCtr < datasize ) {
+      while ( wordCtr < datasize ) {
 
        if ( !fRawReader->ReadNextInt( fDataWord ) ) {
          AliError("Could not read data");
          return kFALSE;
        }
-       WordCtr++;
+       wordCtr++;
 
        // GTU Link Mask?
        if ( (fDataWord & 0xfffff000) ==  0xe0000000 ) {
@@ -629,9 +649,9 @@ Bool_t AliTRDRawStream::ReadAll()
          continue;
        }
 
-       // end_of_tracklet_marker?
-       if ( fDataWord == end_of_tracklet_marker ) {
-         AliDebug(3, "end_of_tracklet_marker found");
+       // endoftrackletmarker?
+       if ( fDataWord == endoftrackletmarker ) {
+         AliDebug(3, "end-of-tracklet-marker found");
          fStatus = 1;
          break;
        } 
@@ -649,16 +669,16 @@ Bool_t AliTRDRawStream::ReadAll()
       // 2) Look for non-end_of_tracklet_marker
       //
       fStatus = 0;
-      while ( WordCtr < datasize ) { 
+      while ( wordCtr < datasize ) { 
 
        if ( !fRawReader->ReadNextInt( fDataWord ) ) {
          AliError("Could not read data");
          return kFALSE;
        }
-       WordCtr++;
-       //printf("Word %d: 0x%08x\n", WordCtr, fDataWord); 
+       wordCtr++;
+       //printf("Word %d: 0x%08x\n", wordCtr, fDataWord); 
 
-       if ( fDataWord != end_of_tracklet_marker ) {
+       if ( fDataWord != endoftrackletmarker ) {
          fStatus = 1;
          break;
        }
@@ -675,8 +695,9 @@ Bool_t AliTRDRawStream::ReadAll()
 
        // If both half chambers of chamber corresponding to previous header
        // were already processed, we can compress these digits
-       iDET = fGeo->GetDetector(fLAYER, fSTACK, fSM);
+       iDET = fGeo->GetDetector(fLAYER, fSTACK, fSM); // !!this is still the previous HC!!!
        if ( fChamberDone[iDET] == 2 ) {
+         //printf("Compressing data for det %d\n", iDET);
          fDigits->Compress(1,0);
          fTrack0->Compress(1,0);
          fTrack1->Compress(1,0);
@@ -684,22 +705,21 @@ Bool_t AliTRDRawStream::ReadAll()
        }
 
        // Read from new HC header the chamber position (fLAYER, fSTACK, fSM)
-       DecodeHCheader(timeTotal);
-       WordCtr += fHCHWords;
+       DecodeHCheader(timeTotal); // This is the new header!
+       wordCtr += fHCHWords;
        iDET    = fGeo->GetDetector(fLAYER, fSTACK, fSM);
        fRowMax = commonParam->GetRowMax(fLAYER,fSTACK,fSM);
        fColMax = commonParam->GetColMax(fROC);
 
-       // Add a container for the digits of this detector
+       // The container for the digits of this detector
        fDigits = fDigitsManager->GetDigits(iDET);
        fTrack0 = fDigitsManager->GetDictionary(iDET,0);
        fTrack1 = fDigitsManager->GetDictionary(iDET,1);
        fTrack2 = fDigitsManager->GetDictionary(iDET,2);
        
-       fChamberDone[iDET]++;
-       
        // Allocate memory if it was not already done
        if (fDigits->GetNtime() == 0) {
+         //printf("Allocating digits memory for det %d\n", iDET);
          fDigits->Allocate(fRowMax,fColMax,timeTotal);
          fTrack0->Allocate(fRowMax,fColMax,timeTotal);
          fTrack1->Allocate(fRowMax,fColMax,timeTotal);
@@ -708,38 +728,38 @@ Bool_t AliTRDRawStream::ReadAll()
 
        fMCMHctr2 = 0;
 
+       fChamberDone[iDET]++;
+
       }
     
       //
       // 4) Scan MCM data
       //
       fStatus = 0;
-      while ( WordCtr < datasize ) {
+      while ( wordCtr < datasize ) {
 
        if ( !fRawReader->ReadNextInt( fDataWord ) ) {
          AliError("Could not read data");
          return kFALSE;
        }
-       WordCtr++;
-       //printf("Word %d: 0x%08x\n", WordCtr, fDataWord); 
+       wordCtr++;
+       //printf("Word %d: 0x%08x\n", wordCtr, fDataWord); 
       
-       //if ( WordCtr == 4*datasize ) AliInfo(Form("Achtung! WordCtr=%d (%d)", WordCtr, 4*datasize));
-
        if( (fDataWord & 0x0000000f) == 0xC ) { // MCM Header
          DecodeMCMheader();
          if ( fMCM < 0 || fMCM > 15 || fROB < 0 || fROB > 7 ) {
            AliError("Wrong fMCM or fROB. Skip this data");
            break;
          }
-         TBswitch    = 3;  // For first adc channel we expect: (fDataWord & 3) = 3
-         TBswitchCtr = 0;  // 
+         tBswitch    = 3;  // For first adc channel we expect: (fDataWord & 3) = 3
+         tBswitchCtr = 0;  // 
          fADC = fTB  = 0;  // Reset Counter
          fStatus     = 1;  // Now 1 means MCM header is found
          continue;
        }
     
        // End of half-chamber data, finished:
-       if ( fDataWord == end_of_event_marker ) {
+       if ( fDataWord == endofeventmarker ) {
          fGTUctr1 = -1;
          break;
        }
@@ -754,34 +774,33 @@ Bool_t AliTRDRawStream::ReadAll()
            break;
          }
 
-         if ( (fDataWord & 0x00000003) != TBswitch ) {    // Next ADC channel found
+         if ( (fDataWord & 0x00000003) != tBswitch ) {    // Next ADC channel found
            //if ( fTB+1 != timeBins ) AliError(Form("Time bins in data (%d) != DB (%d)", fTB+1, timeBins));
-           TBswitch = (TBswitch & 2) | !(TBswitch & 1);   // 0x3 <--> 0x2
-           TBswitchCtr = 0;
+           tBswitch = (tBswitch & 2) | !(tBswitch & 1);   // 0x3 <--> 0x2
+           tBswitchCtr = 0;
            fADC++;
            fTB=0;
          }
 
-         TBswitchCtr++; // Just read one word
+         tBswitchCtr++; // Just read one word
        
          // We have only timeTotal time bins
-         if ( TBswitchCtr > timeWords ) {
-           AliError(Form("Data is strange. Already found %d words for this ADC channel", (Int_t)TBswitchCtr));
+         if ( tBswitchCtr > timeWords ) {
+           AliError(Form("Data is strange. Already found %d words for this ADC channel", (Int_t)tBswitchCtr));
            continue;
          }
 
          // We have only 21 ADC channels.
-         if ( fADC > 20 ) {
-           AliError(Form("Data %08x : Data is strange. fADC is already %d", (Int_t)fDataWord,
-                         (Int_t)fADC));
+         if ( fADC > (Int_t)fGeo->ADCmax()-1 ) {
+           AliError(Form("Data %08x : Data is strange. fADC is already %d", (Int_t)fDataWord, (Int_t)fADC));
            continue;
          }
 
-         // There are 18 pads connected to each MCM ADC channels 2...19. The
-         // other channels cross to other MCMs and are good for online tracking
-         // in the MCM.
+         // There are 18 pads connected to each MCM ADC channels 2...19. The other channels cross to other
+         // MCMs and are good for online tracking in the MCM.
          if ( fADC > 1 && fADC < (Int_t)fGeo->ADCmax()-1 ) {
 
+           // Get Pad column
            fCOL = fGeo->GetPadCol(fROB, fMCM, fADC);
 
            // We have only 144 Pad Columns
@@ -801,12 +820,18 @@ Bool_t AliTRDRawStream::ReadAll()
 
            // Write Digits
            if ( fCOL >= 0 && fCOL < fColMax && fROW >= 0 && fROW < fRowMax ) {  // A real pad
-             for ( Int_t ctr = 0; ctr <3; ctr++ ) {
+             for ( Int_t ctr = 0; ctr < 3; ctr++ ) {
                if ( fTB+ctr < (Int_t)timeTotal ) {
+                 /*
                  fDigits->SetDataUnchecked(fROW, fCOL, fTB+ctr, fSig[ctr]);
                  fTrack0->SetDataUnchecked(fROW, fCOL, fTB+ctr, 0);
                  fTrack1->SetDataUnchecked(fROW, fCOL, fTB+ctr, 0);
                  fTrack2->SetDataUnchecked(fROW, fCOL, fTB+ctr, 0);
+                 */
+                 fDigits->SetData(fROW, fCOL, fTB+ctr, fSig[ctr]);
+                 fTrack0->SetData(fROW, fCOL, fTB+ctr, 0);
+                 fTrack1->SetData(fROW, fCOL, fTB+ctr, 0);
+                 fTrack2->SetData(fROW, fCOL, fTB+ctr, 0);
                }
              }
            }
@@ -832,6 +857,15 @@ Bool_t AliTRDRawStream::ReadAll()
 
   } // End Super Module loop
 
+  // Compress also the digits from the last detector
+  if ( fChamberDone[iDET] == 2 ) {
+    //printf("Compressing data for det %d\n", iDET);
+    fDigits->Compress(1,0);
+    fTrack0->Compress(1,0);
+    fTrack1->Compress(1,0);
+    fTrack2->Compress(1,0);
+  }
+
   return kTRUE;
 
 }
index 62510556c5979f35c09afb22ff9a23068ab87ccb..9a8e112e7cd7302bb07faba678545c233e169ffe 100644 (file)
@@ -19,8 +19,8 @@ class AliTRDdigitsManager;
 class AliTRDdataArrayI;
 
 // Some constants:
-const UInt_t end_of_tracklet_marker = 0xAAAAAAAA; /*This marks the end of tracklet data words*/
-const UInt_t end_of_event_marker    = 0x00000000; /*This marks the end of half-chamber-data*/
+const UInt_t endoftrackletmarker = 0xAAAAAAAA; /*This marks the end of tracklet data words*/
+const UInt_t endofeventmarker    = 0x00000000; /*This marks the end of half-chamber-data*/
 
 class AliTRDRawStream: public TObject {
 
@@ -57,10 +57,24 @@ class AliTRDRawStream: public TObject {
     Bool_t               SetRawVersion(Int_t rv);
     Int_t                GetRawVersion() const                      { return fRawVersion;     };
 
+    // Get Filter settings:
+    Int_t                TRAPfilterTCon() const                     { return fTCon;           };
+    Int_t                TRAPfilterPEDon() const                    { return fPEDon;          };
+    Int_t                TRAPfilterGAINon() const                   { return fGAINon;         };
+    Int_t                TRAPsendsFilterdData() const               { return fFiltered;       };
+
+    // Get Tracklet parameters:
+    Float_t              GetTrackletPID() const                     { return fTracklPID;      };
+    Float_t              GetTrackletDeflLength() const              { return fTracklDefL;     };
+    Float_t              GetTrackletPadPos() const                  { return fTracklPadPos;   };
+    Int_t                getTrackletPadRow() const                  { return fTracklPadRow;   };
+
     // Check if the link has optical power (HC sends data)
     Bool_t               IsGTULinkActive(Int_t sm, Int_t la, Int_t sta, Int_t side)
-                                  { return ( ((fGTUlinkMask[sm][sta]) >> (2*la+side)) & 0x1 ); };
+      { return ( ((fGTUlinkMask[sm][sta]) >> (2*la+side)) & 0x1 ); };
+
 
+  private :
 
     Int_t    fSig[3];                         //  Signals in the three time bins from Data Word
     Int_t    fADC;                            //  MCM ADC channel and Time Bin of word 1
@@ -103,14 +117,12 @@ class AliTRDRawStream: public TObject {
 
     UShort_t fGTUlinkMask[18][5];             //  Mask with active links
 
-  private :
-
     AliTRDRawStream(const AliTRDRawStream &stream);
     AliTRDRawStream &operator=(const AliTRDRawStream &stream);
 
     AliRawReader *fRawReader;              //  Object for reading the raw data
 
-    // The following is used by V0 (from Bogdan, offline use only):
+    // The following is used for v0:
     Int_t    fCount;                       //  Counter of bytes to be read for current detector
     Int_t    fDetector;                    //  Index of current detector
     Int_t    fPrevDetector;                //  Index of previous detector
@@ -136,10 +148,10 @@ class AliTRDRawStream: public TObject {
     AliTRDgeometry *fGeo;                  //  TRD geometry
 
     AliTRDdigitsManager *fDigitsManager;   //! Manager for the output digits
-    AliTRDdataArrayI    *fDigits;          //! The Output digits
-    AliTRDdataArrayI    *fTrack0;          //! The track dictionary
-    AliTRDdataArrayI    *fTrack1;          //! The track dictionary
-    AliTRDdataArrayI    *fTrack2;          //! The track dictionary
+    AliTRDdataArrayI    *fDigits;          //! Output digits
+    AliTRDdataArrayI    *fTrack0;          //! Track dictionary
+    AliTRDdataArrayI    *fTrack1;          //! Track dictionary
+    AliTRDdataArrayI    *fTrack2;          //! Track dictionary
 
     void  DecodeHCheader(Int_t timeBins);
     void  DecodeHCheaderV1();              // Valid for fRawversion = 1
index 2f53c38c40abee38d81784748de6c3d63726323d..c58a25c4032a53c5ca292526f9142550c5e206fc 100644 (file)
@@ -490,7 +490,7 @@ Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDdataArrayI *digits, Int_t side
 
   // Write end of tracklet marker
   if (nw < maxSize) {
-    buf[nw++] = end_of_tracklet_marker;
+    buf[nw++] = endoftrackletmarker;
   } 
   else {
     of++;
@@ -592,7 +592,7 @@ Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDdataArrayI *digits, Int_t side
 
   // Write end of raw data marker
   if (nw < maxSize) {
-    buf[nw++] = end_of_event_marker; 
+    buf[nw++] = endofeventmarker; 
   }
   else {
     of++;