1#include "GaudiKernel/MsgStream.h"
3#include "CalibData/Tof/TofCalibData.h"
4#include "CalibDataSvc/IInstrumentName.h"
5#include "CalibMySQLCnv/TreeAddress.h"
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"
20#include "CalibDataSvc/ICalibTreeSvc.h"
21#include "CalibDataSvc/ICalibMetaCnvSvc.h"
24#include "CalibData/CalibModel.h"
63 DataObject*& refpObject) {
65 MsgStream log(
msgSvc(),
"TreeTofCalibDataCnv");
66 log<<MSG::DEBUG<<
"SetProperty"<<endreq;
72 TBufferFile *buf1 =
new TBufferFile(TBuffer::kRead);
73 TBufferFile *buf2 =
new TBufferFile(TBuffer::kRead);
74 TBufferFile *buf3 =
new TBufferFile(TBuffer::kRead);
75 TBufferFile *buf4 =
new TBufferFile(TBuffer::kRead);
76 TBufferFile *buf5 = 0;
77 TBufferFile *buf6 = 0;
79 buf1->SetBuffer((*records)[
"BarTofPar"],512000,kFALSE);
80 buf2->SetBuffer((*records)[
"EndTofPar"],512000,kFALSE);
81 buf3->SetBuffer((*records)[
"TofConPar"],512000,kFALSE);
82 buf4->SetBuffer((*records)[
"BarTof"], 512000,kFALSE);
83 if( (*records)[
"EtfTofPar"]!=0 ) {
84 buf5 =
new TBufferFile(TBuffer::kRead);
85 buf5->SetBuffer((*records)[
"EtfTofPar"],512000,kFALSE);
87 if( (*records)[
"EtfTofBunch"]!=0 ) {
88 buf6 =
new TBufferFile(TBuffer::kRead);
89 buf6->SetBuffer((*records)[
"EtfTofBunch"],512000,kFALSE);
92 std::cout<<
" SftVer is "<<(*records)[
"SftVer"];
93 std::cout<<
" CalVerSft is "<<(*records)[
"CalParVer"];
94 std::cout<<
" File name is "<<(*records)[
"FileName"]<<std::endl;
96 TTree *btoftree =
new TTree();
97 TTree *etoftree =
new TTree();
98 TTree *etftree =
new TTree();
99 TTree *etfbunchtree =
new TTree();
100 TTree *btofcommontree =
new TTree();
101 TTree *CalibInfo =
new TTree();
103 btoftree->Streamer(*buf1);
104 etoftree->Streamer(*buf2);
105 btofcommontree->Streamer(*buf3);
106 CalibInfo->Streamer(*buf4);
108 etftree->Streamer(*buf5);
111 etfbunchtree->Streamer(*buf6);
121 std::vector<CalibData::bTofCalibBase> tmpbTof;
122 std::vector<CalibData::eTofCalibBase> tmpeTof;
123 std::vector<CalibData::etfCalibBase> tmpetf;
124 std::vector<CalibData::etfBunchCalibBase> tmpetfBunch;
125 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
126 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
148 for(
unsigned int i=0; i<
nBarAtten; i++ ) {
149 sprintf( brname,
"Atten%i", i );
152 for(
unsigned int i=0; i<
nBarSpeed; i++ ) {
153 sprintf( brname,
"Speed%i", i );
156 for(
unsigned int i=0; i<
nBarPar; i++ ) {
157 sprintf( brname,
"P%i", i );
160 for(
unsigned int i=0; i<
nBarPar; i++ ) {
161 sprintf( brname,
"P%i", i+
nBarPar );
165 sprintf( brname,
"Bunch0_Poff%i", i );
169 sprintf( brname,
"Bunch0_Poff%i", i+
nBarParOff );
173 sprintf( brname,
"Bunch1_Poff%i", i );
177 sprintf( brname,
"Bunch1_Poff%i", i+
nBarParOff );
181 sprintf( brname,
"Bunch2_Poff%i", i );
185 sprintf( brname,
"Bunch2_Poff%i", i+
nBarParOff );
189 sprintf( brname,
"Bunch3_Poff%i", i );
193 sprintf( brname,
"Bunch3_Poff%i", i+
nBarParOff );
196 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
197 sprintf( brname,
"FLeft%i", i );
200 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
201 sprintf( brname,
"FRight%i", i );
205 sprintf( brname,
"FCounter%i", i );
209 for(cnt=0; cnt<176; cnt++){
213 bTof.
setP1( cnvBarPar1 );
214 bTof.
setP2( cnvBarPar2 );
226 tmpbTof.push_back(bTof);
236 for(
unsigned int i=0; i<
nEndAtten; i++ ) {
237 sprintf( ecname,
"Atten%i", i );
240 for(
unsigned int i=0; i<
nEndSpeed; i++ ) {
241 sprintf( ecname,
"Speed%i", i );
244 for(
unsigned int i=0; i<
nEndPar; i++ ) {
245 sprintf( ecname,
"P%i", i );
248 for(
unsigned int i=0; i<
nEndSigma; i++ ) {
249 sprintf( ecname,
"FCounter%i", i );
253 for(cnt=0; cnt<96; cnt++){
257 eTof.
setP( cnvEndPar );
258 eTof.
setFP( cnvEndFPar );
259 tmpeTof.push_back(eTof);
264 if( etftree->GetEntries() != 0 ) {
272 for(
unsigned int i=0; i<
nEtfSpeed; i++ ) {
273 sprintf( etfname,
"Speed%i", i );
276 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
277 sprintf( etfname,
"P%i", i );
279 sprintf( etfname,
"P%i",
nEtfPar+i );
281 sprintf( etfname,
"P%i", 2*
nEtfPar+i );
285 for(cnt=0; cnt<(72*12); cnt++){
288 etf.
setP( cnvEtfPar );
289 etf.
setP1( cnvEtfPar1 );
290 etf.
setP2( cnvEtfPar2 );
291 tmpetf.push_back(etf);
298 if( etfbunchtree->GetEntries() != 0 ) {
300 char etfbunchname[10];
301 for(
unsigned int i=0; i<
nEtfBunch; i++ ) {
302 sprintf( etfbunchname,
"pbunch%i", i );
305 int entries= etfbunchtree->GetEntries();
306 for(cnt=0;cnt<entries;cnt++){
309 tmpetfBunch.push_back( etfBunch );
318 sprintf( brname,
"sigmaCorr%i", i );
322 sprintf( brname,
"t0offset%i", i );
326 int entries = btofcommontree->GetEntries();
327 for(cnt=0;cnt<entries;cnt++){
328 btofcommontree->GetEntry(cnt);
331 tmpbTofCommon.push_back(bTofCommon);
335 int m_run1, m_run2, m_version;
336 int m_qCorr, m_qElec, m_misLable;
337 int m_tofidEast[5], m_tofidWest[5], m_tofidEndcap[5];
339 CalibInfo->SetBranchAddress(
"Run1",&m_run1);
340 CalibInfo->SetBranchAddress(
"Run2",&m_run2);
341 CalibInfo->SetBranchAddress(
"Version",&m_version);
342 CalibInfo->SetBranchAddress(
"ebrId0",&m_tofidEast[0]);
343 CalibInfo->SetBranchAddress(
"ebrId1",&m_tofidEast[1]);
344 CalibInfo->SetBranchAddress(
"ebrId2",&m_tofidEast[2]);
345 CalibInfo->SetBranchAddress(
"ebrId3",&m_tofidEast[3]);
346 CalibInfo->SetBranchAddress(
"ebrId4",&m_tofidEast[4]);
347 CalibInfo->SetBranchAddress(
"ecId0",&m_tofidEndcap[0]);
348 CalibInfo->SetBranchAddress(
"ecId1",&m_tofidEndcap[1]);
349 CalibInfo->SetBranchAddress(
"ecId2",&m_tofidEndcap[2]);
350 CalibInfo->SetBranchAddress(
"ecId3",&m_tofidEndcap[3]);
351 CalibInfo->SetBranchAddress(
"ecId4",&m_tofidEndcap[4]);
352 CalibInfo->SetBranchAddress(
"wbrId0",&m_tofidWest[0]);
353 CalibInfo->SetBranchAddress(
"wbrId1",&m_tofidWest[1]);
354 CalibInfo->SetBranchAddress(
"wbrId2",&m_tofidWest[2]);
355 CalibInfo->SetBranchAddress(
"wbrId3",&m_tofidWest[3]);
356 CalibInfo->SetBranchAddress(
"wbrId4",&m_tofidWest[4]);
357 CalibInfo->SetBranchAddress(
"misLable",&m_misLable);
358 CalibInfo->SetBranchAddress(
"qCorr",&m_qCorr);
359 CalibInfo->SetBranchAddress(
"qElec",&m_qElec);
361 entries= CalibInfo->GetEntries();
362 for(cnt=0;cnt<entries;cnt++){
363 CalibInfo->GetEntry(cnt);
373 tofinfoCol.push_back(tofinfo);
378 refpObject=tmpObject;
383 delete btofcommontree;
386 return StatusCode::SUCCESS;
const CLID CLID_Calib_TofCal
data SetBranchAddress("time",&time)
const unsigned int nBarOffset
const unsigned int nBarParOff
const unsigned int nEndPar
const unsigned int nEtfPar
const unsigned int nBarPar
const unsigned int nBarSigma
const unsigned int nEndSigma
const unsigned int nBarSigCor
const unsigned int nEndSpeed
const unsigned int nEtfSpeed
const unsigned int nEtfBunch
const unsigned int nBarSpeed
const unsigned int nEndAtten
const unsigned int nBarAtten
const unsigned int nBarSigCnt
const unsigned int nBarSigma
const unsigned int nEndSigma
const unsigned int nBarSigCor
const unsigned int nEndSpeed
const unsigned int nBarOffset
const unsigned int nBarParOff
const unsigned int nEtfSpeed
const unsigned int nEtfBunch
const unsigned int nEndPar
const unsigned int nEtfPar
const unsigned int nBarSpeed
const unsigned int nEndAtten
const unsigned int nBarAtten
const unsigned int nBarSigCnt
const unsigned int nBarPar
void setP2(const double *TofP2)
void setPoff1_bunch3(const double *TofPoff1_bunch3)
void setFPleft(const double *FP1)
void setPoff2_bunch1(const double *TofPoff2_bunch1)
void setSpeed(const double *Speed)
void setAtten(const double *Atten)
void setPoff1_bunch0(const double *TofPoff1_bunch0)
void setPoff2_bunch2(const double *TofPoff2_bunch2)
void setPoff1_bunch1(const double *TofPoff1_bunch1)
void setFPcounter(const double *FP3)
void setPoff1_bunch2(const double *TofPoff1_bunch2)
void setPoff2_bunch3(const double *TofPoff2_bunch3)
void setFPright(const double *FP2)
void setPoff2_bunch0(const double *TofPoff2_bunch0)
void setP1(const double *TofP1)
void setSigmaCorr(const double *sigmaCorr)
void setOffset(const double *offset)
void setAtten(const double *Atten)
void setP(const double *TofP)
void setFP(const double *FP)
void setSpeed(const double *Speed)
void setPBunch(const double *etfBunchP)
void setSpeed(const double *Speed)
void setP(const double *etfP)
void setP1(const double *etfP1)
void setP2(const double *etfP2)
void setBrWest(const int *tofidWest)
void setRunEnd(const int run2)
void setVersion(const int version)
void setMisLable(const int misLable)
void setRunBegin(const int run1)
void setBrEast(const int *tofidEast)
void setQElec(const int qElec)
void setQCorr(const int qCorr)
void setEndcap(const int *tofidEndcap)
virtual DatabaseRecord * pp()
const CLID & objType() const
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
static const CLID & classID()
TreeTofCalibDataCnv(ISvcLocator *svc)