1 /**************************************************************************
2 * Copyright(c) 1998-2003, 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 **************************************************************************/
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
23 #include <Riostream.h>
24 #include <TObjArray.h>
26 #include "AliRawDataHeaderSim.h"
27 #include "AliVZEROBuffer.h"
32 ClassImp(AliVZEROBuffer)
34 //_____________________________________________________________________________
35 AliVZEROBuffer::AliVZEROBuffer():TObject(),
40 // default constructor
43 //_____________________________________________________________________________
44 AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(),
49 f = new AliFstream(fileName);
50 // fout=new TFile(fileName,"recreate");
51 // tree=new TTree("tree","Values");
52 AliRawDataHeaderSim header;
53 f->WriteBuffer((char*)(&header), sizeof(header));
57 //_____________________________________________________________________________
58 AliVZEROBuffer::~AliVZEROBuffer(){
59 // Destructor, it closes the IO stream
60 AliRawDataHeaderSim header;
61 header.fSize = f->Tellp();
62 header.SetAttribute(0); // valid data
64 f->WriteBuffer((char*)(&header), sizeof(header));
70 //_____________________________________________________________________________
71 AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source),
77 this->fVerbose=source.fVerbose;
81 //_____________________________________________________________________________
82 AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source)
86 this->fVerbose=source.fVerbose;
90 //_____________________________________________________________________________
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).
96 f->WriteBuffer((char*)(&trigger),sizeof(trigger));
98 // By default all the inputs are unmasked... Hopefully
99 UInt_t triggerMask = 0xffff;
100 f->WriteBuffer((char*)(&triggerMask),sizeof(triggerMask));
103 //_____________________________________________________________________________
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
109 // First the general trigger scalers (16 of them)
110 for(Int_t i = 0; i < 16; i++) {
112 f->WriteBuffer((char*)&data,sizeof(data));
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
123 // First the bunch crossing numbers
124 // for these 10 events
126 for(Int_t i = 0; i < 10; i++) {
128 f->WriteBuffer((char*)&data,sizeof(data));
133 //_____________________________________________________________________________
134 void 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
140 if (/*ADC < 0 || */ ADC > 1023) {
141 AliInfo(Form("ADC saturated: %d. Truncating to 1023",ADC));
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++)
151 f->WriteBuffer((char*)&data,sizeof(data)); }
153 f->WriteBuffer((char*)&data,sizeof(data)); }
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++)
159 f->WriteBuffer((char*)&data,sizeof(data)); }
160 data |= (ADC & 0x3ff) << 16;
161 f->WriteBuffer((char*)&data,sizeof(data)); }
164 // Information about following 10 interaction
165 // Not available in the simulation...
166 for(Int_t i = 0; i < 5; i++)
167 f->WriteBuffer((char*)&data,sizeof(data));
170 //_____________________________________________________________________________
171 void 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
178 for(Int_t i = 0; i < 6; i++) {
180 f->WriteBuffer((char*)&data,sizeof(data));
185 //_____________________________________________________________________________
186 void 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)
193 for(Int_t i = 0; i < 20; i++) {
195 f->WriteBuffer((char*)&data,sizeof(data));
200 //_____________________________________________________________________________
201 void AliVZEROBuffer::WriteMBFlags() {
202 // The method writes information about
203 // the Minimum Bias flags
204 // 3 32-bits words for the 4 channels
205 // of half a CIU card
208 for(Int_t i = 0; i < 3; i++) {
210 f->WriteBuffer((char*)&data,sizeof(data));
214 //_____________________________________________________________________________
215 void 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
220 // Beam-beam and beam-gas scalers for
221 // 4 individual channel (4x4 words)
223 for(Int_t i = 0; i < 16; i++) {
225 f->WriteBuffer((char*)&data,sizeof(data));
229 //_____________________________________________________________________________
230 void 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
236 // Writes the timing information
238 // The signal width is not available the digits!
240 // data |= (width & 0x7f) << 12;
241 f->WriteBuffer((char*)&data,sizeof(data));