]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDRawReader.cxx
Commenting out unused variables (FedoraCore3, gcc 3.4.2)
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.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 // Class to read ADC values from a AliRawReader object. 
21 //
22 // This class uses the AliFMDRawStreamer class to read the ALTRO
23 // formatted data. 
24 // 
25 //          +-------+
26 //          | TTask |
27 //          +-------+
28 //              ^
29 //              |
30 //      +-----------------+  <<references>>  +--------------+
31 //      | AliFMDRawReader |<>----------------| AliRawReader |
32 //      +-----------------+                  +--------------+
33 //              |                                  ^
34 //              | <<uses>>                         |
35 //              V                                  |
36 //      +-----------------+      <<uses>>          |
37 //      | AliFMDRawStream |------------------------+
38 //      +-----------------+
39 //              |
40 //              V
41 //      +----------------+
42 //      | AliAltroStream |
43 //      +----------------+
44 //
45 #include <AliLog.h>             // ALILOG_H
46 #include "AliFMD.h"             // ALIFMD_H
47 #include "AliFMDDigit.h"        // ALIFMDDIGIT_H
48 #include "AliFMDRawStream.h"    // ALIFMDRAWSTREAM_H 
49 #include "AliRawReader.h"       // ALIRAWREADER_H 
50 #include "AliFMDRawReader.h"    // ALIFMDRAWREADER_H 
51 #include <TArrayI.h>            // ROOT_TArrayI
52 // #include <TClonesArray.h>    // ROOT_TClonesArray
53
54 //____________________________________________________________________
55 ClassImp(AliFMDRawReader);
56
57 //____________________________________________________________________
58 AliFMDRawReader::AliFMDRawReader(AliFMD* fmd, AliRawReader* reader) 
59   : TTask("FMDRawReader", "Reader of Raw ADC values from the FMD"),
60     fFMD(fmd),
61     fReader(reader)
62 {
63   // Default CTOR
64   SetSampleRate(fmd->GetSampleRate());
65 }
66
67
68 //____________________________________________________________________
69 void
70 AliFMDRawReader::Exec(Option_t*) 
71 {
72   // Read raw data into the digits array
73   if (!fReader->ReadHeader()) {
74     Error("ReadAdcs", "Couldn't read header");
75     return;
76   }
77
78   // Use AliAltroRawStream to read the ALTRO format.  No need to
79   // reinvent the wheel :-) 
80   AliFMDRawStream input(fReader, fSampleRate);
81   // Select FMD DDL's 
82   fReader->Select(AliFMD::kBaseDDL >> 8);
83   
84   Int_t    oldDDL      = -1;
85   Int_t    count       = 0;
86   UShort_t detector    = 1; // Must be one here
87   UShort_t oldDetector = 0;
88   Bool_t   next        = kTRUE;
89
90   // local Cache 
91   TArrayI counts(10);
92   counts.Reset(-1);
93   
94   // Loop over data in file 
95   while (next) {
96     next = input.Next();
97
98     count++; 
99     Int_t ddl = fReader->GetDDLID();
100     if (ddl != oldDDL || input.IsNewStrip() || !next) {
101       // Make a new digit, if we have some data (oldDetector == 0,
102       // means that we haven't really read anything yet - that is,
103       // it's the first time we get here). 
104       if (oldDetector > 0) {
105         // Got a new strip. 
106         AliDebug(10, Form("Add a new strip: FMD%d%c[%2d,%3d] "
107                           "(current: FMD%d%c[%2d,%3d])", 
108                           oldDetector, input.PrevRing(), 
109                           input.PrevSector() , input.PrevStrip(),
110                           detector , input.Ring(), input.Sector(), 
111                           input.Strip()));
112         fFMD->AddDigit(oldDetector, 
113                        input.PrevRing(), 
114                        input.PrevSector(), 
115                        input.PrevStrip(), 
116                        counts[0], counts[1], counts[2]);
117 #if 0
118         AliFMDDigit* digit = 
119           static_cast<AliFMDDigit*>(fFMD->Digits()->
120                                     UncheckedAt(fFMD->GetNdigits()-1));
121 #endif 
122       }
123         
124       if (!next) { 
125         AliDebug(10, Form("Read %d channels for FMD%d", 
126                           count + 1, detector));
127         break;
128       }
129     
130     
131       // If we got a new DDL, it means we have a new detector. 
132       if (ddl != oldDDL) {
133         if (detector != 0) 
134           AliDebug(10, Form("Read %d channels for FMD%d", 
135                             count + 1, detector));
136         // Reset counts, and update the DDL cache 
137         count       = 0;
138         oldDDL      = ddl;
139         // Check that we're processing a FMD detector 
140         Int_t detId = fReader->GetDetectorID();
141         if (detId != (AliFMD::kBaseDDL >> 8)) {
142           Error("ReadAdcs", "Detector ID %d != %d",
143                 detId, (AliFMD::kBaseDDL >> 8));
144           break;
145         }
146         // Figure out what detector we're deling with 
147         oldDetector = detector;
148         switch (ddl) {
149         case 0: detector = 1; break;
150         case 1: detector = 2; break;
151         case 2: detector = 3; break;
152         default:
153           Error("ReadAdcs", "Unknown DDL 0x%x for FMD", ddl);
154           return;
155         }
156         AliDebug(10, Form("Reading ADCs for 0x%x  - That is FMD%d",
157                           fReader->GetEquipmentId(), detector));
158       }
159       counts.Reset(-1);
160     }
161     
162     counts[input.Sample()] = input.Count();
163     
164     AliDebug(10, Form("ADC of FMD%d%c[%2d,%3d] += %d",
165                       detector, input.Ring(), input.Sector(), 
166                       input.Strip(), input.Count()));
167     oldDetector = detector;
168   }
169   return;
170
171 }
172
173 //____________________________________________________________________
174 // 
175 // EOF
176 //