]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDRawStream.cxx
Bug fix for reading raw data - thanks Frederic YERMIA, Diego, and Gines MARTINEZ
[u/mrichter/AliRoot.git] / FMD / AliFMDRawStream.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //____________________________________________________________________
19 //                                                                          
20 // Buffer to read RAW ALTRO FMD format from a AliRawReader 
21 // 
22 // This class derives from AliAltroBuffer, but overloads the memer
23 // function Next to do some extra processing.  In particular, it tries
24 // to autodetect the sample rate.  If zero-suppression was used when
25 // writing the raw data, then the automatic discovery will not work,
26 // and the sample rate should be set explicitly. 
27 //
28 #include "AliFMDRawStream.h"            // ALIFMDRAWSTREAM_H
29 // #include <AliRawReader.h>            // ALIRAWREADER_H
30 #include "AliFMDParameters.h"
31 // #include <AliLog.h>
32 #include "AliFMDDebug.h" // Better debug macros
33 // #include <iomanip>
34 // #include <iostream>
35
36 //____________________________________________________________________
37 ClassImp(AliFMDRawStream)
38 #if 0
39   ; // This is here to keep Emacs for indenting the next line
40 #endif
41
42 //____________________________________________________________________
43 AliFMDRawStream::AliFMDRawStream(AliRawReader* reader) 
44   : AliAltroRawStream(reader)
45 {
46   // CTOR 
47   fNoAltroMapping = kFALSE;
48   // Select FMD DDL's 
49   SelectRawData("FMD");
50 }
51
52 //_____________________________________________________________________________
53 Bool_t 
54 AliFMDRawStream::ReadChannel(UInt_t& ddl, UInt_t& addr, 
55                              UInt_t& len, UShort_t* data)
56 {
57   // Read one channel and return.   Returns 0 when there's no more
58   // data. 
59   Int_t        l         = 0;
60   static Int_t last      = 0xFFFF; // 0xFFFF means signal is used
61   Bool_t       next      = kTRUE;
62   do {
63     Int_t signal = last;
64     if (last > 0x3FF) {
65       AliFMDDebug(30, ("Last is 0x%x, so reading a new word", last));
66       next   = Next();
67       if(!next){
68         addr = GetPrevHWAddress();
69         ddl  = GetPrevDDLNumber();
70         len  = l+1; // Need to add one - l points to last valid index
71         last = signal;
72         break;
73       }
74       signal = GetSignal();
75       if (GetHWAddress() != GetPrevHWAddress() && GetPrevHWAddress() >= 0) {
76         AliFMDDebug(15, ("New hardware address, was 0x%x, now 0x%x", 
77                           GetPrevHWAddress(), GetHWAddress()));
78         addr = GetPrevHWAddress();
79         ddl  = GetPrevDDLNumber();
80         len  = l+1; // Need to add one - l points to last valid index
81         last = signal;
82         break;
83       }
84     }
85     Int_t t  = GetTime();
86     l        = TMath::Max(l, t);
87     data[t]  = signal;
88     last     = 0xFFFF;
89   } while (next);
90   return next;
91 }
92
93
94 //_____________________________________________________________________________
95 //
96 // EOF
97 //