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"),
72 //____________________________________________________________________
74 AliFMDRawReader::Exec(Option_t*)
76 // Read raw data into the digits array
77 if (!fReader->ReadHeader()) {
78 Error("ReadAdcs", "Couldn't read header");
83 TClonesArray* array = new TClonesArray("AliFMDDigit");
84 fTree->Branch("FMD", &array);
87 AliFMDParameters* pars = AliFMDParameters::Instance();
88 fSampleRate = pars->GetSampleRate(AliFMDParameters::kBaseDDL);
90 // Use AliAltroRawStream to read the ALTRO format. No need to
91 // reinvent the wheel :-)
92 AliFMDRawStream input(fReader, fSampleRate);
94 fReader->Select(AliFMDParameters::kBaseDDL);
98 UShort_t detector = 1; // Must be one here
99 UShort_t oldDetector = 0;
106 // Loop over data in file
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) {
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(),
124 new ((*array)[n]) AliFMDDigit(oldDetector,
128 counts[0], counts[1], counts[2]);
132 static_cast<AliFMDDigit*>(fFMD->Digits()->
133 UncheckedAt(fFMD->GetNdigits()-1));
138 AliDebug(10, Form("Read %d channels for FMD%d",
139 count + 1, detector));
144 // If we got a new DDL, it means we have a new detector.
147 AliDebug(10, Form("Read %d channels for FMD%d",
148 count + 1, detector));
149 // Reset counts, and update the DDL cache
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));
159 // Figure out what detector we're deling with
160 oldDetector = detector;
162 case 0: detector = 1; break;
163 case 1: detector = 2; break;
164 case 2: detector = 3; break;
166 Error("ReadAdcs", "Unknown DDL 0x%x for FMD", ddl);
169 AliDebug(10, Form("Reading ADCs for 0x%x - That is FMD%d",
170 fReader->GetEquipmentId(), detector));
175 counts[input.Sample()] = input.Count();
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;
187 //____________________________________________________________________