BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcMcHitCnv Class Reference

#include <MdcMcHitCnv.h>

+ Inheritance diagram for MdcMcHitCnv:

Public Member Functions

virtual ~MdcMcHitCnv ()
 
- 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

 MdcMcHitCnv (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< MdcMcHitCnv >
 

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 19 of file MdcMcHitCnv.h.

Constructor & Destructor Documentation

◆ ~MdcMcHitCnv()

virtual MdcMcHitCnv::~MdcMcHitCnv ( )
inlinevirtual

Definition at line 29 of file MdcMcHitCnv.h.

29{ };

◆ MdcMcHitCnv()

MdcMcHitCnv::MdcMcHitCnv ( ISvcLocator *  svc)
protected

Definition at line 25 of file MdcMcHitCnv.cxx.

27{
28 // Here we associate this converter with the /Event path on the TDS.
29 MsgStream log(msgSvc(), "MdcMcHitCnv");
30 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
31 m_rootBranchname ="m_mdcMcHitCol";
32 //declareObject(EventModel::MC::MdcMcHitCol, objType(), m_rootTreename, m_rootBranchname);
33 m_adresses.push_back(&m_mdcMcHitCol);
34 m_mdcMcHitCol=0;
35}
IMessageSvc * msgSvc()
static const CLID & classID()
Definition: MdcMcHitCnv.h:24
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 & MdcMcHitCnv::classID ( )
inlinestatic

Definition at line 24 of file MdcMcHitCnv.h.

25 {
26 return CLID_MdcMcHitCol;
27 }
const CLID & CLID_MdcMcHitCol
Definition: EventModel.cxx:215

◆ DataObjectToTObject()

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

transformation to root

Implements RootEventBaseCnv.

Definition at line 91 of file MdcMcHitCnv.cxx.

91 {
92
93 MsgStream log(msgSvc(), "MdcMcHitCnv");
94 log << MSG::DEBUG << "MdcMcHitCnv::DataObjectToTObject" << endreq;
95 StatusCode sc=StatusCode::SUCCESS;
96
97 MdcMcHitCol * mdcMcHitCnvTds=dynamic_cast<MdcMcHitCol *> (obj);
98 if (!mdcMcHitCnvTds) {
99 log << MSG::ERROR << "Could not downcast to MdcMcHitCol" << endreq;
100 return StatusCode::FAILURE;
101 }
102
103 DataObject *evt;
104 m_eds->findObject(EventModel::MC::Event,evt);
105 if (evt==NULL) {
106 log << MSG::ERROR << "Could not get McEvent in TDS " << endreq;
107 return StatusCode::FAILURE;
108 }
109 McEvent * devtTds=dynamic_cast<McEvent *> (evt);
110 if (!devtTds) {
111 log << MSG::ERROR << "MdcMcHitCnv:Could not downcast to TDS McEvent" << endreq;
112 }
113 IOpaqueAddress *addr;
114
115 m_cnvSvc->getMcCnv()->createRep(evt,addr);
117
118 const TObjArray *m_mdcMcHitCol = McEvt->getMdcMcHitCol();
119 if (!m_mdcMcHitCol) return sc;
120 McEvt->clearMdcMcHitCol(); //necessary in case there is I/O at the same time since array is static
121 MdcMcHitCol::const_iterator mdcMcTds;
122
123 for (mdcMcTds = mdcMcHitCnvTds->begin(); mdcMcTds != mdcMcHitCnvTds->end(); mdcMcTds++) {
124 UInt_t id = ((*mdcMcTds)->identify()).get_value() ;
125 UInt_t trackIndex = (*mdcMcTds) ->getTrackIndex();
126 Double_t xPosition = (*mdcMcTds) ->getPositionX() ;
127 Double_t yPosition = (*mdcMcTds) ->getPositionY() ;
128 Double_t zPosition = (*mdcMcTds) ->getPositionZ() ;
129 Double_t driftDistance= (*mdcMcTds) ->getDriftDistance();
130 Double_t depositEnergy = (*mdcMcTds) ->getDepositEnergy() ;
131 Int_t positionFlag = (*mdcMcTds) ->getPositionFlag();
132
133 TMdcMc *mdcMcRoot = new TMdcMc();
134 //m_common.m_mdcMcHitMap[(*mdcMcTds)] = mdcMcRoot;
135
136 mdcMcRoot->setId(id);
137 mdcMcRoot->setTrackIndex(trackIndex);
138 mdcMcRoot->setCurrentTrackPID((*mdcMcTds)->getCurrentTrackPID());
139 mdcMcRoot->setIsSecondary((*mdcMcTds)->getIsSecondary());
140 mdcMcRoot->setPositionX(xPosition);
141 mdcMcRoot->setPositionY(yPosition);
142 mdcMcRoot->setPositionZ(zPosition);
143 mdcMcRoot->setMomentumX((*mdcMcTds)->getMomentumX());
144 mdcMcRoot->setMomentumY((*mdcMcTds)->getMomentumY());
145 mdcMcRoot->setMomentumZ((*mdcMcTds)->getMomentumZ());
146 mdcMcRoot->setDriftDistance(driftDistance);
147 mdcMcRoot->setDepositEnergy(depositEnergy);
148 mdcMcRoot->setPositionFlag(positionFlag);
149 mdcMcRoot->setFlightLength((*mdcMcTds)->getFlightLength());
150 mdcMcRoot->setCreatorProcess((*mdcMcTds)->getCreatorProcess());
151 mdcMcRoot->setDigiIdx((*mdcMcTds)->getDigiIdx());
152
153 McEvt->addMdcMc(mdcMcRoot);
154 }
155
156 return StatusCode::SUCCESS;
157}
#define NULL
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: McCnv.h:35
Definition: McEvent.h:8
McCnv * getMcCnv()
Definition: RootCnvSvc.h:156
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 addMdcMc(TMdcMc *mcHit)
Mdc.
Definition: TMcEvent.cxx:103
void clearMdcMcHitCol()
Definition: TMcEvent.h:35
const TObjArray * getMdcMcHitCol() const
Definition: TMcEvent.h:32
Definition: TMdcMc.h:9
void setMomentumX(Double_t momentumX)
Definition: TMdcMc.h:73
void setCurrentTrackPID(Int_t currentTrackPID)
Definition: TMdcMc.h:67
void setPositionZ(Double_t positionZ)
Definition: TMdcMc.h:72
void setIsSecondary(Int_t isSecondary)
Definition: TMdcMc.h:69
void setDigiIdx(int digiIdx)
Definition: TMdcMc.h:83
void setId(UInt_t id)
Definition: TMdcMc.h:65
void setMomentumY(Double_t momentumY)
Definition: TMdcMc.h:74
void setTrackIndex(UInt_t trackIndex)
Definition: TMdcMc.h:66
void setFlightLength(Double_t flightLength)
Definition: TMdcMc.h:79
void setDepositEnergy(Double_t depositEnergy)
Definition: TMdcMc.h:77
void setPositionX(Double_t positionX)
Definition: TMdcMc.h:70
void setCreatorProcess(TString creatorProcess)
Definition: TMdcMc.h:80
void setPositionFlag(Int_t posFlag)
Definition: TMdcMc.h:78
void setPositionY(Double_t positionY)
Definition: TMdcMc.h:71
void setDriftDistance(Double_t driftDistance)
Definition: TMdcMc.h:76
void setMomentumZ(Double_t momentumZ)
Definition: TMdcMc.h:75
_EXTERN_ std::string Event
Definition: EventModel.h:39
ObjectVector< MdcMcHit > MdcMcHitCol
Definition: MdcMcHit.h:142

◆ TObjectToDataObject()

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

transformation from root

Implements RootEventBaseCnv.

Definition at line 37 of file MdcMcHitCnv.cxx.

37 {
38 // creation of TDS object from root object
39
40 MsgStream log(msgSvc(), "MdcMcHitCnv");
41 log << MSG::DEBUG << "MdcMcHitCnv::TObjectToDataObject" << endreq;
42 StatusCode sc=StatusCode::SUCCESS;
43
44 // create the TDS location for the MdcMc Collection
45 MdcMcHitCol* mdcMcTdsCol = new MdcMcHitCol;
46 refpObject=mdcMcTdsCol;
47
48
49 // now convert
50 if (!m_mdcMcHitCol) return sc;
51 TIter mdcMcIter(m_mdcMcHitCol);
52 TMdcMc *mdcMcRoot = 0;
53 while ((mdcMcRoot = (TMdcMc*)mdcMcIter.Next())) {
54 unsigned int id = mdcMcRoot ->getId();
55 unsigned int trackIndex = mdcMcRoot ->getTrackIndex();
56 double xPosition = mdcMcRoot ->getPositionX() ;
57 double yPosition = mdcMcRoot ->getPositionY() ;
58 double zPosition = mdcMcRoot ->getPositionZ() ;
59 double driftDistance = mdcMcRoot ->getDriftDistance() ;
60 double depositEnergy = mdcMcRoot ->getDepositEnergy() ;
61 int positionFlag = mdcMcRoot->getPositionFlag();
62
63 MdcMcHit *mdcMcTds = new MdcMcHit;
64 m_common.m_rootMdcMcHitMap[mdcMcRoot] = mdcMcTds;
65
66 mdcMcTds->setIdentifier(id);
67 mdcMcTds->setTrackIndex(trackIndex);
68 mdcMcTds->setCurrentTrackPID(mdcMcRoot->getCurrentTrackPID());
69 mdcMcTds->setIsSecondary(mdcMcRoot->getIsSecondary());
70 mdcMcTds->setPositionX(xPosition);
71 mdcMcTds->setPositionY(yPosition);
72 mdcMcTds->setPositionZ(zPosition);
73 mdcMcTds->setMomentumX(mdcMcRoot->getMomentumX());
74 mdcMcTds->setMomentumY(mdcMcRoot->getMomentumY());
75 mdcMcTds->setMomentumZ(mdcMcRoot->getMomentumZ());
76 mdcMcTds->setDriftDistance(driftDistance);
77 mdcMcTds->setDepositEnergy(depositEnergy);
78 mdcMcTds->setPositionFlag(positionFlag);
79 mdcMcTds->setFlightLength(mdcMcRoot->getFlightLength());
80 mdcMcTds->setCreatorProcess(std::string(mdcMcRoot->getCreatorProcess().Data()));
81 mdcMcTds->setDigiIdx(mdcMcRoot->getDigiIdx());
82
83 mdcMcTdsCol->push_back(mdcMcTds);
84 }
85 //m_mdcMcHitCol->Delete(); // wensp add 2005/12/30
86 delete m_mdcMcHitCol;
87 m_mdcMcHitCol = 0;
88 return StatusCode::SUCCESS;
89}
void setMomentumZ(double momentumZ)
Definition: MdcMcHit.h:94
void setMomentumY(double momentumY)
Definition: MdcMcHit.h:93
void setPositionFlag(int posFlag)
Definition: MdcMcHit.h:97
void setPositionZ(double positionZ)
Definition: MdcMcHit.h:91
void setFlightLength(double flightLength)
Definition: MdcMcHit.h:98
void setDepositEnergy(double depositEnergy)
Definition: MdcMcHit.h:96
void setMomentumX(double momentumX)
Definition: MdcMcHit.h:92
void setIdentifier(unsigned int id)
Definition: MdcMcHit.h:84
void setPositionY(double positionY)
Definition: MdcMcHit.h:90
void setDigiIdx(int id)
Definition: MdcMcHit.h:100
void setIsSecondary(int isSec)
Definition: MdcMcHit.h:88
void setTrackIndex(unsigned int trackIndex)
Definition: MdcMcHit.h:85
void setCurrentTrackPID(int currentTrackPID)
Definition: MdcMcHit.h:86
void setCreatorProcess(std::string creatorProcess)
Definition: MdcMcHit.h:99
void setDriftDistance(double driftDistance)
Definition: MdcMcHit.h:95
void setPositionX(double positionX)
Definition: MdcMcHit.h:89
UInt_t getId() const
Definition: TMdcMc.h:17
Double_t getDepositEnergy() const
Definition: TMdcMc.h:50
Int_t getDigiIdx() const
Definition: TMdcMc.h:62
Double_t getPositionZ() const
Definition: TMdcMc.h:35
TString getCreatorProcess() const
Definition: TMdcMc.h:59
Double_t getDriftDistance() const
Definition: TMdcMc.h:47
Double_t getFlightLength() const
Definition: TMdcMc.h:56
Double_t getMomentumX() const
Definition: TMdcMc.h:38
UInt_t getTrackIndex() const
Definition: TMdcMc.h:20
Double_t getMomentumZ() const
Definition: TMdcMc.h:44
Int_t getPositionFlag() const
Definition: TMdcMc.h:53
Double_t getPositionX() const
Definition: TMdcMc.h:29
Double_t getIsSecondary() const
Definition: TMdcMc.h:26
Double_t getPositionY() const
Definition: TMdcMc.h:32
Int_t getCurrentTrackPID() const
Definition: TMdcMc.h:23
Double_t getMomentumY() const
Definition: TMdcMc.h:41
static std::map< const TObject *, const MdcMcHit * > m_rootMdcMcHitMap
Definition: commonData.h:170

Friends And Related Function Documentation

◆ CnvFactory< MdcMcHitCnv >

friend class CnvFactory< MdcMcHitCnv >
friend

Definition at line 9 of file MdcMcHitCnv.h.


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