]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - FMD/AliFMDRawReader.cxx
New defaults values
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.cxx
... / ...
CommitLineData
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 "AliFMDParameters.h" // ALIFMDPARAMETERS_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 <TTree.h> // ROOT_TTree
53#include <TClonesArray.h> // ROOT_TClonesArray
54
55//____________________________________________________________________
56ClassImp(AliFMDRawReader)
57#if 0
58 ; // This is here to keep Emacs for indenting the next line
59#endif
60
61//____________________________________________________________________
62AliFMDRawReader::AliFMDRawReader(AliRawReader* reader, TTree* tree)
63 : TTask("FMDRawReader", "Reader of Raw ADC values from the FMD"),
64 fTree(tree),
65 fReader(reader),
66 fSampleRate(1)
67{
68 // Default CTOR
69}
70
71
72//____________________________________________________________________
73void
74AliFMDRawReader::Exec(Option_t*)
75{
76 // Read raw data into the digits array
77 if (!fReader->ReadHeader()) {
78 Error("ReadAdcs", "Couldn't read header");
79 return;
80 }
81
82 Int_t n = 0;
83 TClonesArray* array = new TClonesArray("AliFMDDigit");
84 fTree->Branch("FMD", &array);
85
86 // Get sample rate
87 AliFMDParameters* pars = AliFMDParameters::Instance();
88 fSampleRate = pars->GetSampleRate(AliFMDParameters::kBaseDDL);
89
90 // Use AliAltroRawStream to read the ALTRO format. No need to
91 // reinvent the wheel :-)
92 AliFMDRawStream input(fReader, fSampleRate);
93 // Select FMD DDL's
94 fReader->Select(AliFMDParameters::kBaseDDL);
95
96 Int_t oldDDL = -1;
97 Int_t count = 0;
98 UShort_t detector = 1; // Must be one here
99 UShort_t oldDetector = 0;
100 Bool_t next = kTRUE;
101
102 // local Cache
103 TArrayI counts(10);
104 counts.Reset(-1);
105
106 // Loop over data in file
107 while (next) {
108 next = input.Next();
109
110 count++;
111 Int_t ddl = fReader->GetDDLID();
112 if (ddl != oldDDL || input.IsNewStrip() || !next) {
113 // Make a new digit, if we have some data (oldDetector == 0,
114 // means that we haven't really read anything yet - that is,
115 // it's the first time we get here).
116 if (oldDetector > 0) {
117 // Got a new strip.
118 AliDebug(10, Form("Add a new strip: FMD%d%c[%2d,%3d] "
119 "(current: FMD%d%c[%2d,%3d])",
120 oldDetector, input.PrevRing(),
121 input.PrevSector() , input.PrevStrip(),
122 detector , input.Ring(), input.Sector(),
123 input.Strip()));
124 new ((*array)[n]) AliFMDDigit(oldDetector,
125 input.PrevRing(),
126 input.PrevSector(),
127 input.PrevStrip(),
128 counts[0], counts[1], counts[2]);
129 n++;
130#if 0
131 AliFMDDigit* digit =
132 static_cast<AliFMDDigit*>(fFMD->Digits()->
133 UncheckedAt(fFMD->GetNdigits()-1));
134#endif
135 }
136
137 if (!next) {
138 AliDebug(10, Form("Read %d channels for FMD%d",
139 count + 1, detector));
140 break;
141 }
142
143
144 // If we got a new DDL, it means we have a new detector.
145 if (ddl != oldDDL) {
146 if (detector != 0)
147 AliDebug(10, Form("Read %d channels for FMD%d",
148 count + 1, detector));
149 // Reset counts, and update the DDL cache
150 count = 0;
151 oldDDL = ddl;
152 // Check that we're processing a FMD detector
153 Int_t detId = fReader->GetDetectorID();
154 if (detId != (AliFMDParameters::kBaseDDL >> 8)) {
155 Error("ReadAdcs", "Detector ID %d != %d",
156 detId, (AliFMDParameters::kBaseDDL >> 8));
157 break;
158 }
159 // Figure out what detector we're deling with
160 oldDetector = detector;
161 switch (ddl) {
162 case 0: detector = 1; break;
163 case 1: detector = 2; break;
164 case 2: detector = 3; break;
165 default:
166 Error("ReadAdcs", "Unknown DDL 0x%x for FMD", ddl);
167 return;
168 }
169 AliDebug(10, Form("Reading ADCs for 0x%x - That is FMD%d",
170 fReader->GetEquipmentId(), detector));
171 }
172 counts.Reset(-1);
173 }
174
175 counts[input.Sample()] = input.Count();
176
177 AliDebug(10, Form("ADC of FMD%d%c[%2d,%3d] += %d",
178 detector, input.Ring(), input.Sector(),
179 input.Strip(), input.Count()));
180 oldDetector = detector;
181 }
182 fTree->Fill();
183 return;
184
185}
186
187//____________________________________________________________________
188//
189// EOF
190//