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<btoftree->GetEntries(); 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<etoftree->GetEntries(); 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<etftree->GetEntries(); 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];
309 int m_runFrom, m_runTo, m_eventFrom, m_eventTo;
311 TTree *CalibInfo = (TTree*)
m_inFile -> Get(
"CalibInfo");
312 CalibInfo->SetBranchAddress(
"Run1", &m_run1 );
313 CalibInfo->SetBranchAddress(
"Run2", &m_run2 );
314 CalibInfo->SetBranchAddress(
"Version", &m_version );
315 CalibInfo->SetBranchAddress(
"ebrId0", &m_tofidEast[0] );
316 CalibInfo->SetBranchAddress(
"ebrId1", &m_tofidEast[1] );
317 CalibInfo->SetBranchAddress(
"ebrId2", &m_tofidEast[2] );
318 CalibInfo->SetBranchAddress(
"ebrId3", &m_tofidEast[3] );
319 CalibInfo->SetBranchAddress(
"ebrId4", &m_tofidEast[4] );
320 CalibInfo->SetBranchAddress(
"ecId0", &m_tofidEndcap[0] );
321 CalibInfo->SetBranchAddress(
"ecId1", &m_tofidEndcap[1] );
322 CalibInfo->SetBranchAddress(
"ecId2", &m_tofidEndcap[2] );
323 CalibInfo->SetBranchAddress(
"ecId3", &m_tofidEndcap[3] );
324 CalibInfo->SetBranchAddress(
"ecId4", &m_tofidEndcap[4] );
325 CalibInfo->SetBranchAddress(
"wbrId0", &m_tofidWest[0] );
326 CalibInfo->SetBranchAddress(
"wbrId1", &m_tofidWest[1] );
327 CalibInfo->SetBranchAddress(
"wbrId2", &m_tofidWest[2] );
328 CalibInfo->SetBranchAddress(
"wbrId3", &m_tofidWest[3] );
329 CalibInfo->SetBranchAddress(
"wbrId4", &m_tofidWest[4] );
330 CalibInfo->SetBranchAddress(
"misLable",&m_misLable );
331 CalibInfo->SetBranchAddress(
"qCorr", &m_qCorr );
332 CalibInfo->SetBranchAddress(
"qElec", &m_qElec );
333 if( CalibInfo->GetBranchStatus(
"runFrom") ){
334 CalibInfo->SetBranchAddress(
"runFrom", &m_runFrom );
335 CalibInfo->SetBranchAddress(
"runTo", &m_runTo );
336 CalibInfo->SetBranchAddress(
"eventFrom", &m_eventFrom );
337 CalibInfo->SetBranchAddress(
"eventTo", &m_eventTo );
346 entries= CalibInfo->GetEntries();
347 for(cnt=0;cnt<entries;cnt++){
348 CalibInfo->GetEntry(cnt);
362 tofinfoCol.push_back(tofinfo);
367 refpObject=tmpObject;
369 return StatusCode::SUCCESS;
374 MsgStream log(
msgSvc(),
"RootTofCalibDataCnv");
379 { log<<MSG::ERROR<<
"unable to open files"<<endreq;
402 char brname[8], ibrname[8];
403 TTree *btoftree =
new TTree(
"BarTofPar",
"BarTofPar");
404 for(
unsigned int i=0; i<
nBarAtten; i++ ) {
405 sprintf( brname,
"Atten%i", i );
406 sprintf( ibrname,
"Atten%i/D", i );
407 btoftree ->
Branch( brname, &cnvBarAtten[i], ibrname );
409 for(
unsigned int i=0; i<
nBarSpeed; i++ ) {
410 sprintf( brname,
"Speed%i", i );
411 sprintf( ibrname,
"Speed%i/D", i );
412 btoftree ->
Branch( brname, &cnvBarSpeed[i], ibrname );
414 for(
unsigned int i=0; i<
nBarPar; i++ ) {
416 sprintf( ibrname,
"P%i/D", i );
417 btoftree ->
Branch( brname, &cnvBarPar1[i], ibrname );
419 for(
unsigned int i=0; i<
nBarPar; i++ ) {
422 btoftree ->
Branch( brname, &cnvBarPar2[i], ibrname );
425 sprintf( brname,
"Bunch0_Poff%i", i );
426 sprintf( ibrname,
"Bunch0_Poff%i/D", i );
427 btoftree ->
Branch( brname, &cnvBarParOff1_bunch0[i], ibrname );
432 btoftree ->
Branch( brname, &cnvBarParOff2_bunch0[i], ibrname );
435 sprintf( brname,
"Bunch1_Poff%i", i );
436 sprintf( ibrname,
"Bunch1_Poff%i/D", i );
437 btoftree ->
Branch( brname, &cnvBarParOff1_bunch1[i], ibrname );
442 btoftree ->
Branch( brname, &cnvBarParOff2_bunch1[i], ibrname );
445 sprintf( brname,
"Bunch2_Poff%i", i );
446 sprintf( ibrname,
"Bunch2_Poff%i/D", i );
447 btoftree ->
Branch( brname, &cnvBarParOff1_bunch2[i], ibrname );
452 btoftree ->
Branch( brname, &cnvBarParOff2_bunch2[i], ibrname );
455 sprintf( brname,
"Bunch3_Poff%i", i );
456 sprintf( ibrname,
"Bunch3_Poff%i/D", i );
457 btoftree ->
Branch( brname, &cnvBarParOff1_bunch3[i], ibrname );
462 btoftree ->
Branch( brname, &cnvBarParOff2_bunch3[i], ibrname );
464 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
465 sprintf( brname,
"FLeft%i", i );
466 sprintf( ibrname,
"FLeft%i/D", i );
467 btoftree ->
Branch( brname, &cnvFLeft[i], ibrname );
469 for(
unsigned int i=0; i<
nBarSigma; i++ ) {
470 sprintf( brname,
"FRight%i", i );
471 sprintf( ibrname,
"FRight%i/D", i );
472 btoftree ->
Branch( brname, &cnvFRight[i], ibrname );
475 sprintf( brname,
"FCounter%i", i );
476 sprintf( ibrname,
"FCounter%i/D", i );
477 btoftree ->
Branch( brname, &cnvFCount[i], ibrname );
480 for(
int i=0; i<176; i++ ) {
481 for(j=0;j<static_cast<int>(
nBarAtten);j++) {
484 for(j=0;j<static_cast<int>(
nBarSpeed);j++) {
487 for(j=0;j<static_cast<int>(
nBarPar);j++){
507 for(j=0;j<static_cast<int>(
nBarSigma);j++){
523 char ecname[8], iecname[8];
524 TTree *etoftree =
new TTree(
"EndTofPar",
"EndTofPar");
525 for(
unsigned int i=0; i<
nEndAtten; i++ ) {
526 sprintf( ecname,
"Atten%i", i );
527 sprintf( iecname,
"Atten%i/D", i );
528 etoftree ->
Branch( ecname, &cnvEndAtten[i], iecname );
530 for(
unsigned int i=0; i<
nEndSpeed; i++ ) {
531 sprintf( ecname,
"Speed%i", i );
532 sprintf( iecname,
"Speed%i/D", i );
533 etoftree ->
Branch( ecname, &cnvEndSpeed[i], iecname );
535 for(
unsigned int i=0; i<
nEndPar; i++ ) {
537 sprintf( iecname,
"P%i/D", i );
538 etoftree ->
Branch( ecname, &cnvEndPar[i], iecname );
540 for(
unsigned int i=0; i<
nEndSigma; i++ ) {
541 sprintf( ecname,
"FCounter%i", i );
542 sprintf( iecname,
"FCounter%i/D", i );
543 etoftree ->
Branch( ecname, &cnvEndFPar[i], iecname );
546 for(
int i=0; i<96; i++){
547 for(j=0;j<static_cast<int>(
nEndAtten);j++) {
550 for(j=0;j<static_cast<int>(
nEndSpeed);j++) {
553 for(j=0;j<static_cast<int>(
nEndPar);j++){
556 for(j=0;j<static_cast<int>(
nEndSigma);j++){
568 char etfname[8], ietfname[8];
569 TTree *etftree =
new TTree(
"EtfTofPar",
"EtfTofPar");
570 for(
unsigned int i=0; i<
nEtfSpeed; i++ ) {
571 sprintf( etfname,
"Speed%i", i );
572 sprintf( ietfname,
"Speed%i/D", i );
573 etftree ->
Branch( etfname, &cnvEtfSpeed[i], ietfname );
575 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
577 sprintf( ietfname,
"P%i/D", i );
578 etftree ->
Branch( etfname, &cnvEtfPar[i], ietfname );
580 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
583 etftree ->
Branch( etfname, &cnvEtfPar1[i], ietfname );
585 for(
unsigned int i=0; i<
nEtfPar; i++ ) {
588 etftree ->
Branch( etfname, &cnvEtfPar2[i], ietfname );
591 for(
int i=0; i<72; i++ ) {
592 for(
int k=0; k<12; k++ ) {
593 for(j=0;j<static_cast<int>(
nEtfSpeed);j++) {
596 for(j=0;j<static_cast<int>(
nEtfPar);j++){
608 char etfbunchname[8], ietfbunchname[8];
609 TTree *etfbunchtree =
new TTree(
"EtfTofBunch",
"EtfTofBunch");
610 for(
unsigned int i=0; i<
nEtfBunch; i++ ) {
611 sprintf( etfbunchname,
"pbunch%i", i );
612 sprintf( ietfbunchname,
"pbunch%i/D", i );
613 etfbunchtree ->
Branch( etfbunchname, &cnvEtfBunchP[i], ietfbunchname );
616 for(j=0;j<static_cast<int>(
nEtfBunch);j++) {
619 etfbunchtree ->
Fill();
626 etfbunchtree ->
Write();
632 log<<MSG::INFO<<
"successfully create RootFile"<<endreq;
const CLID CLID_Calib_TofCal
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
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 getEtfPBunch(int cnx, 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 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 setRunFrom(const int runFrom)
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 setEventTo(const int eventTo)
void setRunTo(const int runTo)
void setBrEast(const int *tofidEast)
void setQElec(const int qElec)
void setEventFrom(const int eventFrom)
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)