]>
Commit | Line | Data |
---|---|---|
eb84342b | 1 | //-*- Mode: C++ -*- |
2 | // $Id: AliHLTGlobalEsdToFlatConverterComponent.cxx $ | |
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: Steffen Weber * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /** @file AliHLTGlobalEsdToFlatConverterComponent.cxx | |
19 | @author Steffen Weber | |
20 | @brief Component to convert ESD objects to flatESD objects | |
21 | */ | |
22 | ||
23 | #include "TMap.h" | |
24 | #include "TSystem.h" | |
25 | #include "TTimeStamp.h" | |
26 | #include "TObjString.h" | |
27 | #include "TList.h" | |
28 | #include "AliESDEvent.h" | |
29 | #include "AliFlatESDEvent.h" | |
30 | #include "AliHLTErrorGuard.h" | |
31 | #include "AliHLTDataTypes.h" | |
32 | #include "AliHLTGlobalEsdToFlatConverterComponent.h" | |
33 | #include "AliHLTITSClusterDataFormat.h" | |
34 | #include "AliHLTTPCDefinitions.h" | |
35 | #include "TTree.h" | |
36 | #include "AliCDBEntry.h" | |
37 | #include "AliCDBManager.h" | |
c2374f56 | 38 | #include "AliSysInfo.h" |
eb84342b | 39 | |
40 | using namespace std; | |
41 | ||
42 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
43 | ClassImp(AliHLTGlobalEsdToFlatConverterComponent) | |
44 | ||
45 | /* | |
46 | * --------------------------------------------------------------------------------- | |
47 | * Constructor / Destructor | |
48 | * --------------------------------------------------------------------------------- | |
49 | */ | |
50 | ||
51 | // ################################################################################# | |
52 | AliHLTGlobalEsdToFlatConverterComponent::AliHLTGlobalEsdToFlatConverterComponent() : | |
53 | AliHLTProcessor() | |
54 | { | |
55 | // an example component which implements the ALICE HLT processor | |
56 | // interface and does some analysis on the input raw data | |
57 | // | |
58 | // see header file for class documentation | |
59 | // or | |
60 | // refer to README to build package | |
61 | // or | |
62 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
63 | // | |
64 | // NOTE: all helper classes should be instantiated in DoInit() | |
65 | } | |
66 | ||
67 | // ################################################################################# | |
68 | AliHLTGlobalEsdToFlatConverterComponent::~AliHLTGlobalEsdToFlatConverterComponent() { | |
69 | // see header file for class documentation | |
70 | } | |
71 | ||
72 | /* | |
73 | * --------------------------------------------------------------------------------- | |
74 | * Public functions to implement AliHLTComponent's interface. | |
75 | * These functions are required for the registration process | |
76 | * --------------------------------------------------------------------------------- | |
77 | */ | |
78 | ||
79 | // ################################################################################# | |
80 | const Char_t* AliHLTGlobalEsdToFlatConverterComponent::GetComponentID() { | |
81 | // see header file for class documentation | |
8e0c1b9d | 82 | return "GlobalEsdToFlatConverter"; |
eb84342b | 83 | } |
84 | ||
85 | // ################################################################################# | |
86 | void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
87 | // see header file for class documentation | |
8e0c1b9d | 88 | list.push_back(kAliHLTDataTypeESDTree|kAliHLTDataOriginOut ); |
89 | list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut ); | |
eb84342b | 90 | list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut ); |
91 | } | |
92 | ||
93 | // ################################################################################# | |
94 | AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() { | |
95 | // see header file for class documentation | |
96 | return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut; | |
97 | } | |
98 | ||
99 | // ################################################################################# | |
100 | void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) { | |
101 | // see header file for class documentation | |
a2e57ab1 | 102 | constBase = 10000; |
ee82d961 | 103 | inputMultiplier = 10.0; |
eb84342b | 104 | } |
105 | ||
106 | ||
107 | // ################################################################################# | |
108 | AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() { | |
109 | // see header file for class documentation | |
110 | return new AliHLTGlobalEsdToFlatConverterComponent; | |
111 | } | |
112 | ||
113 | /* | |
114 | * --------------------------------------------------------------------------------- | |
115 | * Protected functions to implement AliHLTComponent's interface. | |
116 | * These functions provide initialization as well as the actual processing | |
117 | * capabilities of the component. | |
118 | * --------------------------------------------------------------------------------- | |
119 | */ | |
120 | ||
121 | // ################################################################################# | |
122 | Int_t AliHLTGlobalEsdToFlatConverterComponent::DoInit( Int_t argc, const Char_t** argv ) { | |
123 | // see header file for class documentation | |
124 | printf("AliHLTGlobalEsdToFlatConverterComponent::DoInit\n"); | |
125 | // see header file for class documentation | |
126 | int iResult=0; | |
127 | TString argument=""; | |
128 | int bMissingParam=0; | |
129 | ||
130 | // default list of skiped ESD objects | |
131 | TString skipObjects= | |
132 | // "AliESDRun," | |
133 | // "AliESDHeader," | |
134 | // "AliESDZDC," | |
135 | "AliESDFMD," | |
136 | // "AliESDVZERO," | |
137 | // "AliESDTZERO," | |
138 | // "TPCVertex," | |
139 | // "SPDVertex," | |
140 | // "PrimaryVertex," | |
141 | // "AliMultiplicity," | |
142 | // "PHOSTrigger," | |
143 | // "EMCALTrigger," | |
144 | // "SPDPileupVertices," | |
145 | // "TrkPileupVertices," | |
146 | "Cascades," | |
147 | "Kinks," | |
148 | "AliRawDataErrorLogs," | |
149 | "AliESDACORDE"; | |
150 | ||
151 | iResult=Reconfigure(NULL, NULL); | |
152 | TString allArgs = ""; | |
153 | for ( int i = 0; i < argc; i++ ) { | |
154 | if ( !allArgs.IsNull() ) allArgs += " "; | |
155 | allArgs += argv[i]; | |
156 | } | |
157 | ||
158 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
159 | if (pTokens) { | |
160 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
161 | argument=((TObjString*)pTokens->At(i))->String(); | |
162 | if (argument.IsNull()) continue; | |
163 | if (argument.Contains("-skipobject=")) { | |
164 | argument.ReplaceAll("-skipobject=", ""); | |
165 | skipObjects=argument; | |
166 | } else { | |
167 | HLTError("unknown argument %s", argument.Data()); | |
168 | iResult=-EINVAL; | |
169 | break; | |
170 | } | |
171 | } | |
172 | } | |
173 | if (bMissingParam) { | |
174 | HLTError("missing parameter for argument %s", argument.Data()); | |
175 | iResult=-EINVAL; | |
176 | } | |
177 | ||
178 | ||
179 | if (iResult>=0) { | |
180 | SetupCTPData(); | |
181 | } | |
182 | ||
183 | return iResult; | |
184 | } | |
185 | ||
186 | ||
187 | ||
188 | // ################################################################################# | |
189 | Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() { | |
190 | // see header file for class documentation | |
191 | ||
192 | ||
193 | return 0; | |
194 | } | |
195 | ||
196 | // ################################################################################# | |
197 | Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
198 | const AliHLTComponentBlockData* /*blocks*/, | |
199 | AliHLTComponentTriggerData& /*trigData*/, | |
ee82d961 | 200 | AliHLTUInt8_t* outputPtr, |
201 | AliHLTUInt32_t& size, | |
eb84342b | 202 | AliHLTComponentBlockDataList& outputBlocks) { |
203 | // see header file for class documentation | |
204 | ||
c2374f56 | 205 | |
206 | ||
207 | ||
208 | AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Start"); | |
eb84342b | 209 | Int_t iResult=0; |
210 | ||
a2e57ab1 | 211 | |
212 | ||
213 | size_t maxOutputSize = size; | |
214 | size = 0; | |
215 | ||
eb84342b | 216 | // -- Only use data event |
217 | if (!IsDataEvent()) | |
218 | return 0; | |
219 | ||
b904048c | 220 | AliESDEvent *esd; |
8e0c1b9d | 221 | |
222 | ||
eb84342b | 223 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) { |
b904048c | 224 | esd =dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter)); |
eb84342b | 225 | if( esd ){ |
b904048c | 226 | esd->GetStdContent(); |
eb84342b | 227 | iResult=1; |
228 | } else { | |
eb84342b | 229 | } |
230 | } | |
231 | ||
232 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) { | |
233 | //fBenchmark.AddInput(pBlock->fSize); | |
eb84342b | 234 | const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter); |
235 | if( esdFriend ){ | |
eb84342b | 236 | } else { |
eb84342b | 237 | } |
238 | } | |
a2e57ab1 | 239 | |
eb84342b | 240 | |
eb84342b | 241 | AliFlatESDEvent *flatEsd ; |
eb84342b | 242 | |
ee82d961 | 243 | flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr); |
eb84342b | 244 | new (flatEsd) AliFlatESDEvent; |
ee82d961 | 245 | flatEsd->SetFromESD(AliFlatESDEvent::EstimateSize(esd),esd, kTRUE); |
eb84342b | 246 | |
a2e57ab1 | 247 | |
248 | if( maxOutputSize > flatEsd->GetSize() ){ | |
249 | ||
eb84342b | 250 | AliHLTComponentBlockData outBlock; |
251 | FillBlockData( outBlock ); | |
252 | outBlock.fOffset = size; | |
253 | outBlock.fSize = flatEsd->GetSize(); | |
254 | outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut; | |
255 | outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 ); | |
256 | ||
257 | outputBlocks.push_back( outBlock ); | |
ee82d961 | 258 | |
eb84342b | 259 | size += outBlock.fSize; |
a2e57ab1 | 260 | |
261 | } | |
262 | ||
263 | else { | |
264 | ||
265 | return 0; | |
266 | } | |
ee82d961 | 267 | |
eb84342b | 268 | |
c2374f56 | 269 | |
270 | AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Stop",0, flatEsd->GetSize(),flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks()); | |
eb84342b | 271 | |
272 | ||
273 | return iResult; | |
274 | } | |
275 | ||
276 | ||
277 | // ################################################################################# | |
278 | Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) { | |
279 | // see header file for class documentation | |
280 | ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component"); | |
281 | return 0; | |
282 | } | |
283 | ||
284 | ||
285 | int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments) | |
286 | { | |
287 | // see header file for class documentation | |
288 | int iResult=0; | |
289 | if (!arguments) return iResult; | |
290 | ||
291 | TString allArgs=arguments; | |
292 | TString argument; | |
293 | int bMissingParam=0; | |
294 | ||
295 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
296 | if (pTokens) { | |
297 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
298 | argument=((TObjString*)pTokens->At(i))->String(); | |
299 | if (argument.IsNull()) continue; | |
300 | HLTError("unknown argument %s", argument.Data()); | |
301 | iResult=-EINVAL; | |
302 | break; | |
303 | } | |
304 | delete pTokens; | |
305 | } | |
306 | if (bMissingParam) { | |
307 | HLTError("missing parameter for argument %s", argument.Data()); | |
308 | iResult=-EINVAL; | |
309 | } | |
310 | ||
311 | return iResult; | |
312 | } | |
313 | ||
314 | int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
315 | { | |
316 | // see header file for class documentation | |
317 | int iResult=0; | |
318 | const char* path=NULL; | |
319 | const char* defaultNotify=""; | |
320 | if (cdbEntry) { | |
321 | path=cdbEntry; | |
322 | defaultNotify=" (default)"; | |
323 | } | |
324 | if (path) { | |
325 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
326 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
327 | if (pEntry) { | |
328 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
329 | if (pString) { | |
330 | HLTInfo("received configuration object string: \'%s\'", pString->String().Data()); | |
331 | iResult=Configure(pString->String().Data()); | |
332 | } else { | |
333 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
334 | } | |
335 | } else { | |
336 | HLTError("can not fetch object \"%s\" from CDB", path); | |
337 | } | |
338 | } | |
339 | ||
340 | return iResult; | |
341 | } |