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