]>
Commit | Line | Data |
---|---|---|
af095430 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, 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 | /* $Id$ */ | |
16 | ||
17 | // Storing digits in a binary file | |
18 | // according to the DDL mapping | |
19 | // To be used in Alice Data Challenges | |
20 | // This class is used by AliVZERODDL.C macro | |
d983817d | 21 | // Author: B. Cheynis |
af095430 | 22 | |
23 | #include <Riostream.h> | |
24 | #include <TObjArray.h> | |
726d762c | 25 | #include "AliLog.h" |
f7ee745b | 26 | #include "AliRawDataHeaderSim.h" |
af095430 | 27 | #include "AliVZEROBuffer.h" |
28 | ||
29 | //#include "TFile.h" | |
30 | //#include "TTree.h" | |
31 | ||
32 | ClassImp(AliVZEROBuffer) | |
0b2bea8b | 33 | |
34 | //_____________________________________________________________________________ | |
35 | AliVZEROBuffer::AliVZEROBuffer():TObject(), | |
36 | fVerbose(0), | |
726d762c | 37 | f() |
0b2bea8b | 38 | { |
39 | // | |
40 | // default constructor | |
41 | // | |
42 | } | |
af095430 | 43 | //_____________________________________________________________________________ |
0b2bea8b | 44 | AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(), |
45 | fVerbose(0), | |
726d762c | 46 | f() |
0b2bea8b | 47 | { |
af095430 | 48 | // Constructor |
08f92f14 | 49 | f = new AliFstream(fileName); |
af095430 | 50 | // fout=new TFile(fileName,"recreate"); |
51 | // tree=new TTree("tree","Values"); | |
f7ee745b | 52 | AliRawDataHeaderSim header; |
08f92f14 | 53 | f->WriteBuffer((char*)(&header), sizeof(header)); |
0b2bea8b | 54 | |
af095430 | 55 | } |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliVZEROBuffer::~AliVZEROBuffer(){ | |
59 | // Destructor, it closes the IO stream | |
f7ee745b | 60 | AliRawDataHeaderSim header; |
08f92f14 | 61 | header.fSize = f->Tellp(); |
d983817d | 62 | header.SetAttribute(0); // valid data |
08f92f14 | 63 | f->Seekp(0); |
64 | f->WriteBuffer((char*)(&header), sizeof(header)); | |
65 | delete f; | |
af095430 | 66 | //delete tree; |
67 | //delete fout; | |
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
0b2bea8b | 71 | AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source), |
72 | fVerbose(0), | |
726d762c | 73 | f() |
0b2bea8b | 74 | |
75 | { | |
af095430 | 76 | // Copy Constructor |
77 | this->fVerbose=source.fVerbose; | |
78 | return; | |
79 | } | |
80 | ||
81 | //_____________________________________________________________________________ | |
0b2bea8b | 82 | AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source) |
83 | ||
84 | { | |
af095430 | 85 | //Assigment operator |
86 | this->fVerbose=source.fVerbose; | |
87 | return *this; | |
88 | } | |
89 | ||
90 | //_____________________________________________________________________________ | |
726d762c | 91 | void AliVZEROBuffer::WriteTriggerInfo(UInt_t trigger) { |
92 | // The method writes VZERO trigger information | |
93 | // This info is contained in the first two | |
94 | // raw-data words following the raw-data header (CDH). | |
95 | ||
96 | f->WriteBuffer((char*)(&trigger),sizeof(trigger)); | |
97 | ||
98 | // By default all the inputs are unmasked... Hopefully | |
99 | UInt_t triggerMask = 0xffff; | |
100 | f->WriteBuffer((char*)(&triggerMask),sizeof(triggerMask)); | |
101 | } | |
102 | ||
103 | //_____________________________________________________________________________ | |
98512c02 | 104 | void AliVZEROBuffer::WriteTriggerScalers() { |
105 | // The method writes the VZERO trigger scalers | |
106 | // For the moment there is no way to simulate | |
107 | // this, so we fill the necessary 16 words with 0 | |
af095430 | 108 | |
98512c02 | 109 | // First the general trigger scalers (16 of them) |
110 | for(Int_t i = 0; i < 16; i++) { | |
111 | UInt_t data = 0; | |
112 | f->WriteBuffer((char*)&data,sizeof(data)); | |
113 | } | |
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | void AliVZEROBuffer::WriteBunchNumbers() { | |
118 | // The method writes the Bunch Numbers corresponding | |
119 | // to the 10 Minimum Bias events | |
120 | // For the moment there is no way to simulate | |
121 | // this, so we fill the necessary 10 words with 0 | |
122 | ||
123 | // First the bunch crossing numbers | |
124 | // for these 10 events | |
125 | ||
126 | for(Int_t i = 0; i < 10; i++) { | |
127 | UInt_t data = 0; | |
128 | f->WriteBuffer((char*)&data,sizeof(data)); | |
129 | } | |
130 | ||
131 | } | |
726d762c | 132 | |
98512c02 | 133 | //_____________________________________________________________________________ |
db0db003 | 134 | void AliVZEROBuffer::WriteChannel(Int_t cell, UInt_t ADC, Float_t /*Time*/, Bool_t integrator){ |
98512c02 | 135 | // It writes VZERO charge information into a raw data file. |
136 | // Being called by Digits2Raw | |
137 | ||
138 | UInt_t data = 0; | |
139 | ||
c61a7285 | 140 | if (/*ADC < 0 || */ ADC > 1023) { |
98512c02 | 141 | AliInfo(Form("ADC saturated: %d. Truncating to 1023",ADC)); |
142 | ADC = 1023; | |
726d762c | 143 | } |
726d762c | 144 | |
98512c02 | 145 | if(cell%2 == 0) |
146 | // Information about previous 10 interaction | |
147 | // Not available in the simulation... | |
148 | // Even cell number -- skip 5 words | |
149 | { for(Int_t i = 0; i < 5; i++) | |
150 | { data = 0; | |
151 | f->WriteBuffer((char*)&data,sizeof(data)); } | |
de834f34 | 152 | data = ADC & 0x3ff; |
153 | data |= (integrator & 0x1) << 10; | |
98512c02 | 154 | f->WriteBuffer((char*)&data,sizeof(data)); } |
155 | else | |
156 | // Information about previous 10 interaction | |
157 | // Odd cell number -- skip 4 words and shift ADC by 16 bits | |
158 | { for(Int_t i = 0; i < 4; i++) | |
159 | { data = 0; | |
160 | f->WriteBuffer((char*)&data,sizeof(data)); } | |
de834f34 | 161 | data = (ADC & 0x3ff) << 16; |
162 | data |= (integrator & 0x1) << 26; | |
98512c02 | 163 | f->WriteBuffer((char*)&data,sizeof(data)); } |
164 | ||
726d762c | 165 | data = 0; |
166 | // Information about following 10 interaction | |
167 | // Not available in the simulation... | |
168 | for(Int_t i = 0; i < 5; i++) | |
98512c02 | 169 | f->WriteBuffer((char*)&data,sizeof(data)); |
726d762c | 170 | } |
171 | ||
172 | //_____________________________________________________________________________ | |
98512c02 | 173 | void AliVZEROBuffer::WriteBeamFlags() { |
174 | // The method writes information about | |
175 | // the Beam-Beam and Beam-Gas flags i.e. | |
176 | // 6 words for the 4 channels | |
177 | // of half a CIU card | |
726d762c | 178 | |
98512c02 | 179 | |
180 | for(Int_t i = 0; i < 6; i++) { | |
726d762c | 181 | UInt_t data = 0; |
182 | f->WriteBuffer((char*)&data,sizeof(data)); | |
183 | } | |
98512c02 | 184 | } |
726d762c | 185 | |
98512c02 | 186 | |
187 | //_____________________________________________________________________________ | |
188 | void AliVZEROBuffer::WriteMBInfo() { | |
189 | // The method writes information about | |
190 | // the 10 previous minimum-bias events | |
191 | // i.e. channels charge for each of these | |
192 | // 10 events (20 words for the 4 channels | |
193 | // of half a CIU card) | |
194 | ||
195 | for(Int_t i = 0; i < 20; i++) { | |
726d762c | 196 | UInt_t data = 0; |
197 | f->WriteBuffer((char*)&data,sizeof(data)); | |
198 | } | |
199 | } | |
200 | ||
98512c02 | 201 | |
726d762c | 202 | //_____________________________________________________________________________ |
98512c02 | 203 | void AliVZEROBuffer::WriteMBFlags() { |
726d762c | 204 | // The method writes information about |
98512c02 | 205 | // the Minimum Bias flags |
206 | // 3 32-bits words for the 4 channels | |
207 | // of half a CIU card | |
726d762c | 208 | |
98512c02 | 209 | |
210 | for(Int_t i = 0; i < 3; i++) { | |
726d762c | 211 | UInt_t data = 0; |
212 | f->WriteBuffer((char*)&data,sizeof(data)); | |
213 | } | |
98512c02 | 214 | } |
215 | ||
216 | //_____________________________________________________________________________ | |
217 | void AliVZEROBuffer::WriteBeamScalers() { | |
218 | // The method writes the VZERO beam scalers | |
219 | // For the moment there is no way to simulate | |
220 | // this, so we fill the necessary words with 0 | |
726d762c | 221 | |
98512c02 | 222 | // Beam-beam and beam-gas scalers for |
223 | // 4 individual channel (4x4 words) | |
224 | ||
225 | for(Int_t i = 0; i < 16; i++) { | |
726d762c | 226 | UInt_t data = 0; |
227 | f->WriteBuffer((char*)&data,sizeof(data)); | |
228 | } | |
af095430 | 229 | } |
98512c02 | 230 | |
231 | //_____________________________________________________________________________ | |
db0db003 | 232 | void AliVZEROBuffer::WriteTiming(Int_t /*cell*/, UInt_t /* ADC*/, Float_t Time){ |
98512c02 | 233 | // It writes the timing information into a raw data file. |
234 | // Being called by Digits2Raw | |
235 | ||
236 | UInt_t data = 0; | |
db0db003 | 237 | Int_t coarse1, coarse2, fine; |
98512c02 | 238 | |
239 | // Writes the timing information | |
db0db003 | 240 | // data = Time & 0xfff; |
241 | ||
242 | coarse1 = int( Time/25.0 ); | |
243 | coarse2 = int( (Time - 25*coarse1)/(25.0/8.0) ); | |
244 | fine = int( (Time - 25*coarse1 -(25.0/8.0)*coarse2)/(25.0/256.0) ); | |
245 | ||
246 | data = (coarse1 & 0xf) << 8; | |
247 | data |= (coarse2 & 0x7) << 5; | |
248 | data |= (fine & 0x1f); | |
249 | ||
98512c02 | 250 | // The signal width is not available the digits! |
251 | // To be added soon | |
252 | // data |= (width & 0x7f) << 12; | |
253 | f->WriteBuffer((char*)&data,sizeof(data)); | |
254 | } |