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 "AliRawDataHeader.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 AliRawDataHeader header;
53 f->WriteBuffer((char*)(&header), sizeof(header));
57 //_____________________________________________________________________________
58 AliVZEROBuffer::~AliVZEROBuffer(){
59 // Destructor, it closes the IO stream
60 AliRawDataHeader 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::WriteChannel(Int_t cell,Int_t ADC, Int_t Time){
105 // It writes VZERO digits as a raw data file.
106 // Being called by AliVZERODDL.C
109 // Information about previous 10 interaction
110 // Not available in the simulation...
111 for(Int_t i = 0; i < 5; i++)
112 f->WriteBuffer((char*)&data,sizeof(data));
114 // Now write the ADC charge for this channel
115 if (ADC < 0 || ADC > 1023) {
116 AliInfo(Form("ADC saturated: %d. Truncating to 1023",ADC));
119 data = ADC | 0x400; // 'Interaction' flag
120 f->WriteBuffer((char*)&data,sizeof(data));
123 // Information about following 10 interaction
124 // Not available in the simulation...
125 for(Int_t i = 0; i < 5; i++)
126 f->WriteBuffer((char*)&data,sizeof(data));
128 // Now write the timing information
130 // The signal width is not available the digits!
132 // data |= (width & 0x7f) << 12;
133 f->WriteBuffer((char*)&data,sizeof(data));
136 //_____________________________________________________________________________
137 void AliVZEROBuffer::WriteScalers() {
138 // The method writes the VZERO trigger scalers
139 // For the moment there is no way to simulate
140 // this, so we fill the necessary words with 0
142 // First the general trigger scalers (16 of them)
143 for(Int_t i = 0; i < 16; i++) {
145 f->WriteBuffer((char*)&data,sizeof(data));
148 // Then beam-beam and beam-gas scalers for
149 // each individual channel (4x64 words)
150 for(Int_t i = 0; i < 256; i++) {
152 f->WriteBuffer((char*)&data,sizeof(data));
156 //_____________________________________________________________________________
157 void AliVZEROBuffer::WriteMBInfo() {
158 // The method writes information about
159 // the 10 previous minimum-bias events
161 // First the bunch crossing numbers
162 // for these 10 events
163 for(Int_t i = 0; i < 10; i++) {
165 f->WriteBuffer((char*)&data,sizeof(data));
168 // Then channels charge for each of these
169 // 10 events (5 words/channel)
170 for(Int_t i = 0; i < 320; i++) {
172 f->WriteBuffer((char*)&data,sizeof(data));