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 **************************************************************************/
17 Revision 0.02 2005/07/28 A. De Caro:
18 Update format TOF raw data
20 Correction of few wrong corrispondences
21 between 'software' and 'hardware' numberings
23 Revision 0.01 2005/07/22 A. De Caro
24 Implement methods Next()
32 ///////////////////////////////////////////////////////////////////////////////
34 // This class provides access to TOF raw data in DDL files.
36 // It loops over all TOF raw data given by the AliRawReader.
38 ///////////////////////////////////////////////////////////////////////////////
41 #include "AliRawReader.h"
43 #include "AliTOFGeometry.h"
44 #include "AliTOFRawStream.h"
46 ClassImp(AliTOFRawStream)
49 //_____________________________________________________________________________
50 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader)
53 // create an object to read TOF raw digits
56 fRawReader = rawReader;
64 //fCounter = -1; // v0.01
66 fRawReader->Select(5);
70 //_____________________________________________________________________________
71 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
86 //fCounter = -1; // v0.01
90 //_____________________________________________________________________________
91 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
94 // assignment operator
97 fRawReader = stream.fRawReader;
101 fTDCChannel = stream.fTDCChannel;
104 fErrorFlag = stream.fErrorFlag;
105 //fCounter = stream.fCounter; // v0.01
111 //_____________________________________________________________________________
112 AliTOFRawStream::~AliTOFRawStream()
119 //_____________________________________________________________________________
120 Bool_t AliTOFRawStream::Next()
122 // read the next raw digit
123 // returns kFALSE if there is no digit left
125 //fCounter++; // v0.01
132 if (!fRawReader->ReadNextInt(data)) return kFALSE;
133 Int_t dummy = data & 0x007F; // first 7 bits
134 AliInfo(Form("This is the number of the current DDL file %2i",dummy));
138 if (!fRawReader->ReadNextInt(data)) return kFALSE;
140 fTRM = data & 0x000F; // first 4 bits
141 fTDC = (data >> 4) & 0x001F; // next 5 bits
142 fTDCChannel = (data >> 9) & 0x0007; // next 3 bits
143 fADC = (data >> 12) & 0x000FFFFF; // last 20 bits // v0.01
144 //fADC = (data >> 12) & 0x00FF; // next 8 bits // v0.02
146 if (!fRawReader->ReadNextInt(data)) return kFALSE;
148 fErrorFlag = data & 0x00FF; // first 8 bits
149 fTof = (data >> 8) & 0x00FFFFFF; // last 24 bits // v0.01
150 //fTof = (data >> 8) & 0x0FFF; // next 12 bits // v0.02
152 fDDL = fRawReader->GetDDLID();
154 //AliInfo(Form("fDDL %2i,fTRM %2i, fTDC %2i, fTDCChannel %1i",fDDL,fTRM,fTDC,fTDCChannel));
158 //_____________________________________________________________________________
160 Int_t AliTOFRawStream::GetSector() const
163 // Transform the Hardware coordinate to Software coordinate
164 // and also write it in the digit form
168 iSector = (Int_t)((Float_t)fDDL/AliTOFGeometry::NDDL());
173 //_____________________________________________________________________________
175 Int_t AliTOFRawStream::GetPlate() const
178 // Transform the Hardware coordinate to Software coordinate
179 // and also write it in the digit form
184 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
186 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
188 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
190 if (iStripPerSector < AliTOFGeometry::NStripC())
192 else if (iStripPerSector>=AliTOFGeometry::NStripC() &&
193 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())
195 else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB() &&
196 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
198 else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
199 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
201 else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
202 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripC())
210 //_____________________________________________________________________________
212 Int_t AliTOFRawStream::GetStrip() const
215 // Transform the Hardware coordinate to Software coordinate
216 // and also write it in the digit form
221 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
223 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
225 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
227 if (iStripPerSector < AliTOFGeometry::NStripC())
228 iStrip = iStripPerSector;
229 else if (iStripPerSector >=AliTOFGeometry::NStripC() &&
230 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())
231 iStrip = iStripPerSector-AliTOFGeometry::NStripC();
232 else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB() &&
233 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
234 iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB();
235 else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
236 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
237 iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA();
238 else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
239 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripC())
240 iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA()-AliTOFGeometry::NStripB();
247 //_____________________________________________________________________________
249 Int_t AliTOFRawStream::GetPadZ() const
252 // Transform the Hardware coordinate to Software coordinate
253 // and also write it in the digit form
258 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
260 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
262 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
264 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
266 iPadZ = iPadPerStrip%AliTOFGeometry::NpadZ();
271 //_____________________________________________________________________________
273 Int_t AliTOFRawStream::GetPadX() const
276 // Transform the Hardware coordinate to Software coordinate
277 // and also write it in the digit form
282 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
284 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
286 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
288 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
290 iPadX = (Int_t)(iPadPerStrip/(Float_t)AliTOFGeometry::NpadZ());
295 //_____________________________________________________________________________