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