]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROBuffer.cxx
Wrong header file names.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROBuffer.cxx
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
21 // Author: B. Cheynis
22
23 #include <Riostream.h>
24 #include <TObjArray.h>
25 #include "AliLog.h"
26 #include "AliRawDataHeaderSim.h"
27 #include "AliVZEROBuffer.h"
28
29 //#include "TFile.h"
30 //#include "TTree.h"
31
32 ClassImp(AliVZEROBuffer)
33
34 //_____________________________________________________________________________
35 AliVZEROBuffer::AliVZEROBuffer():TObject(),
36     fVerbose(0),
37     f()
38 {
39   //
40   // default constructor
41   //
42 }
43 //_____________________________________________________________________________
44 AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(),
45     fVerbose(0),
46     f()
47 {
48   // Constructor
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));
54
55 }
56
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
63   f->Seekp(0);
64   f->WriteBuffer((char*)(&header), sizeof(header));
65   delete f;
66   //delete tree;
67   //delete fout;
68 }
69
70 //_____________________________________________________________________________
71 AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source),
72    fVerbose(0),
73    f()
74
75 {
76   // Copy Constructor
77   this->fVerbose=source.fVerbose;
78   return;
79 }
80
81 //_____________________________________________________________________________
82 AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source)
83
84 {
85   //Assigment operator
86   this->fVerbose=source.fVerbose;
87   return *this;
88 }
89
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).
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 //_____________________________________________________________________________
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
108
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 }
132
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
137   
138   UInt_t data = 0;
139   
140   if (/*ADC < 0 || */ ADC > 1023) {
141       AliInfo(Form("ADC saturated: %d. Truncating to 1023",ADC));
142       ADC = 1023;
143   }
144
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     
163   data = 0;
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));     
168 }
169
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
176
177
178   for(Int_t i = 0; i < 6; i++) {
179     UInt_t data = 0;
180     f->WriteBuffer((char*)&data,sizeof(data));
181   }
182 }
183
184
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)
192     
193   for(Int_t i = 0; i < 20; i++) {
194     UInt_t data = 0;
195     f->WriteBuffer((char*)&data,sizeof(data));
196   }
197 }
198
199
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
206
207
208   for(Int_t i = 0; i < 3; i++) {
209     UInt_t data = 0;
210     f->WriteBuffer((char*)&data,sizeof(data));
211   }
212 }
213
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
219
220   // Beam-beam and beam-gas scalers for
221   // 4 individual channel (4x4 words)
222   
223   for(Int_t i = 0; i < 16; i++) {
224     UInt_t data = 0;
225     f->WriteBuffer((char*)&data,sizeof(data));
226   }
227 }
228
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
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 }