/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Rec/RecTofTrackCnv.cxx

Go to the documentation of this file.
00001 #ifndef RecTofTrackCnv_CXX
00002 #define RecTofTrackCnv_CXX  1
00003 
00004 #include "GaudiKernel/MsgStream.h"
00005 #include "GaudiKernel/DataObject.h"
00006 #include "GaudiKernel/ObjectVector.h"
00007 
00008 #include "TClonesArray.h"
00009 
00010 #include "EventModel/EventModel.h"
00011 
00012 #include "ReconEvent/ReconEvent.h"
00013 #include "DstEvent/TofHitStatus.h"
00014 #include "MucRecEvent/RecMucTrack.h"
00015 
00016 #include "RootEventData/TRecTofTrack.h" // standard root object
00017 #include "RootEventData/TRecTrackEvent.h"
00018 
00019 #include "RootCnvSvc/Rec/RecTrackCnv.h"
00020 #include "RootCnvSvc/Rec/RecTofTrackCnv.h"
00021 #include "RootCnvSvc/RootAddress.h"
00022 
00023 #include <vector>
00024 
00025 using namespace std;
00026 
00027 // Instantiation of a static factory class used by clients to create
00028 // instances of this service
00029 //static CnvFactory<RecTofTrackCnv> s_factory;
00030 //const ICnvFactory& RecTofTrackCnvFactory = s_factory;
00031 
00032 RecTofTrackCnv::RecTofTrackCnv(ISvcLocator* svc)
00033 : RootEventBaseCnv(classID(), svc)
00034 {
00035 
00036     // Here we associate this converter with the /Event path on the TDS.
00037     MsgStream log(msgSvc(), "RecTofTrackCnv");
00038     //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
00039     //m_rootTreename ="Rec";
00040     //m_rootBranchname ="m_RecTofTrackCol";
00041     //declareObject(EventModel::Recon::RecTofTrackCol, objType(), m_rootTreename, m_rootBranchname);
00042     m_adresses.push_back(&m_recTofTrackCol);
00043     m_recTofTrackCol=0;
00044 }
00045 
00046 StatusCode RecTofTrackCnv::TObjectToDataObject(DataObject*& refpObject) {
00047   // creation of TDS object from root object
00048 
00049 
00050     MsgStream log(msgSvc(), "RecTofTrackCnv");
00051     log << MSG::DEBUG << "RecTofTrackCnv::TObjectToDataObject" << endreq;
00052     StatusCode sc=StatusCode::SUCCESS;
00053 
00054     // create the TDS location for the MucTrack Collection
00055     RecTofTrackCol* recTofTrackTdsCol = new RecTofTrackCol;
00056     refpObject=recTofTrackTdsCol;
00057 
00058     // now convert
00059     if (!m_recTofTrackCol) return sc;
00060     TIter recTofTrackIter(m_recTofTrackCol);
00061     TRecTofTrack *recTofTrackRoot = 0;
00062     while ((recTofTrackRoot = (TRecTofTrack*)recTofTrackIter.Next())) {
00063 
00064       int tofTrackID = recTofTrackRoot->tofTrackID();
00065       int trackID    = recTofTrackRoot->trackID();
00066       int tofID      = recTofTrackRoot->tofID();
00067       unsigned int status = recTofTrackRoot->status();
00068       double path    = recTofTrackRoot->path();
00069       double zrhit   = recTofTrackRoot->zrhit();
00070       double ph      = recTofTrackRoot->ph();
00071       double tof     = recTofTrackRoot->tof();
00072       double errtof  = recTofTrackRoot->errtof();
00073       double beta    = recTofTrackRoot->beta();
00074       double texpElectron = recTofTrackRoot->texpElectron();
00075       double texpMuon     = recTofTrackRoot->texpMuon();
00076       double texpPion     = recTofTrackRoot->texpPion();
00077       double texpKaon     = recTofTrackRoot->texpKaon();
00078       double texpProton   = recTofTrackRoot->texpProton();
00079       double toffsetElectron = recTofTrackRoot->toffsetElectron();
00080       double toffsetMuon     = recTofTrackRoot->toffsetMuon();
00081       double toffsetPion     = recTofTrackRoot->toffsetPion();
00082       double toffsetKaon     = recTofTrackRoot->toffsetKaon();
00083       double toffsetProton   = recTofTrackRoot->toffsetProton();
00084       double toffsetAntiProton = recTofTrackRoot->toffsetAntiProton();
00085       double sigmaElectron = recTofTrackRoot->sigmaElectron();
00086       double sigmaMuon     = recTofTrackRoot->sigmaMuon();
00087       double sigmaPion     = recTofTrackRoot->sigmaPion();
00088       double sigmaKaon     = recTofTrackRoot->sigmaKaon();
00089       double sigmaProton   = recTofTrackRoot->sigmaProton();
00090       double sigmaAntiProton = recTofTrackRoot->sigmaAntiProton();
00091       int quality    = recTofTrackRoot->quality();
00092       double t0      = recTofTrackRoot->t0();
00093       double errt0   = recTofTrackRoot->errt0();
00094       double errz    = recTofTrackRoot->errz();
00095       double phi     = recTofTrackRoot->phi();
00096       double errphi  = recTofTrackRoot->errphi();
00097       double energy    = recTofTrackRoot->energy();
00098       double errenergy = recTofTrackRoot->errenergy();
00099 
00100       RecTofTrack *recTofTrackTds = new RecTofTrack();
00101       m_common.m_rootRecTofTrackMap[recTofTrackRoot] = recTofTrackTds;
00102 
00103       recTofTrackTds->setTofTrackID(tofTrackID);
00104       recTofTrackTds->setTrackID(trackID);
00105       recTofTrackTds->setTofID(tofID);
00106       recTofTrackTds->setStatus(status);
00107       recTofTrackTds->setPath(path);
00108       recTofTrackTds->setZrHit(zrhit);
00109       recTofTrackTds->setPh(ph);
00110       recTofTrackTds->setTof(tof);
00111       recTofTrackTds->setErrTof(errtof);
00112       recTofTrackTds->setBeta(beta);
00113       recTofTrackTds->setTexpElectron(texpElectron);
00114       recTofTrackTds->setTexpMuon(texpMuon);
00115       recTofTrackTds->setTexpPion(texpPion);
00116       recTofTrackTds->setTexpKaon(texpKaon);
00117       recTofTrackTds->setTexpProton(texpProton);
00118       recTofTrackTds->setToffsetElectron(toffsetElectron);
00119       recTofTrackTds->setToffsetMuon(toffsetMuon);
00120       recTofTrackTds->setToffsetPion(toffsetPion);
00121       recTofTrackTds->setToffsetKaon(toffsetKaon);
00122       recTofTrackTds->setToffsetProton(toffsetProton);
00123       recTofTrackTds->setToffsetAntiProton(toffsetAntiProton);
00124       recTofTrackTds->setSigmaElectron(sigmaElectron);
00125       recTofTrackTds->setSigmaMuon(sigmaMuon);
00126       recTofTrackTds->setSigmaPion(sigmaPion);
00127       recTofTrackTds->setSigmaKaon(sigmaKaon);
00128       recTofTrackTds->setSigmaProton(sigmaProton);
00129       recTofTrackTds->setSigmaAntiProton(sigmaAntiProton);
00130       recTofTrackTds->setQuality(quality);
00131       recTofTrackTds->setT0(t0);
00132       recTofTrackTds->setErrT0(errt0);
00133       recTofTrackTds->setErrZ(errz);
00134       recTofTrackTds->setPhi(phi);
00135       recTofTrackTds->setErrPhi(errphi);
00136       recTofTrackTds->setEnergy(energy);
00137       recTofTrackTds->setErrEnergy(errenergy);
00138 
00139       recTofTrackTdsCol->push_back(recTofTrackTds);
00140     }
00141 
00142     delete m_recTofTrackCol;
00143     m_recTofTrackCol = 0;
00144 
00145     return StatusCode::SUCCESS;
00146 }
00147 
00148 StatusCode RecTofTrackCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
00149  
00150   MsgStream log(msgSvc(), "RecTofTrackCnv");
00151   log << MSG::DEBUG << "RecTofTrackCnv::DataObjectToTObject" << endreq;
00152   StatusCode sc=StatusCode::SUCCESS;
00153 
00154   RecTofTrackCol * recTofTrackColTds=dynamic_cast<RecTofTrackCol *> (obj);
00155   if (!recTofTrackColTds) {
00156     log << MSG::ERROR << "Could not downcast to TofTrackCol" << endreq;
00157     return StatusCode::FAILURE;
00158   }
00159 
00160   DataObject *evt;
00161   m_eds->findObject(EventModel::Recon::Event,evt);
00162   if (evt==NULL) {
00163     log << MSG::ERROR << "Could not get RecEvent in TDS "  << endreq;
00164     return StatusCode::FAILURE;
00165   }
00166 
00167   ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
00168   if (!devtTds) {
00169     log << MSG::ERROR << "RecMucTrackCnv:Could not downcast to TDS DigiEvent" << endreq;
00170   }
00171 
00172   IOpaqueAddress *addr;
00173 
00174   m_cnvSvc->getRecTrackCnv()->createRep(evt,addr); 
00175   TRecTrackEvent *recEvt=m_cnvSvc->getRecTrackCnv()->getWriteObject();
00176 
00177   const TObjArray *m_recTofTrackCol = recEvt->getTofTrackCol();
00178   if (!m_recTofTrackCol) return sc;
00179   recEvt->clearTofTrackCol(); //necessary in case there is I/O at the same time since array is static
00180   RecTofTrackCol::const_iterator recTofTrackTds;
00181 
00182   for (recTofTrackTds = recTofTrackColTds->begin(); recTofTrackTds != recTofTrackColTds->end(); recTofTrackTds++) {
00183 
00184     Int_t tofTrackID = (*recTofTrackTds)->tofTrackID();
00185     Int_t trackID    = (*recTofTrackTds)->trackID();
00186     Int_t tofID      = (*recTofTrackTds)->tofID();
00187     Int_t strip      = (*recTofTrackTds)->strip();
00188     UInt_t status    = (*recTofTrackTds)->status();
00189     Double_t path    = (*recTofTrackTds)->path();
00190     Double_t zrhit   = (*recTofTrackTds)->zrhit();
00191     Double_t ph      = (*recTofTrackTds)->ph();
00192     Double_t tof     = (*recTofTrackTds)->tof();
00193     Double_t errtof  = (*recTofTrackTds)->errtof();
00194     Double_t beta    = (*recTofTrackTds)->beta();
00195     Double_t texpElectron = (*recTofTrackTds)->texpElectron();
00196     Double_t texpMuon     = (*recTofTrackTds)->texpMuon();
00197     Double_t texpPion     = (*recTofTrackTds)->texpPion();
00198     Double_t texpKaon     = (*recTofTrackTds)->texpKaon();
00199     Double_t texpProton   = (*recTofTrackTds)->texpProton();
00200     Double_t toffsetElectron = (*recTofTrackTds)->toffsetElectron();
00201     Double_t toffsetMuon     = (*recTofTrackTds)->toffsetMuon();
00202     Double_t toffsetPion     = (*recTofTrackTds)->toffsetPion();
00203     Double_t toffsetKaon     = (*recTofTrackTds)->toffsetKaon();
00204     Double_t toffsetProton   = (*recTofTrackTds)->toffsetProton();
00205     Double_t toffsetAntiProton = (*recTofTrackTds)->toffsetAntiProton();
00206     Double_t sigmaElectron = (*recTofTrackTds)->sigmaElectron();
00207     Double_t sigmaMuon     = (*recTofTrackTds)->sigmaMuon();
00208     Double_t sigmaPion     = (*recTofTrackTds)->sigmaPion();
00209     Double_t sigmaKaon     = (*recTofTrackTds)->sigmaKaon();
00210     Double_t sigmaProton   = (*recTofTrackTds)->sigmaProton();
00211     Double_t sigmaAntiProton = (*recTofTrackTds)->sigmaAntiProton();
00212     Int_t quality    = (*recTofTrackTds)->quality();
00213     Double_t t0      = (*recTofTrackTds)->t0();
00214     Double_t errt0   = (*recTofTrackTds)->errt0();
00215     Double_t errz    = (*recTofTrackTds)->errz();
00216     Double_t phi     = (*recTofTrackTds)->phi();
00217     Double_t errphi  = (*recTofTrackTds)->errphi();
00218     Double_t energy    = (*recTofTrackTds)->energy();
00219     Double_t errenergy = (*recTofTrackTds)->errenergy();
00220     
00221     if( TofHitStatus::is_mrpc( status ) ) { tofID = tofID*12 + strip; }
00222 
00223     TRecTofTrack *recTofTrackRoot = new TRecTofTrack();
00224     //m_common.m_RecTofTrackMap[(*recTofTrackTds)] = recTofTrackRoot;
00225 
00226     recTofTrackRoot->setTofTrackID(tofTrackID);
00227     recTofTrackRoot->setTrackID(trackID);
00228     recTofTrackRoot->setTofID(tofID);
00229     recTofTrackRoot->setStatus(status);
00230     recTofTrackRoot->setPath(path);
00231     recTofTrackRoot->setZrHit(zrhit);
00232     recTofTrackRoot->setPh(ph);
00233     recTofTrackRoot->setTof(tof);
00234     recTofTrackRoot->setErrTof(errtof);
00235     recTofTrackRoot->setBeta(beta);
00236     recTofTrackRoot->setTexpElectron(texpElectron);
00237     recTofTrackRoot->setTexpMuon(texpMuon);
00238     recTofTrackRoot->setTexpPion(texpPion);
00239     recTofTrackRoot->setTexpKaon(texpKaon);
00240     recTofTrackRoot->setTexpProton(texpProton);
00241     recTofTrackRoot->setToffsetElectron(toffsetElectron);
00242     recTofTrackRoot->setToffsetMuon(toffsetMuon);
00243     recTofTrackRoot->setToffsetPion(toffsetPion);
00244     recTofTrackRoot->setToffsetKaon(toffsetKaon);
00245     recTofTrackRoot->setToffsetProton(toffsetProton);
00246     recTofTrackRoot->setToffsetAntiProton(toffsetAntiProton);
00247     recTofTrackRoot->setSigmaElectron(sigmaElectron);
00248     recTofTrackRoot->setSigmaMuon(sigmaMuon);
00249     recTofTrackRoot->setSigmaPion(sigmaPion);
00250     recTofTrackRoot->setSigmaKaon(sigmaKaon);
00251     recTofTrackRoot->setSigmaProton(sigmaProton);
00252     recTofTrackRoot->setSigmaAntiProton(sigmaAntiProton);
00253     recTofTrackRoot->setQuality(quality);
00254     recTofTrackRoot->setT0(t0);
00255     recTofTrackRoot->setErrT0(errt0);
00256     recTofTrackRoot->setErrZ(errz);
00257     recTofTrackRoot->setPhi(phi);
00258     recTofTrackRoot->setErrPhi(errphi);
00259     recTofTrackRoot->setEnergy(energy);
00260     recTofTrackRoot->setErrEnergy(errenergy);
00261 
00262     recEvt->addTofTrack(recTofTrackRoot);
00263 
00264   }
00265 
00266   return StatusCode::SUCCESS;
00267 }
00268 #endif

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