]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSFileWriterComponent.cxx
Coding conventions
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSFileWriterComponent.cxx
CommitLineData
acd526ae 1/**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Per Thomas Hille for the ALICE HLT 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
16#include "AliHLTPHOSFileWriterComponent.h"
f4d27262 17#include <iostream>
18#include "stdio.h"
19#include <TObjString.h>
20
21#include "AliRawReaderMemory.h"
22#include "AliCaloRawStream.h"
23#include <cstdlib>
24#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
25#include "AliHLTPHOSDataHeaderStruct.h"
26#include "AliHLTDataTypes.h"
27
28
29const AliHLTComponentDataType AliHLTPHOSFileWriterComponent::fInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
acd526ae 30
31
32AliHLTPHOSFileWriterComponent gAliHLTPHOSFileWriterComponent;
33
05be0766 34AliHLTPHOSFileWriterComponent::AliHLTPHOSFileWriterComponent(): AliHLTFileWriter(), fCellEnergiesFileWriterPtr(0) \
35 , fDDLPackedFileWriterPtr(0), fDirectory(""),fFilename(""), fEventCount(0)
acd526ae 36{
f4d27262 37 for(int i=0; i<N_DATATYPES; i++)
38 {
39 fDataTypesToFile[i] = kAliHLTVoidDataType;
40 }
41
42 fCellEnergiesFileWriterPtr = new AliHLTPHOSCellEnergiesFileWriter();
43 fDDLPackedFileWriterPtr = new AliHLTPHOSDDLPackedFileWriter();
acd526ae 44
f4d27262 45}
acd526ae 46
47AliHLTPHOSFileWriterComponent::~AliHLTPHOSFileWriterComponent()
48{
f4d27262 49 delete fCellEnergiesFileWriterPtr;
50 delete fDDLPackedFileWriterPtr;
51}
52
53
05be0766 54
55AliHLTPHOSFileWriterComponent::AliHLTPHOSFileWriterComponent(const AliHLTPHOSFileWriterComponent & ): AliHLTFileWriter(), fCellEnergiesFileWriterPtr(0), \
56 fDDLPackedFileWriterPtr(0), fDirectory(""),fFilename(""), fEventCount(0)
f4d27262 57{
58
59}
acd526ae 60
f4d27262 61int
62AliHLTPHOSFileWriterComponent::AddDataType(string dataType)
63{
64 int ret = -1;
65 int tmpCnt = 0;
66 for(int i=0; i< N_DATATYPES; i++)
67 {
68 if( fDataTypesToFile[i] != kAliHLTVoidDataType)
69 {
70 tmpCnt ++;
71 }
72 }
73
74 string cmpString("gkCellEnergyDataType");
75
76 if(dataType.compare("gkCellEnergyDataType") == 0)
77 {
f4d27262 78 fDataTypesToFile[tmpCnt] = AliHLTPHOSDefinitions::gkCellEnergyDataType;
79 cout <<"regsitring dataType for filewriting: fDataTypesToFile[" << tmpCnt <<"]"<<endl;
80 }
81 else if(dataType.compare("gkDDLPackedRawDataType") == 0)
82 {
83 fDataTypesToFile[tmpCnt] = AliHLTPHOSDefinitions::gkDDLPackedRawDataType;
84 }
85
86 cout << "dataType.compare(cmpString) = " <<dataType.compare(cmpString)<<endl;
87 return ret;
88}
89
90
91
92
93int
94AliHLTPHOSFileWriterComponent::Deinit()
95{
96 return 0;
97}
98
99int
100AliHLTPHOSFileWriterComponent::DoDeinit()
101{
102 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSFileWriterComponen DoDeinit");
103 return 0;
acd526ae 104}
105
106const char*
107AliHLTPHOSFileWriterComponent::GetComponentID()
108{
acd526ae 109 return "PhosFileWriter";
110}
111
f4d27262 112AliHLTComponent*
113AliHLTPHOSFileWriterComponent::Spawn()
acd526ae 114{
acd526ae 115 return new AliHLTPHOSFileWriterComponent;
116}
117
f4d27262 118
119void
120AliHLTPHOSFileWriterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
121{
122 const AliHLTComponentDataType* pType=fInputDataTypes;
123 while (pType->fID!=0) {
124 list.push_back(*pType);
125 pType++;
126 }
127}
128
129AliHLTComponentDataType
130AliHLTPHOSFileWriterComponent::GetOutputDataType()
131{
132 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
133}
134
135void
136AliHLTPHOSFileWriterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
137
138{
139 constBase = 30;
140 inputMultiplier = 0.1;
141}
142
6a8ab2ab 143/*
acd526ae 144int
f4d27262 145AliHLTPHOSFileWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData )
146{
147 UInt_t mysize = 0;
148 UInt_t tSize = 0;
149 Int_t tmpChannelCnt = 0;
150 UInt_t offset = 0;
151 const AliHLTComponentDataType *tmpDataType;
152 const AliHLTComponentBlockData* iter = NULL;
153 unsigned long ndx;
154 AliHLTPHOSDataHeaderStruct dataHeader;
155
156 dataHeader.fSize = sizeof(dataHeader);
157 dataHeader.fEventID = evtData.fEventID;
158 cout << "analyzing event: " << fEventCount << endl;
159
160 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
161 {
162 iter = blocks+ndx;
163 mysize = 0;
164 offset = tSize;
165 tmpDataType = &(iter->fDataType);
166
167 if(IsRegisteredDataType(*tmpDataType))
168 {
169 if(*tmpDataType == AliHLTPHOSDefinitions::gkCellEnergyDataType)
170 {
171
6a8ab2ab 172 fCellEnergiesFileWriterPtr->WriteFile(evtData, blocks, trigData, *tmpDataType, fEventCount);
173 // cout <<"AliHLTPHOSFileWriterComponen: data type = is gkCellEnergyDataType. block index = "<< ndx\
174 // <<" EventCount =" << fEventCount << "Event ID"<<evtData.fEventID << endl;
f4d27262 175 }
176 else if(*tmpDataType == AliHLTPHOSDefinitions::gkDDLPackedRawDataType)
177 {
178
6a8ab2ab 179 fDDLPackedFileWriterPtr->WriteFile(evtData, blocks, trigData, *tmpDataType, fEventCount);
f4d27262 180 }
181 }
182
183 // cout <<"AliHLTPHOSFileWriterComponen: data type = is gkCellEnergyDataType. block index = "<< ndx\
184 // <<" EventCount =" << fEventCount << "Event ID"<<evtData.fEventID << endl;
185
186 fEventCount++;
187 }
188 return 0;
189}//end DumpEvent
6a8ab2ab 190*/
f4d27262 191
192
6a8ab2ab 193/*
f4d27262 194int
acd526ae 195AliHLTPHOSFileWriterComponent::DoInit( int argc, const char** argv )
196{
6a8ab2ab 197
198
f4d27262 199 int iResult=0;
200 TString argument="";
201 Bool_t dirSet = kFALSE;
202 Bool_t dataSet = kFALSE;
203 string dataType="";
204 int bMissingParam=0;
205
f4d27262 206 for(int i=0; i<argc; i++)
207 {
208 argument=argv[i];
209
210 if(argument.CompareTo("-directory")==0)
211 {
212 if ((bMissingParam=(++i>=argc)))
213 {
214 break;
215 }
216 fDirectory.assign(argv[i]);
217 fCellEnergiesFileWriterPtr->SetDirectory(fDirectory);
218 fDDLPackedFileWriterPtr->SetDirectory(fDirectory) ;
f4d27262 219 fFilename.insert(0, fDirectory);
220 dirSet = kTRUE;
f4d27262 221 cout << "fDirectory=" << fDirectory << endl;
222 }
223
224 if(argument.CompareTo("-datatype")==0)
225 {
226 if ((bMissingParam=(++i>=argc))) break;
227 cout << "datatype = " << argv[i] << endl;
228 dataType = argv[i];
229
230 AddDataType(dataType);
231 dataSet = kTRUE;
232 }
233
234 cout << "argv[" << i <<"] = " << argv[i] << endl;
235
236 }
237
6a8ab2ab 238*/
239
240 // /*
241 // * We dont start the component if we don know what data to write
242 // * or where to store it
243 // */
244// if((dataSet != kTRUE || dataSet != kTRUE))
245// {
246// iResult = -1;
247// HLTFatal(" either direcory or datatype is not set, usage -datatype <datatype> -driectory <directory>");
248// }
249// else
250// {
251// iResult = 0;
252// }
253// return iResult;
254//}
255
acd526ae 256
257
f4d27262 258Bool_t
259AliHLTPHOSFileWriterComponent::IsRegisteredDataType(const AliHLTComponentDataType& dataType)
260{
261 Bool_t tmp = kFALSE;
262 for(int i =0; i<N_DATATYPES; i++)
263 {
264 if((fDataTypesToFile[i] == dataType) && (dataType != kAliHLTVoidDataType))
265 {
266 tmp = kTRUE;
267 }
268 }
269
270 return tmp;
271}
272