]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROBuffer.cxx
Adding name as attribute and GetModuleName() method;
[u/mrichter/AliRoot.git] / VZERO / AliVZEROBuffer.cxx
CommitLineData
af095430 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
d983817d 21// Author: B. Cheynis
af095430 22
23#include <Riostream.h>
24#include <TObjArray.h>
d983817d 25#include "AliRawDataHeader.h"
af095430 26#include "AliVZEROBuffer.h"
27
28//#include "TFile.h"
29//#include "TTree.h"
30
31ClassImp(AliVZEROBuffer)
32//_____________________________________________________________________________
33AliVZEROBuffer::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");
d983817d 42 AliRawDataHeader header;
43 f.write((char*)(&header), sizeof(header));
af095430 44 fNumberOfDigits=0;
45 fVerbose=0;
af095430 46}
47
48//_____________________________________________________________________________
49AliVZEROBuffer::~AliVZEROBuffer(){
50 // Destructor, it closes the IO stream
d983817d 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));
af095430 56 f.close();
57 //delete tree;
58 //delete fout;
59}
60
61//_____________________________________________________________________________
62AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source){
63 // Copy Constructor
64 this->fVerbose=source.fVerbose;
65 return;
66}
67
68//_____________________________________________________________________________
69AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source){
70 //Assigment operator
71 this->fVerbose=source.fVerbose;
72 return *this;
73}
74
75//_____________________________________________________________________________
7caec66b 76void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC, Int_t Time){
af095430 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;
7caec66b 83 Int_t Time;
af095430 84 };
85
86 DataFile data;
87 data.cell = cell;
88 data.ADC = ADC;
7caec66b 89 data.Time = Time;
af095430 90
af095430 91 fNumberOfDigits++;
92 f.write((char*)(&data),sizeof(data));
93
94}
95