4 #ifndef ALIHLTROOTFILEWRITERCOMPONENT_H
5 #define ALIHLTROOTFILEWRITERCOMPONENT_H
6 //* This file is property of and copyright by the ALICE HLT Project *
7 //* ALICE Experiment at CERN, All rights reserved. *
8 //* See cxx source for full Copyright notice *
10 /** @file AliHLTRootFileWriterComponent.h
11 @author Matthias Richter
13 @brief Base class for writer components to store data in a ROOT file
16 #include "AliHLTFileWriter.h"
21 * @class AliHLTRootFileWriterComponent
22 * The RootFileWriter provides a stand alone component to write incoming
23 * TObject like structures into a Root file. Furthermore it provides a
24 * base class for customized writers.
25 * By default, the \em -concatenate-blocks option of the AliHLTFileWriter
26 * is set. If you want to accumulate all events in the same file set the
27 * -concatenate-events option as well. In that case the \em -overwrite
28 * option might be a good choice in order to avoid multiple keys for the
29 * same object in the root file.
31 * All non-root object data blocks are just ignored.
33 * <h2>General properties:</h2>
35 * Component ID: \b ROOTFileWriter <br>
36 * Library: \b libAliHLTUtil.so <br>
37 * Input Data Types: ::kAliHLTAnyDataType <br>
38 * Output Data Types: none <br>
40 * <h2>Mandatory arguments:</h2>
41 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
43 * <h2>Optional arguments:</h2>
44 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
45 * See AliHLTFileWriter for full list of arguments.
47 * write objects with the TObject::kOverwrite flag and avoid multiple
51 * <h2>Configuration:</h2>
52 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
53 * Configuration by component arguments.
55 * <h2>Default CDB entries:</h2>
56 * The component loads no CDB entries.
58 * <h2>Performance:</h2>
59 * The component does not process any event data.
61 * <h2>Memory consumption:</h2>
62 * The component does not process any event data.
64 * <h2>Output size:</h2>
65 * No data published (AliHLTDataSink).
67 * @ingroup alihlt_util_components
69 class AliHLTRootFileWriterComponent : public AliHLTFileWriter
72 /** standard constructor */
73 AliHLTRootFileWriterComponent();
75 virtual ~AliHLTRootFileWriterComponent();
78 * The id of the component.
79 * @return component id (string)
81 virtual const char* GetComponentID() {return "ROOTFileWriter";};
85 * @return new class instance
87 virtual AliHLTComponent* Spawn() {return new AliHLTRootFileWriterComponent;}
90 // interface functions
95 * Data processing method for the component.
96 * The function can be overloaded by specific ROOT file writer
97 * components. The RootFileWriter processes only TObject like data
98 * structures of the input blocks and uses the
99 * @ref alihltcomponent-high-level-interface. Despite of that it implements
100 * the lox-level DumpEvent method in order to allow child classes to use the
102 * @param evtData event data structure
103 * @param blocks input data block descriptors
104 * @param trigData trigger data structure
106 virtual int DumpEvent( const AliHLTComponentEventData& evtData,
107 const AliHLTComponentBlockData* blocks,
108 AliHLTComponentTriggerData& trigData );
110 using AliHLTFileWriter::DumpEvent;
113 * Scan one argument and adjacent parameters.
114 * \b IMPORTANT: if overloaded by child class, call this function
115 * as the default from the cutomized switch, e.g.
118 * @param argc size of the argument array
119 * @param argv agument array for component initialization
120 * @return number of processed members of the argv <br>
121 * -EINVAL unknown argument <br>
122 * -EPROTO parameter for argument missing <br>
124 virtual int ScanArgument(int argc, const char** argv);
127 * Write ROOT object to current file.
128 * @param eventID ID of the current event
129 * @param pOb pointer to ROOT object
130 * @return neg. error code if failed
132 int WriteObject(const AliHLTEventID_t eventID, const TObject *pOb);
136 * The function calls @ref AliHLTFileWriter::BuildFileName in order to
137 * create a file name and opens it as a root file.
138 * @param eventID ID of the current event
139 * @param blockID ID of the current block
140 * @param option option as specified in TFile
141 * @return pointer to TFile object, the called has to clean-up the object after use.
143 TFile* OpenFile(const AliHLTEventID_t eventID, const int blockID=-1, const char* option="recreate");
145 /** the event ID associated with the current file */
146 AliHLTEventID_t fEventID; // see above
148 /** the name of the current file */
149 TFile* fCurrentFile; //! transient value
151 /** options for the TObject::Write function */
152 Int_t fOptions; //!transient
155 /** copy constructor prohibited */
156 AliHLTRootFileWriterComponent(const AliHLTRootFileWriterComponent&);
157 /** assignment operator prohibited */
158 AliHLTRootFileWriterComponent& operator=(const AliHLTRootFileWriterComponent&);
160 ClassDef(AliHLTRootFileWriterComponent, 1) // ROOT file writer component