CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeTofQElecCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "TreeTofQElecCnv.h"
3#include "CalibData/Tof/TofElecData.h"
4#include "CalibDataSvc/IInstrumentName.h"
5#include "CalibMySQLCnv/TreeAddress.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
21#include "CalibDataSvc/ICalibMetaCnvSvc.h"
22
23// Temporary. Hope to find a better way to do this
24#include "CalibData/CalibModel.h"
25using namespace CalibData;
26//static CnvFactory<TreeTofElecDataCnv> TofCal_factory;
27//const ICnvFactory& TreeTofElecDataCnvFactory = TofCal_factory;
28
29
30
33
34 }
35
36
37const CLID& TreeTofElecDataCnv::objType() const {
38 return CLID_TofQ_Elec;
39}
40
42 return CLID_TofQ_Elec;
43}
44
45StatusCode TreeTofElecDataCnv::i_createObj(IOpaqueAddress* addr,
46 DataObject*& refpObject) {
47
48 MsgStream log(msgSvc(), "TreeTofElecDataCnv");
49 log<<MSG::DEBUG<<"SetProperty"<<endreq;
50
51 TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
52 DatabaseRecord *records=add->pp();
53
54 TBufferFile *buf1 = new TBufferFile(TBuffer::kRead);
55 TBufferFile *buf2 = new TBufferFile(TBuffer::kRead);
56 TBufferFile *buf3 = new TBufferFile(TBuffer::kRead);
57 TBufferFile *buf4 = new TBufferFile(TBuffer::kRead);
58 TBufferFile *buf5 = new TBufferFile(TBuffer::kRead);
59 TBufferFile *buf6 = new TBufferFile(TBuffer::kRead);
60 TBufferFile *buf7 = new TBufferFile(TBuffer::kRead);
61 TBufferFile *buf8 = new TBufferFile(TBuffer::kRead);
62
63 buf1->SetBuffer((*records)["BarBoardNum"],512000,kFALSE);
64 buf2->SetBuffer((*records)["EndBoardNum"],512000,kFALSE);
65 buf3->SetBuffer((*records)["QELecBarParEast"],512000,kFALSE);
66 buf4->SetBuffer((*records)["QELecBarParWest"],512000,kFALSE);
67 buf5->SetBuffer((*records)["QELecEndPar"],512000,kFALSE);
68 buf6->SetBuffer((*records)["SimQELecBarParEast"],512000,kFALSE);
69 buf7->SetBuffer((*records)["SimQELecBarParWest"],512000,kFALSE);
70 buf8->SetBuffer((*records)["SimQELecEndPar"],512000,kFALSE);
71
72 std::cout<<" SftVer is "<<(*records)["SftVer"];
73 std::cout<<" CalVerSft is "<<(*records)["CalParVer"];
74 std::cout<<" File name is "<<(*records)["FileName"]<<std::endl;
75
76
77 TTree *BarBoardNum= new TTree();
78 TTree *EndBoardNum= new TTree();
79 TTree *QElecBarParEast = new TTree();
80 TTree *QElecBarParWest = new TTree();
81 TTree *QElecEndPar = new TTree();
82 TTree *SimQElecBarParEast = new TTree();
83 TTree *SimQElecBarParWest = new TTree();
84 TTree *SimQElecEndPar = new TTree();
85 BarBoardNum->Streamer(*buf1);
86 EndBoardNum->Streamer(*buf2);
87 QElecBarParEast->Streamer(*buf3);
88 QElecBarParWest->Streamer(*buf4);
89 QElecEndPar->Streamer(*buf5);
90 SimQElecBarParEast->Streamer(*buf6);
91 SimQElecBarParWest->Streamer(*buf7);
92 SimQElecEndPar->Streamer(*buf8);
93
94
97
98 std::vector<CalibData::BarrelElec> tmpbTof;//; = new vector<CalibData::bTofCalibBase>;
99 std::vector<CalibData::EndcapElec> tmpeTof;
100
101 // Read in the object
102 int cnt;
103 // read btoftree ------------------------------------------------------------
104 unsigned int num[4];
105 double num1[4];
106 BarBoardNum -> SetBranchAddress("Board", &num1[0]);
107 BarBoardNum -> SetBranchAddress("Channel", &num1[1]);
108 BarBoardNum -> SetBranchAddress("Crate", &num1[2]);
109 BarBoardNum -> SetBranchAddress("Fee", &num1[3]);
110 double p[11];
111 QElecBarParEast->SetBranchAddress("P0",&p[0]);
112 QElecBarParEast->SetBranchAddress("P1",&p[1]);
113 QElecBarParEast->SetBranchAddress("P2",&p[2]);
114 QElecBarParEast->SetBranchAddress("P3",&p[3]);
115 QElecBarParEast->SetBranchAddress("P4",&p[4]);
116 QElecBarParEast->SetBranchAddress("P5",&p[5]);
117 QElecBarParEast->SetBranchAddress("P6",&p[6]);
118 QElecBarParEast->SetBranchAddress("P7",&p[7]);
119 QElecBarParEast->SetBranchAddress("P8",&p[8]);
120 QElecBarParEast->SetBranchAddress("P9",&p[9]);
121 QElecBarParEast->SetBranchAddress("P10",&p[10]);
122 double p_w[11];
123 QElecBarParWest->SetBranchAddress("P0",&p_w[0]);
124 QElecBarParWest->SetBranchAddress("P1",&p_w[1]);
125 QElecBarParWest->SetBranchAddress("P2",&p_w[2]);
126 QElecBarParWest->SetBranchAddress("P3",&p_w[3]);
127 QElecBarParWest->SetBranchAddress("P4",&p_w[4]);
128 QElecBarParWest->SetBranchAddress("P5",&p_w[5]);
129 QElecBarParWest->SetBranchAddress("P6",&p_w[6]);
130 QElecBarParWest->SetBranchAddress("P7",&p_w[7]);
131 QElecBarParWest->SetBranchAddress("P8",&p_w[8]);
132 QElecBarParWest->SetBranchAddress("P9",&p_w[9]);
133 QElecBarParWest->SetBranchAddress("P10",&p_w[10]);
134 double p_se[11];
135 SimQElecBarParEast->SetBranchAddress("P0",&p_se[0]);
136 SimQElecBarParEast->SetBranchAddress("P1",&p_se[1]);
137 SimQElecBarParEast->SetBranchAddress("P2",&p_se[2]);
138 SimQElecBarParEast->SetBranchAddress("P3",&p_se[3]);
139 SimQElecBarParEast->SetBranchAddress("P4",&p_se[4]);
140 SimQElecBarParEast->SetBranchAddress("P5",&p_se[5]);
141 SimQElecBarParEast->SetBranchAddress("P6",&p_se[6]);
142 SimQElecBarParEast->SetBranchAddress("P7",&p_se[7]);
143 SimQElecBarParEast->SetBranchAddress("P8",&p_se[8]);
144 SimQElecBarParEast->SetBranchAddress("P9",&p_se[9]);
145 SimQElecBarParEast->SetBranchAddress("P10",&p_se[10]);
146 double p_sw[11];
147 SimQElecBarParWest->SetBranchAddress("P0",&p_sw[0]);
148 SimQElecBarParWest->SetBranchAddress("P1",&p_sw[1]);
149 SimQElecBarParWest->SetBranchAddress("P2",&p_sw[2]);
150 SimQElecBarParWest->SetBranchAddress("P3",&p_sw[3]);
151 SimQElecBarParWest->SetBranchAddress("P4",&p_sw[4]);
152 SimQElecBarParWest->SetBranchAddress("P5",&p_sw[5]);
153 SimQElecBarParWest->SetBranchAddress("P6",&p_sw[6]);
154 SimQElecBarParWest->SetBranchAddress("P7",&p_sw[7]);
155 SimQElecBarParWest->SetBranchAddress("P8",&p_sw[8]);
156 SimQElecBarParWest->SetBranchAddress("P9",&p_sw[9]);
157 SimQElecBarParWest->SetBranchAddress("P10",&p_sw[10]);
158
159 for(cnt=0; cnt<352; cnt++){
160 BarBoardNum -> GetEntry(cnt);
161 num[0]=num1[0];
162 num[1]=num1[1];
163 num[2]=num1[2];
164 num[3]=num1[3];
165 if(cnt%2!=0){
166 bTof.setNumWest(num);
167 }
168 if(cnt%2==0){
169 bTof.setNumEast(num);
170 int kkk=cnt/2;
171 QElecBarParEast->GetEntry(kkk);
172 QElecBarParWest->GetEntry(kkk);
173 SimQElecBarParEast->GetEntry(kkk);
174 SimQElecBarParWest->GetEntry(kkk);
175 bTof.setP1(p);
176 bTof.setP2(p_w);
177 bTof.setSimP1(p_se);
178 bTof.setSimP2(p_sw);
179 }
180 if(cnt%2!=0)
181 tmpbTof.push_back(bTof);
182 }
183
184 //read etoftree
185 EndBoardNum -> SetBranchAddress("Board", &num1[0]);
186 EndBoardNum -> SetBranchAddress("Channel", &num1[1]);
187 EndBoardNum -> SetBranchAddress("Crate", &num1[2]);
188 EndBoardNum -> SetBranchAddress("Fee", &num1[3]);
189 QElecEndPar-> SetBranchAddress("P0",&p[0]);
190 QElecEndPar->SetBranchAddress("P1",&p[1]);
191 QElecEndPar->SetBranchAddress("P2",&p[2]);
192 QElecEndPar->SetBranchAddress("P3",&p[3]);
193 QElecEndPar->SetBranchAddress("P4",&p[4]);
194 QElecEndPar->SetBranchAddress("P5",&p[5]);
195 QElecEndPar->SetBranchAddress("P6",&p[6]);
196 QElecEndPar->SetBranchAddress("P7",&p[7]);
197 QElecEndPar->SetBranchAddress("P8",&p[8]);
198 QElecEndPar->SetBranchAddress("P9",&p[9]);
199 QElecEndPar->SetBranchAddress("P10",&p[10]);
200 SimQElecEndPar-> SetBranchAddress("P0",&p_w[0]);
201 SimQElecEndPar->SetBranchAddress("P1",&p_w[1]);
202 SimQElecEndPar->SetBranchAddress("P2",&p_w[2]);
203 SimQElecEndPar->SetBranchAddress("P3",&p_w[3]);
204 SimQElecEndPar->SetBranchAddress("P4",&p_w[4]);
205 SimQElecEndPar->SetBranchAddress("P5",&p_w[5]);
206 SimQElecEndPar->SetBranchAddress("P6",&p_w[6]);
207 SimQElecEndPar->SetBranchAddress("P7",&p_w[7]);
208 SimQElecEndPar->SetBranchAddress("P8",&p_w[8]);
209 SimQElecEndPar->SetBranchAddress("P9",&p_w[9]);
210 SimQElecEndPar->SetBranchAddress("P10",&p_w[10]);
211 for(cnt=0; cnt<96; cnt++){
212 EndBoardNum->GetEntry(cnt);
213 QElecEndPar->GetEntry(cnt);
214 SimQElecEndPar->GetEntry(cnt);
215 num[0]=num1[0];
216 num[1]=num1[1];
217 num[2]=num1[2];
218 num[3]=num1[3];
219
220 eTof.setNum(num);
221 eTof.setP(p);
222 eTof.setSimP(p_w);
223 tmpeTof.push_back(eTof);
224 }
225
226 CalibData::TofElecData *tmpObject = new CalibData::TofElecData(&tmpbTof,&tmpeTof);
227
228
229 refpObject=tmpObject;
230 delete BarBoardNum;
231 delete EndBoardNum;
232 delete QElecBarParEast;
233 delete QElecBarParWest;
234 delete QElecEndPar;
235 delete SimQElecBarParEast;
236 delete SimQElecBarParWest;
237 delete SimQElecEndPar;
238
239 return StatusCode::SUCCESS;
240
241
242}
243
data SetBranchAddress("time",&time)
data GetEntry(0)
static const CLID & classID()
TreeTofElecDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
int num[96]
Definition: ranlxd.c:373