/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Hlt/DstHltInfCnv.cxx

Go to the documentation of this file.
00001 #ifndef DstHltInfCnv_CXX
00002 #define DstHltInfCnv_CXX  1
00003 
00004 #include "GaudiKernel/MsgStream.h"
00005 #include "GaudiKernel/DataObject.h"
00006 
00007 #include "TClonesArray.h"
00008 
00009 #include "EventModel/EventModel.h"
00010 #include "Identifier/HltID.h"
00011 #include "HltEvent/HltEvent.h"   //TDS object
00012 #include "HltEvent/DstHltInf.h"   //TDS object
00013 #include "RootEventData/THltEvent.h" // standard root object
00014 #include "RootEventData/TDstHltInf.h" // standard root object
00015 #include "RootCnvSvc/Hlt/HltCnv.h"
00016 #include "RootCnvSvc/Hlt/DstHltInfCnv.h"
00017 #include "RootCnvSvc/RootAddress.h"
00018 
00019 
00020 // Instantiation of a static factory class used by clients to create
00021 // instances of this service
00022 
00023 DstHltInfCnv::DstHltInfCnv(ISvcLocator* svc)
00024   : RootEventBaseCnv(classID(), svc),
00025     m_old(false)
00026 {
00027     // Here we associate this converter with the /Event path on the TDS.
00028     MsgStream log(msgSvc(), "DstHltInfCnv");
00029     //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
00030     m_rootBranchname ="m_dstHltInf";
00031     //declareObject(EventModel::MC::DstHltInf, objType(), m_rootTreename, m_rootBranchname);
00032     m_adresses.push_back(&m_dstHltInf);
00033     m_dstHltInf=0;
00034 }
00035 
00036 StatusCode DstHltInfCnv::TObjectToDataObject(DataObject*& refpObject) {
00037   // creation of TDS object from root object
00038 
00039   MsgStream log(msgSvc(), "DstHltInfCnv");
00040   log << MSG::DEBUG << "DstHltInfCnv::TObjectToDataObject" << endreq;
00041   StatusCode sc=StatusCode::SUCCESS;
00042 
00043   // create the TDS location for the trigger data
00044   DstHltInf* dstHltInfTds = new DstHltInf;
00045   refpObject=dstHltInfTds;
00046 
00047   // now convert
00048   if(!m_dstHltInf) return sc;
00049 
00050   int evt = m_dstHltInf->getEventType();
00051   int alg = m_dstHltInf->getAlgProcess();
00052   int cri = m_dstHltInf->getCriteriaTable();
00053   int ver = m_dstHltInf->getVersion();
00054   float etot = m_dstHltInf->getTotalEnergy();
00055   
00056   dstHltInfTds->setEventType(evt);
00057   dstHltInfTds->setAlgProcess(alg);
00058   dstHltInfTds->setCriteriaTable(cri);
00059   dstHltInfTds->setVersion(ver);
00060   dstHltInfTds->setTotalEnergy(etot);
00061   
00062   try{
00063     uint32_t nsub= m_dstHltInf->getNumber();
00064     uint32_t ncon= m_dstHltInf->getNCON();
00065     uint32_t nmdc= nsub     &0XFF;
00066     uint32_t ntof=(nsub>>8 )&0XFF;
00067     uint32_t nemc=(nsub>>16)&0XFF;
00068     uint32_t nmuc= nsub>>24;
00069     if(nmuc>HltID::getID_MUC_MAX()+1 || nemc>HltID::getID_EMC_MAX()+1
00070        ||ntof>HltID::getID_TOF_MAX()+1 || nmdc>HltID::getID_MDC_MAX()+1){
00071       throw exception();
00072     }    
00073     dstHltInfTds->setNumber(nsub);
00074     dstHltInfTds->setNCON(ncon);
00075   }
00076   catch(...){
00077     //log << MSG::ERROR   << "***********************************************************" << endreq;
00078     //log << MSG::ERROR   << "Input ROOT object is older version, please reconstrut again" << endreq;
00079     //log << MSG::ERROR   << " or check out old RootCnvSvc! (mailto: fucd@ihep.ac.cn)" << endreq;
00080     //log << MSG::WARNING << "***** Continuing run may cause a little memory leakage ****" << endreq;
00081     //m_old=true;
00082   }
00083   
00084   delete m_dstHltInf;
00085   m_dstHltInf = 0;
00086   
00087   return StatusCode::SUCCESS;
00088 }
00089 
00090 StatusCode DstHltInfCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
00091 
00092   MsgStream log(msgSvc(), "DstHltInfCnv");
00093   log << MSG::DEBUG << "DstHltInfCnv::DataObjectToTObject" << endreq;
00094   StatusCode sc=StatusCode::SUCCESS;
00095  
00096   DstHltInf * dstHltInfCnvTds=dynamic_cast<DstHltInf*> (obj);
00097   if (!dstHltInfCnvTds) {
00098     log << MSG::ERROR << "Could not downcast to DstHltInf" << endreq;
00099     return StatusCode::FAILURE;
00100   }
00101  
00102   DataObject *evt;
00103   m_eds->findObject(EventModel::Hlt::Event,evt);
00104   if (evt==NULL) {
00105     log << MSG::ERROR << "Could not get DstHltInf in TDS "  << endreq;
00106     return StatusCode::FAILURE;
00107   }
00108 
00109   HltEvent* devtTds=dynamic_cast<HltEvent *> (evt);
00110   if (!devtTds) {
00111     log << MSG::ERROR << "DstHltInfCnv:Could not downcast to TDS DstHltInf" << endreq;
00112   }
00113 
00114   IOpaqueAddress *addr;
00115   m_cnvSvc->getHltCnv()->createRep(evt,addr); 
00116 
00117   THltEvent *hltInf=m_cnvSvc->getHltCnv()->getWriteObject();
00118 
00119   const TObject *tHltInf = hltInf->getDstHltInf();
00120   if (!tHltInf) return sc;
00121   hltInf->clearDstHltInf();
00122 
00123   Int_t typ = dstHltInfCnvTds->getEventType();
00124   Int_t alg = dstHltInfCnvTds->getAlgProcess();
00125   Int_t cri = dstHltInfCnvTds->getCriteriaTable();
00126   Int_t ver = dstHltInfCnvTds->getVersion();
00127   Double_t etot = dstHltInfCnvTds->getTotalEnergy();
00128   Int_t nsub = dstHltInfCnvTds->getNumber();
00129   Int_t ncon = dstHltInfCnvTds->getNCON();
00130 
00131   TDstHltInf *dstHltInfRoot = new TDstHltInf();
00132 
00133   dstHltInfRoot->setEventType(typ);
00134   dstHltInfRoot->setAlgProcess(alg);
00135   dstHltInfRoot->setCriteriaTable(cri);
00136   dstHltInfRoot->setVersion(ver);
00137   dstHltInfRoot->setTotalEnergy(etot);
00138   dstHltInfRoot->setNumber(nsub);
00139   dstHltInfRoot->setNCON(ncon);
00140 
00141   hltInf->addDstHltInf(dstHltInfRoot);
00142 
00143   return StatusCode::SUCCESS;
00144 }
00145 #endif

Generated on Tue Nov 29 22:58:46 2016 for BOSS_7.0.2 by  doxygen 1.4.7