]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROBuffer.cxx
Various fixes in order to compile the DA source code
[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 "AliRawDataHeader.h"
26 #include "AliVZEROBuffer.h"
27
28 //#include "TFile.h"
29 //#include "TTree.h"
30
31 ClassImp(AliVZEROBuffer)
32
33 //_____________________________________________________________________________
34 AliVZEROBuffer::AliVZEROBuffer():TObject(),
35     fVerbose(0),
36     f(),
37     fNumberOfDigits(0)
38 {
39   //
40   // default constructor
41   //
42 }
43 //_____________________________________________________________________________
44 AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(),
45     fVerbose(0),
46     f(),
47     fNumberOfDigits(0)
48 {
49   // Constructor
50 #ifndef __DECCXX
51   f.open(fileName,ios::binary|ios::out);
52 #else
53   f.open(fileName,ios::out);
54 #endif
55   // fout=new TFile(fileName,"recreate");
56   // tree=new TTree("tree","Values");
57   AliRawDataHeader header;
58   f.write((char*)(&header), sizeof(header));
59
60 }
61
62 //_____________________________________________________________________________
63 AliVZEROBuffer::~AliVZEROBuffer(){
64   // Destructor, it closes the IO stream
65   AliRawDataHeader header;
66   header.fSize = f.tellp();
67   header.SetAttribute(0);  // valid data
68   f.seekp(0);
69   f.write((char*)(&header), sizeof(header));
70   f.close();
71   //delete tree;
72   //delete fout;
73 }
74
75 //_____________________________________________________________________________
76 AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source),
77    fVerbose(0),
78    f(),
79    fNumberOfDigits(0)
80
81 {
82   // Copy Constructor
83   this->fVerbose=source.fVerbose;
84   return;
85 }
86
87 //_____________________________________________________________________________
88 AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source)
89
90 {
91   //Assigment operator
92   this->fVerbose=source.fVerbose;
93   return *this;
94 }
95
96 //_____________________________________________________________________________
97 void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC, Int_t Time){
98   // It writes VZERO digits as a raw data file. 
99   // Being called by AliVZERODDL.C
100
101   struct DataFile{
102     Int_t cell;
103     Int_t ADC;
104     Int_t Time;
105   };
106   
107   DataFile  data;
108   data.cell = cell;
109   data.ADC  = ADC;
110   data.Time = Time;
111
112   fNumberOfDigits++;
113   f.write((char*)(&data),sizeof(data));
114
115 }
116