00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00036
00037
00038
00039
00040 #include "UseTof.h"
00041 #include "TFile.h"
00042 #include "TTree.h"
00043 #include "TDirectory.h"
00044 #include "TObject.h"
00045
00046 UseTof::UseTof( const std::string& name,
00047 ISvcLocator* pSvcLocator )
00048 : Algorithm ( name, pSvcLocator ), m_pCalibDataSvc(0)
00049 {
00050
00051
00052 }
00053
00054
00055 StatusCode UseTof::initialize() {
00056 StatusCode sc;
00057 MsgStream log(msgSvc(), name());
00058 log << MSG::INFO << "Initialize()" << endreq;
00059
00060
00061
00062
00063 log<<MSG::INFO << "setProperties()" << endreq;
00064
00065 sc = service("CalibDataSvc", m_pCalibDataSvc, true);
00066
00067 if ( !sc.isSuccess() ) {
00068 log << MSG::ERROR
00069 << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
00070 << endreq;
00071 return sc;
00072 } else {
00073 log << MSG::DEBUG
00074 << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc"
00075 << endreq;
00076 }
00077
00078 sc = service("CalibRootCnvSvc", m_pRootSvc, true);
00079 if ( !sc.isSuccess() ) {
00080 log << MSG::ERROR
00081 << "Could not get ICalibRootSvc interface of CalibRootCnvSvc"
00082 << endreq;
00083 return sc;
00084 }
00085
00086
00087 sc = setProperties();
00088
00089 return StatusCode::SUCCESS;
00090
00091 }
00092
00093
00094 StatusCode UseTof::execute( ) {
00095
00096 MsgStream log(msgSvc(), name());
00097
00098
00099
00100 std::string fullPath = "/Calib/TofCal";
00101 log << MSG::INFO<<"execute() fullPath = "<<fullPath<< endreq;
00102
00103 SmartDataPtr<CalibData::TofCalibData> btof(m_pCalibDataSvc, fullPath);
00104
00105 TFile *f1 = new TFile("TofCalConst.root","read");
00106
00107 TTree *btoftree = (TTree*)f1 -> Get("BarTofPar");
00108 double fCount[10];
00109 double fLeft[5];
00110 double fRight[5];
00111 btoftree ->SetBranchAddress("FCounter0",&fCount[0]);
00112 btoftree ->SetBranchAddress("FCounter1",&fCount[1]);
00113 btoftree ->SetBranchAddress("FCounter2",&fCount[2]);
00114 btoftree ->SetBranchAddress("FCounter3",&fCount[3]);
00115 btoftree ->SetBranchAddress("FCounter4",&fCount[4]);
00116 btoftree ->SetBranchAddress("FCounter5",&fCount[5]);
00117 btoftree ->SetBranchAddress("FCounter6",&fCount[6]);
00118 btoftree ->SetBranchAddress("FCounter7",&fCount[7]);
00119 btoftree ->SetBranchAddress("FCounter8",&fCount[8]);
00120 btoftree ->SetBranchAddress("FCounter9",&fCount[9]);
00121 btoftree->SetBranchAddress("FLeft0",&fLeft[0]);
00122 btoftree->SetBranchAddress("FLeft1",&fLeft[1]);
00123 btoftree->SetBranchAddress("FLeft2",&fLeft[2]);
00124 btoftree->SetBranchAddress("FLeft3",&fLeft[3]);
00125 btoftree->SetBranchAddress("FLeft4",&fLeft[4]);
00126 btoftree->SetBranchAddress("FRight0",&fRight[0]);
00127 btoftree->SetBranchAddress("FRight1",&fRight[1]);
00128 btoftree->SetBranchAddress("FRight2",&fRight[2]);
00129 btoftree->SetBranchAddress("FRight3",&fRight[3]);
00130 btoftree->SetBranchAddress("FRight4",&fRight[4]);
00131
00132
00133
00134 for(int i =0;i<176;i++)
00135 {
00136 btoftree -> GetEntry(i);
00137
00138 double bAtten0 = btof->getBTofAtten(i,0);
00139 double bAtten1 = btof->getBTofAtten(i,1);
00140 double bP0 = btof->getBTofPleft(i,0);
00141 double bP1 = btof->getBTofPleft(i,1);
00142 double bP2 = btof->getBTofPleft(i,2);
00143 double bP3 = btof->getBTofPleft(i,3);
00144 double bP4 = btof->getBTofPleft(i,4);
00145 double bP5 = btof->getBTofPleft(i,5);
00146 double bP10 = btof->getBTofPright(i,0);
00147
00148
00149 double bSpeed0 = btof->getBTofSpeed(i,0);
00150 double bSpeed1 = btof->getBTofSpeed(i,1);
00151
00152
00153
00154
00155
00156
00157 double fCount1[10],fLeft1[5],fRight1[5];
00158 for(int j=0;j<10;j++){
00159 fCount1[j]=btof->getBTofFcounter(i,j);
00160 if(fCount1[j]!=fCount[j]) std::cout<<"error error error error"<<std::endl;
00161
00162
00163 }
00164
00165 for(int j=0;j<5;j++){
00166 fLeft1[j]=btof->getBTofFleft(i,j);
00167 if(fLeft1[j]!=fLeft[j]) std::cout<<"error error error error"<<std::endl;
00168
00169 }
00170
00171
00172 for(int j=0;j<5;j++){
00173 fRight1[j]=btof->getBTofFright(i,j);
00174 if( fRight1[j]!= fRight[j]) std::cout<<"error error error error"<<std::endl;
00175
00176 }
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 }
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 double sigma[8];
00269
00270 for(int i=0;i<8;i++){
00271 sigma[i]=btof->getBTofSigmaCorr(i);
00272 std::cout<<" sigma["<<i<<"]="<< sigma[i];
00273 }
00274 std::cout<<"\n";
00275
00276 std::cout<<"t0offset0 ="<< btof->getBTofOffset(0)<<" t0offset1 ="<< btof->getBTofOffset(1)<<std::endl;
00277
00278 std::cout<<" btof->getRunBegin()"<<btof->getRunBegin();
00279 std::cout<<"btof->getRunEnd()"<<btof->getRunEnd();
00280 std::cout<<"btof->getVersion()"<<btof->getVersion();
00281 std::cout<<"btof->getQCorr()"<<btof->getQCorr();
00282 std::cout<<"btof->getMisLable()"<<btof->getMisLable();
00283 std::cout<<"btof->getQElec()"<<btof->getQElec();
00284 for(int i=0;i<5;i++){
00285 std::cout<<"i==="<<i<<std::endl;
00286 std::cout<<" btof->getBrEast(int index)"<<btof->getBrEast(i);
00287 std::cout<<" btof->getBrWest(int index)"<<btof->getBrWest(i);
00288 std::cout<<" btof->getEndcap(int index)"<<btof->getEndcap(i);
00289 }
00290
00291
00292
00293 return StatusCode::SUCCESS;
00294 }
00295
00296
00297
00298 StatusCode UseTof::finalize( ) {
00299
00300 MsgStream log(msgSvc(), name());
00301 log << MSG::INFO
00302 << " UseTof FINALIZE!! "
00303 << endreq;
00304
00305 return StatusCode::SUCCESS;
00306 }
00307
00308