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 // START raw data conversion class //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include <Riostream.h>
27 #include "AliSTARTRawData.h"
28 #include "AliSTARTdigit.h"
30 #include "AliRawDataHeader.h"
32 ClassImp(AliSTARTRawData)
34 //_____________________________________________________________________________
35 AliSTARTRawData::AliSTARTRawData():TObject()
38 - 48 channels (2 words each as in TOF DDL) for :
39 word 1 :0-5bit number of PMT; word 2: 0-7 error sign, 8-31 TDC
40 and the same but for amplified signal. Now I wrote the same time because
41 CDF are not ready and differences didn't measured yet.
43 - 96 channel for amplitude: very preliminary, QTC features are not
44 known now, preliminary i put as T1 time signal for this PMT in first
45 channel and T1+A in second, where A=Log(Amplitude);
46 and the same for amplified but A=Log(10*Amplitude).
48 - T0-A and T0-C 2 channels
49 - T0A-T0C vertex information
50 - Time Meaner where T0C TOF increase to the T0A TOF distance
51 - 6 multiplicity signals the same way as amplitude and with the same
58 fTimeTDC = new TArrayI(24);
59 fADC = new TArrayI(24);
60 fTimeTDCAmp = new TArrayI(24);
61 fADCAmp = new TArrayI(24);
62 fSumMult = new TArrayI(6);
67 //_____________________________________________________________________________
68 AliSTARTRawData::AliSTARTRawData(const AliSTARTRawData &r):TObject()
71 // AliSTARTrawData copy constructor
74 ((AliSTARTRawData &) r).Copy(*this);
78 //_____________________________________________________________________________
79 AliSTARTRawData::~AliSTARTRawData()
95 //_____________________________________________________________________________
96 AliSTARTRawData &AliSTARTRawData::operator=(const AliSTARTRawData &r)
99 // Assignment operator
102 if (this != &r) ((AliSTARTRawData &) r).Copy(*this);
107 //_____________________________________________________________________________
108 void AliSTARTRawData::GetDigits(AliSTARTdigit *fDigits, UInt_t *buf)
111 //This method packs the START digits in a proper 32 bits structure
113 //read START digits and fill TDC and ADC arrays
119 // Get the digits array
121 fDigits->GetTime(*fTimeTDC);
122 fDigits->GetADC(*fADC);
123 fDigits->GetTimeAmp(*fTimeTDCAmp);
124 fDigits->GetADCAmp(*fADCAmp);
125 fDigits->GetSumMult(*fSumMult);
127 // Loop through all PMT
129 for (Int_t det = 0; det < 24; det++) {
130 Int_t time=fTimeTDC->At(det);
131 Int_t qtc=fADC->At(det);
132 Int_t timeAmp=fTimeTDCAmp->At(det);
133 Int_t qtcAmp=fADCAmp->At(det);
135 //conver ADC to time (preliminary algorithm)
137 // DDL 1 0-5 -#PMT, 6-31 - empty
140 PackWord(baseWord,word, 0, 5);
142 buf[fIndex]=baseWord;
149 PackWord(baseWord,word,0, 7); // Error flag
151 PackWord(baseWord,word,8,31); // time-of-flight
153 buf[fIndex]=baseWord;
158 // DDL2 2 0-5 -#PMT, 6-31 - empty
160 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
162 buf[fIndex]=baseWord;
168 PackWord(baseWord,word,0, 7); // Error flag
170 PackWord(baseWord,word,8,31); // time-of-flight
172 buf[fIndex]=baseWord;
179 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
181 buf[fIndex]=baseWord;
187 PackWord(baseWord,word,0, 7); // Error flag
189 PackWord(baseWord,word,8,31); // time-of-flight
191 buf[fIndex]=baseWord;
199 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
201 buf[fIndex]=baseWord;
204 PackWord(baseWord,word,0, 7); // Error flag
206 PackWord(baseWord,word,8,31); // time-of-flight
208 buf[fIndex]=baseWord;
213 // DDL 4 amplified QTC charge * 10
215 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
217 buf[fIndex]=baseWord;
223 PackWord(baseWord,word,0, 7); // Error flag
225 PackWord(baseWord,word,8,31); // time-of-flight
227 buf[fIndex]=baseWord;
229 //Amplified ADC -> TDC
234 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
236 buf[fIndex]=baseWord;
239 PackWord(baseWord,word,0, 7); // Error flag
241 PackWord(baseWord,word,8,31); // time-of-flight
243 buf[fIndex]=baseWord;
254 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
255 word=fDigits->MeanTime();
256 PackWord(baseWord,word, 6, 31); // TDC on the right side from Marin
257 buf[fIndex]=baseWord;
261 PackWord(baseWord,word,0, 7); // Error flag
262 word=fDigits->MeanTime();
263 PackWord(baseWord,word,8,31); // time-of-flight
265 buf[fIndex]=baseWord;
269 // besttime right & left
271 // buf[fIndex]=baseWord;
273 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
274 word=fDigits->BestTimeRight();
275 PackWord(baseWord,word, 6, 31); // TDC on the right side from Marin
277 buf[fIndex]=baseWord;
281 PackWord(baseWord,word,0, 7); // Error flag
282 word=fDigits->BestTimeRight();
283 PackWord(baseWord,word,8,31); // time-of-flight
285 buf[fIndex]=baseWord;
288 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
289 word=fDigits->BestTimeLeft();
290 PackWord(baseWord,word, 6, 31); // TDC on the right side from Marin
292 buf[fIndex]=baseWord;
297 PackWord(baseWord,word,0, 7); // Error flag
298 word=fDigits->BestTimeLeft();
299 PackWord(baseWord,word,8,31); // time-of-flight
301 buf[fIndex]=baseWord;
305 PackWord(baseWord,word, 0, 5); // number of PMT on the right side
306 word=fDigits->TimeDiff();
307 PackWord(baseWord,word, 6, 31); // TDC on the right side from Marin
309 buf[fIndex]=baseWord;
314 PackWord(baseWord,word,0, 7); // Error flag
315 word=fDigits->TimeDiff();
316 PackWord(baseWord,word,8,31); // time-of-flight
318 buf[fIndex]=baseWord;
322 for (Int_t i=0; i<6; i++)
324 Int_t mult=fSumMult->At(i);
326 PackWord(baseWord,word, 0, 5);
328 PackWord(baseWord,word, 6, 31); // TDC on the right side from Marin
330 buf[fIndex]=baseWord;
334 PackWord(baseWord,word,0, 7); // Error flag
336 PackWord(baseWord,word,8,31); // time QTC
338 buf[fIndex]=baseWord;
343 //-------------------------------------------------------------------------------------
345 void AliSTARTRawData::PackWord(UInt_t &BaseWord, UInt_t Word, Int_t StartBit, Int_t StopBit)
347 //This method packs a word into the Baseword buffer starting form the "StartBit"
348 //and tacking StopBit-StartBit+1 bits
349 UInt_t dummyWord,offSet;
352 //The BaseWord is being filled with 1 from StartBit to StopBit
353 length=StopBit-StartBit+1;
354 sum=(UInt_t)TMath::Power(2,length)-1;
357 Error("PackWord", "Word to be filled is not within desired length\n"
358 "Word:%d Start bit:%d Stop Bit:%d",Word,StartBit,StopBit);
363 BaseWord=BaseWord|offSet;
365 //The Word to be filled is shifted to the position StartBit
366 //and the remaining Left and Right bits are filled with 1
367 sum=(UInt_t)TMath::Power(2,StartBit)-1;
368 dummyWord=0xFFFFFFFF<<length;
370 dummyWord<<=StartBit;
372 BaseWord=BaseWord&dummyWord;
376 //---------------------------------------------------------------------------------------
378 Int_t AliSTARTRawData::RawDataSTART(AliSTARTdigit *fDigits)
380 //This method creates the Raw data files for START detector
383 const Int_t kSize=512; //2*AliTOFGeometry::NpadXSector()
384 //max number of digits per DDL file times 2
392 ofstream outfile; // logical name of the output file
393 AliRawDataHeader header;
394 //loop over TOF DDL files
395 sprintf(fileName,"START_%d.ddl", 0xd00);
396 // sprintf(fileName,"START_0xd00.ddl"); //The name of the output file
398 outfile.open(fileName,ios::binary);
400 outfile.open(fileName);
402 //write Dummy DATA HEADER
403 UInt_t dataHeaderPosition=outfile.tellp();
404 outfile.write((char*)(&header),sizeof(header));
408 PackWord(baseWord,word,0, 31); // Number of DDL file
411 buf[fIndex]=baseWord;
412 GetDigits(fDigits,buf);
414 outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
415 for(Int_t ii=0;ii<(fIndex+1);ii++) buf[ii]=0;
418 //Write REAL DATA HEADER
419 UInt_t currentFilePosition=outfile.tellp();
420 outfile.seekp(dataHeaderPosition);
421 header.fSize=currentFilePosition-dataHeaderPosition;
422 header.SetAttribute(0); // valid data
423 outfile.write((char*)(&header),sizeof(header));