]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROBuffer.cxx
Test case for B0 -> mu
[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 AliVZEROBuffer::AliVZEROBuffer(const char* fileName){
34   // Constructor
35 #ifndef __DECCXX
36   f.open(fileName,ios::binary|ios::out);
37 #else
38   f.open(fileName,ios::out);
39 #endif
40   // fout=new TFile(fileName,"recreate");
41   // tree=new TTree("tree","Values");
42   AliRawDataHeader header;
43   f.write((char*)(&header), sizeof(header));
44   fNumberOfDigits=0;
45   fVerbose=0;
46   remove("VZEROdigits.txt");
47 }
48
49 //_____________________________________________________________________________
50 AliVZEROBuffer::~AliVZEROBuffer(){
51   // Destructor, it closes the IO stream
52   AliRawDataHeader header;
53   header.fSize = f.tellp();
54   header.SetAttribute(0);  // valid data
55   f.seekp(0);
56   f.write((char*)(&header), sizeof(header));
57   f.close();
58   //delete tree;
59   //delete fout;
60 }
61
62 //_____________________________________________________________________________
63 AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source){
64   // Copy Constructor
65   this->fVerbose=source.fVerbose;
66   return;
67 }
68
69 //_____________________________________________________________________________
70 AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source){
71   //Assigment operator
72   this->fVerbose=source.fVerbose;
73   return *this;
74 }
75
76 //_____________________________________________________________________________
77 void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC){
78   // It writes VZERO digits as a raw data file. 
79   // Being called by AliVZERODDL.C
80
81   struct DataFile{
82     Int_t cell;
83     Int_t ADC;
84   };
85   
86   DataFile  data;
87   data.cell = cell;
88   data.ADC  = ADC;
89
90   ofstream ftxt;
91   ftxt.open("VZEROdigits.txt",ios::app);
92   
93   fNumberOfDigits++;
94   f.write((char*)(&data),sizeof(data));
95
96 }
97