]>
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> | |
726d762c | 25 | #include "AliLog.h" |
d983817d | 26 | #include "AliRawDataHeader.h" |
af095430 | 27 | #include "AliVZEROBuffer.h" |
28 | ||
29 | //#include "TFile.h" | |
30 | //#include "TTree.h" | |
31 | ||
32 | ClassImp(AliVZEROBuffer) | |
0b2bea8b | 33 | |
34 | //_____________________________________________________________________________ | |
35 | AliVZEROBuffer::AliVZEROBuffer():TObject(), | |
36 | fVerbose(0), | |
726d762c | 37 | f() |
0b2bea8b | 38 | { |
39 | // | |
40 | // default constructor | |
41 | // | |
42 | } | |
af095430 | 43 | //_____________________________________________________________________________ |
0b2bea8b | 44 | AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(), |
45 | fVerbose(0), | |
726d762c | 46 | f() |
0b2bea8b | 47 | { |
af095430 | 48 | // Constructor |
08f92f14 | 49 | f = new AliFstream(fileName); |
af095430 | 50 | // fout=new TFile(fileName,"recreate"); |
51 | // tree=new TTree("tree","Values"); | |
d983817d | 52 | AliRawDataHeader header; |
08f92f14 | 53 | f->WriteBuffer((char*)(&header), sizeof(header)); |
0b2bea8b | 54 | |
af095430 | 55 | } |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliVZEROBuffer::~AliVZEROBuffer(){ | |
59 | // Destructor, it closes the IO stream | |
d983817d | 60 | AliRawDataHeader header; |
08f92f14 | 61 | header.fSize = f->Tellp(); |
d983817d | 62 | header.SetAttribute(0); // valid data |
08f92f14 | 63 | f->Seekp(0); |
64 | f->WriteBuffer((char*)(&header), sizeof(header)); | |
65 | delete f; | |
af095430 | 66 | //delete tree; |
67 | //delete fout; | |
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
0b2bea8b | 71 | AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source), |
72 | fVerbose(0), | |
726d762c | 73 | f() |
0b2bea8b | 74 | |
75 | { | |
af095430 | 76 | // Copy Constructor |
77 | this->fVerbose=source.fVerbose; | |
78 | return; | |
79 | } | |
80 | ||
81 | //_____________________________________________________________________________ | |
0b2bea8b | 82 | AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source) |
83 | ||
84 | { | |
af095430 | 85 | //Assigment operator |
86 | this->fVerbose=source.fVerbose; | |
87 | return *this; | |
88 | } | |
89 | ||
90 | //_____________________________________________________________________________ | |
726d762c | 91 | void AliVZEROBuffer::WriteTriggerInfo(UInt_t trigger) { |
92 | // The method writes VZERO trigger information | |
93 | // This info is contained in the first two | |
94 | // raw-data words following the raw-data header (CDH). | |
95 | ||
96 | f->WriteBuffer((char*)(&trigger),sizeof(trigger)); | |
97 | ||
98 | // By default all the inputs are unmasked... Hopefully | |
99 | UInt_t triggerMask = 0xffff; | |
100 | f->WriteBuffer((char*)(&triggerMask),sizeof(triggerMask)); | |
101 | } | |
102 | ||
103 | //_____________________________________________________________________________ | |
104 | void AliVZEROBuffer::WriteChannel(Int_t cell,Int_t ADC, Int_t Time){ | |
af095430 | 105 | // It writes VZERO digits as a raw data file. |
106 | // Being called by AliVZERODDL.C | |
107 | ||
726d762c | 108 | UInt_t data = 0; |
109 | // Information about previous 10 interaction | |
110 | // Not available in the simulation... | |
111 | for(Int_t i = 0; i < 5; i++) | |
112 | f->WriteBuffer((char*)&data,sizeof(data)); | |
113 | ||
114 | // Now write the ADC charge for this channel | |
115 | if (ADC < 0 || ADC > 1023) { | |
116 | AliInfo(Form("ADC saturated: %d. Truncating to 1023",ADC)); | |
117 | ADC = 1023; | |
118 | } | |
119 | data = ADC | 0x400; // 'Interaction' flag | |
120 | f->WriteBuffer((char*)&data,sizeof(data)); | |
121 | ||
122 | data = 0; | |
123 | // Information about following 10 interaction | |
124 | // Not available in the simulation... | |
125 | for(Int_t i = 0; i < 5; i++) | |
126 | f->WriteBuffer((char*)&data,sizeof(data)); | |
127 | ||
128 | // Now write the timing information | |
129 | data = Time & 0xfff; | |
130 | // The signal width is not available the digits! | |
131 | // To be added soon | |
132 | // data |= (width & 0x7f) << 12; | |
133 | f->WriteBuffer((char*)&data,sizeof(data)); | |
134 | } | |
135 | ||
136 | //_____________________________________________________________________________ | |
137 | void AliVZEROBuffer::WriteScalers() { | |
138 | // The method writes the VZERO trigger scalers | |
139 | // For the moment there is no way to simulate | |
140 | // this, so we fill the necessary words with 0 | |
141 | ||
142 | // First the general trigger scalers (16 of them) | |
143 | for(Int_t i = 0; i < 16; i++) { | |
144 | UInt_t data = 0; | |
145 | f->WriteBuffer((char*)&data,sizeof(data)); | |
146 | } | |
147 | ||
148 | // Then beam-beam and beam-gas scalers for | |
149 | // each individual channel (4x64 words) | |
150 | for(Int_t i = 0; i < 256; i++) { | |
151 | UInt_t data = 0; | |
152 | f->WriteBuffer((char*)&data,sizeof(data)); | |
153 | } | |
154 | } | |
155 | ||
156 | //_____________________________________________________________________________ | |
157 | void AliVZEROBuffer::WriteMBInfo() { | |
158 | // The method writes information about | |
159 | // the 10 previous minimum-bias events | |
160 | ||
161 | // First the bunch crossing numbers | |
162 | // for these 10 events | |
163 | for(Int_t i = 0; i < 10; i++) { | |
164 | UInt_t data = 0; | |
165 | f->WriteBuffer((char*)&data,sizeof(data)); | |
166 | } | |
167 | ||
168 | // Then channels charge for each of these | |
169 | // 10 events (5 words/channel) | |
170 | for(Int_t i = 0; i < 320; i++) { | |
171 | UInt_t data = 0; | |
172 | f->WriteBuffer((char*)&data,sizeof(data)); | |
173 | } | |
af095430 | 174 | } |