]>
Commit | Line | Data |
---|---|---|
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 | ||
31 | ClassImp(AliVZEROBuffer) | |
0b2bea8b | 32 | |
33 | //_____________________________________________________________________________ | |
34 | AliVZEROBuffer::AliVZEROBuffer():TObject(), | |
35 | fVerbose(0), | |
36 | f(), | |
37 | fNumberOfDigits(0) | |
38 | { | |
39 | // | |
40 | // default constructor | |
41 | // | |
42 | } | |
af095430 | 43 | //_____________________________________________________________________________ |
0b2bea8b | 44 | AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(), |
45 | fVerbose(0), | |
46 | f(), | |
47 | fNumberOfDigits(0) | |
48 | { | |
af095430 | 49 | // Constructor |
08f92f14 | 50 | f = new AliFstream(fileName); |
af095430 | 51 | // fout=new TFile(fileName,"recreate"); |
52 | // tree=new TTree("tree","Values"); | |
d983817d | 53 | AliRawDataHeader header; |
08f92f14 | 54 | f->WriteBuffer((char*)(&header), sizeof(header)); |
0b2bea8b | 55 | |
af095430 | 56 | } |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliVZEROBuffer::~AliVZEROBuffer(){ | |
60 | // Destructor, it closes the IO stream | |
d983817d | 61 | AliRawDataHeader header; |
08f92f14 | 62 | header.fSize = f->Tellp(); |
d983817d | 63 | header.SetAttribute(0); // valid data |
08f92f14 | 64 | f->Seekp(0); |
65 | f->WriteBuffer((char*)(&header), sizeof(header)); | |
66 | delete f; | |
af095430 | 67 | //delete tree; |
68 | //delete fout; | |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
0b2bea8b | 72 | AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source), |
73 | fVerbose(0), | |
74 | f(), | |
75 | fNumberOfDigits(0) | |
76 | ||
77 | { | |
af095430 | 78 | // Copy Constructor |
79 | this->fVerbose=source.fVerbose; | |
80 | return; | |
81 | } | |
82 | ||
83 | //_____________________________________________________________________________ | |
0b2bea8b | 84 | AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source) |
85 | ||
86 | { | |
af095430 | 87 | //Assigment operator |
88 | this->fVerbose=source.fVerbose; | |
89 | return *this; | |
90 | } | |
91 | ||
92 | //_____________________________________________________________________________ | |
7caec66b | 93 | void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC, Int_t Time){ |
af095430 | 94 | // It writes VZERO digits as a raw data file. |
95 | // Being called by AliVZERODDL.C | |
96 | ||
97 | struct DataFile{ | |
98 | Int_t cell; | |
99 | Int_t ADC; | |
7caec66b | 100 | Int_t Time; |
af095430 | 101 | }; |
102 | ||
103 | DataFile data; | |
104 | data.cell = cell; | |
105 | data.ADC = ADC; | |
7caec66b | 106 | data.Time = Time; |
af095430 | 107 | |
af095430 | 108 | fNumberOfDigits++; |
08f92f14 | 109 | f->WriteBuffer((char*)(&data),sizeof(data)); |
af095430 | 110 | } |