3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliHLTRootFileStreamerComponent.cxx
20 @author Matthias Richter
22 @brief Save objects in a ROOT memory file
26 #include "AliHLTRootFileStreamerComponent.h"
29 /** ROOT macro for the implementation of ROOT specific class methods */
30 ClassImp(AliHLTRootFileStreamerComponent)
32 AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent()
35 fDataType(kAliHLTVoidDataType),
36 fSpecification(~(AliHLTUInt32_t)0)
38 // see header file for class documentation
40 // refer to README to build package
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent(const AliHLTRootFileStreamerComponent&)
49 fDataType(kAliHLTVoidDataType),
50 fSpecification(~(AliHLTUInt32_t)0)
52 // see header file for class documentation
55 AliHLTRootFileStreamerComponent& AliHLTRootFileStreamerComponent::operator=(const AliHLTRootFileStreamerComponent&)
57 // see header file for class documentation
61 AliHLTRootFileStreamerComponent::~AliHLTRootFileStreamerComponent()
63 // see header file for class documentation
66 void AliHLTRootFileStreamerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
68 // see header file for class documentation
70 list.push_back(kAliHLTAllDataTypes);
73 AliHLTComponentDataType AliHLTRootFileStreamerComponent::GetOutputDataType()
75 // see header file for class documentation
79 void AliHLTRootFileStreamerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
81 // see header file for class documentation
86 int AliHLTRootFileStreamerComponent::DoInit( int argc, const char** argv )
88 // see header file for class documentation
93 for (int i=0; i<argc && iResult>=0; i++) {
95 if (argument.IsNull()) continue;
98 if (argument.CompareTo("-datatype")==0) {
99 if ((bMissingParam=(++i>=argc))) break;
100 memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
101 if ((bMissingParam=(++i>=argc))) break;
102 memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
105 } else if (argument.CompareTo("-dataspec")==0) {
106 if ((bMissingParam=(++i>=argc))) break;
107 TString parameter(argv[i]);
108 parameter.Remove(TString::kLeading, ' '); // remove all blanks
109 if (parameter.IsDigit()) {
110 fSpecification=(AliHLTUInt32_t)parameter.Atoi();
111 } else if (parameter.BeginsWith("0x") &&
112 parameter.Replace(0,2,"",0).IsHex()) {
113 sscanf(parameter.Data(),"%x", &fSpecification);
115 HLTError("wrong parameter for argument %s, number expected", argument.Data());
119 HLTError("unknown argument %s", argument.Data());
124 HLTError("missing parameter for argument %s", argument.Data());
130 int AliHLTRootFileStreamerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
131 AliHLTComponentTriggerData& /*trigData*/ )
133 // see header file for class documentation
135 AliHLTMemoryFile* pFile=CreateMemoryFile(fDataType,fSpecification);
138 for (const TObject* pObj=GetFirstInputObject();
140 pObj=GetNextInputObject()) {
141 iResult=Write(pFile, pObj);
144 HLTDebug("wrote object of class %s, data type %s", pObj->ClassName(), (DataType2Text(GetDataType(pObj)).c_str()));
147 HLTInfo("wrote %d object(s) from %d input blocks to file", count, GetNumberOfInputBlocks());
148 iResult=CloseMemoryFile(pFile);