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 "AliTOFGeometryV5.h"
45 #include "AliTOFRawStream.h"
47 ClassImp(AliTOFRawStream)
50 //_____________________________________________________________________________
51 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader)
54 // create an object to read TOF raw digits
57 fRawReader = rawReader;
65 //fCounter = -1; // v0.01
67 fTOFGeometry = new AliTOFGeometryV5();
69 fRawReader->Select(5);
73 //_____________________________________________________________________________
74 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
89 //fCounter = -1; // v0.01
91 fTOFGeometry = new AliTOFGeometryV5();
95 //_____________________________________________________________________________
96 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
99 // assignment operator
102 fRawReader = stream.fRawReader;
106 fTDCChannel = stream.fTDCChannel;
109 fErrorFlag = stream.fErrorFlag;
110 //fCounter = stream.fCounter; // v0.01
112 fTOFGeometry = stream.fTOFGeometry;
118 //_____________________________________________________________________________
119 AliTOFRawStream::~AliTOFRawStream()
128 //_____________________________________________________________________________
129 Bool_t AliTOFRawStream::Next()
131 // read the next raw digit
132 // returns kFALSE if there is no digit left
134 //fCounter++; // v0.01
141 if (!fRawReader->ReadNextInt(data)) return kFALSE;
142 Int_t dummy = data & 0x007F; // first 7 bits
143 AliInfo(Form("This is the number of the current DDL file %2i",dummy));
147 if (!fRawReader->ReadNextInt(data)) return kFALSE;
149 fTRM = data & 0x000F; // first 4 bits
150 fTDC = (data >> 4) & 0x001F; // next 5 bits
151 fTDCChannel = (data >> 9) & 0x0007; // next 3 bits
152 fADC = (data >> 12) & 0x000FFFFF; // last 20 bits // v0.01
153 //fADC = (data >> 12) & 0x00FF; // next 8 bits // v0.02
155 if (!fRawReader->ReadNextInt(data)) return kFALSE;
157 fErrorFlag = data & 0x00FF; // first 8 bits
158 fTof = (data >> 8) & 0x00FFFFFF; // last 24 bits // v0.01
159 //fTof = (data >> 8) & 0x0FFF; // next 12 bits // v0.02
161 fDDL = fRawReader->GetDDLID();
163 //AliInfo(Form("fDDL %2i,fTRM %2i, fTDC %2i, fTDCChannel %1i",fDDL,fTRM,fTDC,fTDCChannel));
167 //_____________________________________________________________________________
169 Int_t AliTOFRawStream::GetSector() const
172 // Transform the Hardware coordinate to Software coordinate
173 // and also write it in the digit form
177 iSector = (Int_t)((Float_t)fDDL/AliTOFGeometry::NDDL());
182 //_____________________________________________________________________________
184 Int_t AliTOFRawStream::GetPlate() const
187 // Transform the Hardware coordinate to Software coordinate
188 // and also write it in the digit form
193 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
195 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
197 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
199 if (iStripPerSector < fTOFGeometry->NStripC())
201 else if (iStripPerSector>=fTOFGeometry->NStripC() &&
202 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB())
204 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB() &&
205 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
207 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
208 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
210 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
211 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+fTOFGeometry->NStripC())
219 //_____________________________________________________________________________
221 Int_t AliTOFRawStream::GetStrip() const
224 // Transform the Hardware coordinate to Software coordinate
225 // and also write it in the digit form
230 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
232 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
234 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
236 if (iStripPerSector < fTOFGeometry->NStripC())
237 iStrip = iStripPerSector;
238 else if (iStripPerSector >=fTOFGeometry->NStripC() &&
239 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB())
240 iStrip = iStripPerSector-fTOFGeometry->NStripC();
241 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB() &&
242 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
243 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB();
244 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
245 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
246 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA();
247 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
248 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+fTOFGeometry->NStripC())
249 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA()-AliTOFGeometry::NStripB();
256 //_____________________________________________________________________________
258 Int_t AliTOFRawStream::GetPadZ() const
261 // Transform the Hardware coordinate to Software coordinate
262 // and also write it in the digit form
267 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
269 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
271 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
273 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
275 iPadZ = iPadPerStrip%AliTOFGeometry::NpadZ();
280 //_____________________________________________________________________________
282 Int_t AliTOFRawStream::GetPadX() const
285 // Transform the Hardware coordinate to Software coordinate
286 // and also write it in the digit form
291 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
293 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
295 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
297 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
299 iPadX = (Int_t)(iPadPerStrip/(Float_t)AliTOFGeometry::NpadZ());
304 //_____________________________________________________________________________