/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/CalibSvc/CalibTreeCnv/CalibTreeCnv-00-01-18/src/cnv/TreeMdcCalibDataCnv.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/MsgStream.h"
00002 #include "TreeMdcCalibDataCnv.h"
00003 #include "CalibData/Mdc/MdcCalibData.h"
00004 #include "CalibDataSvc/IInstrumentName.h"
00005 #include "CalibMySQLCnv/TreeAddress.h"
00006 #include "TFile.h"
00007 #include "TTree.h"
00008 #include "TObjArray.h"
00009 #include "TDirectory.h"
00010 #include "TObject.h"
00011 #include "TBuffer.h"
00012 
00013 #include "GaudiKernel/CnvFactory.h"
00014 #include "GaudiKernel/IOpaqueAddress.h"
00015 #include "GaudiKernel/DataObject.h"
00016 #include "GaudiKernel/IAddressCreator.h"
00017 #include "GaudiKernel/IDataProviderSvc.h"
00018 #include "GaudiKernel/IConversionSvc.h"
00019 #include "GaudiKernel/GenericAddress.h"
00020 
00021 #include "CalibDataSvc/ICalibTreeSvc.h"    //maybe
00022 #include "CalibDataSvc/ICalibMetaCnvSvc.h"
00023 
00024 // Temporary.  Hope to find a better way to do this
00025 #include "CalibData/CalibModel.h"
00026 using namespace CalibData;
00027 //static CnvFactory<TreeMdcCalibDataCnv> MdcCal_factory;
00028 //const  ICnvFactory& TreeMdcCalibDataCnvFactory = MdcCal_factory;
00029 
00030 
00031 
00032 TreeMdcCalibDataCnv::TreeMdcCalibDataCnv( ISvcLocator* svc) :
00033   TreeCalBaseCnv(svc, CLID_Calib_MdcCal) { 
00034 
00035   }
00036 
00037 
00038 const CLID& TreeMdcCalibDataCnv::objType() const {
00039   return CLID_Calib_MdcCal;
00040 }
00041 
00042 const CLID& TreeMdcCalibDataCnv::classID() {
00043   return CLID_Calib_MdcCal;
00044 }
00045 
00046 StatusCode TreeMdcCalibDataCnv::i_createObj(IOpaqueAddress* addr,
00047     DataObject*& refpObject) {
00048 
00049   MsgStream log(msgSvc(), "TreeMdcCalibDataCnv");
00050   log<<MSG::DEBUG<<"SetProperty"<<endreq;
00051   CalibData::MdcCalibData *tmpObject = new CalibData::MdcCalibData ;  
00052   TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
00053   DatabaseRecord *records=add->pp();
00054 
00055   TBufferFile *buf1 = new TBufferFile(TBuffer::kRead);
00056   TBufferFile *buf2 = new TBufferFile(TBuffer::kRead);
00057   TBufferFile *buf3 = new TBufferFile(TBuffer::kRead);
00058   TBufferFile *buf4 = new TBufferFile(TBuffer::kRead);
00059   TBufferFile *buf5 = new TBufferFile(TBuffer::kRead);
00060   TBufferFile *buf6 = new TBufferFile(TBuffer::kRead);
00061 
00062   buf1->SetBuffer((*records)["XtTree"],512000,kFALSE);
00063   buf2->SetBuffer((*records)["QtTree"],512000,kFALSE);
00064   buf3->SetBuffer((*records)["T0Tree"],512000,kFALSE);
00065   buf4->SetBuffer((*records)["SdTree"],512000,kFALSE);
00066   buf5->SetBuffer((*records)["NewXtTrees"],51200000,kFALSE);
00067   buf6->SetBuffer((*records)["R2tTrees"],25600000,kFALSE);
00068 
00069   std::cout<<" SftVer is "<<(*records)["SftVer"];
00070   std::cout<<"TreeMdcCalibDataCnv: CalVerSft is "<<(*records)["CalParVer"]<<std::endl;
00071   std::cout<<"TreeMdcCalibDataCnv: Calib file name is "<<(*records)["FileName"]<<std::endl;
00072 
00073   TTree* xttree = new TTree(); 
00074   xttree->Streamer(*buf1); 
00075 
00076   TTree* qttree = new TTree(); 
00077   qttree->Streamer(*buf2);
00078 
00079   TTree* t0tree= new TTree(); 
00080   t0tree->Streamer(*buf3); 
00081 
00082   TTree* sdtree = new TTree(); 
00083   sdtree->Streamer(*buf4); 
00084 
00085   TObjArray newxttrees;
00086   DatabaseRecord::iterator it = (*records).find("NewXtTrees");
00087   if(it!=(*records).end()){
00088     if((*it).second!=NULL) {
00089       newxttrees.Streamer(*buf5); 
00090     }
00091   } 
00092 
00093   TObjArray r2ttrees;
00094   it = (*records).find("R2tTrees");
00095   if(it!=(*records).end()){
00096     if((*it).second!=NULL) {
00097       r2ttrees.Streamer(*buf6); 
00098     }
00099   } 
00100   
00101 
00102   // Read in the object
00103   int i;
00104   int nentries;
00105 
00106   //read xttree-----------------------------
00107   double xtpar;
00108   int  xtkey;
00109   xttree -> SetBranchAddress("xtpar", &xtpar);
00110   xttree -> SetBranchAddress("xtkey", &xtkey);
00111   nentries = xttree -> GetEntries();
00112   for(i=0; i<nentries; i++){
00113     xttree -> GetEntry(i);
00114     tmpObject -> setXtpar(xtkey,xtpar);
00115   }
00116 
00117   //read newxttrees-----------------------------
00118   if((43*18*2)==newxttrees.GetEntries()){ 
00119     tmpObject->setNewXtpar(&newxttrees); 
00120     for(int i=0;i<43*18*2;i++){
00121       TTree* tempTree = (TTree*) newxttrees.At(i);
00122       delete tempTree;
00123     }
00124   }
00125   //read r2ttrees-----------------------------
00126   if(43==r2ttrees.GetEntries()){ 
00127     tmpObject->setR2tpar(&r2ttrees); 
00128     for(int i=0;i<43;i++){
00129       TTree* tempTree = (TTree*) r2ttrees.At(i);
00130       delete tempTree;
00131     }
00132   }
00133 
00134   // read t0tree ------------------------------------------------------------
00135   double t0;
00136   double delt0;
00137   t0tree -> SetBranchAddress("t0", &t0);
00138   t0tree -> SetBranchAddress("delt0", &delt0);
00139   nentries = t0tree -> GetEntries();
00140   for(i=0; i<nentries; i++){
00141     t0tree -> GetEntry(i);
00142     tmpObject -> setT0(t0);
00143     tmpObject -> setDelT0(delt0);
00144   }
00145   // read qttree ------------------------------------------------------------
00146   double qtpar0;
00147   double qtpar1;
00148   qttree -> SetBranchAddress("qtpar0", &qtpar0);
00149   qttree -> SetBranchAddress("qtpar1", &qtpar1);
00150   nentries = qttree -> GetEntries();
00151   for(i=0; i<nentries; i++){
00152     qttree -> GetEntry(i);
00153     tmpObject -> setQtpar0(qtpar0);
00154     tmpObject -> setQtpar1(qtpar1);
00155   }
00156 
00157   // read Sdtree ---------------------------------------------------------
00158   double sdpar;
00159   int  sdkey;
00160   sdtree -> SetBranchAddress("sdpar", &sdpar);
00161   sdtree -> SetBranchAddress("sdkey", &sdkey);
00162   nentries = sdtree -> GetEntries();
00163 
00164   for(i=0; i<nentries; i++){
00165     sdtree -> GetEntry(i);
00166     tmpObject -> setSdpar(sdkey,sdpar);
00167   }
00168 
00169   refpObject=tmpObject;
00170   delete xttree;
00171   delete qttree;
00172   delete t0tree;
00173   delete sdtree;
00174 
00175   delete buf1;
00176   delete buf2;
00177   delete buf3;
00178   delete buf4;
00179   delete buf5;
00180   delete buf6;
00181 
00182   return StatusCode::SUCCESS;
00183 
00184 
00185 }
00186 

Generated on Tue Nov 29 22:57:52 2016 for BOSS_7.0.2 by  doxygen 1.4.7