LCOV - code coverage report
Current view: top level - FMD/FMDrec - AliFMDRawReader.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 7 57.1 %
Date: 2016-06-14 17:26:59 Functions: 6 13 46.2 %

          Line data    Source code
       1             : #ifndef ALIFMDRAWREADER_H
       2             : #define ALIFMDRAWREADER_H
       3             : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
       4             :  * reserved. 
       5             :  *
       6             :  * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
       7             :  *
       8             :  * See cxx source for full Copyright notice                               
       9             :  */
      10             : //____________________________________________________________________
      11             : // 
      12             : // Class to read ADC values from a AliRawReader object. 
      13             : // Note, that it uses an ALTRO reader, which is wrong. 
      14             : // Perhaps we need to implement it our selves
      15             : // 
      16             : /* $Id$ */
      17             : /** @file    AliFMDRawReader.h
      18             :     @author  Christian Holm Christensen <cholm@nbi.dk>
      19             :     @date    Mon Mar 27 12:45:23 2006
      20             :     @brief   Class to read raw data 
      21             :     @ingroup FMD_rec
      22             : */
      23             : #include <TTask.h>
      24             : #include <TClonesArray.h>
      25             : #include "AliFMDUShortMap.h"
      26             : 
      27             : //____________________________________________________________________
      28             : class AliRawReader;
      29             : class AliAltroRawStreamV3;
      30             : class TTree;
      31             : class TClonesArray;
      32             : class TArrayS;
      33             : class AliFMDCalibSampleRate;
      34             : class AliFMDCalibStripRange;
      35             : class AliFMDUShortMap;
      36             : 
      37             : //____________________________________________________________________
      38             : /** @brief Class to read ALTRO formated raw data from an AliRawReader
      39             :     object. 
      40             :     @code 
      41             :     AliRawReader*    reader    = new AliRawReaderFile(0);
      42             :     AliFMDRawReader* fmdReader = new AliFMDRawReader(reader);
      43             :     TClonesArray*    array     = new TClonesArray("AliFMDDigit");
      44             :     fmdReader->ReadAdcs(array);
      45             :     @endcode 
      46             :     @ingroup FMD_rec
      47             : */
      48             : class AliFMDRawReader : public TTask 
      49             : {
      50             : public:
      51             :   /** Number of possible DDLs */
      52             :   enum { 
      53             :     kNDDL = 3
      54             :   };
      55             :   enum { 
      56             :     kBadSignal = 0x7FFF // Largest signed 16bit short integer
      57             :   };
      58             :   /** 
      59             :    * CTOR 
      60             :    *
      61             :    * @param reader Raw reader
      62             :    * @param array  Output tree 
      63             :    */
      64             :   AliFMDRawReader(AliRawReader* reader, TTree* array);
      65             :   /** 
      66             :    * DTOR 
      67             :    */
      68          16 :   virtual ~AliFMDRawReader() {}
      69           0 :   void SetVerbose(Bool_t verb=kTRUE) { fVerbose = verb; }
      70             :   /** 
      71             :    * Read in, and store in output tree 
      72             :    *
      73             :    * @param option Not used 
      74             :    */
      75             :   virtual void   Exec(Option_t* option="");
      76             :   /**
      77             :    * Read ADC's into a TClonesArray of AliFMDDigit objects. 
      78             :    *
      79             :    * @param array       Array to read into 
      80             :    * 
      81             :    * @return @c true on success 
      82             :    */
      83             :   virtual Bool_t ReadAdcs(TClonesArray* array);
      84             :   /** 
      85             :    * Read ADCs into a unsigned short map. 
      86             :    * 
      87             :    * @param map Map to read into 
      88             :    * 
      89             :    * @return true on success 
      90             :    */
      91             :   virtual Bool_t ReadAdcs(AliFMDUShortMap& map);
      92             :   /** 
      93             :    * Read SOD event into passed objects.
      94             :    * 
      95             :    * @param samplerate   The sample rate object to fill
      96             :    * @param striprange   The strip range object to fill
      97             :    * @param pulseSize    The pulse size object to fill
      98             :    * @param pulseLength  The pulse length (in events) object to fill
      99             :    * 
     100             :    * @return @c true on success
     101             :    */  
     102             :   virtual Bool_t ReadSODevent(AliFMDCalibSampleRate* samplerate, 
     103             :                               AliFMDCalibStripRange* striprange, 
     104             :                               TArrayS &pulseSize, 
     105             :                               TArrayS &pulseLength, 
     106             :                               Bool_t* detectors=0);
     107             :   /** 
     108             :    * Check of the data from DDL @a ddl is zero-suppressed
     109             :    * 
     110             :    * @param ddl DDL number (0-2)
     111             :    * 
     112             :    * @return @c true if the data from this DDL is zero-suppressed. 
     113             :    */  
     114          24 :   Bool_t IsZeroSuppressed(UShort_t ddl) const { return fZeroSuppress[ddl]; }
     115             :   /** 
     116             :    * The factor used to multiply the noise when making on-line
     117             :    * pedestal subtraction.
     118             :    * 
     119             :    * @param ddl DDL number (0-2)
     120             :    * 
     121             :    * @return The factor used. 
     122             :    */
     123          24 :   UShort_t NoiseFactor(UShort_t ddl) const { return fNoiseFactor[ddl]; }
     124             : 
     125             :   /** 
     126             :    * Get the next signal
     127             :    * 
     128             :    * @param det  On return, the detector
     129             :    * @param rng  On return, the ring
     130             :    * @param sec  On return, the sector
     131             :    * @param str  On return, the strip
     132             :    * @param sam  On return, the sample
     133             :    * @param rat  On return, the sample rate
     134             :    * @param adc  On return, the ADC value
     135             :    * @param zs   On return, whether zero-supp. is enabled
     136             :    * @param fac  On return, the usd noise factor
     137             :    * 
     138             :    * @return 0 if there's no more data.  -1 if the read sample
     139             :    * corresponds to a bad bunch in the channel.  Positive return
     140             :    * values represent a bit mask of 
     141             :    * - 0x1  New DDL 
     142             :    * - 0x2  New Channel 
     143             :    * - 0x4  New Bunch 
     144             :    * - 0x8  New Sample 
     145             :    */
     146             :   Int_t NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec, UShort_t& str,
     147             :                     UShort_t& sam, UShort_t& rat, Short_t&  adc, 
     148             :                     Bool_t&   zs,  UShort_t& fac);
     149             :   /** 
     150             :    * Get the next signal
     151             :    * 
     152             :    * @param det  On return, the detector
     153             :    * @param rng  On return, the ring
     154             :    * @param sec  On return, the sector
     155             :    * @param str  On return, the strip
     156             :    * @param adc  On return, the ADC value
     157             :    * @param zs   On return, whether zero-supp. is enabled
     158             :    * @param fac  On return, the usd noise factor
     159             :    * 
     160             :    * @return 0 if there's no more data.  -1 if the read sample
     161             :    * corresponds to a bad bunch in the channel.  Positive return
     162             :    * values represent a bit mask of 
     163             :    * - 0x1  New DDL 
     164             :    * - 0x2  New Channel 
     165             :    * - 0x4  New Bunch 
     166             :    * - 0x8  New Sample 
     167             :    */
     168             :   Int_t NextSignal(UShort_t& det, Char_t&   rng, 
     169             :                    UShort_t& sec, UShort_t& str, 
     170             :                    Short_t&  adc, Bool_t&   zs, 
     171             :                    UShort_t& fac);
     172             :   /** 
     173             :    * Get number of read-out errors.  Note, that a channel marked as
     174             :    * bad counts as 10 errors 
     175             :    * 
     176             :    * @param ddl DDL off set ([0,kNDDL-1])
     177             :    * 
     178             :    * @return Number of seen errors 
     179             :    */
     180           0 :   UShort_t GetNErrors(UShort_t ddl) const {return (ddl >= kNDDL ? 0 : fNErrors[ddl]);}
     181             :   /** 
     182             :    * Get the phase of the L1 signal 
     183             :    * 
     184             :    * @param ddl DDL number ([0,kNDDL-1])
     185             :    * 
     186             :    * @return Phase of the L1 signal in steps of 25ns. 
     187             :    */
     188           0 :   UShort_t GetL1Phase(UShort_t ddl) const {return (ddl >= kNDDL ? -1 : fL1Phase[ddl]);}
     189             :   /** 
     190             :    * Whether to keep a sample based on the rate used. 
     191             :    * 
     192             :    * @param samp Sample number 
     193             :    * @param rate Over sampling rate
     194             :    * 
     195             :    * @return Whether to keep the sample or not
     196             :    */
     197             :   static Bool_t SelectSample(UShort_t samp, UShort_t rate);
     198             : protected:
     199             :   /** 
     200             :    * Copy constructor 
     201             :    * 
     202             :    * @param o Object to construct from
     203             :    */  
     204             :   AliFMDRawReader(const AliFMDRawReader& o) 
     205             :     : TTask(o), 
     206             :       fTree(0), 
     207             :       fReader(0), 
     208             :       fData(0),
     209             :       fNbytes(0), 
     210             :       fMinStrip(0), 
     211             :       fMaxStrip(127),
     212             :       fPreSamp(14+5),
     213             :       fSeen(0),
     214             :       fVerbose(o.fVerbose), 
     215             :       fErrors(o.fErrors), 
     216             :       fNErrChanLen(o.fNErrChanLen), 
     217             :       fNErrAddress(o.fNErrAddress)
     218             :   {}
     219             :   /** 
     220             :    * Assignment operator
     221             :    * 
     222             :    * @return Reference to this object
     223             :    */
     224             :   AliFMDRawReader& operator=(const AliFMDRawReader&) { return *this; }
     225             :   /** 
     226             :    * Process a new DDL.  Sets the internal data members fZeroSuppress, 
     227             :    * fSampleRate, and fNoiseFactor based on information in the RCU trailer. 
     228             :    * 
     229             :    * @param input Input stream
     230             :    * @param det   On return, the detector number
     231             :    * 
     232             :    * @return negative value in case of problems, the DDL number otherwise
     233             :    */
     234             :   Int_t NewDDL(AliAltroRawStreamV3& input, UShort_t& det);
     235             :   /** 
     236             :    * Processs a new channel.  Sets the internal data members
     237             :    * fMinStrip, fMaxStrip, and fPreSamp. 
     238             :    * 
     239             :    * @param input   Input stream
     240             :    * @param det     Detector number
     241             :    * @param ring    On return, the ring identifier 
     242             :    * @param sec     On return, the sector number
     243             :    * @param strbase On return, the strip base
     244             :    * 
     245             :    * @return negative value in case of problems, hardware address otherwise
     246             :    */
     247             :   Int_t NewChannel(const AliAltroRawStreamV3& input, 
     248             :                    UShort_t det, Char_t&  ring, 
     249             :                    UShort_t& sec, Short_t& strbase);
     250             :   /** 
     251             :    * Process a new bunch.
     252             :    * 
     253             :    * @param input    Input stream
     254             :    * @param start    On input, the old start time. On return, the start time
     255             :    * @param length   On return, the bunch length
     256             :    * 
     257             :    * @return true on success, false otherwise 
     258             :    */
     259             :   Bool_t NewBunch(const AliAltroRawStreamV3& input, 
     260             :                   UShort_t&  start, UShort_t& length);
     261             :   /** 
     262             :    * Process a new timebin
     263             :    * 
     264             :    * @param input   Input stream
     265             :    * @param i       Index into bunch data
     266             :    * @param t       Time
     267             :    * @param sec     Sector number
     268             :    * @param strbase Base of strip numbers for this channel
     269             :    * @param str     On return, the strip number
     270             :    * @param samp    On return, the sample number
     271             :    * 
     272             :    * @return negative value in case of problems, ADC value otherwise
     273             :    */  
     274             :   Int_t NewSample(const AliAltroRawStreamV3& input, 
     275             :                   Int_t i, UShort_t t, UShort_t sec,
     276             :                   UShort_t  strbase, Short_t&  str, UShort_t& samp);
     277             : 
     278             :   /** 
     279             :    * 
     280             :    * Get the number of words 
     281             :    * 
     282             :    * @return Number of 32bit words 
     283             :    */
     284             :   ULong_t GetNwords() const {return fNbytes / 4;}
     285             :   /** 
     286             :    * Get the next 32bit word from payload
     287             :    * 
     288             :    * @param idx Which 32bit word to get
     289             :    * 
     290             :    * @return 
     291             :    */
     292             :   UInt_t Get32bitWord(Int_t idx);
     293             :   /** 
     294             :    * Get short index for a given half-ring
     295             :    * 
     296             :    * @param det   Detector number
     297             :    * @param ring  Ring identifer
     298             :    * @param board Board number
     299             :    * 
     300             :    * @return 
     301             :    */
     302             :   Int_t GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board) const;
     303             :   void AddError(Int_t ddl, Int_t hwaddr);
     304             :   void ReadbackError(const AliAltroRawStreamV3& input, const char* format, ...);
     305             : 
     306             :   TTree*          fTree;             //! Pointer to tree to read into 
     307             :   AliRawReader*   fReader;           //! Pointer to raw reader 
     308             :   UShort_t        fSampleRate[kNDDL];// The sample rate (if 0,infer from data)
     309             :   UChar_t*        fData;             // Data pointer
     310             :   ULong_t         fNbytes;           // Number of bytes
     311             :   Bool_t          fZeroSuppress[kNDDL]; // Zero suppression flag
     312             :   UShort_t        fNoiseFactor[kNDDL];  // Noise factor 
     313             :   UShort_t        fMinStrip;        // Current minimum strip number (0)
     314             :   UShort_t        fMaxStrip;        // Current maximum strip number (127)
     315             :   UShort_t        fPreSamp;         // Current number of pre-samples (14+5)
     316             :   AliFMDUShortMap fSeen;            // Seen strips 
     317             :   UShort_t        fNErrors[kNDDL];  // Number of errors per DDL
     318             :   UShort_t        fL1Phase[kNDDL];  // Number of errors per DDL
     319             :   Bool_t          fVerbose;         // Whether to be verbose 
     320             :   TClonesArray    fErrors;          // Clones array of channels with errors 
     321             :   UShort_t        fNErrChanLen;     // Number of channel length errors 
     322             :   UShort_t        fNErrAddress;     // Number of address errors 
     323             :   
     324     8608164 :   ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache 
     325             : };
     326             : 
     327             : #endif
     328             : //____________________________________________________________________
     329             : //
     330             : // Local Variables:
     331             : //   mode: C++
     332             : // End:
     333             : //
     334             : // EOF
     335             : //
     336             : 

Generated by: LCOV version 1.11