]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROBuffer.cxx
Compilation warning removed
[u/mrichter/AliRoot.git] / VZERO / AliVZEROBuffer.cxx
CommitLineData
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
32ClassImp(AliVZEROBuffer)
0b2bea8b 33
34//_____________________________________________________________________________
35AliVZEROBuffer::AliVZEROBuffer():TObject(),
36 fVerbose(0),
726d762c 37 f()
0b2bea8b 38{
39 //
40 // default constructor
41 //
42}
af095430 43//_____________________________________________________________________________
0b2bea8b 44AliVZEROBuffer::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//_____________________________________________________________________________
58AliVZEROBuffer::~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 71AliVZEROBuffer::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 82AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source)
83
84{
af095430 85 //Assigment operator
86 this->fVerbose=source.fVerbose;
87 return *this;
88}
89
90//_____________________________________________________________________________
726d762c 91void 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 104void 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//_____________________________________________________________________________
117void 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//_____________________________________________________________________________
134void AliVZEROBuffer::WriteChannel(Int_t cell, UInt_t ADC, UInt_t Time){
135 // It writes VZERO charge information into a raw data file.
136 // Being called by Digits2Raw
137
138 UInt_t data = 0;
139
726d762c 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)); }
152 data = ADC | 0x400;
153 f->WriteBuffer((char*)&data,sizeof(data)); }
154 else
155 // Information about previous 10 interaction
156 // Odd cell number -- skip 4 words and shift ADC by 16 bits
157 { for(Int_t i = 0; i < 4; i++)
158 { data = 0;
159 f->WriteBuffer((char*)&data,sizeof(data)); }
160 data |= (ADC & 0x3ff) << 16;
161 f->WriteBuffer((char*)&data,sizeof(data)); }
162
726d762c 163 data = 0;
164 // Information about following 10 interaction
165 // Not available in the simulation...
166 for(Int_t i = 0; i < 5; i++)
98512c02 167 f->WriteBuffer((char*)&data,sizeof(data));
726d762c 168}
169
170//_____________________________________________________________________________
98512c02 171void AliVZEROBuffer::WriteBeamFlags() {
172 // The method writes information about
173 // the Beam-Beam and Beam-Gas flags i.e.
174 // 6 words for the 4 channels
175 // of half a CIU card
726d762c 176
98512c02 177
178 for(Int_t i = 0; i < 6; i++) {
726d762c 179 UInt_t data = 0;
180 f->WriteBuffer((char*)&data,sizeof(data));
181 }
98512c02 182}
726d762c 183
98512c02 184
185//_____________________________________________________________________________
186void AliVZEROBuffer::WriteMBInfo() {
187 // The method writes information about
188 // the 10 previous minimum-bias events
189 // i.e. channels charge for each of these
190 // 10 events (20 words for the 4 channels
191 // of half a CIU card)
192
193 for(Int_t i = 0; i < 20; i++) {
726d762c 194 UInt_t data = 0;
195 f->WriteBuffer((char*)&data,sizeof(data));
196 }
197}
198
98512c02 199
726d762c 200//_____________________________________________________________________________
98512c02 201void AliVZEROBuffer::WriteMBFlags() {
726d762c 202 // The method writes information about
98512c02 203 // the Minimum Bias flags
204 // 3 32-bits words for the 4 channels
205 // of half a CIU card
726d762c 206
98512c02 207
208 for(Int_t i = 0; i < 3; i++) {
726d762c 209 UInt_t data = 0;
210 f->WriteBuffer((char*)&data,sizeof(data));
211 }
98512c02 212}
213
214//_____________________________________________________________________________
215void AliVZEROBuffer::WriteBeamScalers() {
216 // The method writes the VZERO beam scalers
217 // For the moment there is no way to simulate
218 // this, so we fill the necessary words with 0
726d762c 219
98512c02 220 // Beam-beam and beam-gas scalers for
221 // 4 individual channel (4x4 words)
222
223 for(Int_t i = 0; i < 16; i++) {
726d762c 224 UInt_t data = 0;
225 f->WriteBuffer((char*)&data,sizeof(data));
226 }
af095430 227}
98512c02 228
229//_____________________________________________________________________________
230void AliVZEROBuffer::WriteTiming(Int_t cell, UInt_t ADC, UInt_t Time){
231 // It writes the timing information into a raw data file.
232 // Being called by Digits2Raw
233
234 UInt_t data = 0;
235
236 // Writes the timing information
237 data = Time & 0xfff;
238 // The signal width is not available the digits!
239 // To be added soon
240 // data |= (width & 0x7f) << 12;
241 f->WriteBuffer((char*)&data,sizeof(data));
242}