CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
RecCgemDedxHitCnv.cxx
Go to the documentation of this file.
1#ifndef RecCgemDedxHitCnv_CXX
2#define RecCgemDedxHitCnv_CXX 1
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/DataObject.h"
5#include "GaudiKernel/ObjectVector.h"
6#include "TClonesArray.h"
11
12#include "RootEventData/TRecCgemDedxHit.h" // standard root object
14
18
19#include <vector>
20
21using namespace std;
22
23// Instantiation of a static factory class used by clients to create
24// instances of this service
25//static CnvFactory<RecCgemDedxCnv> s_factory;
26//const ICnvFactory& RecCgemDedxCnvFactory = s_factory;
27
29: RootEventBaseCnv(classID(), svc)
30{
31
32 // Here we associate this converter with the /Event path on the TDS.
33 MsgStream log(msgSvc(), "RecCgemDedxHitCnv");
34 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
35 //m_rootTreename ="Rec";
36 m_rootBranchname ="m_recCgemDedxHitCol";
37 // declareObject(EventModel::Recon::RecCgemDedxCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_recCgemDedxHitCol);
39 m_recCgemDedxHitCol=0;
40}
41
42StatusCode RecCgemDedxHitCnv::TObjectToDataObject(DataObject*& refpObject) {
43 // creation of TDS object from root object
44 MsgStream log(msgSvc(), "RecCgemDedxHitCnv");
45 log << MSG::DEBUG << "RecCgemDedxHitCnv::TObjectToDataObject" << endreq;
46 StatusCode sc=StatusCode::SUCCESS;
47 // create the TDS location for the Dedx Collection
48 RecCgemDedxHitCol* recCgemDedxHitCol = new RecCgemDedxHitCol;
49 refpObject=recCgemDedxHitCol;
50
51 // now convert
52 if (!m_recCgemDedxHitCol) return sc;
53 TIter dedxIter(m_recCgemDedxHitCol);
54 TRecCgemDedxHit *recCgemDedxHitRoot = 0;
55 while ((recCgemDedxHitRoot = (TRecCgemDedxHit*)dedxIter.Next())) {
56 int trackId = recCgemDedxHitRoot->trkId();
57// unsigned int cgemIdMSB(recCgemDedxHitRoot->cgemIdMSB());
58// unsigned int cgemIdLSB(recCgemDedxHitRoot->cgemIdLSB());
59 unsigned int cgemId(recCgemDedxHitRoot->cgemId());
60 double pathlength = recCgemDedxHitRoot->pathLength();
61 log << MSG::DEBUG<<"check Reconstrunction of dE/dx Hit root"<<" pathlength is : "<<pathlength<<endreq;
62 RecCgemDedxHit *recCgemDedxHit = new RecCgemDedxHit();
63 m_common.m_rootRecCgemDedxHitMap[recCgemDedxHitRoot] = recCgemDedxHit;
64 recCgemDedxHit->setTrkId(trackId);
65// recCgemDedxHit->setCgemId( Identifier64(cgemIdMSB,cgemIdLSB) );
66 recCgemDedxHit->setCgemId( Identifier(cgemId) );
67 recCgemDedxHit->setPathLength( pathlength);
68 // log << MSG::DEBUG<<"check Reconstrunction of dE/dx Hit root"<<" pathlength 2 is : "<<(*recdedxhit)->getPathLength()<<endreq;
69 recCgemDedxHitCol->push_back(recCgemDedxHit);
70 //delete dedxTds;
71 // dedxTds = NULL;
72 }
73 //m_dedxCol->Delete();
74 delete m_recCgemDedxHitCol;
75 m_recCgemDedxHitCol = 0;
76
77 return StatusCode::SUCCESS;
78}
79
80
81StatusCode RecCgemDedxHitCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
82 MsgStream log(msgSvc(), "RecCgemDedxHitCnv");
83 log << MSG::DEBUG << "RecCgemDedxHitCnv::DataObjectToTObject" << endreq;
84 StatusCode sc=StatusCode::SUCCESS;
85 RecCgemDedxHitCol * recCgemDedxHitCol=dynamic_cast<RecCgemDedxHitCol *> (obj);
86 if (!recCgemDedxHitCol) {
87 log << MSG::ERROR << "Could not downcast to RecCgemDedxHitCol" << endreq;
88 return StatusCode::FAILURE;
89 }
90 DataObject *evt;
91 m_eds->findObject(EventModel::Recon::Event,evt);
92 if (evt==NULL) {
93 log << MSG::ERROR << "Could not get RecEvent in TDS " << endreq;
94 return StatusCode::FAILURE;
95 }
96 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
97 if (!devtTds) {
98 log << MSG::ERROR << "RecCgemDedxHitCnv:Could not downcast to TDS RecEvent" << endreq;
99 }
100 IOpaqueAddress *addr;
101 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
103 const TObjArray *m_recCgemDedxHitCol = recEvt->getRecCgemDedxHitCol();
104 if (!m_recCgemDedxHitCol) return sc;
105 recEvt->clearRecCgemDedxHitCol(); //necessary in case there is I/O at the same time since array is static
106 RecCgemDedxHitCol::const_iterator recCgemDedxHit;
107 for (recCgemDedxHit = recCgemDedxHitCol->begin(); recCgemDedxHit != recCgemDedxHitCol->end(); recCgemDedxHit++) {
108 int trackId = (*recCgemDedxHit)->getTrkId();
109// UInt_t cgemIdMSB =(*recCgemDedxHit)->getCgemId().get_valueMSB();
110// UInt_t cgemIdLSB =(*recCgemDedxHit)->getCgemId().get_valueLSB();
111 UInt_t cgemId =(*recCgemDedxHit)->getCgemId().get_value();
112 double pathlength = (*recCgemDedxHit)->getPathLength();
113 log << MSG::DEBUG<<"check Reconstrunction of dE/dx Hit root"<<" pathlength is : "<<pathlength<<endreq;
114 TRecCgemDedxHit *recCgemDedxHitRoot = new TRecCgemDedxHit();
115 //m_common.m_recCgemDedxHitMap[(*recCgemDedxHit)] = recCgemDedxHitRoot;
116 recCgemDedxHitRoot->setTrkId(trackId);
117// recCgemDedxHitRoot->setCgemIdMSB( cgemIdMSB );
118// recCgemDedxHitRoot->setCgemIdLSB( cgemIdLSB );
119 recCgemDedxHitRoot->setCgemId( cgemId );
120
121 recCgemDedxHitRoot->setPathLength( pathlength);
122 log << MSG::DEBUG<<"check Reconstrunction of dE/dx Hit root"<<" pathlength 2 is : "<<(*recCgemDedxHit)->getPathLength()<<endreq;
123 recEvt->addRecCgemDedxHit(recCgemDedxHitRoot);
124 }
125
126 return StatusCode::SUCCESS;
127}
128
129#endif
ObjectVector< RecCgemDedxHit > RecCgemDedxHitCol
IMessageSvc * msgSvc()
RecCgemDedxHitCnv(ISvcLocator *svc)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
void setTrkId(int trkid)
void setCgemId(Identifier cgemid)
void setPathLength(double pathlength)
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::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 setCgemId(UInt_t cgemid)
const UInt_t cgemId() const
const Double_t pathLength(void) const
void setTrkId(Int_t trkid)
void setPathLength(double pathlength)
const Int_t trkId(void) const
const TObjArray * getRecCgemDedxHitCol() const
retrieve the whole TObjArray of Dedx Data
void clearRecCgemDedxHitCol()
clear the whole array
void addRecCgemDedxHit(TRecCgemDedxHit *Track)
Add a Dedx into the TOF Data collection.
static std::map< const TObject *, const RecCgemDedxHit * > m_rootRecCgemDedxHitMap
Definition commonData.h:285
_EXTERN_ std::string Event
Definition EventModel.h:90