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