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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 /// This class provides access to CTP DDL raw data.
20 /// The raw data format is taken form the trigger TDR.
21 /// The meaning of the trigger class and cluster masks
22 /// are given in the trigger description file (in /data)
23 /// and in the AliCentralTrigger class.
25 ///////////////////////////////////////////////////////////////////////////////
27 #include "AliCTPRawStream.h"
28 #include "AliRawReader.h"
31 #include "AliTriggerIR.h"
33 ClassImp(AliCTPRawStream)
35 //_____________________________________________________________________________
36 AliCTPRawStream::AliCTPRawStream(AliRawReader* rawReader) :
37 fIRArray("AliTriggerIR",3),
47 // create an object to read CTP raw data
49 // select the raw data corresponding to
50 // the CTP detector id
52 AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("TRG")));
53 fRawReader->Select("TRG");
56 //_____________________________________________________________________________
57 AliCTPRawStream::AliCTPRawStream(const AliCTPRawStream& stream) :
59 fIRArray("AliTriggerIR",3),
70 AliFatal("Copy constructor not implemented");
73 //_____________________________________________________________________________
74 AliCTPRawStream& AliCTPRawStream::operator = (const AliCTPRawStream&
77 AliFatal("Assignment operator not implemented");
81 //_____________________________________________________________________________
82 AliCTPRawStream::~AliCTPRawStream()
88 //_____________________________________________________________________________
89 void AliCTPRawStream::Reset()
91 // reset raw stream params
94 fClassMask = fClusterMask = 0;
96 if (fRawReader) fRawReader->Reset();
99 //_____________________________________________________________________________
100 Bool_t AliCTPRawStream::Next()
102 // read the whole CTP raw data stream
103 // return kFALSE in case of error
105 UChar_t *data = NULL;
107 // CTP raw data does not contain CDH
108 fRawReader->RequireHeader(kFALSE);
110 if (!fRawReader->ReadNextData(data)) {
111 fRawReader->RequireHeader(kTRUE);
115 if ((fRawReader->GetDataSize()) < 32 ||
116 ((fRawReader->GetDataSize() % 4) != 0)) {
117 AliError(Form("Wrong CTP raw data size: %d",fRawReader->GetDataSize()));
118 fRawReader->RequireHeader(kTRUE);
123 fBC |= (data[1] & 0xF) << 8;
125 fOrbit = data[4] << 12;
126 fOrbit |= (data[5] & 0xF) << 20;
128 fOrbit |= (data[9] & 0xF) << 8;
130 fClusterMask = data[12] >> 2;
132 fClassMask = ((ULong64_t)data[12] & 0x3) << 48;
134 fClassMask |= (ULong64_t)data[16] << 36;
135 fClassMask |= ((ULong64_t)data[17] & 0xF) << 44;
137 fClassMask |= (ULong64_t)data[20] << 24;
138 fClassMask |= ((ULong64_t)data[21] & 0xF) << 32;
140 fClassMask |= (ULong64_t)data[24] << 12;
141 fClassMask |= ((ULong64_t)data[25] & 0xF) << 20;
143 fClassMask |= (ULong64_t)data[28];
144 fClassMask |= ((ULong64_t)data[29] & 0xF) << 8;
146 if (fRawReader->GetDataSize() == 32) {
147 AliDebug(1,"No trigger input and interaction records found");
148 fRawReader->RequireHeader(kTRUE);
152 // Read detector trigger inputs
153 if (fRawReader->GetDataSize() < 52) {
154 AliError(Form("Wrong CTP raw data size: %d",fRawReader->GetDataSize()));
155 fRawReader->RequireHeader(kTRUE);
159 fL0TriggerInputs = data[32] << 12;
160 fL0TriggerInputs |= (data[33] & 0xF) << 20;
161 fL0TriggerInputs |= data[36];
162 fL0TriggerInputs |= (data[37] & 0xF) << 8;
164 fL1TriggerInputs = data[40] << 12;
165 fL1TriggerInputs |= (data[41] & 0xF) << 20;
166 fL1TriggerInputs |= data[44];
167 fL1TriggerInputs |= (data[45] & 0xF) << 8;
169 fL2TriggerInputs = data[48] << 12;
170 fL2TriggerInputs |= (data[49] & 0xF) << 20;
172 if (fRawReader->GetDataSize() == 52) {
173 AliDebug(1,"No interaction records found");
174 fRawReader->RequireHeader(kTRUE);
181 UInt_t *irdata = NULL;
184 Bool_t incomplete = kFALSE, transerr = kFALSE;
185 while (iword < fRawReader->GetDataSize()) {
186 if (data[iword+1] & 0x80) {
187 UChar_t flag = ((data[iword+1] >> 4) & 0x3);
190 new (fIRArray[fIRArray.GetEntriesFast()])
191 AliTriggerIR(orbit,irsize,irdata,incomplete,transerr);
192 irdata = NULL; irsize = 0;
195 orbit = data[iword] << 12;
196 orbit |= (data[iword+1] & 0xF) << 20;
197 transerr = ((data[iword+1] >> 6) & 0x1);
201 else if (flag == 3) {
204 orbit |= data[iword];
205 orbit |= ((data[iword+1] & 0xF) << 8);
210 UShort_t bc = data[iword];
211 bc |= ((data[iword] & 0xF) << 8);
218 irdata = (UInt_t *)&data[iword];
227 AliWarning(Form("Invalid interaction record (%d %d)",iword,fRawReader->GetDataSize()));
233 new (fIRArray[fIRArray.GetEntriesFast()])
234 AliTriggerIR(orbit,irsize,irdata,incomplete,transerr);
235 irdata = NULL; irsize = 0;
238 // Restore the raw-reader state!!
239 fRawReader->RequireHeader(kTRUE);