]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROBuffer.cxx
final channel to row col mapping plugged in
[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 }
47
48 //_____________________________________________________________________________
49 AliVZEROBuffer::~AliVZEROBuffer(){
50   // Destructor, it closes the IO stream
51   AliRawDataHeader header;
52   header.fSize = f.tellp();
53   header.SetAttribute(0);  // valid data
54   f.seekp(0);
55   f.write((char*)(&header), sizeof(header));
56   f.close();
57   //delete tree;
58   //delete fout;
59 }
60
61 //_____________________________________________________________________________
62 AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source){
63   // Copy Constructor
64   this->fVerbose=source.fVerbose;
65   return;
66 }
67
68 //_____________________________________________________________________________
69 AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source){
70   //Assigment operator
71   this->fVerbose=source.fVerbose;
72   return *this;
73 }
74
75 //_____________________________________________________________________________
76 void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC, Int_t Time){
77   // It writes VZERO digits as a raw data file. 
78   // Being called by AliVZERODDL.C
79
80   struct DataFile{
81     Int_t cell;
82     Int_t ADC;
83     Int_t Time;
84   };
85   
86   DataFile  data;
87   data.cell = cell;
88   data.ADC  = ADC;
89   data.Time = Time;
90
91   fNumberOfDigits++;
92   f.write((char*)(&data),sizeof(data));
93
94 }
95