New classes to manage new (compressed) format of SDD raw data (F. Prino)
[u/mrichter/AliRoot.git] / ITS / AliITSCompressRawDataSDD.cxx
CommitLineData
7765ca40 1/**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id:$*/
17
18///////////////////////////////////////////////////////////////////
19// //
20// Class to decode the SDD Raw Data from the CarlosRX format to //
21// a compressed format consisting in a word of 32 bit per cell //
22// The 32 bits for a data word are defined as follows: //
23// 31 control bit (0=data word, 1= control word) //
24// 30 - //
25// 29 | //
26// 28 |-> 4 bits to identify the Carlos (0-11) inside the DDL //
27// 27 - //
28// 26 detecot side (0= left, =right) //
29// 25 - //
30// 24 | //
31// 23 | //
32// 22 | //
33// 21 |-> 8 bits to identify the anode number (0-255) //
34// 20 | //
35// 19 | //
36// 18 - //
37// 17 - //
38// 16 | //
39// 15 | //
40// 14 | //
41// 13 |-> 8 bits to identify the time bin (0-255) //
42// 12 | //
43// 11 | //
44// 10 - //
45// 9 - //
46// 8 | //
47// 7 | //
48// 6 | //
49// 5 | //
50// 4 |-> 10 bit for the ADC counts //
51// 3 | //
52// 2 | //
53// 1 | //
54// 0 - //
55// //
56// Plus 2 types of control words: //
57// - DDL identifier with the 4 more significant bits = 1000 //
58// - End of module data (needed by the Cluster Finder) = 1111 //
59// //
60// Origin: F.Prino, Torino, prino@to.infn.it //
61// //
62///////////////////////////////////////////////////////////////////
63
64#include "AliITSCompressRawDataSDD.h"
65#include "AliRawReader.h"
66#include "AliRawReaderDate.h"
67#include "AliRawReaderRoot.h"
68#include "AliITSRawStreamSDD.h"
69
70
71ClassImp(AliITSCompressRawDataSDD)
72
73AliITSCompressRawDataSDD::AliITSCompressRawDataSDD(TString filename):
74TObject(),
75fEventRange(kFALSE),
76fFirstEvent(0),
77fLastEvent(0)
78{
79 fNameFile=filename;
80}
81//______________________________________________________________________
82void AliITSCompressRawDataSDD::Compress(){
83 Int_t iev=0;
84 if(fEventRange) iev=fFirstEvent;
85 AliRawReader *rd;
86 if(fNameFile.Contains(".root")){
87 rd=new AliRawReaderRoot(fNameFile.Data(),iev);
88 }else{
89 rd=new AliRawReaderDate(fNameFile.Data(),iev);
90 }
91
92 FILE *outtxt=fopen("data.txt","w");
93 Int_t oldddl=-1;
94 UInt_t word=0;
95 do{
96 rd->Reset();
97
98 AliITSRawStreamSDD s(rd);
99 while(s.Next()){
100 if(rd->GetDDLID()!=oldddl){
101 word=8<<28;
102 word+=rd->GetDDLID();
103 fprintf(outtxt,"%08X\n",word);
104 oldddl=rd->GetDDLID();
105 }
106 if(s.IsCompletedModule()==kFALSE){
107 word=s.GetCarlosId()<<27;
108 word+=s.GetChannel()<<26;
109 word+=s.GetCoord1()<<18;
110 word+=s.GetCoord2()<<10;
111 word+=s.GetSignal();
112 fprintf(outtxt,"%08X\n",word);
113 }
114 if(s.IsCompletedModule()==kTRUE){
115 word=15<<28;
116 word+=s.GetCarlosId();
117 fprintf(outtxt,"%08X\n",word);
118 }
119 }
120 iev++;
121 if(fEventRange && iev>fLastEvent) break;
122 }while(rd->NextEvent());
123 fclose(outtxt);
124}