2#include "GaudiKernel/MsgStream.h"
4#include "CalibData/Tof/TofCalibData.h"
5#include "CalibData/Tof/eTofCalibBase.h"
6#include "CalibData/Tof/bTofCalibBase.h"
7#include "CalibDataSvc/IInstrumentName.h"
11#include "TDirectory.h"
14#include "GaudiKernel/CnvFactory.h"
15#include "GaudiKernel/IOpaqueAddress.h"
16#include "GaudiKernel/DataObject.h"
17#include "GaudiKernel/IAddressCreator.h"
18#include "GaudiKernel/IDataProviderSvc.h"
19#include "GaudiKernel/IConversionSvc.h"
20#include "GaudiKernel/GenericAddress.h"
22#include "CalibDataSvc/ICalibRootSvc.h"
23#include "CalibDataSvc/ICalibMetaCnvSvc.h"
29#include "CalibData/CalibModel.h"
63 DataObject*& refpObject) {
65 MsgStream log(
msgSvc(),
"RootTofCalibDataCnv");
66 log<<MSG::DEBUG<<
"SetProperty"<<endreq;
71 { log<<MSG::ERROR<<
"unable to open files"<<endreq;
79 std::vector<CalibData::bTofCalibBase> tmpbTof;
80 std::vector<CalibData::eTofCalibBase> tmpeTof;
81 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
82 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
103 TTree *btoftree = (TTree*)
m_inFile -> Get(
"BarTofPar");
106 for(
unsigned int i=0; i<
nBarAtten; i++ ) {
107 sprintf( brname,
"Atten%i", i );
110 for(
unsigned int i=0; i<
nBarSpeed; i++ ) {
111 sprintf( brname,
"Speed%i", i );
114 for(
unsigned int i=0; i<
nBarPar; i++ ) {
115 sprintf( brname,
"P%i", i );
118 for(
unsigned int i=0; i<
nBarPar; i++ ) {
119 sprintf( brname,
"P%i", i+
nBarPar );
123 sprintf( brname,
"Bunch0_Poff%i", i );
127 sprintf( brname,
"Bunch0_Poff%i", i+
nBarParOff );
131 sprintf( brname,
"Bunch1_Poff%i", i );
135 sprintf( brname,
"Bunch1_Poff%i", i+
nBarParOff );
139 sprintf( brname,
"Bunch2_Poff%i", i );
143 sprintf( brname,
"Bunch2_Poff%i", i+
nBarParOff );
147 sprintf( brname,
"Bunch3_Poff%i", i );
151 sprintf( brname,
"Bunch3_Poff%i", i+
nBarParOff );
154 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
155 sprintf( brname,
"FLeft%i", i );
158 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
159 sprintf( brname,
"FRight%i", i );
163 sprintf( brname,
"FCounter%i", i );
167 for(cnt=0; cnt<176; cnt++){
171 bTof.
setP1( cnvBarPar1 );
172 bTof.
setP2( cnvBarPar2 );
184 tmpbTof.push_back(bTof);
193 TTree *etoftree = (TTree*)
m_inFile -> Get(
"EndTofPar");
196 for(
unsigned int i=0; i<
nEndAtten; i++ ) {
197 sprintf( ecname,
"Atten%i", i );
200 for(
unsigned int i=0; i<
nEndSpeed; i++ ) {
201 sprintf( ecname,
"Speed%i", i );
204 for(
unsigned int i=0; i<
nEndPar; i++ ) {
205 sprintf( ecname,
"P%i", i );
208 for(
unsigned int i=0; i<
nEndSigma; i++ ) {
209 sprintf( ecname,
"FCounter%i", i );
213 for(cnt=0; cnt<96; cnt++){
217 eTof.
setP( cnvEndPar );
218 eTof.
setFP( cnvEndFPar );
219 tmpeTof.push_back(eTof);
225 TTree *btofcommontree = (TTree*)
m_inFile -> Get(
"BarTofParCommon");
227 sprintf( brname,
"sigmaCorr%i", i );
231 sprintf( brname,
"t0offset%i", i );
235 int entries = btofcommontree->GetEntries();
236 for(cnt=0;cnt<entries;cnt++){
237 btofcommontree->GetEntry(cnt);
240 tmpbTofCommon.push_back(bTofCommon);
243 int m_run1, m_run2, m_version;
244 int m_qCorr, m_qElec, m_misLable;
245 int m_tofidEast[5], m_tofidWest[5], m_tofidEndcap[5];
247 TTree *CalibInfo = (TTree*)
m_inFile -> Get(
"CalibInfo");
248 CalibInfo->SetBranchAddress(
"Run1",&m_run1);
249 CalibInfo->SetBranchAddress(
"Run2",&m_run2);
250 CalibInfo->SetBranchAddress(
"Version",&m_version);
251 CalibInfo->SetBranchAddress(
"ebrId0",&m_tofidEast[0]);
252 CalibInfo->SetBranchAddress(
"ebrId1",&m_tofidEast[1]);
253 CalibInfo->SetBranchAddress(
"ebrId2",&m_tofidEast[2]);
254 CalibInfo->SetBranchAddress(
"ebrId3",&m_tofidEast[3]);
255 CalibInfo->SetBranchAddress(
"ebrId4",&m_tofidEast[4]);
256 CalibInfo->SetBranchAddress(
"ecId0",&m_tofidEndcap[0]);
257 CalibInfo->SetBranchAddress(
"ecId1",&m_tofidEndcap[1]);
258 CalibInfo->SetBranchAddress(
"ecId2",&m_tofidEndcap[2]);
259 CalibInfo->SetBranchAddress(
"ecId3",&m_tofidEndcap[3]);
260 CalibInfo->SetBranchAddress(
"ecId4",&m_tofidEndcap[4]);
261 CalibInfo->SetBranchAddress(
"wbrId0",&m_tofidWest[0]);
262 CalibInfo->SetBranchAddress(
"wbrId1",&m_tofidWest[1]);
263 CalibInfo->SetBranchAddress(
"wbrId2",&m_tofidWest[2]);
264 CalibInfo->SetBranchAddress(
"wbrId3",&m_tofidWest[3]);
265 CalibInfo->SetBranchAddress(
"wbrId4",&m_tofidWest[4]);
266 CalibInfo->SetBranchAddress(
"misLable",&m_misLable);
267 CalibInfo->SetBranchAddress(
"qCorr",&m_qCorr);
268 CalibInfo->SetBranchAddress(
"qElec",&m_qElec);
270 entries= CalibInfo->GetEntries();
271 for(cnt=0;cnt<entries;cnt++){
272 CalibInfo->GetEntry(cnt);
282 tofinfoCol.push_back(tofinfo);
287 refpObject=tmpObject;
289 return StatusCode::SUCCESS;
294 MsgStream log(
msgSvc(),
"RootTofCalibDataCnv");
299 { log<<MSG::ERROR<<
"unable to open files"<<endreq;
322 char brname[8], ibrname[8];
323 TTree *btoftree =
new TTree(
"BarTofPar",
"BarTofPar");
324 for(
unsigned int i=0; i<
nBarAtten; i++ ) {
325 sprintf( brname,
"Atten%i", i );
326 sprintf( ibrname,
"Atten%i/D", i );
327 btoftree -> Branch( brname, &cnvBarAtten[i], ibrname );
329 for(
unsigned int i=0; i<
nBarSpeed; i++ ) {
330 sprintf( brname,
"Speed%i", i );
331 sprintf( ibrname,
"Speed%i/D", i );
332 btoftree -> Branch( brname, &cnvBarSpeed[i], ibrname );
334 for(
unsigned int i=0; i<
nBarPar; i++ ) {
335 sprintf( brname,
"P%i", i );
336 sprintf( ibrname,
"P%i/D", i );
337 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
339 for(
unsigned int i=0; i<
nBarPar; i++ ) {
340 sprintf( brname,
"P%i", i+
nBarPar );
341 sprintf( ibrname,
"P%i/D", i+
nBarPar );
342 btoftree -> Branch( brname, &cnvBarPar2[i], ibrname );
345 sprintf( brname,
"Bunch0_Poff%i", i );
346 sprintf( ibrname,
"Bunch0_Poff%i/D", i );
347 btoftree -> Branch( brname, &cnvBarParOff1_bunch0[i], ibrname );
350 sprintf( brname,
"Bunch0_Poff%i", i+
nBarParOff );
351 sprintf( ibrname,
"Bunch0_Poff%i/D", i+
nBarParOff );
352 btoftree -> Branch( brname, &cnvBarParOff2_bunch0[i], ibrname );
355 sprintf( brname,
"Bunch1_Poff%i", i );
356 sprintf( ibrname,
"Bunch1_Poff%i/D", i );
357 btoftree -> Branch( brname, &cnvBarParOff1_bunch1[i], ibrname );
360 sprintf( brname,
"Bunch1_Poff%i", i+
nBarParOff );
361 sprintf( ibrname,
"Bunch1_Poff%i/D", i+
nBarParOff );
362 btoftree -> Branch( brname, &cnvBarParOff2_bunch1[i], ibrname );
365 sprintf( brname,
"Bunch2_Poff%i", i );
366 sprintf( ibrname,
"Bunch2_Poff%i/D", i );
367 btoftree -> Branch( brname, &cnvBarParOff1_bunch2[i], ibrname );
370 sprintf( brname,
"Bunch2_Poff%i", i+
nBarParOff );
371 sprintf( ibrname,
"Bunch2_Poff%i/D", i+
nBarParOff );
372 btoftree -> Branch( brname, &cnvBarParOff2_bunch2[i], ibrname );
375 sprintf( brname,
"Bunch3_Poff%i", i );
376 sprintf( ibrname,
"Bunch3_Poff%i/D", i );
377 btoftree -> Branch( brname, &cnvBarParOff1_bunch3[i], ibrname );
380 sprintf( brname,
"Bunch3_Poff%i", i+
nBarParOff );
381 sprintf( ibrname,
"Bunch3_Poff%i/D", i+
nBarParOff );
382 btoftree -> Branch( brname, &cnvBarParOff2_bunch3[i], ibrname );
384 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
385 sprintf( brname,
"FLeft%i", i );
386 sprintf( ibrname,
"FLeft%i/D", i );
387 btoftree -> Branch( brname, &cnvFLeft[i], ibrname );
389 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
390 sprintf( brname,
"FRight%i", i );
391 sprintf( ibrname,
"FRight%i/D", i );
392 btoftree -> Branch( brname, &cnvFRight[i], ibrname );
395 sprintf( brname,
"FCounter%i", i );
396 sprintf( ibrname,
"FCounter%i/D", i );
397 btoftree -> Branch( brname, &cnvFCount[i], ibrname );
400 for(
int i=0; i<176; i++ ) {
401 for(j=0;j<static_cast<int>(
nBarAtten);j++) {
404 for(j=0;j<static_cast<int>(
nBarSpeed);j++) {
407 for(j=0;j<static_cast<int>(
nBarPar);j++){
427 for(j=0;j<static_cast<int>(
nBarSigma);j++){
443 char ecname[8], iecname[8];
444 TTree *etoftree =
new TTree(
"EndTofPar",
"EndTofPar");
445 for(
unsigned int i=0; i<
nEndAtten; i++ ) {
446 sprintf( ecname,
"Atten%i", i );
447 sprintf( iecname,
"Atten%i/D", i );
448 etoftree -> Branch( ecname, &cnvEndAtten[i], iecname );
450 for(
unsigned int i=0; i<
nEndSpeed; i++ ) {
451 sprintf( ecname,
"Speed%i", i );
452 sprintf( iecname,
"Speed%i/D", i );
453 etoftree -> Branch( ecname, &cnvEndSpeed[i], iecname );
455 for(
unsigned int i=0; i<
nEndPar; i++ ) {
456 sprintf( ecname,
"P%i", i );
457 sprintf( iecname,
"P%i/D", i );
458 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
460 for(
unsigned int i=0; i<
nEndSigma; i++ ) {
461 sprintf( ecname,
"FCounter%i", i );
462 sprintf( iecname,
"FCounter%i/D", i );
463 etoftree -> Branch( ecname, &cnvEndFPar[i], iecname );
466 for(
int i=0; i<96; i++){
467 for(j=0;j<static_cast<int>(
nEndAtten);j++) {
470 for(j=0;j<static_cast<int>(
nEndSpeed);j++) {
473 for(j=0;j<static_cast<int>(
nEndPar);j++){
476 for(j=0;j<static_cast<int>(
nEndSigma);j++){
488 log<<MSG::INFO<<
"successfully create RootFile"<<endreq;
const CLID CLID_Calib_TofCal
data SetBranchAddress("time",&time)
const unsigned int nBarOffset
const unsigned int nBarParOff
const unsigned int nEndPar
const unsigned int nBarPar
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 nEndPar
const unsigned int nBarSpeed
const unsigned int nEndAtten
const unsigned int nBarAtten
const unsigned int nBarSigCnt
const unsigned int nBarPar
double getETofFP(int index, int pardex)
double getBTofPoffleft_bunch1(int index, int pardex)
double getBTofPoffleft_bunch3(int index, int pardex)
double getBTofSpeed(int index, int pardex)
double getETofP(int index, int pardex)
double getBTofPoffright_bunch3(int index, int pardex)
double getBTofPoffright_bunch2(int index, int pardex)
double getBTofFleft(int index, int pardex)
double getBTofPoffright_bunch0(int index, int pardex)
double getBTofPoffright_bunch1(int index, int pardex)
double getBTofFright(int index, int pardex)
double getBTofFcounter(int index, int pardex)
double getBTofPoffleft_bunch2(int index, int pardex)
double getETofAtten(int index, int pardex)
double getBTofAtten(int index, int pardex)
double getBTofPoffleft_bunch0(int index, int pardex)
double getBTofPleft(int index, int pardex)
double getETofSpeed(int index, int pardex)
double getBTofPright(int index, int pardex)
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 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)
StatusCode openRead(const std::string &fname)
virtual StatusCode openWrite(const std::string &fname)
static const CLID & classID()
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
const CLID & objType() const
RootTofCalibDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)