]>
Commit | Line | Data |
---|---|---|
4ddfc222 | 1 | // -*- Mode: C++ -*- |
2 | // @(#) $Id$ | |
3 | ||
4 | #ifndef ALIHLTROOTFILEWRITERCOMPONENT_H | |
5 | #define ALIHLTROOTFILEWRITERCOMPONENT_H | |
79c114b5 | 6 | /* This file is property of and copyright by the ALICE HLT Project * |
7 | * ALICE Experiment at CERN, All rights reserved. * | |
4ddfc222 | 8 | * See cxx source for full Copyright notice */ |
9 | ||
10 | /** @file AliHLTRootFileWriterComponent.h | |
11 | @author Matthias Richter | |
12 | @date | |
13 | @brief Base class for writer components to store data in a ROOT file | |
14 | ||
15 | */ | |
16 | #include "AliHLTFileWriter.h" | |
5df0cbb9 | 17 | //#include "TObject.h" |
4ddfc222 | 18 | |
19 | class TFile; | |
20 | ||
21 | /** | |
22 | * @class AliHLTRootFileWriterComponent | |
23 | * The RootFileWriter provides a stand alone component to write incoming | |
24 | * TObject like structures into a Root file. Furthermore it functions as | |
25 | * base class for customized writers. | |
26 | * @see AliHLTFileWriter for parameters | |
27 | */ | |
28 | class AliHLTRootFileWriterComponent : public AliHLTFileWriter | |
29 | { | |
30 | public: | |
31 | /** standard constructor */ | |
32 | AliHLTRootFileWriterComponent(); | |
33 | /** not a valid copy constructor, defined according to effective C++ style */ | |
34 | AliHLTRootFileWriterComponent(const AliHLTRootFileWriterComponent&); | |
35 | /** not a valid assignment op, but defined according to effective C++ style */ | |
36 | AliHLTRootFileWriterComponent& operator=(const AliHLTRootFileWriterComponent&); | |
37 | /** destructor */ | |
5df0cbb9 | 38 | virtual ~AliHLTRootFileWriterComponent(); |
4ddfc222 | 39 | |
40 | /** | |
41 | * The id of the component. | |
42 | * @return component id (string) | |
43 | */ | |
44 | virtual const char* GetComponentID() {return "ROOTFileWriter";}; | |
45 | ||
46 | /** | |
47 | * Spawn function. | |
48 | * @return new class instance | |
49 | */ | |
50 | virtual AliHLTComponent* Spawn() {return new AliHLTRootFileWriterComponent;} | |
51 | ||
52 | protected: | |
79c114b5 | 53 | /** |
54 | * Close the writer. | |
55 | * Cleanup and others. | |
56 | */ | |
57 | int CloseWriter(); | |
58 | ||
4ddfc222 | 59 | /** |
60 | * Data processing method for the component. | |
61 | * The function can be overloaded by specific ROOT file writer | |
62 | * components. The RootFileWriter processes only TObject like data | |
63 | * structures of the input blocks and uses the | |
64 | * @ref alihltcomponent-high-level-interface. Despite of that it implements | |
65 | * the lox-level DumpEvent method in order to allow child classes to use the | |
66 | * low-level method. | |
67 | * @param evtData event data structure | |
68 | * @param blocks input data block descriptors | |
69 | * @param trigData trigger data structure | |
70 | */ | |
71 | virtual int DumpEvent( const AliHLTComponentEventData& evtData, | |
72 | const AliHLTComponentBlockData* blocks, | |
73 | AliHLTComponentTriggerData& trigData ); | |
74 | ||
75 | /** | |
76 | * Scan one argument and adjacent parameters. | |
77 | * \b IMPORTANT: if overloaded by child class, call this function | |
78 | * as the default from the cutomized switch, e.g. | |
79 | * <pre> | |
80 | * </pre> | |
81 | * @param argc size of the argument array | |
82 | * @param argv agument array for component initialization | |
83 | * @return number of processed members of the argv <br> | |
84 | * -EINVAL unknown argument <br> | |
85 | * -EPROTO parameter for argument missing <br> | |
86 | */ | |
87 | virtual int ScanArgument(int argc, const char** argv); | |
88 | ||
89 | /** | |
90 | * Write ROOT object to current file. | |
91 | * @param eventID ID of the current event | |
92 | * @param pOb pointer to ROOT object | |
93 | * @return neg. error code if failed | |
94 | */ | |
95 | int WriteObject(const AliHLTEventID_t eventID, const TObject *pOb); | |
96 | ||
97 | /** | |
98 | * Open a ROOT file. | |
99 | * The function calls @ref AliHLTFileWriter::BuildFileName in order to | |
100 | * create a file name and opens it as a root file. | |
101 | * @param eventID ID of the current event | |
102 | * @param blockID ID of the current block | |
103 | * @param option option as specified in TFile | |
104 | * @return pointer to TFile object, the called has to clean-up the object after use. | |
105 | */ | |
106 | TFile* OpenFile(const AliHLTEventID_t eventID, const int blockID=-1, const char* option="recreate"); | |
107 | ||
108 | /** the event ID associated with the current file */ | |
109 | AliHLTEventID_t fEventID; // see above | |
110 | ||
111 | /** the name of the current file */ | |
112 | TFile* fCurrentFile; //! transient value | |
113 | ||
114 | ClassDef(AliHLTRootFileWriterComponent, 0) | |
115 | }; | |
116 | #endif |