00001
00002 #include "GaudiKernel/MsgStream.h"
00003 #include "RootTofCalibDataCnv.h"
00004 #include "CalibData/Tof/TofCalibData.h"
00005 #include "CalibData/Tof/bTofCalibBase.h"
00006 #include "CalibData/Tof/eTofCalibBase.h"
00007 #include "CalibData/Tof/etfCalibBase.h"
00008 #include "CalibData/Tof/etfBunchCalibBase.h"
00009 #include "CalibDataSvc/IInstrumentName.h"
00010
00011 #include "TFile.h"
00012 #include "TTree.h"
00013 #include "TDirectory.h"
00014 #include "TObject.h"
00015
00016 #include "GaudiKernel/CnvFactory.h"
00017 #include "GaudiKernel/IOpaqueAddress.h"
00018 #include "GaudiKernel/DataObject.h"
00019 #include "GaudiKernel/IAddressCreator.h"
00020 #include "GaudiKernel/IDataProviderSvc.h"
00021 #include "GaudiKernel/IConversionSvc.h"
00022 #include "GaudiKernel/GenericAddress.h"
00023
00024 #include "CalibDataSvc/ICalibRootSvc.h"
00025 #include "CalibDataSvc/ICalibMetaCnvSvc.h"
00026
00027
00028 #include "CalibData/CalibModel.h"
00029 using namespace CalibData;
00030
00031 const unsigned int nBarAtten = 8;
00032 const unsigned int nBarSpeed = 2;
00033 const unsigned int nBarPar = 10;
00034 const unsigned int nBarParOff = 20;
00035 const unsigned int nBarSigma = 5;
00036 const unsigned int nBarSigCnt = 10;
00037
00038 const unsigned int nBarSigCor = 8;
00039 const unsigned int nBarOffset = 2;
00040
00041 const unsigned int nEndAtten = 5;
00042 const unsigned int nEndSpeed = 4;
00043 const unsigned int nEndPar = 8;
00044 const unsigned int nEndSigma = 5;
00045
00046 const unsigned int nEtfSpeed = 4;
00047 const unsigned int nEtfPar = 20;
00048 const unsigned int nEtfBunch = 4;
00049
00050
00051 RootTofCalibDataCnv::RootTofCalibDataCnv( ISvcLocator* svc) :
00052 RootCalBaseCnv(svc, CLID_Calib_TofCal) {
00053 }
00054
00055
00056 const CLID& RootTofCalibDataCnv::objType() const {
00057 return CLID_Calib_TofCal;
00058 }
00059
00060 const CLID& RootTofCalibDataCnv::classID() {
00061 return CLID_Calib_TofCal;
00062 }
00063
00064 StatusCode RootTofCalibDataCnv::i_createObj(const std::string& fname,
00065 DataObject*& refpObject) {
00066
00067 MsgStream log(msgSvc(), "RootTofCalibDataCnv");
00068 log<<MSG::DEBUG<<"SetProperty"<<endreq;
00069
00070
00071 StatusCode sc = openRead(fname);
00072 if(!sc)
00073 { log<<MSG::ERROR<<"unable to open files"<<endreq;
00074 }
00075
00076 CalibData::bTofCalibBase bTof;
00077 CalibData::eTofCalibBase eTof;
00078 CalibData::etfCalibBase etf;
00079 CalibData::etfBunchCalibBase etfBunch;
00080 CalibData::bTofCommonCalibBase bTofCommon;
00081 CalibData::tofCalibInfoBase tofinfo;
00082
00083 std::vector<CalibData::bTofCalibBase> tmpbTof;
00084 std::vector<CalibData::eTofCalibBase> tmpeTof;
00085 std::vector<CalibData::etfCalibBase> tmpetf;
00086 std::vector<CalibData::etfBunchCalibBase> tmpetfBunch;
00087 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
00088 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
00089
00090 int cnt;
00091
00092
00093 double cnvBarAtten[nBarAtten];
00094 double cnvBarSpeed[nBarSpeed];
00095 double cnvBarPar1[nBarPar];
00096 double cnvBarPar2[nBarPar];
00097 double cnvBarParOff1_bunch0[nBarParOff];
00098 double cnvBarParOff2_bunch0[nBarParOff];
00099 double cnvBarParOff1_bunch1[nBarParOff];
00100 double cnvBarParOff2_bunch1[nBarParOff];
00101 double cnvBarParOff1_bunch2[nBarParOff];
00102 double cnvBarParOff2_bunch2[nBarParOff];
00103 double cnvBarParOff1_bunch3[nBarParOff];
00104 double cnvBarParOff2_bunch3[nBarParOff];
00105 double cnvFLeft[nBarSigma];
00106 double cnvFRight[nBarSigma];
00107 double cnvFCount[nBarSigCnt];
00108
00109 TTree *btoftree = (TTree*)m_inFile -> Get("BarTofPar");
00110
00111 char brname[10];
00112 for( unsigned int i=0; i<nBarAtten; i++ ) {
00113 sprintf( brname, "Atten%i", i );
00114 btoftree -> SetBranchAddress( brname, &cnvBarAtten[i] );
00115 }
00116 for( unsigned int i=0; i<nBarSpeed; i++ ) {
00117 sprintf( brname, "Speed%i", i );
00118 btoftree -> SetBranchAddress( brname, &cnvBarSpeed[i] );
00119 }
00120 for( unsigned int i=0; i<nBarPar; i++ ) {
00121 sprintf( brname, "P%i", i );
00122 btoftree -> SetBranchAddress( brname, &cnvBarPar1[i] );
00123 }
00124 for( unsigned int i=0; i<nBarPar; i++ ) {
00125 sprintf( brname, "P%i", i+nBarPar );
00126 btoftree -> SetBranchAddress( brname, &cnvBarPar2[i] );
00127 }
00128 for( unsigned int i=0; i<nBarParOff; i++ ) {
00129 sprintf( brname, "Bunch0_Poff%i", i );
00130 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch0[i] );
00131 }
00132 for( unsigned int i=0; i<nBarParOff; i++ ) {
00133 sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
00134 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch0[i] );
00135 }
00136 for( unsigned int i=0; i<nBarParOff; i++ ) {
00137 sprintf( brname, "Bunch1_Poff%i", i );
00138 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch1[i] );
00139 }
00140 for( unsigned int i=0; i<nBarParOff; i++ ) {
00141 sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
00142 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch1[i] );
00143 }
00144 for( unsigned int i=0; i<nBarParOff; i++ ) {
00145 sprintf( brname, "Bunch2_Poff%i", i );
00146 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch2[i] );
00147 }
00148 for( unsigned int i=0; i<nBarParOff; i++ ) {
00149 sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
00150 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch2[i] );
00151 }
00152 for( unsigned int i=0; i<nBarParOff; i++ ) {
00153 sprintf( brname, "Bunch3_Poff%i", i );
00154 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch3[i] );
00155 }
00156 for( unsigned int i=0; i<nBarParOff; i++ ) {
00157 sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
00158 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch3[i] );
00159 }
00160 for( unsigned int i=0; i<nBarSigma; i++ ) {
00161 sprintf( brname, "FLeft%i", i );
00162 btoftree -> SetBranchAddress( brname, &cnvFLeft[i] );
00163 }
00164 for( unsigned int i=0; i<nBarSigma; i++ ) {
00165 sprintf( brname, "FRight%i", i );
00166 btoftree -> SetBranchAddress( brname, &cnvFRight[i] );
00167 }
00168 for( unsigned int i=0; i<nBarSigCnt; i++ ) {
00169 sprintf( brname, "FCounter%i", i );
00170 btoftree -> SetBranchAddress( brname, &cnvFCount[i] );
00171 }
00172
00173 for(cnt=0; cnt<176; cnt++){
00174 btoftree -> GetEntry(cnt);
00175 bTof.setAtten( cnvBarAtten );
00176 bTof.setSpeed( cnvBarSpeed );
00177 bTof.setP1( cnvBarPar1 );
00178 bTof.setP2( cnvBarPar2 );
00179 bTof.setPoff1_bunch0( cnvBarParOff1_bunch0 );
00180 bTof.setPoff2_bunch0( cnvBarParOff2_bunch0 );
00181 bTof.setPoff1_bunch1( cnvBarParOff1_bunch1 );
00182 bTof.setPoff2_bunch1( cnvBarParOff2_bunch1 );
00183 bTof.setPoff1_bunch2( cnvBarParOff1_bunch2 );
00184 bTof.setPoff2_bunch2( cnvBarParOff2_bunch2 );
00185 bTof.setPoff1_bunch3( cnvBarParOff1_bunch3 );
00186 bTof.setPoff2_bunch3( cnvBarParOff2_bunch3 );
00187 bTof.setFPleft( cnvFLeft );
00188 bTof.setFPright( cnvFRight );
00189 bTof.setFPcounter( cnvFCount );
00190 tmpbTof.push_back(bTof);
00191 }
00192
00193
00194 double cnvEndAtten[nEndAtten];
00195 double cnvEndSpeed[nEndSpeed];
00196 double cnvEndPar[nEndPar];
00197 double cnvEndFPar[nEndSigma];
00198
00199 TTree *etoftree = (TTree*)m_inFile -> Get("EndTofPar");
00200
00201 char ecname[10];
00202 for( unsigned int i=0; i<nEndAtten; i++ ) {
00203 sprintf( ecname, "Atten%i", i );
00204 etoftree -> SetBranchAddress( ecname, &cnvEndAtten[i] );
00205 }
00206 for( unsigned int i=0; i<nEndSpeed; i++ ) {
00207 sprintf( ecname, "Speed%i", i );
00208 etoftree -> SetBranchAddress( ecname, &cnvEndSpeed[i] );
00209 }
00210 for( unsigned int i=0; i<nEndPar; i++ ) {
00211 sprintf( ecname, "P%i", i );
00212 etoftree -> SetBranchAddress( ecname, &cnvEndPar[i] );
00213 }
00214 for( unsigned int i=0; i<nEndSigma; i++ ) {
00215 sprintf( ecname, "FCounter%i", i );
00216 etoftree -> SetBranchAddress( ecname, &cnvEndFPar[i] );
00217 }
00218
00219 for(cnt=0; cnt<96; cnt++){
00220 etoftree -> GetEntry(cnt);
00221 eTof.setAtten( cnvEndAtten );
00222 eTof.setSpeed( cnvEndSpeed );
00223 eTof.setP( cnvEndPar );
00224 eTof.setFP( cnvEndFPar );
00225 tmpeTof.push_back(eTof);
00226 }
00227
00228
00229 double cnvEtfSpeed[nEtfSpeed];
00230 double cnvEtfPar[nEtfPar];
00231 double cnvEtfPar1[nEtfPar];
00232 double cnvEtfPar2[nEtfPar];
00233
00234 if( NULL!=m_inFile->Get("EtfTofPar") ) {
00235 TTree *etftree = (TTree*)m_inFile -> Get("EtfTofPar");
00236
00237 char etfname[10];
00238 for( unsigned int i=0; i<nEtfSpeed; i++ ) {
00239 sprintf( etfname, "Speed%i", i );
00240 etftree -> SetBranchAddress( etfname, &cnvEtfSpeed[i] );
00241 }
00242 for( unsigned int i=0; i<nEtfPar; i++ ) {
00243 sprintf( etfname, "P%i", i );
00244 etftree -> SetBranchAddress( etfname, &cnvEtfPar[i] );
00245 }
00246 for( unsigned int i=0; i<nEtfPar; i++ ) {
00247 sprintf( etfname, "P%i", i+nEtfPar );
00248 etftree -> SetBranchAddress( etfname, &cnvEtfPar1[i] );
00249 }
00250 for( unsigned int i=0; i<nEtfPar; i++ ) {
00251 sprintf( etfname, "P%i", i+2*nEtfPar );
00252 etftree -> SetBranchAddress( etfname, &cnvEtfPar2[i] );
00253 }
00254
00255 for(cnt=0; cnt<(72*12); cnt++){
00256 etftree -> GetEntry(cnt);
00257 etf.setSpeed( cnvEtfSpeed );
00258 etf.setP( cnvEtfPar );
00259 etf.setP1( cnvEtfPar1 );
00260 etf.setP2( cnvEtfPar2 );
00261 tmpetf.push_back(etf);
00262 }
00263 }
00264
00265
00266 double cnvEtfBunchP[nEtfBunch];
00267
00268 if( NULL!=m_inFile->Get("EtfTofBunch") ) {
00269 TTree *etfbunchtree = (TTree*)m_inFile -> Get("EtfTofBunch");
00270
00271 char etfbunchname[10];
00272 for( unsigned int i=0; i<nEtfBunch; i++ ) {
00273 sprintf( etfbunchname, "pbunch%i", i );
00274 etfbunchtree -> SetBranchAddress( etfbunchname, &cnvEtfBunchP[i] );
00275 }
00276
00277 int entries= etfbunchtree->GetEntries();
00278 for(cnt=0;cnt<entries;cnt++){
00279 etfbunchtree -> GetEntry(cnt);
00280 etfBunch.setPBunch( cnvEtfBunchP );
00281 tmpetfBunch.push_back( etfBunch );
00282 }
00283 }
00284
00285
00286 double cnvBarSigCor[nBarSigCor];
00287 double cnvBarOffset[nBarOffset];
00288 TTree *btofcommontree = (TTree*)m_inFile -> Get("BarTofParCommon");
00289 for( unsigned int i=0; i<nBarSigCor; i++ ) {
00290 sprintf( brname, "sigmaCorr%i", i );
00291 btofcommontree-> SetBranchAddress( brname, &cnvBarSigCor[i] );
00292 }
00293 for( unsigned int i=0; i<nBarOffset; i++ ) {
00294 sprintf( brname, "t0offset%i", i );
00295 btofcommontree-> SetBranchAddress( brname, &cnvBarOffset[i]);
00296 }
00297
00298 int entries = btofcommontree->GetEntries();
00299 for(cnt=0;cnt<entries;cnt++){
00300 btofcommontree->GetEntry(cnt);
00301 bTofCommon.setSigmaCorr( cnvBarSigCor );
00302 bTofCommon.setOffset( cnvBarOffset );
00303 tmpbTofCommon.push_back(bTofCommon);
00304 }
00305
00306 int m_run1, m_run2, m_version;
00307 int m_qCorr, m_qElec, m_misLable;
00308 int m_tofidEast[5], m_tofidWest[5], m_tofidEndcap[5];
00309
00310 TTree *CalibInfo = (TTree*)m_inFile -> Get("CalibInfo");
00311 CalibInfo->SetBranchAddress("Run1", &m_run1 );
00312 CalibInfo->SetBranchAddress("Run2", &m_run2 );
00313 CalibInfo->SetBranchAddress("Version", &m_version );
00314 CalibInfo->SetBranchAddress("ebrId0", &m_tofidEast[0] );
00315 CalibInfo->SetBranchAddress("ebrId1", &m_tofidEast[1] );
00316 CalibInfo->SetBranchAddress("ebrId2", &m_tofidEast[2] );
00317 CalibInfo->SetBranchAddress("ebrId3", &m_tofidEast[3] );
00318 CalibInfo->SetBranchAddress("ebrId4", &m_tofidEast[4] );
00319 CalibInfo->SetBranchAddress("ecId0", &m_tofidEndcap[0] );
00320 CalibInfo->SetBranchAddress("ecId1", &m_tofidEndcap[1] );
00321 CalibInfo->SetBranchAddress("ecId2", &m_tofidEndcap[2] );
00322 CalibInfo->SetBranchAddress("ecId3", &m_tofidEndcap[3] );
00323 CalibInfo->SetBranchAddress("ecId4", &m_tofidEndcap[4] );
00324 CalibInfo->SetBranchAddress("wbrId0", &m_tofidWest[0] );
00325 CalibInfo->SetBranchAddress("wbrId1", &m_tofidWest[1] );
00326 CalibInfo->SetBranchAddress("wbrId2", &m_tofidWest[2] );
00327 CalibInfo->SetBranchAddress("wbrId3", &m_tofidWest[3] );
00328 CalibInfo->SetBranchAddress("wbrId4", &m_tofidWest[4] );
00329 CalibInfo->SetBranchAddress("misLable",&m_misLable );
00330 CalibInfo->SetBranchAddress("qCorr", &m_qCorr );
00331 CalibInfo->SetBranchAddress("qElec", &m_qElec );
00332
00333 entries= CalibInfo->GetEntries();
00334 for(cnt=0;cnt<entries;cnt++){
00335 CalibInfo->GetEntry(cnt);
00336 tofinfo.setRunBegin(m_run1);
00337 tofinfo.setRunEnd(m_run2);
00338 tofinfo.setVersion(m_version);
00339 tofinfo.setQCorr(m_qCorr);
00340 tofinfo.setQElec(m_qElec);
00341 tofinfo.setMisLable(m_misLable);
00342 tofinfo.setBrEast(m_tofidEast);
00343 tofinfo.setBrWest(m_tofidWest);
00344 tofinfo.setEndcap(m_tofidEndcap);
00345 tofinfoCol.push_back(tofinfo);
00346 }
00347
00348 CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tmpetf,&tmpetfBunch,&tofinfoCol);
00349
00350 refpObject=tmpObject;
00351
00352 return StatusCode::SUCCESS;
00353 }
00354
00355 StatusCode RootTofCalibDataCnv::createRoot(const std::string& fname,
00356 CalibData::CalibBase1* pTDSObj) {
00357 MsgStream log(msgSvc(), "RootTofCalibDataCnv");
00358
00359
00360 StatusCode sc = openWrite(fname);
00361 if(!sc)
00362 { log<<MSG::ERROR<<"unable to open files"<<endreq;
00363 }
00364
00365 int j;
00366 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
00367
00368
00369 double cnvBarAtten[nBarAtten];
00370 double cnvBarSpeed[nBarSpeed];
00371 double cnvBarPar1[nBarPar];
00372 double cnvBarPar2[nBarPar];
00373 double cnvBarParOff1_bunch0[nBarParOff];
00374 double cnvBarParOff2_bunch0[nBarParOff];
00375 double cnvBarParOff1_bunch1[nBarParOff];
00376 double cnvBarParOff2_bunch1[nBarParOff];
00377 double cnvBarParOff1_bunch2[nBarParOff];
00378 double cnvBarParOff2_bunch2[nBarParOff];
00379 double cnvBarParOff1_bunch3[nBarParOff];
00380 double cnvBarParOff2_bunch3[nBarParOff];
00381 double cnvFLeft[nBarSigma];
00382 double cnvFRight[nBarSigma];
00383 double cnvFCount[nBarSigCnt];
00384
00385 char brname[8], ibrname[8];
00386 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
00387 for( unsigned int i=0; i<nBarAtten; i++ ) {
00388 sprintf( brname, "Atten%i", i );
00389 sprintf( ibrname, "Atten%i/D", i );
00390 btoftree -> Branch( brname, &cnvBarAtten[i], ibrname );
00391 }
00392 for( unsigned int i=0; i<nBarSpeed; i++ ) {
00393 sprintf( brname, "Speed%i", i );
00394 sprintf( ibrname, "Speed%i/D", i );
00395 btoftree -> Branch( brname, &cnvBarSpeed[i], ibrname );
00396 }
00397 for( unsigned int i=0; i<nBarPar; i++ ) {
00398 sprintf( brname, "P%i", i );
00399 sprintf( ibrname, "P%i/D", i );
00400 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
00401 }
00402 for( unsigned int i=0; i<nBarPar; i++ ) {
00403 sprintf( brname, "P%i", i+nBarPar );
00404 sprintf( ibrname, "P%i/D", i+nBarPar );
00405 btoftree -> Branch( brname, &cnvBarPar2[i], ibrname );
00406 }
00407 for( unsigned int i=0; i<nBarParOff; i++ ) {
00408 sprintf( brname, "Bunch0_Poff%i", i );
00409 sprintf( ibrname, "Bunch0_Poff%i/D", i );
00410 btoftree -> Branch( brname, &cnvBarParOff1_bunch0[i], ibrname );
00411 }
00412 for( unsigned int i=0; i<nBarParOff; i++ ) {
00413 sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
00414 sprintf( ibrname, "Bunch0_Poff%i/D", i+nBarParOff );
00415 btoftree -> Branch( brname, &cnvBarParOff2_bunch0[i], ibrname );
00416 }
00417 for( unsigned int i=0; i<nBarParOff; i++ ) {
00418 sprintf( brname, "Bunch1_Poff%i", i );
00419 sprintf( ibrname, "Bunch1_Poff%i/D", i );
00420 btoftree -> Branch( brname, &cnvBarParOff1_bunch1[i], ibrname );
00421 }
00422 for( unsigned int i=0; i<nBarParOff; i++ ) {
00423 sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
00424 sprintf( ibrname, "Bunch1_Poff%i/D", i+nBarParOff );
00425 btoftree -> Branch( brname, &cnvBarParOff2_bunch1[i], ibrname );
00426 }
00427 for( unsigned int i=0; i<nBarParOff; i++ ) {
00428 sprintf( brname, "Bunch2_Poff%i", i );
00429 sprintf( ibrname, "Bunch2_Poff%i/D", i );
00430 btoftree -> Branch( brname, &cnvBarParOff1_bunch2[i], ibrname );
00431 }
00432 for( unsigned int i=0; i<nBarParOff; i++ ) {
00433 sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
00434 sprintf( ibrname, "Bunch2_Poff%i/D", i+nBarParOff );
00435 btoftree -> Branch( brname, &cnvBarParOff2_bunch2[i], ibrname );
00436 }
00437 for( unsigned int i=0; i<nBarParOff; i++ ) {
00438 sprintf( brname, "Bunch3_Poff%i", i );
00439 sprintf( ibrname, "Bunch3_Poff%i/D", i );
00440 btoftree -> Branch( brname, &cnvBarParOff1_bunch3[i], ibrname );
00441 }
00442 for( unsigned int i=0; i<nBarParOff; i++ ) {
00443 sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
00444 sprintf( ibrname, "Bunch3_Poff%i/D", i+nBarParOff );
00445 btoftree -> Branch( brname, &cnvBarParOff2_bunch3[i], ibrname );
00446 }
00447 for( unsigned int i=0; i<nBarSigma; i++ ) {
00448 sprintf( brname, "FLeft%i", i );
00449 sprintf( ibrname, "FLeft%i/D", i );
00450 btoftree -> Branch( brname, &cnvFLeft[i], ibrname );
00451 }
00452 for( unsigned int i=0; i<nBarSigma; i++ ) {
00453 sprintf( brname, "FRight%i", i );
00454 sprintf( ibrname, "FRight%i/D", i );
00455 btoftree -> Branch( brname, &cnvFRight[i], ibrname );
00456 }
00457 for( unsigned int i=0; i<nBarSigCnt; i++ ) {
00458 sprintf( brname, "FCounter%i", i );
00459 sprintf( ibrname, "FCounter%i/D", i );
00460 btoftree -> Branch( brname, &cnvFCount[i], ibrname );
00461 }
00462
00463 for( int i=0; i<176; i++ ) {
00464 for(j=0;j<static_cast<int>(nBarAtten);j++) {
00465 cnvBarAtten[j] = btof->getBTofAtten(i,j);
00466 }
00467 for(j=0;j<static_cast<int>(nBarSpeed);j++) {
00468 cnvBarSpeed[j] = btof->getBTofSpeed(i,j);
00469 }
00470 for(j=0;j<static_cast<int>(nBarPar);j++){
00471 cnvBarPar1[j] = btof->getBTofPleft(i,j);
00472 cnvBarPar2[j] = btof->getBTofPright(i,j);
00473 }
00474 for(j=0;j<static_cast<int>(nBarParOff);j++){
00475 cnvBarParOff1_bunch0[j] = btof->getBTofPoffleft_bunch0(i,j);
00476 cnvBarParOff2_bunch0[j] = btof->getBTofPoffright_bunch0(i,j);
00477 }
00478 for(j=0;j<static_cast<int>(nBarParOff);j++){
00479 cnvBarParOff1_bunch1[j] = btof->getBTofPoffleft_bunch1(i,j);
00480 cnvBarParOff2_bunch1[j] = btof->getBTofPoffright_bunch1(i,j);
00481 }
00482 for(j=0;j<static_cast<int>(nBarParOff);j++){
00483 cnvBarParOff1_bunch2[j] = btof->getBTofPoffleft_bunch2(i,j);
00484 cnvBarParOff2_bunch2[j] = btof->getBTofPoffright_bunch2(i,j);
00485 }
00486 for(j=0;j<static_cast<int>(nBarParOff);j++){
00487 cnvBarParOff1_bunch3[j] = btof->getBTofPoffleft_bunch3(i,j);
00488 cnvBarParOff2_bunch3[j] = btof->getBTofPoffright_bunch3(i,j);
00489 }
00490 for(j=0;j<static_cast<int>(nBarSigma);j++){
00491 cnvFLeft[j] = btof->getBTofFleft(i,j);
00492 cnvFRight[j] = btof->getBTofFright(i,j);
00493 }
00494 for(j=0;j<static_cast<int>(nBarSigCnt);j++){
00495 cnvFCount[j] = btof->getBTofFcounter(i,j);
00496 }
00497 btoftree -> Fill();
00498 }
00499
00500
00501 double cnvEndAtten[nEndAtten];
00502 double cnvEndSpeed[nEndSpeed];
00503 double cnvEndPar[nEndPar];
00504 double cnvEndFPar[nEndSigma];
00505
00506 char ecname[8], iecname[8];
00507 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
00508 for( unsigned int i=0; i<nEndAtten; i++ ) {
00509 sprintf( ecname, "Atten%i", i );
00510 sprintf( iecname, "Atten%i/D", i );
00511 etoftree -> Branch( ecname, &cnvEndAtten[i], iecname );
00512 }
00513 for( unsigned int i=0; i<nEndSpeed; i++ ) {
00514 sprintf( ecname, "Speed%i", i );
00515 sprintf( iecname, "Speed%i/D", i );
00516 etoftree -> Branch( ecname, &cnvEndSpeed[i], iecname );
00517 }
00518 for( unsigned int i=0; i<nEndPar; i++ ) {
00519 sprintf( ecname, "P%i", i );
00520 sprintf( iecname, "P%i/D", i );
00521 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
00522 }
00523 for( unsigned int i=0; i<nEndSigma; i++ ) {
00524 sprintf( ecname, "FCounter%i", i );
00525 sprintf( iecname, "FCounter%i/D", i );
00526 etoftree -> Branch( ecname, &cnvEndFPar[i], iecname );
00527 }
00528
00529 for(int i=0; i<96; i++){
00530 for(j=0;j<static_cast<int>(nEndAtten);j++) {
00531 cnvEndAtten[j] = btof->getETofAtten(i,j);
00532 }
00533 for(j=0;j<static_cast<int>(nEndSpeed);j++) {
00534 cnvEndSpeed[j] = btof->getETofSpeed(i,j);
00535 }
00536 for(j=0;j<static_cast<int>(nEndPar);j++){
00537 cnvEndPar[j] = btof->getETofP(i,j);
00538 }
00539 for(j=0;j<static_cast<int>(nEndSigma);j++){
00540 cnvEndFPar[j] = btof->getETofFP(i,j);
00541 }
00542 etoftree -> Fill();
00543 }
00544
00545
00546 double cnvEtfSpeed[nEtfSpeed];
00547 double cnvEtfPar[nEtfPar];
00548 double cnvEtfPar1[nEtfPar];
00549 double cnvEtfPar2[nEtfPar];
00550
00551 char etfname[8], ietfname[8];
00552 TTree *etftree = new TTree("EtfTofPar", "EtfTofPar");
00553 for( unsigned int i=0; i<nEtfSpeed; i++ ) {
00554 sprintf( etfname, "Speed%i", i );
00555 sprintf( ietfname, "Speed%i/D", i );
00556 etftree -> Branch( etfname, &cnvEtfSpeed[i], ietfname );
00557 }
00558 for( unsigned int i=0; i<nEtfPar; i++ ) {
00559 sprintf( etfname, "P%i", i );
00560 sprintf( ietfname, "P%i/D", i );
00561 etftree -> Branch( etfname, &cnvEtfPar[i], ietfname );
00562 }
00563 for( unsigned int i=0; i<nEtfPar; i++ ) {
00564 sprintf( etfname, "P%i", i+nEtfPar );
00565 sprintf( ietfname, "P%i/D", i+nEtfPar );
00566 etftree -> Branch( etfname, &cnvEtfPar1[i], ietfname );
00567 }
00568 for( unsigned int i=0; i<nEtfPar; i++ ) {
00569 sprintf( etfname, "P%i", i+2*nEtfPar );
00570 sprintf( ietfname, "P%i/D", i+2*nEtfPar );
00571 etftree -> Branch( etfname, &cnvEtfPar2[i], ietfname );
00572 }
00573
00574 for( int i=0; i<72; i++ ) {
00575 for( int k=0; k<12; k++ ) {
00576 for(j=0;j<static_cast<int>(nEtfSpeed);j++) {
00577 cnvEtfSpeed[j] = btof->getEtfSpeed(i,k,j);
00578 }
00579 for(j=0;j<static_cast<int>(nEtfPar);j++){
00580 cnvEtfPar[j] = btof->getEtfPcombine(i,k,j);
00581 cnvEtfPar1[j] = btof->getEtfPleft(i,k,j);
00582 cnvEtfPar2[j] = btof->getEtfPright(i,k,j);
00583 }
00584 etftree -> Fill();
00585 }
00586 }
00587
00588
00589 double cnvEtfBunchP[nEtfBunch];
00590
00591 char etfbunchname[8], ietfbunchname[8];
00592 TTree *etfbunchtree = new TTree("EtfTofBunch", "EtfTofBunch");
00593 for( unsigned int i=0; i<nEtfBunch; i++ ) {
00594 sprintf( etfbunchname, "pbunch%i", i );
00595 sprintf( ietfbunchname, "pbunch%i/D", i );
00596 etfbunchtree -> Branch( etfbunchname, &cnvEtfBunchP[i], ietfbunchname );
00597 }
00598
00599 for(j=0;j<static_cast<int>(nEtfBunch);j++) {
00600 cnvEtfBunchP[j] = btof->getEtfPBunch(j);
00601 }
00602 etfbunchtree -> Fill();
00603
00604
00605
00606 btoftree -> Write();
00607 etoftree -> Write();
00608 etftree -> Write();
00609 etfbunchtree -> Write();
00610 delete btoftree;
00611 delete etoftree;
00612 delete etftree;
00613 delete etfbunchtree;
00614 closeWrite();
00615 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
00616
00617 return sc;
00618 }