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 <TObjString.h>
21 #include "AliRawReaderMemory.h"
22 #include "AliCaloRawStream.h"
24 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
25 #include "AliHLTPHOSDataHeaderStruct.h"
26 #include "AliHLTDataTypes.h"
29 const AliHLTComponentDataType AliHLTPHOSFileWriterComponent::fInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
32 AliHLTPHOSFileWriterComponent gAliHLTPHOSFileWriterComponent;
34 AliHLTPHOSFileWriterComponent::AliHLTPHOSFileWriterComponent(): AliHLTFileWriter(), fCellEnergiesFileWriterPtr(0) \
35 , fDDLPackedFileWriterPtr(0), fDirectory(""),fFilename(""), fEventCount(0)
37 for(int i=0; i<N_DATATYPES; i++)
39 fDataTypesToFile[i] = kAliHLTVoidDataType;
42 fCellEnergiesFileWriterPtr = new AliHLTPHOSCellEnergiesFileWriter();
43 fDDLPackedFileWriterPtr = new AliHLTPHOSDDLPackedFileWriter();
47 AliHLTPHOSFileWriterComponent::~AliHLTPHOSFileWriterComponent()
49 delete fCellEnergiesFileWriterPtr;
50 delete fDDLPackedFileWriterPtr;
55 AliHLTPHOSFileWriterComponent::AliHLTPHOSFileWriterComponent(const AliHLTPHOSFileWriterComponent & ): AliHLTFileWriter(), fCellEnergiesFileWriterPtr(0), \
56 fDDLPackedFileWriterPtr(0), fDirectory(""),fFilename(""), 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 fDataTypesToFile[tmpCnt] = AliHLTPHOSDefinitions::gkCellEnergyDataType;
79 cout <<"regsitring dataType for filewriting: fDataTypesToFile[" << tmpCnt <<"]"<<endl;
81 else if(dataType.compare("gkDDLPackedRawDataType") == 0)
83 fDataTypesToFile[tmpCnt] = AliHLTPHOSDefinitions::gkDDLPackedRawDataType;
86 cout << "dataType.compare(cmpString) = " <<dataType.compare(cmpString)<<endl;
94 AliHLTPHOSFileWriterComponent::Deinit()
100 AliHLTPHOSFileWriterComponent::DoDeinit()
102 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSFileWriterComponen DoDeinit");
107 AliHLTPHOSFileWriterComponent::GetComponentID()
109 return "PhosFileWriter";
113 AliHLTPHOSFileWriterComponent::Spawn()
115 return new AliHLTPHOSFileWriterComponent;
120 AliHLTPHOSFileWriterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
122 const AliHLTComponentDataType* pType=fInputDataTypes;
123 while (pType->fID!=0) {
124 list.push_back(*pType);
129 AliHLTComponentDataType
130 AliHLTPHOSFileWriterComponent::GetOutputDataType()
132 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
136 AliHLTPHOSFileWriterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
140 inputMultiplier = 0.1;
145 AliHLTPHOSFileWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData )
149 Int_t tmpChannelCnt = 0;
151 const AliHLTComponentDataType *tmpDataType;
152 const AliHLTComponentBlockData* iter = NULL;
154 AliHLTPHOSDataHeaderStruct dataHeader;
156 dataHeader.fSize = sizeof(dataHeader);
157 dataHeader.fEventID = evtData.fEventID;
158 cout << "analyzing event: " << fEventCount << endl;
160 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
165 tmpDataType = &(iter->fDataType);
167 if(IsRegisteredDataType(*tmpDataType))
169 if(*tmpDataType == AliHLTPHOSDefinitions::gkCellEnergyDataType)
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;
176 else if(*tmpDataType == AliHLTPHOSDefinitions::gkDDLPackedRawDataType)
179 fDDLPackedFileWriterPtr->WriteFile(evtData, blocks, trigData, *tmpDataType, fEventCount);
183 // cout <<"AliHLTPHOSFileWriterComponen: data type = is gkCellEnergyDataType. block index = "<< ndx\
184 // <<" EventCount =" << fEventCount << "Event ID"<<evtData.fEventID << endl;
195 AliHLTPHOSFileWriterComponent::DoInit( int argc, const char** argv )
201 Bool_t dirSet = kFALSE;
202 Bool_t dataSet = kFALSE;
206 for(int i=0; i<argc; i++)
210 if(argument.CompareTo("-directory")==0)
212 if ((bMissingParam=(++i>=argc)))
216 fDirectory.assign(argv[i]);
217 fCellEnergiesFileWriterPtr->SetDirectory(fDirectory);
218 fDDLPackedFileWriterPtr->SetDirectory(fDirectory) ;
219 fFilename.insert(0, fDirectory);
221 cout << "fDirectory=" << fDirectory << endl;
224 if(argument.CompareTo("-datatype")==0)
226 if ((bMissingParam=(++i>=argc))) break;
227 cout << "datatype = " << argv[i] << endl;
230 AddDataType(dataType);
234 cout << "argv[" << i <<"] = " << argv[i] << endl;
241 // * We dont start the component if we don know what data to write
242 // * or where to store it
244 // if((dataSet != kTRUE || dataSet != kTRUE))
247 // HLTFatal(" either direcory or datatype is not set, usage -datatype <datatype> -driectory <directory>");
259 AliHLTPHOSFileWriterComponent::IsRegisteredDataType(const AliHLTComponentDataType& dataType)
262 for(int i =0; i<N_DATATYPES; i++)
264 if((fDataTypesToFile[i] == dataType) && (dataType != kAliHLTVoidDataType))