BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
RootEmcCalibDataCnv.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/cnv/RootEmcCalibDataCnv.cxx,v 1.7 2009/05/13 07:13:06 hem Exp $
2#include "GaudiKernel/MsgStream.h"
6
7#include "TFile.h"
8#include "TTree.h"
9#include "TDirectory.h"
10#include "TObject.h"
11
12#include "GaudiKernel/CnvFactory.h"
13#include "GaudiKernel/IOpaqueAddress.h"
14#include "GaudiKernel/DataObject.h"
15#include "GaudiKernel/IAddressCreator.h"
16#include "GaudiKernel/IDataProviderSvc.h"
17#include "GaudiKernel/IConversionSvc.h"
18#include "GaudiKernel/GenericAddress.h"
19
20#include "CalibDataSvc/ICalibRootSvc.h" //maybe
22
23// Temporary. Hope to find a better way to do this
25using namespace CalibData;
26//static CnvFactory<RootEmcCalibDataCnv> EmcCal_factory;
27//const ICnvFactory& RootEmcCalibDataCnvFactory = EmcCal_factory;
28
29
30
35
36
37const CLID& RootEmcCalibDataCnv::objType() const {
38 return CLID_Calib_EmcCal;
39}
40
42 return CLID_Calib_EmcCal;
43}
44
45StatusCode RootEmcCalibDataCnv::i_createObj(const std::string& fname,
46 DataObject*& refpObject) {
47
48 MsgStream log(msgSvc(), "RootEmcCalibDataCnv");
49 log<<MSG::DEBUG<<"SetProperty"<<endreq;
50
51 StatusCode sc = openRead(fname);
52 if(!sc)
53 { log<<MSG::ERROR<<"unable to open files"<<endreq;
54 }
55
57 // Read in our object
58 int i;
59 int nentries;
60
61 // read DigiCalibConst ------------------------------------------------------------
62 double EmcCalibConst[6240];
63 int EmcIxtalNumber[6240];
64 vector<double> DigiCalibConst;
65 vector<int> IxtalNumber;
66 TTree *Digitree = (TTree*)m_inFile -> Get("DigiCalibConst");
67 Digitree -> SetBranchAddress("DigiCalibConst", EmcCalibConst);
68 Digitree -> SetBranchAddress("IxtalNumber", EmcIxtalNumber);
69 Digitree -> GetEntry(0);
70 for(i=0; i<6240; i++){
71 DigiCalibConst.push_back(EmcCalibConst[i]);
72 IxtalNumber.push_back(EmcIxtalNumber[i]);
73 }
74 tmpObject -> setDigiCalibConst(&DigiCalibConst);
75 tmpObject -> setIxtalNumber(&IxtalNumber);
76
77 refpObject=tmpObject;
78
79 return StatusCode::SUCCESS;
80}
81
82StatusCode RootEmcCalibDataCnv::createRoot(const std::string& fname,
83 CalibData::CalibBase1* pTDSObj) {
84
85 MsgStream log(msgSvc(), "RootEmcCalibDataCnv");
86
87 // Open the file, create the branch
88 StatusCode sc = openWrite(fname);
89 if(!sc)
90 { log<<MSG::ERROR<<"unable to open files"<<endreq;
91 }
92 // write the Data in the TCDS to RootFile
93 CalibData::EmcCalibData* tmpObject = dynamic_cast<CalibData::EmcCalibData*>(pTDSObj);
94 int tmpNo;
95 double EmcCalibConst;
96 int EmcIxtalNumber;
97 int i;
98
99 //DigiCalibConst------------------------------------------------------------------
100 TTree *Digitree = new TTree("DigiCalibConst", "DigiCalibConst");
101 Digitree -> Branch("DigiCalibConst", &EmcCalibConst, "EmcCalibConst/D");
102 Digitree -> Branch("IxtalNumber", &EmcIxtalNumber, "IxtalNumber/I");
103 tmpNo = tmpObject -> getDigiCalibConstNo();
104 for(i=0; i<tmpNo; i++){
105 EmcCalibConst = tmpObject -> getDigiCalibConst(i);
106 EmcIxtalNumber = tmpObject -> getIxtalNumber(i);
107 Digitree -> Fill();
108 }
109
110
111 Digitree -> Write();
112
113
114 delete Digitree;
115
116 closeWrite();
117 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
118 return sc;
119
120}
const CLID CLID_Calib_EmcCal
Definition CalibModel.h:47
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
curve Fill()
curve Write()
data GetEntry(0)
data SetBranchAddress("time",&time)
Int_t nentries
IMessageSvc * msgSvc()
StatusCode openRead(const std::string &fname)
StatusCode closeWrite()
virtual StatusCode openWrite(const std::string &fname)
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)
const CLID & objType() const
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
RootEmcCalibDataCnv(ISvcLocator *svc)
static const CLID & classID()