]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDRawReader.h
Added option to swap sides (Ruben)
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.h
index 3584d5e7c45263166a2162cb6c08c8db9d58129d..d50037451ddfac15183aa1c89db402cf121a3fbc 100644 (file)
@@ -33,6 +33,7 @@ class TClonesArray;
 class TArrayS;
 class AliFMDCalibSampleRate;
 class AliFMDCalibStripRange;
+class AliFMDUShortMap;
 
 //____________________________________________________________________
 /** @brief Class to read ALTRO formated raw data from an AliRawReader
@@ -48,6 +49,13 @@ class AliFMDCalibStripRange;
 class AliFMDRawReader : public TTask 
 {
 public:
+  /** Number of possible DDLs */
+  enum { 
+    kNDDL = 3
+  };
+  enum { 
+    kBadSignal = 0x7FFF // Largest signed 16bit short integer
+  };
   /** 
    * CTOR 
    *
@@ -69,14 +77,18 @@ public:
    * Read ADC's into a TClonesArray of AliFMDDigit objects. 
    *
    * @param array       Array to read into 
-   * @param summable    Create SDigits rather than digits 
-   * @param pedSub      Whether to do pedestal subtraction.
-   * @param noiseFactor If we do pedestal subtraction, then this is
-   *        the number we use to suppress remenants of the noise.
    * 
    * @return @c true on success 
    */
   virtual Bool_t ReadAdcs(TClonesArray* array);
+  /** 
+   * Read ADCs into a unsigned short map. 
+   * 
+   * @param map Map to read into 
+   * 
+   * @return true on success 
+   */
+  virtual Bool_t ReadAdcs(AliFMDUShortMap& map);
   /** 
    * Read SOD event into passed objects.
    * 
@@ -123,9 +135,15 @@ public:
    * @param zs   On return, whether zero-supp. is enabled
    * @param fac  On return, the usd noise factor
    * 
-   * @return true if valid data is returned
+   * @return 0 if there's no more data.  -1 if the read sample
+   * corresponds to a bad bunch in the channel.  Positive return
+   * values represent a bit mask of 
+   * - 0x1  New DDL 
+   * - 0x2  New Channel 
+   * - 0x4  New Bunch 
+   * - 0x8  New Sample 
    */
-  Bool_t NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec, UShort_t& str,
+  Int_t NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec, UShort_t& str,
                    UShort_t& sam, UShort_t& rat, Short_t&  adc, 
                    Bool_t&   zs,  UShort_t& fac);
   /** 
@@ -139,12 +157,35 @@ public:
    * @param zs   On return, whether zero-supp. is enabled
    * @param fac  On return, the usd noise factor
    * 
-   * @return true if valid data is returned
+   * @return 0 if there's no more data.  -1 if the read sample
+   * corresponds to a bad bunch in the channel.  Positive return
+   * values represent a bit mask of 
+   * - 0x1  New DDL 
+   * - 0x2  New Channel 
+   * - 0x4  New Bunch 
+   * - 0x8  New Sample 
    */
-  Bool_t NextSignal(UShort_t& det, Char_t&   rng, 
-                   UShort_t& sec, UShort_t& str, 
-                   Short_t&  adc, Bool_t&   zs, 
-                   UShort_t& fac);
+  Int_t NextSignal(UShort_t& det, Char_t&   rng, 
+                  UShort_t& sec, UShort_t& str, 
+                  Short_t&  adc, Bool_t&   zs, 
+                  UShort_t& fac);
+  /** 
+   * Get number of read-out errors.  Note, that a channel marked as
+   * bad counts as 10 errors 
+   * 
+   * @param ddl DDL off set ([0,kNDDL-1])
+   * 
+   * @return Number of seen errors 
+   */
+  UShort_t GetNErrors(UShort_t ddl) const {return (ddl >= kNDDL ? 0 : fNErrors[ddl]);}
+  /** 
+   * Get the phase of the L1 signal 
+   * 
+   * @param ddl DDL number ([0,kNDDL-1])
+   * 
+   * @return Phase of the L1 signal in steps of 25ns. 
+   */
+  UShort_t GetL1Phase(UShort_t ddl) const {return (ddl >= kNDDL ? -1 : fL1Phase[ddl]);}
   /** 
    * Whether to keep a sample based on the rate used. 
    * 
@@ -199,9 +240,20 @@ protected:
    * 
    * @return negative value in case of problems, hardware address otherwise
    */
-  Int_t NewChannel(AliAltroRawStreamV3& input, UShort_t det, Char_t&  ring, 
+  Int_t NewChannel(const AliAltroRawStreamV3& input, 
+                  UShort_t det, Char_t&  ring, 
                   UShort_t& sec, Short_t& strbase);
-
+  /** 
+   * Process a new bunch.
+   * 
+   * @param input    Input stream
+   * @param start    On input, the old start time. On return, the start time
+   * @param length   On return, the bunch length
+   * 
+   * @return true on success, false otherwise 
+   */
+  Bool_t NewBunch(const AliAltroRawStreamV3& input, 
+                 UShort_t&  start, UShort_t& length);
   /** 
    * Process a new timebin
    * 
@@ -215,7 +267,8 @@ protected:
    * 
    * @return negative value in case of problems, ADC value otherwise
    */  
-  Int_t NewSample(AliAltroRawStreamV3& input, Int_t i, UShort_t t, UShort_t sec,
+  Int_t NewSample(const AliAltroRawStreamV3& input, 
+                 Int_t i, UShort_t t, UShort_t sec,
                  UShort_t  strbase, Short_t&  str, UShort_t& samp);
 
   /** 
@@ -242,18 +295,20 @@ protected:
    * 
    * @return 
    */
-  Int_t GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board);
-  TTree*          fTree;            //! Pointer to tree to read into 
-  AliRawReader*   fReader;          //! Pointer to raw reader 
-  UShort_t        fSampleRate[3];   // The sample rate (if 0,inferred from data)
-  UChar_t*        fData;            // Data pointer
-  ULong_t        fNbytes;          // Number of bytes
-  Bool_t          fZeroSuppress[3]; // Zero suppression flag
-  UShort_t        fNoiseFactor[3];  // Noise factor 
+  Int_t GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board) const;
+  TTree*          fTree;             //! Pointer to tree to read into 
+  AliRawReader*   fReader;           //! Pointer to raw reader 
+  UShort_t        fSampleRate[kNDDL];// The sample rate (if 0,infer from data)
+  UChar_t*        fData;             // Data pointer
+  ULong_t        fNbytes;           // Number of bytes
+  Bool_t          fZeroSuppress[kNDDL]; // Zero suppression flag
+  UShort_t        fNoiseFactor[kNDDL];  // Noise factor 
   UShort_t        fMinStrip;        // Current minimum strip number (0)
   UShort_t        fMaxStrip;        // Current maximum strip number (127)
   UShort_t        fPreSamp;         // Current number of pre-samples (14+5)
-  AliFMDUShortMap fSeen;
+  AliFMDUShortMap fSeen;            // Seen strips 
+  UShort_t        fNErrors[kNDDL];  // Number of errors per DDL
+  UShort_t        fL1Phase[kNDDL];  // Number of errors per DDL
   
   ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache 
 };