2#include "GaudiKernel/MsgStream.h"
4#include "CalibData/Tof/TofCalibData.h"
5#include "CalibData/Tof/bTofCalibBase.h"
6#include "CalibData/Tof/eTofCalibBase.h"
7#include "CalibData/Tof/etfCalibBase.h"
8#include "CalibData/Tof/etfBunchCalibBase.h"
9#include "CalibDataSvc/IInstrumentName.h"
13#include "TDirectory.h"
16#include "GaudiKernel/CnvFactory.h"
17#include "GaudiKernel/IOpaqueAddress.h"
18#include "GaudiKernel/DataObject.h"
19#include "GaudiKernel/IAddressCreator.h"
20#include "GaudiKernel/IDataProviderSvc.h"
21#include "GaudiKernel/IConversionSvc.h"
22#include "GaudiKernel/GenericAddress.h"
24#include "CalibDataSvc/ICalibRootSvc.h"
25#include "CalibDataSvc/ICalibMetaCnvSvc.h"
28#include "CalibData/CalibModel.h"
65 DataObject*& refpObject) {
67 MsgStream log(
msgSvc(),
"RootTofCalibDataCnv");
68 log<<MSG::DEBUG<<
"SetProperty"<<endreq;
73 { log<<MSG::ERROR<<
"unable to open files"<<endreq;
83 std::vector<CalibData::bTofCalibBase> tmpbTof;
84 std::vector<CalibData::eTofCalibBase> tmpeTof;
85 std::vector<CalibData::etfCalibBase> tmpetf;
86 std::vector<CalibData::etfBunchCalibBase> tmpetfBunch;
87 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
88 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
109 TTree *btoftree = (TTree*)
m_inFile -> Get(
"BarTofPar");
112 for(
unsigned int i=0; i<
nBarAtten; i++ ) {
113 sprintf( brname,
"Atten%i", i );
116 for(
unsigned int i=0; i<
nBarSpeed; i++ ) {
117 sprintf( brname,
"Speed%i", i );
120 for(
unsigned int i=0; i<
nBarPar; i++ ) {
124 for(
unsigned int i=0; i<
nBarPar; i++ ) {
129 sprintf( brname,
"Bunch0_Poff%i", i );
137 sprintf( brname,
"Bunch1_Poff%i", i );
145 sprintf( brname,
"Bunch2_Poff%i", i );
153 sprintf( brname,
"Bunch3_Poff%i", i );
160 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
161 sprintf( brname,
"FLeft%i", i );
164 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
165 sprintf( brname,
"FRight%i", i );
169 sprintf( brname,
"FCounter%i", i );
173 for(cnt=0; cnt<176; cnt++){
177 bTof.
setP1( cnvBarPar1 );
178 bTof.
setP2( cnvBarPar2 );
190 tmpbTof.push_back(bTof);
199 TTree *etoftree = (TTree*)
m_inFile -> Get(
"EndTofPar");
202 for(
unsigned int i=0; i<
nEndAtten; i++ ) {
203 sprintf( ecname,
"Atten%i", i );
206 for(
unsigned int i=0; i<
nEndSpeed; i++ ) {
207 sprintf( ecname,
"Speed%i", i );
210 for(
unsigned int i=0; i<
nEndPar; i++ ) {
214 for(
unsigned int i=0; i<
nEndSigma; i++ ) {
215 sprintf( ecname,
"FCounter%i", i );
219 for(cnt=0; cnt<96; cnt++){
223 eTof.
setP( cnvEndPar );
224 eTof.
setFP( cnvEndFPar );
225 tmpeTof.push_back(eTof);
234 if( NULL!=
m_inFile->Get(
"EtfTofPar") ) {
235 TTree *etftree = (TTree*)
m_inFile -> Get(
"EtfTofPar");
238 for(
unsigned int i=0; i<
nEtfSpeed; i++ ) {
239 sprintf( etfname,
"Speed%i", i );
242 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
246 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
250 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
255 for(cnt=0; cnt<(72*12); cnt++){
258 etf.
setP( cnvEtfPar );
259 etf.
setP1( cnvEtfPar1 );
260 etf.
setP2( cnvEtfPar2 );
261 tmpetf.push_back(etf);
268 if( NULL!=
m_inFile->Get(
"EtfTofBunch") ) {
269 TTree *etfbunchtree = (TTree*)
m_inFile -> Get(
"EtfTofBunch");
271 char etfbunchname[10];
272 for(
unsigned int i=0; i<
nEtfBunch; i++ ) {
273 sprintf( etfbunchname,
"pbunch%i", i );
277 int entries= etfbunchtree->GetEntries();
278 for(cnt=0;cnt<entries;cnt++){
281 tmpetfBunch.push_back( etfBunch );
288 TTree *btofcommontree = (TTree*)
m_inFile -> Get(
"BarTofParCommon");
290 sprintf( brname,
"sigmaCorr%i", i );
294 sprintf( brname,
"t0offset%i", i );
298 int entries = btofcommontree->GetEntries();
299 for(cnt=0;cnt<entries;cnt++){
300 btofcommontree->GetEntry(cnt);
303 tmpbTofCommon.push_back(bTofCommon);
306 int m_run1, m_run2, m_version;
307 int m_qCorr, m_qElec, m_misLable;
308 int m_tofidEast[5], m_tofidWest[5], m_tofidEndcap[5];
310 TTree *CalibInfo = (TTree*)
m_inFile -> Get(
"CalibInfo");
311 CalibInfo->SetBranchAddress(
"Run1", &m_run1 );
312 CalibInfo->SetBranchAddress(
"Run2", &m_run2 );
313 CalibInfo->SetBranchAddress(
"Version", &m_version );
314 CalibInfo->SetBranchAddress(
"ebrId0", &m_tofidEast[0] );
315 CalibInfo->SetBranchAddress(
"ebrId1", &m_tofidEast[1] );
316 CalibInfo->SetBranchAddress(
"ebrId2", &m_tofidEast[2] );
317 CalibInfo->SetBranchAddress(
"ebrId3", &m_tofidEast[3] );
318 CalibInfo->SetBranchAddress(
"ebrId4", &m_tofidEast[4] );
319 CalibInfo->SetBranchAddress(
"ecId0", &m_tofidEndcap[0] );
320 CalibInfo->SetBranchAddress(
"ecId1", &m_tofidEndcap[1] );
321 CalibInfo->SetBranchAddress(
"ecId2", &m_tofidEndcap[2] );
322 CalibInfo->SetBranchAddress(
"ecId3", &m_tofidEndcap[3] );
323 CalibInfo->SetBranchAddress(
"ecId4", &m_tofidEndcap[4] );
324 CalibInfo->SetBranchAddress(
"wbrId0", &m_tofidWest[0] );
325 CalibInfo->SetBranchAddress(
"wbrId1", &m_tofidWest[1] );
326 CalibInfo->SetBranchAddress(
"wbrId2", &m_tofidWest[2] );
327 CalibInfo->SetBranchAddress(
"wbrId3", &m_tofidWest[3] );
328 CalibInfo->SetBranchAddress(
"wbrId4", &m_tofidWest[4] );
329 CalibInfo->SetBranchAddress(
"misLable",&m_misLable );
330 CalibInfo->SetBranchAddress(
"qCorr", &m_qCorr );
331 CalibInfo->SetBranchAddress(
"qElec", &m_qElec );
333 entries= CalibInfo->GetEntries();
334 for(cnt=0;cnt<entries;cnt++){
335 CalibInfo->GetEntry(cnt);
345 tofinfoCol.push_back(tofinfo);
350 refpObject=tmpObject;
352 return StatusCode::SUCCESS;
357 MsgStream log(
msgSvc(),
"RootTofCalibDataCnv");
362 { log<<MSG::ERROR<<
"unable to open files"<<endreq;
385 char brname[8], ibrname[8];
386 TTree *btoftree =
new TTree(
"BarTofPar",
"BarTofPar");
387 for(
unsigned int i=0; i<
nBarAtten; i++ ) {
388 sprintf( brname,
"Atten%i", i );
389 sprintf( ibrname,
"Atten%i/D", i );
390 btoftree -> Branch( brname, &cnvBarAtten[i], ibrname );
392 for(
unsigned int i=0; i<
nBarSpeed; i++ ) {
393 sprintf( brname,
"Speed%i", i );
394 sprintf( ibrname,
"Speed%i/D", i );
395 btoftree -> Branch( brname, &cnvBarSpeed[i], ibrname );
397 for(
unsigned int i=0; i<
nBarPar; i++ ) {
399 sprintf( ibrname,
"P%i/D", i );
400 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
402 for(
unsigned int i=0; i<
nBarPar; i++ ) {
405 btoftree -> Branch( brname, &cnvBarPar2[i], ibrname );
408 sprintf( brname,
"Bunch0_Poff%i", i );
409 sprintf( ibrname,
"Bunch0_Poff%i/D", i );
410 btoftree -> Branch( brname, &cnvBarParOff1_bunch0[i], ibrname );
415 btoftree -> Branch( brname, &cnvBarParOff2_bunch0[i], ibrname );
418 sprintf( brname,
"Bunch1_Poff%i", i );
419 sprintf( ibrname,
"Bunch1_Poff%i/D", i );
420 btoftree -> Branch( brname, &cnvBarParOff1_bunch1[i], ibrname );
425 btoftree -> Branch( brname, &cnvBarParOff2_bunch1[i], ibrname );
428 sprintf( brname,
"Bunch2_Poff%i", i );
429 sprintf( ibrname,
"Bunch2_Poff%i/D", i );
430 btoftree -> Branch( brname, &cnvBarParOff1_bunch2[i], ibrname );
435 btoftree -> Branch( brname, &cnvBarParOff2_bunch2[i], ibrname );
438 sprintf( brname,
"Bunch3_Poff%i", i );
439 sprintf( ibrname,
"Bunch3_Poff%i/D", i );
440 btoftree -> Branch( brname, &cnvBarParOff1_bunch3[i], ibrname );
445 btoftree -> Branch( brname, &cnvBarParOff2_bunch3[i], ibrname );
447 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
448 sprintf( brname,
"FLeft%i", i );
449 sprintf( ibrname,
"FLeft%i/D", i );
450 btoftree -> Branch( brname, &cnvFLeft[i], ibrname );
452 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
453 sprintf( brname,
"FRight%i", i );
454 sprintf( ibrname,
"FRight%i/D", i );
455 btoftree -> Branch( brname, &cnvFRight[i], ibrname );
458 sprintf( brname,
"FCounter%i", i );
459 sprintf( ibrname,
"FCounter%i/D", i );
460 btoftree -> Branch( brname, &cnvFCount[i], ibrname );
463 for(
int i=0; i<176; i++ ) {
464 for(j=0;j<static_cast<int>(
nBarAtten);j++) {
467 for(j=0;j<static_cast<int>(
nBarSpeed);j++) {
470 for(j=0;j<static_cast<int>(
nBarPar);j++){
490 for(j=0;j<static_cast<int>(
nBarSigma);j++){
506 char ecname[8], iecname[8];
507 TTree *etoftree =
new TTree(
"EndTofPar",
"EndTofPar");
508 for(
unsigned int i=0; i<
nEndAtten; i++ ) {
509 sprintf( ecname,
"Atten%i", i );
510 sprintf( iecname,
"Atten%i/D", i );
511 etoftree -> Branch( ecname, &cnvEndAtten[i], iecname );
513 for(
unsigned int i=0; i<
nEndSpeed; i++ ) {
514 sprintf( ecname,
"Speed%i", i );
515 sprintf( iecname,
"Speed%i/D", i );
516 etoftree -> Branch( ecname, &cnvEndSpeed[i], iecname );
518 for(
unsigned int i=0; i<
nEndPar; i++ ) {
520 sprintf( iecname,
"P%i/D", i );
521 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
523 for(
unsigned int i=0; i<
nEndSigma; i++ ) {
524 sprintf( ecname,
"FCounter%i", i );
525 sprintf( iecname,
"FCounter%i/D", i );
526 etoftree -> Branch( ecname, &cnvEndFPar[i], iecname );
529 for(
int i=0; i<96; i++){
530 for(j=0;j<static_cast<int>(
nEndAtten);j++) {
533 for(j=0;j<static_cast<int>(
nEndSpeed);j++) {
536 for(j=0;j<static_cast<int>(
nEndPar);j++){
539 for(j=0;j<static_cast<int>(
nEndSigma);j++){
551 char etfname[8], ietfname[8];
552 TTree *etftree =
new TTree(
"EtfTofPar",
"EtfTofPar");
553 for(
unsigned int i=0; i<
nEtfSpeed; i++ ) {
554 sprintf( etfname,
"Speed%i", i );
555 sprintf( ietfname,
"Speed%i/D", i );
556 etftree -> Branch( etfname, &cnvEtfSpeed[i], ietfname );
558 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
560 sprintf( ietfname,
"P%i/D", i );
561 etftree -> Branch( etfname, &cnvEtfPar[i], ietfname );
563 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
566 etftree -> Branch( etfname, &cnvEtfPar1[i], ietfname );
568 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
571 etftree -> Branch( etfname, &cnvEtfPar2[i], ietfname );
574 for(
int i=0; i<72; i++ ) {
575 for(
int k=0; k<12; k++ ) {
576 for(j=0;j<static_cast<int>(
nEtfSpeed);j++) {
579 for(j=0;j<static_cast<int>(
nEtfPar);j++){
591 char etfbunchname[8], ietfbunchname[8];
592 TTree *etfbunchtree =
new TTree(
"EtfTofBunch",
"EtfTofBunch");
593 for(
unsigned int i=0; i<
nEtfBunch; i++ ) {
594 sprintf( etfbunchname,
"pbunch%i", i );
595 sprintf( ietfbunchname,
"pbunch%i/D", i );
596 etfbunchtree -> Branch( etfbunchname, &cnvEtfBunchP[i], ietfbunchname );
599 for(j=0;j<static_cast<int>(
nEtfBunch);j++) {
602 etfbunchtree -> Fill();
609 etfbunchtree -> Write();
615 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 nEtfPar
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 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
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 getEtfSpeed(int index, int strip, int pardex)
double getBTofFright(int index, int pardex)
double getBTofFcounter(int index, int pardex)
double getBTofPoffleft_bunch2(int index, int pardex)
double getEtfPleft(int index, int strip, int pardex)
double getEtfPcombine(int index, int strip, int pardex)
double getETofAtten(int index, int pardex)
double getBTofAtten(int index, int pardex)
double getEtfPBunch(int pardex)
double getBTofPoffleft_bunch0(int index, int pardex)
double getEtfPright(int index, int strip, 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 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)
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)
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)