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 #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
31 //____________________________________________________________________
32 ClassImp(AliFMDRawReader);
34 //____________________________________________________________________
35 AliFMDRawReader::AliFMDRawReader(AliFMD* fmd, AliRawReader* reader)
36 : TTask("FMDRawReader", "Reader of Raw ADC values from the FMD"),
41 SetSampleRate(fmd->GetSampleRate());
45 //____________________________________________________________________
47 AliFMDRawReader::Exec(Option_t*)
49 // Read raw data into the digits array
50 if (!fReader->ReadHeader()) {
51 Error("ReadAdcs", "Couldn't read header");
55 // Use AliAltroRawStream to read the ALTRO format. No need to
56 // reinvent the wheel :-)
57 AliFMDRawStream input(fReader, fSampleRate);
59 fReader->Select(AliFMD::kBaseDDL >> 8);
63 UShort_t detector = 1; // Must be one here
64 UShort_t oldDetector = 0;
71 // Loop over data in file
76 Int_t ddl = fReader->GetDDLID();
77 if (ddl != oldDDL || input.IsNewStrip() || !next) {
78 // Make a new digit, if we have some data (oldDetector == 0,
79 // means that we haven't really read anything yet - that is,
80 // it's the first time we get here).
81 if (oldDetector > 0) {
83 AliDebug(10, Form("Add a new strip: FMD%d%c[%2d,%3d] "
84 "(current: FMD%d%c[%2d,%3d])",
85 oldDetector, input.PrevRing(),
86 input.PrevSector() , input.PrevStrip(),
87 detector , input.Ring(), input.Sector(),
89 fFMD->AddDigit(oldDetector,
93 counts[0], counts[1], counts[2]);
96 static_cast<AliFMDDigit*>(fFMD->Digits()->
97 UncheckedAt(fFMD->GetNdigits()-1));
102 AliDebug(10, Form("Read %d channels for FMD%d",
103 count + 1, detector));
108 // If we got a new DDL, it means we have a new detector.
111 AliDebug(10, Form("Read %d channels for FMD%d",
112 count + 1, detector));
113 // Reset counts, and update the DDL cache
116 // Check that we're processing a FMD detector
117 Int_t detId = fReader->GetDetectorID();
118 if (detId != (AliFMD::kBaseDDL >> 8)) {
119 Error("ReadAdcs", "Detector ID %d != %d",
120 detId, (AliFMD::kBaseDDL >> 8));
123 // Figure out what detector we're deling with
124 oldDetector = detector;
126 case 0: detector = 1; break;
127 case 1: detector = 2; break;
128 case 2: detector = 3; break;
130 Error("ReadAdcs", "Unknown DDL 0x%x for FMD", ddl);
133 AliDebug(10, Form("Reading ADCs for 0x%x - That is FMD%d",
134 fReader->GetEquipmentId(), detector));
139 counts[input.Sample()] = input.Count();
141 AliDebug(10, Form("ADC of FMD%d%c[%2d,%3d] += %d",
142 detector, input.Ring(), input.Sector(),
143 input.Strip(), input.Count()));
144 oldDetector = detector;
150 //____________________________________________________________________