BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
RecMdcDedxHitCnv Class Reference

#include <RecMdcDedxHitCnv.h>

+ Inheritance diagram for RecMdcDedxHitCnv:

Public Member Functions

virtual ~RecMdcDedxHitCnv ()
 
- Public Member Functions inherited from RootEventBaseCnv
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
 
virtual ~RootEventBaseCnv ()
 
virtual long repSvcType () const
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
 
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode DataObjectToTObject (DataObject *dat, RootAddress *addr)=0
 Do the concrete conversion from TDS to ROOT.
 
virtual StatusCode TObjectToDataObject (DataObject *&dat)=0
 Do the concrete conversion from ROOT to TDS.
 
TObject * getReadObject () const
 get the object to be read
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

static const CLID & classID ()
 
- Static Public Member Functions inherited from RootEventBaseCnv
static const unsigned char storageType ()
 Storage type and class ID.
 

Protected Member Functions

 RecMdcDedxHitCnv (ISvcLocator *svc)
 
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
 
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< RecMdcDedxHitCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RootEventBaseCnv
RootCnvSvcm_cnvSvc
 
std::vector< RootCnvSvc::Leafm_leaves
 
RootInterfacem_rootInterface
 pointer to the RootInterface
 
IDataProviderSvc * m_eds
 pointer to eventdataservice
 
int m_branchNr
 the branchNr of this converter for writing
 
int m_branchNrDst
 
int m_branchNrMc
 
int m_branchNrRecon
 
int m_branchNrEvtRec
 
int m_branchNrEvtHeader
 
int m_branchNrEvtNavigator
 
TObject * m_objRead
 the object that was read
 
CLID CLID_top
 the CLID of the upper converter if any
 
TArrayS * m_branchNumbers
 array with number of branches for reading
 
std::string m_rootBranchname
 root branchname (may be concatenated of severals)
 
std::string m_rootTreename
 each converter knows it's treename
 
std::string m_currentFileName
 
std::vector< void * > m_adresses
 each converter knows the corresponding adresses
 
RootEvtSelectorm_evtsel
 

Detailed Description

Definition at line 15 of file RecMdcDedxHitCnv.h.

Constructor & Destructor Documentation

◆ ~RecMdcDedxHitCnv()

virtual RecMdcDedxHitCnv::~RecMdcDedxHitCnv ( )
inlinevirtual

Definition at line 25 of file RecMdcDedxHitCnv.h.

25{ };

◆ RecMdcDedxHitCnv()

RecMdcDedxHitCnv::RecMdcDedxHitCnv ( ISvcLocator *  svc)
protected

Definition at line 28 of file RecMdcDedxHitCnv.cxx.

30{
31
32 // Here we associate this converter with the /Event path on the TDS.
33 MsgStream log(msgSvc(), "RecMdcDedxHitCnv");
34 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
35 //m_rootTreename ="Rec";
36 m_rootBranchname ="m_recMdcDedxHitCol";
37 // declareObject(EventModel::Recon::RecMdcDedxCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_recMdcDedxHitCol);
39 m_recMdcDedxHitCol=0;
40}
IMessageSvc * msgSvc()
static const CLID & classID()
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)

Member Function Documentation

◆ classID()

static const CLID & RecMdcDedxHitCnv::classID ( )
inlinestatic

Definition at line 20 of file RecMdcDedxHitCnv.h.

21 {
23 }
const CLID & CLID_RecMdcDedxHitCol
Definition: EventModel.cxx:301

◆ DataObjectToTObject()

StatusCode RecMdcDedxHitCnv::DataObjectToTObject ( DataObject *  obj,
RootAddress addr 
)
protectedvirtual

transformation to root

Implements RootEventBaseCnv.

Definition at line 124 of file RecMdcDedxHitCnv.cxx.

