BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeEmcCalibDataCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
6#include "TFile.h"
7#include "TTree.h"
8#include "TDirectory.h"
9#include "TObject.h"
10#include "TBuffer.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/ICalibTreeSvc.h" //maybe
22
23// Temporary. Hope to find a better way to do this
25using namespace CalibData;
26//static CnvFactory<TreeEmcCalibDataCnv> EmcCal_factory;
27//const ICnvFactory& TreeEmcCalibDataCnvFactory = EmcCal_factory;
28
29
30
33
34 }
35
36
37const CLID& TreeEmcCalibDataCnv::objType() const {
38 return CLID_Calib_EmcCal;
39}
40
42 return CLID_Calib_EmcCal;
43}
44
45StatusCode TreeEmcCalibDataCnv::i_createObj(IOpaqueAddress* addr,
46 DataObject*& refpObject) {
47
48 MsgStream log(msgSvc(), "TreeEmcCalibDataCnv");
49 log<<MSG::DEBUG<<"SetProperty"<<endreq;
50 // gROOT->Reset();
51 // gDirectory = gROOT;
52 //TFile("temp.root");
53 TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
54 DatabaseRecord *records=add->pp();
55 TBufferFile *buf1 = new TBufferFile(TBuffer::kRead);
56 buf1->SetBuffer((*records)["DigiCalibConst"],512000,kFALSE);
57
58 std::cout<<" SftVer is "<<(*records)["SftVer"];
59 std::cout<<" CalVerSft is "<<(*records)["CalParVer"];
60 std::cout<<" File name is "<<(*records)["FileName"]<<std::endl;
61
62 TTree* Digitree= new TTree();
63
64 Digitree->Streamer(*buf1);
65
66 Digitree->Print();
67
69 // Read in our object
70 int i;
71 int nentries;
72
73 // read DigiCalibConst ------------------------------------------------------------
74 double emcdata;
75 // Digitree -> SetBranchAddress("DigiCalibConst", &emcdata);
76 // Digitree -> SetBranchAddress("DigiCalibConst", &emcdata);
77 // nentries = Digitree-> GetEntries();
78 // std::cout<<"nentries=="<<nentries<<std::endl;
79
80
81 double EmcCalibConst[6240];
82 int EmcIxtalNumber[6240];
83 vector<double> DigiCalibConst;
84 vector<int> IxtalNumber;
85 Digitree->SetBranchAddress("DigiCalibConst", EmcCalibConst);
86 Digitree -> SetBranchAddress("IxtalNumber", EmcIxtalNumber);
87 Digitree -> GetEntry(0);
88 for(i=0; i<6240; i++){
89 DigiCalibConst.push_back(EmcCalibConst[i]);
90 IxtalNumber.push_back(EmcIxtalNumber[i]);
91 }
92 tmpObject -> setDigiCalibConst(&DigiCalibConst);
93 tmpObject -> setIxtalNumber(&IxtalNumber);
94 refpObject=tmpObject;
95 // temp->Close();
96 delete Digitree;
97 return StatusCode::SUCCESS;
98
99
100}
101
const CLID CLID_Calib_EmcCal
Definition: CalibModel.h:47
data SetBranchAddress("time",&time)
data GetEntry(0)
Int_t nentries
IMessageSvc * msgSvc()
virtual DatabaseRecord * pp()
Definition: TreeAddress.h:130
TreeEmcCalibDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
static const CLID & classID()