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