]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/util/AliHLTRootFileStreamerComponent.cxx
attaching file writer to the StreamerInfo component
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTRootFileStreamerComponent.cxx
CommitLineData
79c114b5 1// @(#) $Id$
2
6daf06e2 3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
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//**************************************************************************
79c114b5 18
19/** @file AliHLTRootFileStreamerComponent.cxx
20 @author Matthias Richter
21 @date
22 @brief Save objects in a ROOT memory file
23
24 */
25
26#include "AliHLTRootFileStreamerComponent.h"
27#include "TString.h"
28
79c114b5 29/** ROOT macro for the implementation of ROOT specific class methods */
30ClassImp(AliHLTRootFileStreamerComponent)
31
32AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent()
33 :
34 AliHLTProcessor(),
35 fDataType(kAliHLTVoidDataType),
36 fSpecification(~(AliHLTUInt32_t)0)
37{
38 // see header file for class documentation
39 // or
40 // refer to README to build package
41 // or
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
43
44}
45
46AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent(const AliHLTRootFileStreamerComponent&)
47 :
48 AliHLTProcessor(),
49 fDataType(kAliHLTVoidDataType),
50 fSpecification(~(AliHLTUInt32_t)0)
51{
52 // see header file for class documentation
53}
54
55AliHLTRootFileStreamerComponent& AliHLTRootFileStreamerComponent::operator=(const AliHLTRootFileStreamerComponent&)
56{
57 // see header file for class documentation
58 return *this;
59}
60
61AliHLTRootFileStreamerComponent::~AliHLTRootFileStreamerComponent()
62{
63 // see header file for class documentation
64}
65
66void AliHLTRootFileStreamerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
67{
68 // see header file for class documentation
69 list.clear();
6daf06e2 70 list.push_back(kAliHLTAllDataTypes);
79c114b5 71}
72
73AliHLTComponentDataType AliHLTRootFileStreamerComponent::GetOutputDataType()
74{
75 // see header file for class documentation
76 return fDataType;
77}
78
79void AliHLTRootFileStreamerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
80{
81 // see header file for class documentation
82 constBase=500;
83 inputMultiplier=5.0;
84}
85
86int AliHLTRootFileStreamerComponent::DoInit( int argc, const char** argv )
87{
88 // see header file for class documentation
89
90 int iResult=0;
91 TString argument="";
92 int bMissingParam=0;
93 for (int i=0; i<argc && iResult>=0; i++) {
94 argument=argv[i];
95 if (argument.IsNull()) continue;
96
97 // -datatype
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])));
103
104 // -dataspec
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);
114 } else {
115 HLTError("wrong parameter for argument %s, number expected", argument.Data());
116 iResult=-EINVAL;
117 }
118 } else {
119 HLTError("unknown argument %s", argument.Data());
120 break;
121 }
122 }
123 if (bMissingParam) {
124 HLTError("missing parameter for argument %s", argument.Data());
125 iResult=-EINVAL;
126 }
127 return iResult;
128}
129
298ef463 130int AliHLTRootFileStreamerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
79c114b5 131 AliHLTComponentTriggerData& /*trigData*/ )
132{
133 // see header file for class documentation
134 int iResult=0;
135 AliHLTMemoryFile* pFile=CreateMemoryFile(fDataType,fSpecification);
136 if (pFile) {
79c114b5 137 int count=0;
6daf06e2 138 for (const TObject* pObj=GetFirstInputObject();
139 pObj && iResult>=0;
140 pObj=GetNextInputObject()) {
79c114b5 141 iResult=Write(pFile, pObj);
142 if (iResult) {
143 count++;
144 HLTDebug("wrote object of class %s, data type %s", pObj->ClassName(), (DataType2Text(GetDataType(pObj)).c_str()));
145 }
79c114b5 146 }
147 HLTInfo("wrote %d object(s) from %d input blocks to file", count, GetNumberOfInputBlocks());
148 iResult=CloseMemoryFile(pFile);
149 } else {
150 iResult=-ENOMEM;
151 }
152 return iResult;
153}