1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //____________________________________________________________________
20 // Class to read ADC values from a AliRawReader object.
22 // This class uses the AliFMDRawStreamer class to read the ALTRO
30 // +-----------------+ <<references>> +--------------+
31 // | AliFMDRawReader |<>----------------| AliRawReader |
32 // +-----------------+ +--------------+
36 // +-----------------+ <<uses>> |
37 // | AliFMDRawStream |------------------------+
38 // +-----------------+
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
55 //____________________________________________________________________
56 ClassImp(AliFMDRawReader)
58 ; // This is here to keep Emacs for indenting the next line
61 //____________________________________________________________________
62 AliFMDRawReader::AliFMDRawReader(AliRawReader* reader, TTree* tree)
63 : TTask("FMDRawReader", "Reader of Raw ADC values from the FMD"),
69 AliFMDParameters* pars = AliFMDParameters::Instance();
70 fSampleRate = pars->GetSampleRate();
74 //____________________________________________________________________
76 AliFMDRawReader::Exec(Option_t*)
78 // Read raw data into the digits array
79 if (!fReader->ReadHeader()) {
80 Error("ReadAdcs", "Couldn't read header");
85 TClonesArray* array = new TClonesArray("AliFMDDigit");
86 fTree->Branch("FMD", &array);
88 // Use AliAltroRawStream to read the ALTRO format. No need to
89 // reinvent the wheel :-)
90 AliFMDRawStream input(fReader, fSampleRate);
92 fReader->Select(AliFMDParameters::kBaseDDL >> 8);
96 UShort_t detector = 1; // Must be one here
97 UShort_t oldDetector = 0;
104 // Loop over data in file
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) {
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(),
122 new ((*array)[n]) AliFMDDigit(oldDetector,
126 counts[0], counts[1], counts[2]);
130 static_cast<AliFMDDigit*>(fFMD->Digits()->
131 UncheckedAt(fFMD->GetNdigits()-1));
136 AliDebug(10, Form("Read %d channels for FMD%d",
137 count + 1, detector));
142 // If we got a new DDL, it means we have a new detector.
145 AliDebug(10, Form("Read %d channels for FMD%d",
146 count + 1, detector));
147 // Reset counts, and update the DDL cache
150 // Check that we're processing a FMD detector
151 Int_t detId = fReader->GetDetectorID();
152 if (detId != (AliFMDParameters::kBaseDDL >> 8)) {
153 Error("ReadAdcs", "Detector ID %d != %d",
154 detId, (AliFMDParameters::kBaseDDL >> 8));
157 // Figure out what detector we're deling with
158 oldDetector = detector;
160 case 0: detector = 1; break;
161 case 1: detector = 2; break;
162 case 2: detector = 3; break;
164 Error("ReadAdcs", "Unknown DDL 0x%x for FMD", ddl);
167 AliDebug(10, Form("Reading ADCs for 0x%x - That is FMD%d",
168 fReader->GetEquipmentId(), detector));
173 counts[input.Sample()] = input.Count();
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;
185 //____________________________________________________________________