1 /**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Per Thomas Hille for the ALICE HLT Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //#include "AliHLTPHOSFileWriterComponent.h"
19 #include "AliHLTPHOSFileWriterComponent.h"
22 #include <TObjString.h>
24 #include "AliRawReaderMemory.h"
25 #include "AliCaloRawStream.h"
27 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
28 #include "AliHLTPHOSDataHeaderStruct.h"
29 #include "AliHLTDataTypes.h"
32 const AliHLTComponentDataType AliHLTPHOSFileWriterComponent::fInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
35 AliHLTPHOSFileWriterComponent gAliHLTPHOSFileWriterComponent;
37 AliHLTPHOSFileWriterComponent::AliHLTPHOSFileWriterComponent():AliHLTDataSink(), fCellEnergiesFileWriterPtr(0), fDDLPackedFileWriterPtr(0), fDirectory(0),fFilename(0), fEventCount(0)
39 for(int i=0; i<N_DATATYPES; i++)
41 fDataTypesToFile[i] = kAliHLTVoidDataType;
44 fCellEnergiesFileWriterPtr = new AliHLTPHOSCellEnergiesFileWriter();
45 fDDLPackedFileWriterPtr = new AliHLTPHOSDDLPackedFileWriter();
49 AliHLTPHOSFileWriterComponent::~AliHLTPHOSFileWriterComponent()
51 delete fCellEnergiesFileWriterPtr;
52 delete fDDLPackedFileWriterPtr;
56 AliHLTPHOSFileWriterComponent::AliHLTPHOSFileWriterComponent(const AliHLTPHOSFileWriterComponent & ):AliHLTDataSink(), fCellEnergiesFileWriterPtr(0), fDDLPackedFileWriterPtr(0), fDirectory(0),fFilename(0), fEventCount(0)
62 AliHLTPHOSFileWriterComponent::AddDataType(string dataType)
66 for(int i=0; i< N_DATATYPES; i++)
68 if( fDataTypesToFile[i] != kAliHLTVoidDataType)
74 string cmpString("gkCellEnergyDataType");
76 if(dataType.compare("gkCellEnergyDataType") == 0)
78 cout << "!!!!!!!!!!!!!!AliHLTPHOSFileWriterComponent::AddDataType"<< dataType << endl;
79 // fDataTypesToFilePtr[N_DATATYPES] = new AliHLTPHOSDefinitions::gkCellEnergyDataType;
80 fDataTypesToFile[tmpCnt] = AliHLTPHOSDefinitions::gkCellEnergyDataType;
81 cout <<"regsitring dataType for filewriting: fDataTypesToFile[" << tmpCnt <<"]"<<endl;
83 else if(dataType.compare("gkDDLPackedRawDataType") == 0)
85 fDataTypesToFile[tmpCnt] = AliHLTPHOSDefinitions::gkDDLPackedRawDataType;
88 cout << "dataType.compare(cmpString) = " <<dataType.compare(cmpString)<<endl;
96 AliHLTPHOSFileWriterComponent::Deinit()
102 AliHLTPHOSFileWriterComponent::DoDeinit()
104 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSFileWriterComponen DoDeinit");
109 AliHLTPHOSFileWriterComponent::GetComponentID()
111 return "PhosFileWriter";
115 AliHLTPHOSFileWriterComponent::Spawn()
117 return new AliHLTPHOSFileWriterComponent;
122 AliHLTPHOSFileWriterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
124 const AliHLTComponentDataType* pType=fInputDataTypes;
125 while (pType->fID!=0) {
126 list.push_back(*pType);
131 AliHLTComponentDataType
132 AliHLTPHOSFileWriterComponent::GetOutputDataType()
134 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
138 AliHLTPHOSFileWriterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
142 inputMultiplier = 0.1;
146 AliHLTPHOSFileWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData )
150 Int_t tmpChannelCnt = 0;
152 const AliHLTComponentDataType *tmpDataType;
153 const AliHLTComponentBlockData* iter = NULL;
155 AliHLTPHOSDataHeaderStruct dataHeader;
157 dataHeader.fSize = sizeof(dataHeader);
158 dataHeader.fEventID = evtData.fEventID;
159 cout << "analyzing event: " << fEventCount << endl;
161 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
166 tmpDataType = &(iter->fDataType);
168 if(IsRegisteredDataType(*tmpDataType))
170 if(*tmpDataType == AliHLTPHOSDefinitions::gkCellEnergyDataType)
173 fCellEnergiesFileWriterPtr->WriteFile(evtData, blocks, trigData, fEventCount);
174 cout <<"AliHLTPHOSFileWriterComponen: data type = is gkCellEnergyDataType. block index = "<< ndx\
175 <<" EventCount =" << fEventCount << "Event ID"<<evtData.fEventID << endl;
177 else if(*tmpDataType == AliHLTPHOSDefinitions::gkDDLPackedRawDataType)
180 fDDLPackedFileWriterPtr->WriteFile(evtData, blocks, trigData, fEventCount);
184 // cout <<"AliHLTPHOSFileWriterComponen: data type = is gkCellEnergyDataType. block index = "<< ndx\
185 // <<" EventCount =" << fEventCount << "Event ID"<<evtData.fEventID << endl;
194 AliHLTPHOSFileWriterComponent::DoInit( int argc, const char** argv )
198 Bool_t dirSet = kFALSE;
199 Bool_t dataSet = kFALSE;
203 fFilename.assign(256,0);
205 for(int i=0; i<argc; i++)
209 if(argument.CompareTo("-directory")==0)
211 if ((bMissingParam=(++i>=argc)))
215 fDirectory.assign(argv[i]);
216 fCellEnergiesFileWriterPtr->SetDirectory(fDirectory);
217 fDDLPackedFileWriterPtr->SetDirectory(fDirectory) ;
219 fFilename.insert(0, fDirectory);
222 cout << "fDirectory=" << fDirectory << endl;
225 if(argument.CompareTo("-datatype")==0)
227 if ((bMissingParam=(++i>=argc))) break;
228 cout << "datatype = " << argv[i] << endl;
231 AddDataType(dataType);
235 cout << "argv[" << i <<"] = " << argv[i] << endl;
240 * We dont start the component if we don know what data to write
241 * or where to store it
243 if((dataSet != kTRUE || dataSet != kTRUE))
246 HLTFatal(" either direcory or datatype is not set, usage -datatype <datatype> -driectory <directory>");
257 AliHLTPHOSFileWriterComponent::IsRegisteredDataType(const AliHLTComponentDataType& dataType)
260 for(int i =0; i<N_DATATYPES; i++)
262 if((fDataTypesToFile[i] == dataType) && (dataType != kAliHLTVoidDataType))