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 fTOFGeometry = new AliTOFGeometry();
68 fRawReader->Select(5);
72 //_____________________________________________________________________________
73 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
88 //fCounter = -1; // v0.01
90 fTOFGeometry = new AliTOFGeometry();
94 //_____________________________________________________________________________
95 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
98 // assignment operator
101 fRawReader = stream.fRawReader;
105 fTDCChannel = stream.fTDCChannel;
108 fErrorFlag = stream.fErrorFlag;
109 //fCounter = stream.fCounter; // v0.01
111 fTOFGeometry = stream.fTOFGeometry;
117 //_____________________________________________________________________________
118 AliTOFRawStream::~AliTOFRawStream()
127 //_____________________________________________________________________________
128 Bool_t AliTOFRawStream::Next()
130 // read the next raw digit
131 // returns kFALSE if there is no digit left
133 //fCounter++; // v0.01
140 if (!fRawReader->ReadNextInt(data)) return kFALSE;
141 Int_t dummy = data & 0x007F; // first 7 bits
142 AliInfo(Form("This is the number of the current DDL file %2i",dummy));
146 if (!fRawReader->ReadNextInt(data)) return kFALSE;
148 fTRM = data & 0x000F; // first 4 bits
149 fTDC = (data >> 4) & 0x001F; // next 5 bits
150 fTDCChannel = (data >> 9) & 0x0007; // next 3 bits
151 fADC = (data >> 12) & 0x000FFFFF; // last 20 bits // v0.01
152 //fADC = (data >> 12) & 0x00FF; // next 8 bits // v0.02
154 if (!fRawReader->ReadNextInt(data)) return kFALSE;
156 fErrorFlag = data & 0x00FF; // first 8 bits
157 fTof = (data >> 8) & 0x00FFFFFF; // last 24 bits // v0.01
158 //fTof = (data >> 8) & 0x0FFF; // next 12 bits // v0.02
160 fDDL = fRawReader->GetDDLID();
162 //AliInfo(Form("fDDL %2i,fTRM %2i, fTDC %2i, fTDCChannel %1i",fDDL,fTRM,fTDC,fTDCChannel));
166 //_____________________________________________________________________________
168 Int_t AliTOFRawStream::GetSector() const
171 // Transform the Hardware coordinate to Software coordinate
172 // and also write it in the digit form
176 iSector = (Int_t)((Float_t)fDDL/AliTOFGeometry::NDDL());
181 //_____________________________________________________________________________
183 Int_t AliTOFRawStream::GetPlate() const
186 // Transform the Hardware coordinate to Software coordinate
187 // and also write it in the digit form
192 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
194 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
196 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
198 if (iStripPerSector < fTOFGeometry->NStripC())
200 else if (iStripPerSector>=fTOFGeometry->NStripC() &&
201 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB())
203 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB() &&
204 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
206 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
207 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
209 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
210 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+fTOFGeometry->NStripC())
218 //_____________________________________________________________________________
220 Int_t AliTOFRawStream::GetStrip() const
223 // Transform the Hardware coordinate to Software coordinate
224 // and also write it in the digit form
229 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
231 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
233 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
235 if (iStripPerSector < fTOFGeometry->NStripC())
236 iStrip = iStripPerSector;
237 else if (iStripPerSector >=fTOFGeometry->NStripC() &&
238 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB())
239 iStrip = iStripPerSector-fTOFGeometry->NStripC();
240 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB() &&
241 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
242 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB();
243 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
244 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
245 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA();
246 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
247 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+fTOFGeometry->NStripC())
248 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA()-AliTOFGeometry::NStripB();
255 //_____________________________________________________________________________
257 Int_t AliTOFRawStream::GetPadZ() const
260 // Transform the Hardware coordinate to Software coordinate
261 // and also write it in the digit form
266 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
268 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
270 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
272 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
274 iPadZ = iPadPerStrip%AliTOFGeometry::NpadZ();
279 //_____________________________________________________________________________
281 Int_t AliTOFRawStream::GetPadX() const
284 // Transform the Hardware coordinate to Software coordinate
285 // and also write it in the digit form
290 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
292 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
294 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
296 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
298 iPadX = (Int_t)(iPadPerStrip/(Float_t)AliTOFGeometry::NpadZ());
303 //_____________________________________________________________________________