00001 #include "GaudiKernel/MsgStream.h"
00002 #include "TreeTofQElecCnv.h"
00003 #include "CalibData/Tof/TofElecData.h"
00004 #include "CalibDataSvc/IInstrumentName.h"
00005 #include "CalibMySQLCnv/TreeAddress.h"
00006 #include "TFile.h"
00007 #include "TTree.h"
00008 #include "TDirectory.h"
00009 #include "TObject.h"
00010 #include "TBuffer.h"
00011
00012 #include "GaudiKernel/CnvFactory.h"
00013 #include "GaudiKernel/IOpaqueAddress.h"
00014 #include "GaudiKernel/DataObject.h"
00015 #include "GaudiKernel/IAddressCreator.h"
00016 #include "GaudiKernel/IDataProviderSvc.h"
00017 #include "GaudiKernel/IConversionSvc.h"
00018 #include "GaudiKernel/GenericAddress.h"
00019
00020 #include "CalibDataSvc/ICalibTreeSvc.h"
00021 #include "CalibDataSvc/ICalibMetaCnvSvc.h"
00022
00023
00024 #include "CalibData/CalibModel.h"
00025 using namespace CalibData;
00026
00027
00028
00029
00030
00031 TreeTofElecDataCnv::TreeTofElecDataCnv( ISvcLocator* svc) :
00032 TreeCalBaseCnv(svc, CLID_TofQ_Elec) {
00033
00034 }
00035
00036
00037 const CLID& TreeTofElecDataCnv::objType() const {
00038 return CLID_TofQ_Elec;
00039 }
00040
00041 const CLID& TreeTofElecDataCnv::classID() {
00042 return CLID_TofQ_Elec;
00043 }
00044
00045 StatusCode TreeTofElecDataCnv::i_createObj(IOpaqueAddress* addr,
00046 DataObject*& refpObject) {
00047
00048 MsgStream log(msgSvc(), "TreeTofElecDataCnv");
00049 log<<MSG::DEBUG<<"SetProperty"<<endreq;
00050
00051 TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
00052 DatabaseRecord *records=add->pp();
00053
00054 TBufferFile *buf1 = new TBufferFile(TBuffer::kRead);
00055 TBufferFile *buf2 = new TBufferFile(TBuffer::kRead);
00056 TBufferFile *buf3 = new TBufferFile(TBuffer::kRead);
00057 TBufferFile *buf4 = new TBufferFile(TBuffer::kRead);
00058 TBufferFile *buf5 = new TBufferFile(TBuffer::kRead);
00059 TBufferFile *buf6 = new TBufferFile(TBuffer::kRead);
00060 TBufferFile *buf7 = new TBufferFile(TBuffer::kRead);
00061 TBufferFile *buf8 = new TBufferFile(TBuffer::kRead);
00062
00063 buf1->SetBuffer((*records)["BarBoardNum"],512000,kFALSE);
00064 buf2->SetBuffer((*records)["EndBoardNum"],512000,kFALSE);
00065 buf3->SetBuffer((*records)["QELecBarParEast"],512000,kFALSE);
00066 buf4->SetBuffer((*records)["QELecBarParWest"],512000,kFALSE);
00067 buf5->SetBuffer((*records)["QELecEndPar"],512000,kFALSE);
00068 buf6->SetBuffer((*records)["SimQELecBarParEast"],512000,kFALSE);
00069 buf7->SetBuffer((*records)["SimQELecBarParWest"],512000,kFALSE);
00070 buf8->SetBuffer((*records)["SimQELecEndPar"],512000,kFALSE);
00071
00072 std::cout<<" SftVer is "<<(*records)["SftVer"];
00073 std::cout<<" CalVerSft is "<<(*records)["CalParVer"];
00074 std::cout<<" File name is "<<(*records)["FileName"]<<std::endl;
00075
00076
00077 TTree *BarBoardNum= new TTree();
00078 TTree *EndBoardNum= new TTree();
00079 TTree *QElecBarParEast = new TTree();
00080 TTree *QElecBarParWest = new TTree();
00081 TTree *QElecEndPar = new TTree();
00082 TTree *SimQElecBarParEast = new TTree();
00083 TTree *SimQElecBarParWest = new TTree();
00084 TTree *SimQElecEndPar = new TTree();
00085 BarBoardNum->Streamer(*buf1);
00086 EndBoardNum->Streamer(*buf2);
00087 QElecBarParEast->Streamer(*buf3);
00088 QElecBarParWest->Streamer(*buf4);
00089 QElecEndPar->Streamer(*buf5);
00090 SimQElecBarParEast->Streamer(*buf6);
00091 SimQElecBarParWest->Streamer(*buf7);
00092 SimQElecEndPar->Streamer(*buf8);
00093
00094
00095 CalibData::BarrelElec bTof;
00096 CalibData::EndcapElec eTof;
00097
00098 std::vector<CalibData::BarrelElec> tmpbTof;
00099 std::vector<CalibData::EndcapElec> tmpeTof;
00100
00101
00102 int cnt;
00103
00104 unsigned int num[4];
00105 double num1[4];
00106 BarBoardNum -> SetBranchAddress("Board", &num1[0]);
00107 BarBoardNum -> SetBranchAddress("Channel", &num1[1]);
00108 BarBoardNum -> SetBranchAddress("Crate", &num1[2]);
00109 BarBoardNum -> SetBranchAddress("Fee", &num1[3]);
00110 double p[11];
00111 QElecBarParEast->SetBranchAddress("P0",&p[0]);
00112 QElecBarParEast->SetBranchAddress("P1",&p[1]);
00113 QElecBarParEast->SetBranchAddress("P2",&p[2]);
00114 QElecBarParEast->SetBranchAddress("P3",&p[3]);
00115 QElecBarParEast->SetBranchAddress("P4",&p[4]);
00116 QElecBarParEast->SetBranchAddress("P5",&p[5]);
00117 QElecBarParEast->SetBranchAddress("P6",&p[6]);
00118 QElecBarParEast->SetBranchAddress("P7",&p[7]);
00119 QElecBarParEast->SetBranchAddress("P8",&p[8]);
00120 QElecBarParEast->SetBranchAddress("P9",&p[9]);
00121 QElecBarParEast->SetBranchAddress("P10",&p[10]);
00122 double p_w[11];
00123 QElecBarParWest->SetBranchAddress("P0",&p_w[0]);
00124 QElecBarParWest->SetBranchAddress("P1",&p_w[1]);
00125 QElecBarParWest->SetBranchAddress("P2",&p_w[2]);
00126 QElecBarParWest->SetBranchAddress("P3",&p_w[3]);
00127 QElecBarParWest->SetBranchAddress("P4",&p_w[4]);
00128 QElecBarParWest->SetBranchAddress("P5",&p_w[5]);
00129 QElecBarParWest->SetBranchAddress("P6",&p_w[6]);
00130 QElecBarParWest->SetBranchAddress("P7",&p_w[7]);
00131 QElecBarParWest->SetBranchAddress("P8",&p_w[8]);
00132 QElecBarParWest->SetBranchAddress("P9",&p_w[9]);
00133 QElecBarParWest->SetBranchAddress("P10",&p_w[10]);
00134 double p_se[11];
00135 SimQElecBarParEast->SetBranchAddress("P0",&p_se[0]);
00136 SimQElecBarParEast->SetBranchAddress("P1",&p_se[1]);
00137 SimQElecBarParEast->SetBranchAddress("P2",&p_se[2]);
00138 SimQElecBarParEast->SetBranchAddress("P3",&p_se[3]);
00139 SimQElecBarParEast->SetBranchAddress("P4",&p_se[4]);
00140 SimQElecBarParEast->SetBranchAddress("P5",&p_se[5]);
00141 SimQElecBarParEast->SetBranchAddress("P6",&p_se[6]);
00142 SimQElecBarParEast->SetBranchAddress("P7",&p_se[7]);
00143 SimQElecBarParEast->SetBranchAddress("P8",&p_se[8]);
00144 SimQElecBarParEast->SetBranchAddress("P9",&p_se[9]);
00145 SimQElecBarParEast->SetBranchAddress("P10",&p_se[10]);
00146 double p_sw[11];
00147 SimQElecBarParWest->SetBranchAddress("P0",&p_sw[0]);
00148 SimQElecBarParWest->SetBranchAddress("P1",&p_sw[1]);
00149 SimQElecBarParWest->SetBranchAddress("P2",&p_sw[2]);
00150 SimQElecBarParWest->SetBranchAddress("P3",&p_sw[3]);
00151 SimQElecBarParWest->SetBranchAddress("P4",&p_sw[4]);
00152 SimQElecBarParWest->SetBranchAddress("P5",&p_sw[5]);
00153 SimQElecBarParWest->SetBranchAddress("P6",&p_sw[6]);
00154 SimQElecBarParWest->SetBranchAddress("P7",&p_sw[7]);
00155 SimQElecBarParWest->SetBranchAddress("P8",&p_sw[8]);
00156 SimQElecBarParWest->SetBranchAddress("P9",&p_sw[9]);
00157 SimQElecBarParWest->SetBranchAddress("P10",&p_sw[10]);
00158
00159 for(cnt=0; cnt<352; cnt++){
00160 BarBoardNum -> GetEntry(cnt);
00161 num[0]=num1[0];
00162 num[1]=num1[1];
00163 num[2]=num1[2];
00164 num[3]=num1[3];
00165 if(cnt%2!=0){
00166 bTof.setNumWest(num);
00167 }
00168 if(cnt%2==0){
00169 bTof.setNumEast(num);
00170 int kkk=cnt/2;
00171 QElecBarParEast->GetEntry(kkk);
00172 QElecBarParWest->GetEntry(kkk);
00173 SimQElecBarParEast->GetEntry(kkk);
00174 SimQElecBarParWest->GetEntry(kkk);
00175 bTof.setP1(p);
00176 bTof.setP2(p_w);
00177 bTof.setSimP1(p_se);
00178 bTof.setSimP2(p_sw);
00179 }
00180 if(cnt%2!=0)
00181 tmpbTof.push_back(bTof);
00182 }
00183
00184
00185 EndBoardNum -> SetBranchAddress("Board", &num1[0]);
00186 EndBoardNum -> SetBranchAddress("Channel", &num1[1]);
00187 EndBoardNum -> SetBranchAddress("Crate", &num1[2]);
00188 EndBoardNum -> SetBranchAddress("Fee", &num1[3]);
00189 QElecEndPar-> SetBranchAddress("P0",&p[0]);
00190 QElecEndPar->SetBranchAddress("P1",&p[1]);
00191 QElecEndPar->SetBranchAddress("P2",&p[2]);
00192 QElecEndPar->SetBranchAddress("P3",&p[3]);
00193 QElecEndPar->SetBranchAddress("P4",&p[4]);
00194 QElecEndPar->SetBranchAddress("P5",&p[5]);
00195 QElecEndPar->SetBranchAddress("P6",&p[6]);
00196 QElecEndPar->SetBranchAddress("P7",&p[7]);
00197 QElecEndPar->SetBranchAddress("P8",&p[8]);
00198 QElecEndPar->SetBranchAddress("P9",&p[9]);
00199 QElecEndPar->SetBranchAddress("P10",&p[10]);
00200 SimQElecEndPar-> SetBranchAddress("P0",&p_w[0]);
00201 SimQElecEndPar->SetBranchAddress("P1",&p_w[1]);
00202 SimQElecEndPar->SetBranchAddress("P2",&p_w[2]);
00203 SimQElecEndPar->SetBranchAddress("P3",&p_w[3]);
00204 SimQElecEndPar->SetBranchAddress("P4",&p_w[4]);
00205 SimQElecEndPar->SetBranchAddress("P5",&p_w[5]);
00206 SimQElecEndPar->SetBranchAddress("P6",&p_w[6]);
00207 SimQElecEndPar->SetBranchAddress("P7",&p_w[7]);
00208 SimQElecEndPar->SetBranchAddress("P8",&p_w[8]);
00209 SimQElecEndPar->SetBranchAddress("P9",&p_w[9]);
00210 SimQElecEndPar->SetBranchAddress("P10",&p_w[10]);
00211 for(cnt=0; cnt<96; cnt++){
00212 EndBoardNum->GetEntry(cnt);
00213 QElecEndPar->GetEntry(cnt);
00214 SimQElecEndPar->GetEntry(cnt);
00215 num[0]=num1[0];
00216 num[1]=num1[1];
00217 num[2]=num1[2];
00218 num[3]=num1[3];
00219
00220 eTof.setNum(num);
00221 eTof.setP(p);
00222 eTof.setSimP(p_w);
00223 tmpeTof.push_back(eTof);
00224 }
00225
00226 CalibData::TofElecData *tmpObject = new CalibData::TofElecData(&tmpbTof,&tmpeTof);
00227
00228
00229 refpObject=tmpObject;
00230 delete BarBoardNum;
00231 delete EndBoardNum;
00232 delete QElecBarParEast;
00233 delete QElecBarParWest;
00234 delete QElecEndPar;
00235 delete SimQElecBarParEast;
00236 delete SimQElecBarParWest;
00237 delete SimQElecEndPar;
00238
00239 return StatusCode::SUCCESS;
00240
00241
00242 }
00243