]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDRawReader.cxx
new event cut class by Markus for local event selection for TRD
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.cxx
index 08260c04c34ecc001e422cdc9d9f6a57feb388c9..bed80daa311444a0301ba166d982519b07da33fa 100644 (file)
@@ -112,6 +112,7 @@ AliFMDRawReader::Exec(Option_t*)
   Int_t nWrite = fTree->Fill();
   AliFMDDebug(1, ("Got a grand total of %d digits, wrote %d bytes to tree", 
                   array->GetEntriesFast(), nWrite));
+  delete array;
 }
 
 //____________________________________________________________________
@@ -132,22 +133,85 @@ AliFMDRawReader::NewDDL(AliAltroRawStreamV3& input, UShort_t& det)
   UInt_t ddl = input.GetDDLNumber();
   AliFMDDebug(2, ("DDL number %d", ddl));
 
-  // Get zero suppression flag
-  fZeroSuppress[ddl] = input.GetZeroSupp();
+  /* Note, previously, the ALTROCFG1 register was interpreted as 
+   * 
+   * Bits    Value    Description
+   *   0- 3      0/1   1st Baseline filter, mode 
+   *   4- 5   Over-1   2nd baseline filter, # of pre-samples
+   *   6- 9   factor   2nd baseline filter, # of post-samples 
+   *  10-          0   2nd baseline filter, enable
+   *  11-12       00   Zero suppression, glitch filter mode
+   *  13-15      001   Zero suppression, # of post samples
+   *  16-17       01   Zero suppression, # of pre  samples
+   *  18         0/1   Zero suppression, enable
+   *
+   * The interpretation used in AliAltroRawStreamerV3 - which
+   * corresponds directly to ALTRO DPCFG register - is 
+   *
+   * Bits    Value  Description
+   *   0- 3    0/1   1st Baseline filter, mode 
+   *   4         0   Polarity (if '1', then "1's inverse")
+   *   5- 6     01   Zero suppression, # of pre samples
+   *   7-10   0001   Zero suppression, # of post samples
+   *  11         0   2nd baseline filter, enable
+   *  12-13     00   Zero suppression, glitch filter mode
+   *  14-16 factor   2nd baseline filter, # of post-samples
+   *  17-18     01   2nd baseline filter, # of pre-samples 
+   *  19       0/1   Zero suppression, enable
+   *
+   *  Writing 'x' for variable values, that means we have the
+   *  following patterns for the 2 cases 
+   *
+   *    bit #  20   16   12    8    4    0
+   *     old    |0x01|0010|00xx|xxxx|xxxx|
+   *     new    |x01x|xx00|0000|1010|xxxx|
+   *
+   *  That means that we can check if bits 10-13 are '1000' or
+   *  '0000', which will tell us if the value was written with the
+   *  new or the old interpretation.    That is, we can check that 
+   *
+   *    if (((altrocfg1 >> 10) & 0x8) == 0x8) { 
+   *      // old interpretation 
+   *    }
+   *    else { 
+   *      // New interpretation 
+   *    }
+   *
+   * That means, that we should never 
+   *
+   *  - change the # of zero suppression post samples 
+   *  - Turn on 2nd baseline correction 
+   *  - Change the zero-suppression glitch filter mode
+   *
+   * This change as introduced in version 1.2 of Rcu++
+   */
+  UInt_t cfg1 = input.GetAltroCFG1();
+  if (((cfg1 >> 10) & 0x8) == 0x8) {
+    UInt_t cfg2 = input.GetAltroCFG2();
+    AliFMDDebug(3, ("We have data from older MiniConf 0x%x cfg2=0x%08x", 
+                   ((cfg1 >> 10) & 0x8), cfg2));
+    fZeroSuppress[ddl] = (cfg1 >>  0) & 0x1;
+    fNoiseFactor[ddl]  = (cfg1 >>  6) & 0xF;
+    fSampleRate[ddl]   = (cfg2 >> 20) & 0xF;
+  }
+  else {
+    AliFMDDebug(3, ("We have data from newer MiniConf 0x%x", 
+                   ((cfg1 >> 10) & 0x8)));
+    fZeroSuppress[ddl] = input.GetZeroSupp();
+    // WARNING: We store the noise factor in the 2nd baseline
+    // filters excluded post samples, since we'll never use that
+    // mode. 
+    fNoiseFactor[ddl]  = input.GetNPostsamples();
+    // WARNING: We store the sample rate in the number of pre-trigger
+    // samples, since we'll never use that mode.
+    fSampleRate[ddl]     = input.GetNPretriggerSamples();
+  }
   AliFMDDebug(3, ("RCU @ DDL %d zero suppression: %s", 
                   ddl, (fZeroSuppress[ddl] ? "yes" : "no")));
