]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/util/AliHLTEsdCollectorComponent.cxx
handling of steering events
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTEsdCollectorComponent.cxx
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   AliHLTEsdCollectorComponent.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Base class for writer components to store data in a ROOT file
23
24                                                                           */
25
26 #include "AliHLTEsdCollectorComponent.h"
27 #include "AliHLTEsdManager.h"
28 #include "TString.h"
29
30 /** ROOT macro for the implementation of ROOT specific class methods */
31 ClassImp(AliHLTEsdCollectorComponent)
32
33 AliHLTEsdCollectorComponent::AliHLTEsdCollectorComponent()
34   :
35   AliHLTFileWriter(),
36   fpManager(NULL)
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   // all event go into the same file, but there are individual files for
45   // different data blocks
46   SetMode(kConcatenateEvents);
47 }
48
49 AliHLTEsdCollectorComponent::~AliHLTEsdCollectorComponent()
50 {
51   // see header file for class documentation
52 }
53
54 int AliHLTEsdCollectorComponent::InitWriter()
55 {
56   // see header file for class documentation
57   int iResult=0;
58
59   // choose .root as default extension
60   if (GetExtension().IsNull()) SetExtension("root");
61
62   if ((fpManager=AliHLTEsdManager::New())) {
63     fpManager->SetDirectory(GetDirectory().Data());
64   } else {
65     HLTError("can not find AliHLTEsdManager class descriptor");
66     iResult=-ENODEV;
67   }
68
69   return iResult;
70 }
71
72 int AliHLTEsdCollectorComponent::CloseWriter()
73 {
74   // see header file for class documentation
75   if (fpManager!=NULL) {
76     AliHLTEsdManager::Delete(fpManager);
77     fpManager=NULL;
78   }
79   return 0;
80 }
81
82 int AliHLTEsdCollectorComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
83                                             const AliHLTComponentBlockData* /*blocks*/, 
84                                             AliHLTComponentTriggerData& /*trigData*/ )
85 {
86   // see header file for class documentation
87   int iResult=0;
88   if (!fpManager) return -ENODEV;
89
90   for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
91        pBlock && iResult>=0;
92        pBlock=GetNextInputBlock()) {
93     if (pBlock->fDataType!=kAliHLTDataTypeESDObject &&
94         pBlock->fDataType!=kAliHLTDataTypeESDTree) continue;
95     HLTInfo("writing ESD, data type %s event %d", (DataType2Text(pBlock->fDataType).c_str()), GetEventCount());
96     iResult=fpManager->WriteESD(reinterpret_cast<const AliHLTUInt8_t*>(pBlock->fPtr),
97                                 pBlock->fSize, pBlock->fDataType, NULL, GetEventCount());
98   }
99   return iResult;
100 }
101
102 int AliHLTEsdCollectorComponent::ScanArgument(int /*argc*/, const char** /*argv*/)
103 {
104   // see header file for class documentation
105   // no other arguments known
106   int iResult=-EINVAL;
107   return iResult;
108 }