CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RootEsTimeCalibDataCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
5
6#include "TFile.h"
7#include "TTree.h"
8#include "TDirectory.h"
9#include "TObject.h"
10
11#include "GaudiKernel/CnvFactory.h"
12#include "GaudiKernel/IOpaqueAddress.h"
13#include "GaudiKernel/DataObject.h"
14#include "GaudiKernel/IAddressCreator.h"
15#include "GaudiKernel/IDataProviderSvc.h"
16#include "GaudiKernel/IConversionSvc.h"
17#include "GaudiKernel/GenericAddress.h"
18
19#include "CalibDataSvc/ICalibRootSvc.h" //maybe
21
22// Temporary. Hope to find a better way to do this
24using namespace CalibData;
25//static CnvFactory<RootEsTimeCalibDataCnv> EsTimeCal_factory;
26//const ICnvFactory& RootEsTimeCalibDataCnvFactory = EsTimeCal_factory;
27
28
29
32
33}
34
35
38}
39
42}
43
44StatusCode RootEsTimeCalibDataCnv::i_createObj(const std::string& fname,
45 DataObject*& refpObject) {
46
47 MsgStream log(msgSvc(), "RootEsTimeCalibDataCnv");
48 log<<MSG::DEBUG<<"SetProperty"<<endreq;
49
50 StatusCode sc = openRead(fname);
51 if(!sc)
52 { log<<MSG::ERROR<<"unable to open files"<<endreq;
53 }
54
56 // Read in our object
57 int i;
58 int nentries;
59
60 // read TestCalibConst ------------------------------------------------------------
61 double EsTimeCalibConst;
62 vector<double> TestCalibConst;
63 TTree *Testtree = (TTree*)m_inFile -> Get("h2");
64 Testtree -> SetBranchAddress("meant0", &EsTimeCalibConst);
65 int no= Testtree -> GetEntries();
66 for(i=0; i<no; i++){
67 Testtree->GetEntry(i);
68 TestCalibConst.push_back(EsTimeCalibConst);
69 }
70
71 double t0offsete,t0offsetb;
72 int bunchtime;
73 TTree *tree2 = (TTree*)m_inFile -> Get("calibconst");
74 tree2->SetBranchAddress("t0offsete", &t0offsete);
75 tree2->SetBranchAddress("t0offsetb", &t0offsetb);
76 tree2->SetBranchAddress("bunchtime", &bunchtime);
77 tree2->GetEntry(0);
78 tmpObject ->setToffsetb(t0offsetb);
79 tmpObject ->setToffsete(t0offsete);
80 tmpObject ->setBunchTime(bunchtime);
81
82 tmpObject -> setTestCalibConst(&TestCalibConst);
83
84 refpObject=tmpObject;
85
86 return StatusCode::SUCCESS;
87}
88
89StatusCode RootEsTimeCalibDataCnv::createRoot(const std::string& fname,
90 CalibData::CalibBase1* pTDSObj) {
91
92 MsgStream log(msgSvc(), "RootEsTimeCalibDataCnv");
93
94 // Open the file, create the branch
95 StatusCode sc = openWrite(fname);
96 if(!sc)
97 { log<<MSG::ERROR<<"unable to open files"<<endreq;
98 }
99 // write the Data in the TCDS to RootFile
100 /* CalibData::EsTimeCalibData* tmpObject = dynamic_cast<CalibData::EsTimeCalibData*>(pTDSObj);
101 int tmpNo;
102 double EsTimeCalibConst;
103 int i;
104
105 //TestCalibConst------------------------------------------------------------------
106 TTree *Testtree = new TTree("TestCalibConst", "TestCalibConst");
107 Testtree -> Branch("TestCalibConst", &EsTimeCalibConst, "EsTimeCalibConst/D");
108 tmpNo = tmpObject -> getTestCalibConstNo();
109 for(i=0; i<tmpNo; i++){
110 EsTimeCalibConst = tmpObject -> getTestCalibConst(i);
111 Testtree -> Fill();
112 }
113
114
115 Testtree -> Write();
116
117
118 delete Testtree;
119
120 closeWrite();*/
121 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
122 return sc;
123
124}
const CLID CLID_Calib_EsTimeCal
Definition: CalibModel.h:51
data SetBranchAddress("time",&time)
Int_t nentries
IMessageSvc * msgSvc()
void setToffsetb(const double toffsetb)
void setBunchTime(const int bunchtime)
void setToffsete(const double toffsete)
StatusCode openRead(const std::string &fname)
virtual StatusCode openWrite(const std::string &fname)
const CLID & objType() const
RootEsTimeCalibDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
static const CLID & classID()