-
-  // WARNING: We store the noise factor in the 2nd baseline
-  // filters excluded post samples, since we'll never use that
-  // mode. 
-  fNoiseFactor[ddl]  = input.GetNPostsamples();
-  AliFMDDebug(3, ("RCU @ DDL %d noise factor: %d", ddl,fNoiseFactor[ddl]));
-    
-  // WARNING: We store the sample rate in the number of pre-trigger
-  // samples, since we'll never use that mode.
-  fSampleRate[ddl]     = input.GetNPretriggerSamples();
+  AliFMDDebug(3, ("RCU @ DDL %d noise factor: %d", ddl,fNoiseFactor[ddl]));    
   AliFMDDebug(3, ("RCU @ DDL %d sample rate: %d", ddl,fSampleRate[ddl]));
 
+
   // Get Errors seen 
   Int_t nChAddrMismatch = input.GetNChAddrMismatch();
   Int_t nChLenMismatch  = input.GetNChLengthMismatch();
@@ -204,7 +268,7 @@ AliFMDRawReader::NewChannel(AliAltroRawStreamV3& input,  UShort_t det,
                  "hardware address 0x%03x", ddl, hwaddr));
     return -1;
   }
-  AliFMDDebug(3, ("Board: 0x%02x, Altro: 0x%x, Channel: 0x%x", 
+  AliFMDDebug(4, ("Board: 0x%02x, Altro: 0x%x, Channel: 0x%x", 
                  board, chip, channel));
 
   // Get the 'conditions'
@@ -496,40 +560,6 @@ Bool_t AliFMDRawReader::ReadSODevent(AliFMDCalibSampleRate* sampleRate,
   streamer.Reset();
   streamer.SelectRawData("FMD");
   //fReader->GetDDLID();
-  //Int_t detID = fReader->GetDetectorID();
-  
-  //  while(fReader->ReadNextData(fData)) {
-  /*  
-    Int_t ddl   = fReader->GetDDLID();
-    Int_t detID = fReader->GetDetectorID();
-    if (detectors) detectors[map->DDL2Detector(ddl)-1] = kTRUE;
-    AliFMDDebug(0, (" From reader: DDL number is %d , det ID is %d",ddl,detID));
-    
-    fNbytes = fReader->GetDataSize();
-    
-    ULong_t nWords      = GetNwords();
-    UInt_t  trailerLast = Get32bitWord(nWords);
-    AliFMDDebug(20, (" # Bytes: %d, # Words: %d, Last word: 0x%08x", 
-                    fNbytes, nWords, trailerLast));
-    if ((trailerLast & 0xFFFF0000) != 0xAAAA0000) {
-      AliWarning(Form("Last word 0x%08x does not match RCU II trailer",
-                     trailerLast));
-      //return kFALSE;
-    }
-    
-    // 7 last bits is size of trailer
-    ULong_t nTrailerWords = trailerLast & 0x7f; 
-    ULong_t nPayloadWords = Get32bitWord(nWords - nTrailerWords+1);
-
-    AliFMDDebug(20, (" # trailer words: %d, # payload words: %d", 
-                    nTrailerWords, nPayloadWords));
-    
-    ULong_t nPayloadWords = streamer.GetSOD...();
-    UInt_t   payloadWords* = streamer.GetSOD...();
-  */
-
-  
-  
   while (streamer.NextDDL()) {
     Int_t ddl   = streamer.GetDDLNumber();
     Int_t detID = fReader->GetDetectorID();
@@ -541,11 +571,11 @@ Bool_t AliFMDRawReader::ReadSODevent(AliFMDCalibSampleRate* sampleRate,
     UInt_t*  payloadWords  = reinterpret_cast<UInt_t*>(payloadData);
     //UInt_t*   payloadWords  = streamer.GetRCUPayloadInSOD();
 
-    std::cout<<nPayloadWords<<"    "<<ddl<<std::endl;
+    //std::cout<<nPayloadWords<<"    "<<ddl<<std::endl;
     for (ULong_t i = 1; i <= nPayloadWords ; i++, payloadWords++) {
       UInt_t payloadWord = *payloadWords; // Get32bitWord(i);
     
-      std::cout<<i<<Form("  word: 0x%x",payloadWord)<<std::endl;
+      //std::cout<<i<<Form("  word: 0x%x",payloadWord)<<std::endl;
       // address is only 24 bit
       UInt_t address       = (0xffffff & payloadWord);
       UInt_t type          = ((address >> 21) & 0xf);