124 {
125 MsgStream log(msgSvc(), "RecMdcDedxHitCnv");
126 log << MSG::DEBUG << "RecMdcDedxHitCnv::DataObjectToTObject" << endreq;
127 StatusCode sc=StatusCode::SUCCESS;
128
129 RecMdcDedxHitCol * recMdcDedxHitCol=dynamic_cast<RecMdcDedxHitCol *> (obj);
130 if (!recMdcDedxHitCol) {
131 log << MSG::ERROR << "Could not downcast to RecMdcDedxHitCol" << endreq;
132 return StatusCode::FAILURE;
133 }
134
135 DataObject *evt;
136 m_eds->findObject(EventModel::Recon::Event,evt);
137 if (evt==NULL) {
138 log << MSG::ERROR << "Could not get RecEvent in TDS " << endreq;
139 return StatusCode::FAILURE;
140 }
141 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
142 if (!devtTds) {
143 log << MSG::ERROR << "RecMdcDedxHitCnv:Could not downcast to TDS RecEvent" << endreq;
144 }
145 IOpaqueAddress *addr;
146 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
148 const TObjArray *m_recMdcDedxHitCol = recEvt->getRecMdcDedxHitCol();
149 if (!m_recMdcDedxHitCol) return sc;
150 recEvt->clearRecMdcDedxHitCol(); //necessary in case there is I/O at the same time since array is static
151
152 //******************** get according mdcHIt and mdcKalHelixSeg of MdcDedxHit ****************
153
154 RecMdcHitCol::iterator recMdcHitColbegin, recMdcHitColend;
155 RecMdcKalHelixSegCol::iterator recMdcKalHelixSegColbegin, recMdcKalHelixSegColend;
156
157 IDataProviderSvc* dataSvc = 0;
158 sc = serviceLocator()->getService("EventDataSvc",
159 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
160 if ( sc.isFailure() ) {
161 log << MSG::FATAL << "Could not get EventDataSvc in RecMdcDedxHitCnv" << endreq;
162 return sc;
163 }
164
165 // Retrieve Mdc Hit
166 SmartDataPtr<RecMdcHitCol> recMdcHitCol(dataSvc, EventModel::Recon::RecMdcHitCol);
167 if (!recMdcHitCol) {
168 log << MSG::ERROR << "Could not downcast to RecMdcHitCol" << endreq;
169 return StatusCode::FAILURE;
170 }
171 else {
172 recMdcHitColbegin = recMdcHitCol->begin();
173 recMdcHitColend = recMdcHitCol->end();
174 }
175
176 SmartDataPtr<RecMdcKalHelixSegCol> recMdcKalHelixSegCol(dataSvc, EventModel::Recon::RecMdcKalHelixSegCol);
177 if (!recMdcKalHelixSegCol) {
178 log << MSG::ERROR << "Could not downcast to RecMdcKalHelixSegCol" << endreq;
179 return StatusCode::FAILURE;
180 }
181 else {
182 recMdcKalHelixSegColbegin = recMdcKalHelixSegCol->begin();
183 recMdcKalHelixSegColend = recMdcKalHelixSegCol->end();
184 }
185 //******************************************************************************
186
187
188 RecMdcDedxHitCol::const_iterator recMdcDedxHit;
189 for (recMdcDedxHit = recMdcDedxHitCol->begin(); recMdcDedxHit != recMdcDedxHitCol->end(); recMdcDedxHit++) {
190 int trackId = (*recMdcDedxHit)->getTrkId();
191 int flagLR = (*recMdcDedxHit)->getFlagLR();
192 UInt_t mdcId =(*recMdcDedxHit)->getMdcId().get_value();
193 double pathlength = (*recMdcDedxHit)->getPathLength();
194 double dedx = (*recMdcDedxHit)->getDedx();
195
196 log << MSG::DEBUG<<"DataObjectToTObject: check Reconstrunction of dE/dx Hit::"<<" trackId: "<<trackId<<" flagLR: "<<flagLR<<" pathlength: "<<pathlength<<" dedx: "<<dedx<<endreq;
197 TRecMdcDedxHit *recMdcDedxHitRoot = new TRecMdcDedxHit();
198 //m_common.m_recMdcDedxHitMap[(*recMdcDedxHit)] = recMdcDedxHitRoot;
199 recMdcDedxHitRoot->setTrkId(trackId);
200 recMdcDedxHitRoot->setFlagLR(flagLR);
201 recMdcDedxHitRoot->setMdcId( mdcId );
202 recMdcDedxHitRoot->setPathLength( pathlength);
203 recMdcDedxHitRoot->setDedx(dedx);
204
205 //int trackId1 = recMdcDedxHitRoot->trkId();
206 //cout<<"trackId: "<<trackId1<<endl;
207 //int flagLR1 = recMdcDedxHitRoot->flagLR();
208 //cout<<"flagLR: "<<flagLR1<<endl;
209 //long int mdcId1(recMdcDedxHitRoot->mdcId());
210 //cout<<"mdcID: "<<mdcId1<<endl;
211 //double pathlength1 = recMdcDedxHitRoot->pathLength();
212 //cout<<"pathlength: " <<pathlength1<<endl;
213 //double dedx1 = recMdcDedxHitRoot->getDedx();
214 //cout<<"dedx: "<<dedx1<<endl;
215
216
217 if ( (*recMdcDedxHit)->isMdcHitValid() ) {
218 RecMdcHitCol::iterator it = find(recMdcHitColbegin, recMdcHitColend, (*recMdcDedxHit)->getMdcHit());
219 recMdcDedxHitRoot->setMdcHitId( it - recMdcHitColbegin );
220 }
221 else{
222 recMdcDedxHitRoot->setMdcHitId(-1);
223 }
224
225 if ( (*recMdcDedxHit)->isMdcKalHelixSegValid() ) {
226 RecMdcKalHelixSegCol::iterator it = find(recMdcKalHelixSegColbegin, recMdcKalHelixSegColend, (*recMdcDedxHit)->getMdcKalHelixSeg());
227 recMdcDedxHitRoot->setMdcKalHelixSegId( it - recMdcKalHelixSegColbegin );
228 }
229 else{
230 recMdcDedxHitRoot->setMdcKalHelixSegId(-1);
231 }
232
233 //log << MSG::DEBUG<<"check Reconstrunction of dE/dx Hit root"<<" pathlength 2 is : "<<(*recMdcDedxHit)->getPathLength()<<endreq;
234 recEvt->addRecMdcDedxHit(recMdcDedxHitRoot);
235 }
236
237 return StatusCode::SUCCESS;
238}
ObjectVector< RecMdcDedxHit > RecMdcDedxHitCol
Definition: RecMdcDedxHit.h:78
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: RecTrackCnv.h:36
RecTrackCnv * getRecTrackCnv()
Definition: RootCnvSvc.h:166
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void setDedx(double dedx)
void setMdcId(UInt_t mdcid)
void setFlagLR(Int_t lr)
void setMdcHitId(const int mdcHitId)
void setMdcKalHelixSegId(const int mdcKalHelixSegId)
void setTrkId(Int_t trkid)
void setPathLength(double pathlength)
const TObjArray * getRecMdcDedxHitCol() const
retrieve the whole TObjArray of Dedx Data
void clearRecMdcDedxHitCol()
clear the whole array
void addRecMdcDedxHit(TRecMdcDedxHit *Track)
Add a Dedx into the TOF Data collection.
_EXTERN_ std::string RecMdcKalHelixSegCol
Definition: EventModel.h:87
_EXTERN_ std::string Event
Definition: EventModel.h:80
_EXTERN_ std::string RecMdcHitCol
Definition: EventModel.h:81

◆ TObjectToDataObject()

StatusCode RecMdcDedxHitCnv::TObjectToDataObject ( DataObject *&  obj)
protectedvirtual

transformation from root

Implements RootEventBaseCnv.

Definition at line 42 of file RecMdcDedxHitCnv.cxx.

42 {
43 // creation of TDS object from root object
44 MsgStream log(msgSvc(), "RecMdcDedxHitCnv");
45 log << MSG::DEBUG << "RecMdcDedxHitCnv::TObjectToDataObject" << endreq;
46 StatusCode sc=StatusCode::SUCCESS;
47 // create the TDS location for the Dedx Collection
48 RecMdcDedxHitCol* recMdcDedxHitCol = new RecMdcDedxHitCol;
49 refpObject=recMdcDedxHitCol;
50
51 //***************************register rec hit data in TDS****************************
52 IDataProviderSvc* dataSvc = 0;
53 sc = serviceLocator()->getService("EventDataSvc",
54 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
55 if ( sc.isFailure() ) {
56 log << MSG::FATAL << "Could not get EventDataSvc in RecMdcDedxHitCnv" << endreq;
57 return sc;
58 }
59
60 // Retrieve Mdc Hit
61 SmartDataPtr<RecMdcHitCol> mdcHitCol(dataSvc, EventModel::Recon::RecMdcHitCol);
62 if(!mdcHitCol)
63 {
64 log << MSG::INFO << "Could not find RecMdcHitCol" << endreq;
65 }
66
67 // Retrieve MdcKal Helix Segment
68 SmartDataPtr<RecMdcKalHelixSegCol> mdcKalHelixSegCol(dataSvc, EventModel::Recon::RecMdcKalHelixSegCol);
69 if (!mdcKalHelixSegCol) {
70 log << MSG::INFO << "Could not find RecMdcKalHelixSegCol" << endreq;
71 }
72 //**********************************************************************
73
74
75 // now convert
76 if (!m_recMdcDedxHitCol) return sc;
77 TIter dedxIter(m_recMdcDedxHitCol);
78 TRecMdcDedxHit *recMdcDedxHitRoot = 0;
79 while ((recMdcDedxHitRoot = (TRecMdcDedxHit*)dedxIter.Next())) {
80 int trackId = recMdcDedxHitRoot->trkId();
81 //cout<<"trackId: "<<trackId<<endl;
82 int flagLR = recMdcDedxHitRoot->flagLR();
83 //cout<<"flagLR: "<<flagLR<<endl;
84 long int mdcId(recMdcDedxHitRoot->mdcId());
85 //cout<<"mdcID: "<<mdcId<<endl;
86 double pathlength = recMdcDedxHitRoot->pathLength();
87 //cout<<"pathlength: " <<pathlength<<endl;
88 double dedx = recMdcDedxHitRoot->getDedx();
89 //cout<<"dedx: "<<dedx<<endl;
90
91 log << MSG::DEBUG<<"TObjectToDataObject: check Reconstrunction of dE/dx Hit root::"<<" trackId: "<<trackId<<" flagLR: "<<flagLR<<" pathlength: "<<pathlength<<" dedx: "<<dedx<<endreq;
92 RecMdcDedxHit *recMdcDedxHit = new RecMdcDedxHit();
93 m_common.m_rootRecMdcDedxHitMap[recMdcDedxHitRoot] = recMdcDedxHit;
94 recMdcDedxHit->setTrkId(trackId);
95 recMdcDedxHit->setFlagLR(flagLR);
96 recMdcDedxHit->setMdcId( Identifier(mdcId) );
97 recMdcDedxHit->setPathLength( pathlength);
98 recMdcDedxHit->setDedx(dedx);
99 // log << MSG::DEBUG<<"check Reconstrunction of dE/dx Hit root"<<" pathlength 2 is : "<<(*recdedxhit)->getPathLength()<<endreq;
100
101 int mdcHitId = recMdcDedxHitRoot->mdcHitId();
102 //std::cout << __FILE__ << __LINE__ << " size: " << mdcHitCol->size() << " id: " << mdcHitId << std::endl;
103 if ( mdcHitId >= 0 ) {
104 recMdcDedxHit->setMdcHit( dynamic_cast<RecMdcHit*>(mdcHitCol->containedObject(mdcHitId)));
105 }
106 int mdcKalHelixSegId = recMdcDedxHitRoot->mdcKalHelixSegId();
107 //std::cout << __FILE__ << __LINE__ << " size: " << mdcKalHelixSegCol->size() << " id: " << mdcKalHelixSegId << std::endl;
108 if ( mdcKalHelixSegId >= 0 ) {
109 recMdcDedxHit->setMdcKalHelixSeg( dynamic_cast<RecMdcKalHelixSeg*>(mdcKalHelixSegCol->containedObject(mdcKalHelixSegId)));
110 }
111
112 recMdcDedxHitCol->push_back(recMdcDedxHit);
113 //delete dedxTds;
114 // dedxTds = NULL;
115 }
116 //m_dedxCol->Delete();
117 delete m_recMdcDedxHitCol;
118 m_recMdcDedxHitCol = 0;
119
120 return StatusCode::SUCCESS;
121}
void setMdcId(Identifier mdcid)
Definition: RecMdcDedxHit.h:64
void setDedx(double dedx)
Definition: RecMdcDedxHit.h:62
void setFlagLR(int lr)
Definition: RecMdcDedxHit.h:61
void setMdcKalHelixSeg(const RecMdcKalHelixSeg *mdcKalHelixSeg)
Definition: RecMdcDedxHit.h:57
void setTrkId(int trkid)
Definition: RecMdcDedxHit.h:60
void setMdcHit(const RecMdcHit *mdcHit)
Definition: RecMdcDedxHit.h:58
void setPathLength(double pathlength)
Definition: RecMdcDedxHit.h:63
const Int_t mdcHitId()
const Double_t getDedx(void) const
const Int_t mdcKalHelixSegId()
const Int_t trkId(void) const
const Int_t flagLR(void) const
const Double_t pathLength(void) const
const UInt_t mdcId() const
static std::map< const TObject *, const RecMdcDedxHit * > m_rootRecMdcDedxHitMap
Definition: commonData.h:230

Friends And Related Function Documentation

◆ CnvFactory< RecMdcDedxHitCnv >

friend class CnvFactory< RecMdcDedxHitCnv >
friend

Definition at line 9 of file RecMdcDedxHitCnv.h.


The documentation for this class was generated from the following files: