BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeCalBaseCnv.h
Go to the documentation of this file.
1#ifndef TreeCalBaseCnv_h
2#define TreeCalBaseCnv_h
3
4/** @class TreeCalBaseCnv
5
6 Base class for calibration converters from Trees to TCDS.
7 All such converters need to do certain things, which are
8 handled here.
9
10 @author HUANG Bin
11*/
12#include "GaudiKernel/Converter.h"
13#include <string>
14
15#include "CalibDataSvc/ICalibTreeSvc.h"
16#include "TBufferFile.h"
17#include "TObject.h"
18
19class ISvcLocator;
20class GenericAddress;
21class ICalibTreeSvc;
23class IInstrumentName;
24class ITime;
25
26class TFile;
27class TTree;
28class TDirectory;
29class TObject;
30
31namespace CalibData {
32 class CalibTime;
33 class CalibBase;
34 class CalibBase1;
35 class DacCol;
36} // namespace CalibData
37
38class TreeCalBaseCnv : public Converter {
39
40public:
41 virtual ~TreeCalBaseCnv();
42
43 // Standard public converter stuff
44 virtual StatusCode initialize();
45 virtual StatusCode finalize();
46
47 /**
48 Create the transient representation of an object, given an opaque
49 address. This and the following update method comprise the core
50 functionality of calibration converters.
51 */
52 virtual StatusCode createObj( IOpaqueAddress* addr, DataObject*& refpObject );
53
55
56 static const unsigned char storageType() { return CALIBTREE_StorageType; }
57
58 /**
59 Constructor for this converter
60 @param svc a ISvcLocator interface to find services
61 @param clid the type of object the converter is able to convert
62 */
63 TreeCalBaseCnv( ISvcLocator* svc, const CLID& clid );
64
65 // End standard public converter stuff
66
67 /**
68 Create ROOT file corresponding to TDS object input.
69 Default implementation is to return an error. Must be separately
70 implemented for each calibration type.
71
72
73 @param fname Filename for output file
74 @param pTDSObj Pointer to tds object to be converted
75 */
76 virtual StatusCode createRoot( const std::string& fname, CalibData::CalibBase1* pTDSObj );
77
78 /**
79 Read in object (by default the first) from specified branch.
80 */
81 /* virtual StatusCode readRootObj(const std::string& treename,
82 const std::string& branch, TObject*& pCalib,
83 unsigned index=0);
84
85 virtual StatusCode readRootObj(TTree* tree,
86 const std::string& branch, TObject*& pCalib,
87 unsigned index=0);
88 */
89protected:
90 /** This creates the transient representation of an object from the
91 * corresponding ROOT object it, then fills it and process it.
92 * This implementation actually only calls the i_* methods of the
93 * "right" converter to do the job; so the very first thing it
94 * does is get a pointer to the appropriate derived converter.
95 * Converters typically don't need to override this method
96 * but only to override/implement some of the i_* methods.
97
98 * @param pRootObj pointer to the ROOT object
99 * @param refpObject the object to be built
100 * @param address the opaque address for this object
101 * @return status depending on the completion of the call
102 */
103 /* virtual StatusCode internalCreateObj (const std::string& fname,
104 // was TObject* pRootObj,
105 DataObject*& refpObject,
106 IOpaqueAddress* address);
107
108 */
109 virtual StatusCode internalCreateObj( DataObject*& refpObject, IOpaqueAddress* address );
110
111 /** This creates the transient representation of an object from the
112 * corresponding ROOT object. This actually does the "new" operation
113 * and deals with the attributes of the node. This base class implementation
114 * does nothing; it should not normally be called because it doesn't
115 * correspond to any TCDS class. Instead,
116 * i_createObj of some derived class will be called.
117 * @param fname The ROOT file to be read in
118 * to be used to builds the object
119 * @param refpObject the object to be built
120 * @return status depending on the completion of the call
121 */
122 virtual StatusCode i_createObj( IOpaqueAddress* address, DataObject*& refpObject );
123 // virtual StatusCode i_createObj (const std::string& fname,
124 // DataObject*& refpObject);
125
126 /// In case there is additional work to do on the created object
127 virtual StatusCode i_processObj( DataObject* pObject, IOpaqueAddress* address );
128
129 /**
130 Given a pointer to a TDS object which can be cast to "our" type, fill
131 in corresponding information in the corresponding root class
132
133 @param pTDSObj Pointer to tds object to be converted
134 @param pRootObj Pointer to destination root object
135
136 ...maybe don't need pRootObj argument; keep this as the (protected)
137 data member m_rootObj. Or else this routine could set the protected
138 member to this passed-in value
139 */
140 virtual StatusCode fillRoot( CalibData::CalibBase* pTDSObj, TObject* pRootObj );
141
142 /**
143 Utility used by derived converters to start writing a ROOT file
144 (open TFile, make a TTree, give it a branch)
145 @param fname Name for new file
146 @param className Name of class for object specified in next parameter;
147 used to name branch as well)
148 @param pCalib pointer to object used to create the branch
149
150 */
151 // virtual StatusCode openWrite(const std::string& fname);
152
153 /**
154 Finish up writing file opened with openWrite:
155 fill the tree
156 write the file
157 close the file
158 Delete TFile (causes associated Tree to be deleted)
159 */
160 // StatusCode closeWrite();
161
162 /**
163 Utility for "leaf" converters to call
164 @param Root file to open for read
165// @param Name of branch to be read in
166// @param ref. to pCalib pointer which will be set to address of
167 read-in object
168 */
169 // StatusCode openRead(const std::string& fname, const std::string& branch,
170 // TObject*& pCalib);
171 // StatusCode openRead(const std::string& fname);
172
173 /** Clean up when we've finished reading in */
174 // StatusCode closeRead();
175
176 /// Another convenience for derived classes: sets information belonging
177 /// to the calibration base class, namely validity interval and serial
178 /// number.
180
181 // Might want to verify that instrument, calType are correct,
182 // for example. If so, might as well provide the service in
183 // the base converter.
184 ////// virtual StatusCode readHeader(const DOM_Element&);
185
189
193 // Note by keeping this stuff here we're disallowing possibility of
194 // interleaved writes of different calibrations
195 TFile* m_outFile;
196 TTree* m_ttree;
197
198 TFile* m_inFile;
199
200 TDirectory* m_saveDir;
201
202 // Don't think we want this after all
203 // store pointer to intermediate (between TDS and permanent file) form
204 // of calibration data as root obj. It will normally be the responsibility
205 // of the "leaf" calibration converter to create and delete it.
206 // calibRootData::Base* m_rootObj;
207
208 // Is it reasonable to always call our TTree "Calib" ?
209 // Branches will be named after calibration type
210private:
211 // Return true if something was there to be cleaned
212 bool doClean();
213};
214
215#endif
Simple interface to keep track of which instrument (LAT, EM, etc.) the process is concerned with....
TDirectory * m_saveDir
ICalibTreeSvc * getCalibTreeSvc()
virtual StatusCode initialize()
static const unsigned char storageType()
virtual ~TreeCalBaseCnv()
virtual StatusCode fillRoot(CalibData::CalibBase *pTDSObj, TObject *pRootObj)
virtual StatusCode i_processObj(DataObject *pObject, IOpaqueAddress *address)
In case there is additional work to do on the created object.
virtual StatusCode finalize()
TreeCalBaseCnv(ISvcLocator *svc, const CLID &clid)
ICalibMetaCnvSvc * m_metaSvc
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
virtual StatusCode createObj(IOpaqueAddress *addr, DataObject *&refpObject)
IInstrumentName * m_instrSvc
ICalibTreeSvc * m_treeSvc
virtual StatusCode internalCreateObj(DataObject *&refpObject, IOpaqueAddress *address)
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
void setBaseInfo(CalibData::CalibBase1 *pObj)
Another utility for derived classes to use.