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 AliHLTEsdCollectorComponent.cxx
20 @author Matthias Richter
22 @brief Base class for writer components to store data in a ROOT file
26 #include "AliHLTEsdCollectorComponent.h"
27 #include "AliHLTEsdManager.h"
30 /** ROOT macro for the implementation of ROOT specific class methods */
31 ClassImp(AliHLTEsdCollectorComponent)
33 AliHLTEsdCollectorComponent::AliHLTEsdCollectorComponent()
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
44 // all event go into the same file, but there are individual files for
45 // different data blocks
46 SetMode(kConcatenateEvents);
49 AliHLTEsdCollectorComponent::~AliHLTEsdCollectorComponent()
51 // see header file for class documentation
54 int AliHLTEsdCollectorComponent::InitWriter()
56 // see header file for class documentation
59 // choose .root as default extension
60 if (GetExtension().IsNull()) SetExtension("root");
62 if ((fpManager=AliHLTEsdManager::New())) {
63 TString option="-writelocal";
64 if (!GetDirectory().IsNull()) {
65 option+=" -directory=";
66 option+=GetDirectory();
68 if (!fTreeName.IsNull()) {
69 option+=" -treename=";
72 iResult=fpManager->SetOption(option.Data());
74 HLTError("can not find AliHLTEsdManager class descriptor");
81 int AliHLTEsdCollectorComponent::CloseWriter()
83 // see header file for class documentation
84 if (fpManager!=NULL) {
85 AliHLTEsdManager::Delete(fpManager);
91 int AliHLTEsdCollectorComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
92 const AliHLTComponentBlockData* /*blocks*/,
93 AliHLTComponentTriggerData& /*trigData*/ )
95 // see header file for class documentation
97 if (!IsDataEvent() && !CheckMode(kWriteAllEvents)) return 0;
98 if (!fpManager) return -ENODEV;
100 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
101 pBlock && iResult>=0;
102 pBlock=GetNextInputBlock()) {
103 if (pBlock->fDataType!=kAliHLTDataTypeESDObject &&
104 pBlock->fDataType!=kAliHLTDataTypeESDTree) continue;
105 HLTInfo("writing ESD, data type %s event %d", (DataType2Text(pBlock->fDataType).c_str()), GetEventCount());
106 iResult=fpManager->WriteESD(reinterpret_cast<const AliHLTUInt8_t*>(pBlock->fPtr),
107 pBlock->fSize, pBlock->fDataType, NULL, GetEventCount());
112 int AliHLTEsdCollectorComponent::ScanArgument(int argc, const char** argv)
114 // see header file for class documentation
115 if (argc<=0) return 0;
118 TString argument=argv[iArg];
121 if (argument.CompareTo("-treename")==0) {
123 HLTError("expecting parameter for argument '-treename'");
126 fTreeName=argv[iArg];