]>
Commit | Line | Data |
---|---|---|
79c114b5 | 1 | // @(#) $Id$ |
2 | ||
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 | **************************************************************************/ | |
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 | ||
29 | /** the global object for component registration */ | |
30 | AliHLTRootFileStreamerComponent gAliHLTRootFileStreamerComponent; | |
31 | ||
32 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
33 | ClassImp(AliHLTRootFileStreamerComponent) | |
34 | ||
35 | AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent() | |
36 | : | |
37 | AliHLTProcessor(), | |
38 | fDataType(kAliHLTVoidDataType), | |
39 | fSpecification(~(AliHLTUInt32_t)0) | |
40 | { | |
41 | // see header file for class documentation | |
42 | // or | |
43 | // refer to README to build package | |
44 | // or | |
45 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
46 | ||
47 | } | |
48 | ||
49 | AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent(const AliHLTRootFileStreamerComponent&) | |
50 | : | |
51 | AliHLTProcessor(), | |
52 | fDataType(kAliHLTVoidDataType), | |
53 | fSpecification(~(AliHLTUInt32_t)0) | |
54 | { | |
55 | // see header file for class documentation | |
56 | } | |
57 | ||
58 | AliHLTRootFileStreamerComponent& AliHLTRootFileStreamerComponent::operator=(const AliHLTRootFileStreamerComponent&) | |
59 | { | |
60 | // see header file for class documentation | |
61 | return *this; | |
62 | } | |
63 | ||
64 | AliHLTRootFileStreamerComponent::~AliHLTRootFileStreamerComponent() | |
65 | { | |
66 | // see header file for class documentation | |
67 | } | |
68 | ||
69 | void AliHLTRootFileStreamerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
70 | { | |
71 | // see header file for class documentation | |
72 | list.clear(); | |
73 | list.push_back(kAliHLTAnyDataType); | |
74 | } | |
75 | ||
76 | AliHLTComponentDataType AliHLTRootFileStreamerComponent::GetOutputDataType() | |
77 | { | |
78 | // see header file for class documentation | |
79 | return fDataType; | |
80 | } | |
81 | ||
82 | void AliHLTRootFileStreamerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
83 | { | |
84 | // see header file for class documentation | |
85 | constBase=500; | |
86 | inputMultiplier=5.0; | |
87 | } | |
88 | ||
89 | int AliHLTRootFileStreamerComponent::DoInit( int argc, const char** argv ) | |
90 | { | |
91 | // see header file for class documentation | |
92 | ||
93 | int iResult=0; | |
94 | TString argument=""; | |
95 | int bMissingParam=0; | |
96 | for (int i=0; i<argc && iResult>=0; i++) { | |
97 | argument=argv[i]; | |
98 | if (argument.IsNull()) continue; | |
99 | ||
100 | // -datatype | |
101 | if (argument.CompareTo("-datatype")==0) { | |
102 | if ((bMissingParam=(++i>=argc))) break; | |
103 | memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i]))); | |
104 | if ((bMissingParam=(++i>=argc))) break; | |
105 | memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i]))); | |
106 | ||
107 | // -dataspec | |
108 | } else if (argument.CompareTo("-dataspec")==0) { | |
109 | if ((bMissingParam=(++i>=argc))) break; | |
110 | TString parameter(argv[i]); | |
111 | parameter.Remove(TString::kLeading, ' '); // remove all blanks | |
112 | if (parameter.IsDigit()) { | |
113 | fSpecification=(AliHLTUInt32_t)parameter.Atoi(); | |
114 | } else if (parameter.BeginsWith("0x") && | |
115 | parameter.Replace(0,2,"",0).IsHex()) { | |
116 | sscanf(parameter.Data(),"%x", &fSpecification); | |
117 | } else { | |
118 | HLTError("wrong parameter for argument %s, number expected", argument.Data()); | |
119 | iResult=-EINVAL; | |
120 | } | |
121 | } else { | |
122 | HLTError("unknown argument %s", argument.Data()); | |
123 | break; | |
124 | } | |
125 | } | |
126 | if (bMissingParam) { | |
127 | HLTError("missing parameter for argument %s", argument.Data()); | |
128 | iResult=-EINVAL; | |
129 | } | |
130 | return iResult; | |
131 | } | |
132 | ||
298ef463 | 133 | int AliHLTRootFileStreamerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, |
79c114b5 | 134 | AliHLTComponentTriggerData& /*trigData*/ ) |
135 | { | |
136 | // see header file for class documentation | |
137 | int iResult=0; | |
138 | AliHLTMemoryFile* pFile=CreateMemoryFile(fDataType,fSpecification); | |
139 | if (pFile) { | |
140 | const TObject* pObj=GetFirstInputObject(kAliHLTAnyDataType); | |
141 | int count=0; | |
142 | while (pObj && iResult>=0) { | |
143 | iResult=Write(pFile, pObj); | |
144 | if (iResult) { | |
145 | count++; | |
146 | HLTDebug("wrote object of class %s, data type %s", pObj->ClassName(), (DataType2Text(GetDataType(pObj)).c_str())); | |
147 | } | |
148 | pObj=GetNextInputObject(); | |
149 | } | |
150 | HLTInfo("wrote %d object(s) from %d input blocks to file", count, GetNumberOfInputBlocks()); | |
151 | iResult=CloseMemoryFile(pFile); | |
152 | } else { | |
153 | iResult=-ENOMEM; | |
154 | } | |
155 | return iResult; | |
156 | } |