CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
RecEmcHitCnv.cxx
Go to the documentation of this file.
1#ifndef RecEmcHitCnv_CXX
2#define RecEmcHitCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
11
14
15#include "RootEventData/TRecEmcHit.h" // standard root object
17
21
22#include <vector>
23
24using namespace std;
25
26// Instantiation of a static factory class used by clients to create
27// instances of this service
28//static CnvFactory<RecEmcHitCnv> s_factory;
29//const ICnvFactory& RecEmcHitCnvFactory = s_factory;
30
32: RootEventBaseCnv(classID(), svc)
33{
34 //cout<<"in RecEmcHitCnv::constructor: hitid= "<<aHit->clID()<<endl;
35
36 // Here we associate this converter with the /Event path on the TDS.
37 MsgStream log(msgSvc(), "RecEmcHitCnv");
38 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
39 m_rootTreename ="Rec";
40 m_rootBranchname ="m_recEmcHitCol";
41 //declareObject(EventModel::Recon::RecEmcHitCol, objType(), m_rootTreename, m_rootBranchname);
42 m_adresses.push_back(&m_recEmcHitCol);
43 m_recEmcHitCol=0;
44}
45
46StatusCode RecEmcHitCnv::TObjectToDataObject(DataObject*& refpObject) {
47
48 // creation of TDS object from root object
49 MsgStream log(msgSvc(), "RecEmcHitCnv");
50 log << MSG::DEBUG << "RecEmcHitCnv::TObjectToDataObject" << endreq;
51 //cout<<"RecEmcHitCnv::TObjectToDataObject"<<endl;
52 StatusCode sc=StatusCode::SUCCESS;
53
54 // create the TDS location for the RecEmcHit Collection
55 RecEmcHitCol* emcHitTdsCol = new RecEmcHitCol;
56 refpObject=emcHitTdsCol;
57
58 // now convert
59 if (!m_recEmcHitCol) return sc;
60 TIter emcHitIter(m_recEmcHitCol);
61 TRecEmcHit *emcHitRoot = 0;
62 while ((emcHitRoot = (TRecEmcHit*)emcHitIter.Next())) {
63 RecEmcID cellId(emcHitRoot->cellId());
64 double energy = emcHitRoot->energy();
65 double time = emcHitRoot->time();
66
67 //cout<<"cellId="<<cellId<<"\tenergy="<<energy<<"\ttime="<<time<<endl;
68
69 RecEmcHit *emcHitTds = new RecEmcHit();
70 m_common.m_rootRecEmcHitMap[emcHitRoot] = emcHitTds;
71
72 emcHitTds->Assign(cellId,energy,time);
73
74 emcHitTdsCol->push_back(emcHitTds);
75 }
76
77 delete m_recEmcHitCol;
78 m_recEmcHitCol = 0;
79
80 return StatusCode::SUCCESS;
81}
82
83StatusCode RecEmcHitCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
84
85 MsgStream log(msgSvc(), "RecEmcHitCnv");
86 log << MSG::DEBUG << "RecEmcHitCnv::DataObjectToTObject" << endreq;
87 //cout<<"RecEmcHitCnv::DataObjectToTObject"<<endl;
88 StatusCode sc=StatusCode::SUCCESS;
89
90 RecEmcHitCol * emcHitColTds=dynamic_cast<RecEmcHitCol *> (obj);
91 if (!emcHitColTds) {
92 log << MSG::ERROR << "Could not downcast to RecEmcHitCol" << endreq;
93 return StatusCode::FAILURE;
94 }
95
96 DataObject *evt;
97 m_eds->findObject(EventModel::Recon::Event,evt);
98 if (evt==NULL) {
99 log << MSG::ERROR << "Could not get RecEvent in TDS " << endreq;
100 return StatusCode::FAILURE;
101 }
102 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
103 if (!devtTds) {
104 log << MSG::ERROR << "RecEmcHitCnv:Could not downcast to TDS DstEvent" << endreq;
105 }
106 IOpaqueAddress *addr;
107
108 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
110
111 const TObjArray *m_emcHitCol = recEvt->getEmcHitCol();
112 if (!m_emcHitCol) return sc;
113
114 //necessary in case there is I/O at the same time since array is static
115 recEvt->clearEmcHitCol();
116
117 RecEmcHitCol::const_iterator emcHitTds;
118
119 for(emcHitTds = emcHitColTds->begin();
120 emcHitTds != emcHitColTds->end();
121 emcHitTds++) {
122 Int_t cellId = (*emcHitTds)->getCellId();
123 Double_t energy = (*emcHitTds)->getEnergy();
124 Double_t time = (*emcHitTds)->getTime();
125
126 TRecEmcHit *emcHitRoot = new TRecEmcHit();
127 //m_common.m_recEmcHitMap[(*emcHitTds)] = emcHitRoot;
128 emcHitRoot->setCellId(cellId);
129 emcHitRoot->setEnergy(energy);
130 emcHitRoot->setTime(time);
131
132 recEvt->addEmcHit(emcHitRoot);
133 }
134
135 return StatusCode::SUCCESS;
136}
137#endif
Double_t time
************Class m_ypar INTEGER m_KeyWgt INTEGER m_nphot INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
Definition KK2f.h:50
ObjectVector< RecEmcHit > RecEmcHitCol
Definition RecEmcHit.h:76
IMessageSvc * msgSvc()
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
RecEmcHitCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
void Assign(const RecEmcID &CellId, const RecEmcEnergy &Energy, const RecEmcTime &Time)
Definition RecEmcHit.cxx:99
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition RecTrackCnv.h:36
Definition of a Root address, derived from IOpaqueAddress.
Definition RootAddress.h:21
RecTrackCnv * getRecTrackCnv()
Definition RootCnvSvc.h:166
Base class for all Root Converters.
std::string m_rootTreename
each converter knows it's treename
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void setCellId(const Int_t id)
Definition TRecEmcHit.h:22
Double_t energy() const
Definition TRecEmcHit.h:18
void setEnergy(const Double_t e)
Definition TRecEmcHit.h:23
Int_t cellId() const
Definition TRecEmcHit.h:17
Double_t time() const
Definition TRecEmcHit.h:19
void setTime(const Double_t time)
Definition TRecEmcHit.h:24
void addEmcHit(TRecEmcHit *Track)
Add a TkrTrack into the Emc data collection *‍/.
void clearEmcHitCol()
clear the whole array (necessary because of the consts-s) *‍/
const TObjArray * getEmcHitCol() const
retrieve the whole TObjArray of EmcHit Data
static std::map< const TObject *, const RecEmcHit * > m_rootRecEmcHitMap
Definition commonData.h:264
_EXTERN_ std::string Event
Definition EventModel.h:90