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