BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcMcHitCnv Class Reference

#include <EmcMcHitCnv.h>

Inheritance diagram for EmcMcHitCnv:

Public Member Functions

virtual ~EmcMcHitCnv ()
 EmcMcHitCnv (ISvcLocator *svc)
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
virtual ~EmcMcHitCnv ()
 EmcMcHitCnv (ISvcLocator *svc)
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
virtual ~EmcMcHitCnv ()
 EmcMcHitCnv (ISvcLocator *svc)
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
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.
TObject * getReadObject () const
 get the object to be read
 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.
TObject * getReadObject () const
 get the object to be read
 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.
TObject * getReadObject () const
 get the object to be read
Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
destinationoperator (const source &) const
destinationoperator (const source &) const

Static Public Member Functions

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

Friends

class CnvFactory< EmcMcHitCnv >

Additional Inherited Members

Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
Protected Attributes inherited from RootEventBaseCnv
IRootCnvSvcm_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

Constructor & Destructor Documentation

◆ ~EmcMcHitCnv() [1/3]

virtual EmcMcHitCnv::~EmcMcHitCnv ( )
inlinevirtual

Definition at line 26 of file Event/RootCnvSvc/include/RootCnvSvc/Mc/EmcMcHitCnv.h.

26{};

◆ EmcMcHitCnv() [1/3]

EmcMcHitCnv::EmcMcHitCnv ( ISvcLocator * svc)

Definition at line 26 of file EmcMcHitCnv.cxx.

26 : RootEventBaseCnv( classID(), svc ) {
27 // Here we associate this converter with the /Event path on the TDS.
28 MsgStream log( msgSvc(), "EmcMcHitCnv" );
29 // log << MSG::DEBUG << "Constructor called for " << objType() << endmsg;
30 m_rootBranchname = "m_emcMcHitCol";
31 // declareObject(EventModel::MC::EmcMcHitCol, objType(), m_rootTreename, m_rootBranchname);
32 m_adresses.push_back( &m_emcMcHitCol );
33 m_emcMcHitCol = 0;
34}
IMessageSvc * msgSvc()
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)

◆ ~EmcMcHitCnv() [2/3]

virtual EmcMcHitCnv::~EmcMcHitCnv ( )
inlinevirtual

◆ EmcMcHitCnv() [2/3]

EmcMcHitCnv::EmcMcHitCnv ( ISvcLocator * svc)

◆ ~EmcMcHitCnv() [3/3]

virtual EmcMcHitCnv::~EmcMcHitCnv ( )
inlinevirtual

◆ EmcMcHitCnv() [3/3]

EmcMcHitCnv::EmcMcHitCnv ( ISvcLocator * svc)

Member Function Documentation

◆ classID() [1/3]

const CLID & EmcMcHitCnv::classID ( )
inlinestatic

Definition at line 24 of file Event/RootCnvSvc/include/RootCnvSvc/Mc/EmcMcHitCnv.h.

24{ return CLID_EmcMcHitCol; }
const CLID & CLID_EmcMcHitCol

Referenced by RootCnvSvc::createConverter(), and EmcMcHitCnv().

◆ classID() [2/3]

const CLID & EmcMcHitCnv::classID ( )
inlinestatic

◆ classID() [3/3]

const CLID & EmcMcHitCnv::classID ( )
inlinestatic

◆ DataObjectToTObject() [1/3]

StatusCode EmcMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
virtual

transformation to root

Implements RootEventBaseCnv.

Definition at line 127 of file EmcMcHitCnv.cxx.

127 {
128
129 MsgStream log( msgSvc(), "EmcMcHitCnv" );
130 log << MSG::DEBUG << "EmcMcHitCnv::DataObjectToTObject" << endmsg;
131 StatusCode sc = StatusCode::SUCCESS;
132
133 EmcMcHitCol* emcMcHitCnvTds = dynamic_cast<EmcMcHitCol*>( obj );
134 if ( !emcMcHitCnvTds )
135 {
136 log << MSG::ERROR << "Could not downcast to EmcMcHitCol" << endmsg;
137 return StatusCode::FAILURE;
138 }
139
140 DataObject* evt;
141 m_eds->findObject( EventModel::MC::Event, evt );
142 if ( evt == NULL )
143 {
144 log << MSG::ERROR << "Could not get McEvent in TDS " << endmsg;
145 return StatusCode::FAILURE;
146 }
147 McEvent* devtTds = dynamic_cast<McEvent*>( evt );
148 if ( !devtTds )
149 { log << MSG::ERROR << "EmcMcHitCnv:Could not downcast to TDS McEvent" << endmsg; }
150 IOpaqueAddress* addr;
151
152 m_cnvSvc->getMcCnv()->createRep( evt, addr );
153 TMcEvent* McEvt = m_cnvSvc->getMcCnv()->getWriteObject();
154
155 const TObjArray* m_emcMcHitCol = McEvt->getEmcMcHitCol();
156 if ( !m_emcMcHitCol ) return sc;
157 McEvt->clearEmcMcHitCol(); // necessary in case there is I/O at the same time since array is
158 // static
159 EmcMcHitCol::const_iterator emcMcTds;
160
161 for ( emcMcTds = emcMcHitCnvTds->begin(); emcMcTds != emcMcHitCnvTds->end(); emcMcTds++ )
162 {
163 UInt_t id = ( ( *emcMcTds )->identify() ).get_value();
164 UInt_t trackIndex = ( *emcMcTds )->getTrackIndex();
165
166 int hitEmc = ( *emcMcTds )->getHitEmc();
167 int PDGCode = ( *emcMcTds )->getPDGCode();
168 double PDGCharge = ( *emcMcTds )->getPDGCharge();
169 double time = ( *emcMcTds )->getTime();
170 std::map<Identifier, Double_t> TdshitMap = ( *emcMcTds )->getHitMap();
171
172 map<Int_t, Double_t> HitMap;
173 map<Identifier, Double_t>::iterator iHitMap;
174 for ( iHitMap = TdshitMap.begin(); iHitMap != TdshitMap.end(); iHitMap++ )
175 {
176
177 Int_t id( iHitMap->first.get_value() );
178 pair<Int_t, Double_t> Hit( id, iHitMap->second );
179 HitMap.insert( Hit );
180
181 // RecEmcHitCol::iterator iHit;
182 // for(iHit=emcRecHitCol->begin();
183 // iHit!=emcRecHitCol->end();
184 // iHit++) {
185
186 // RecEmcID idHit((*iHit)->getCellId());
187
188 // if(id==idHit) {
189 // RecEmcFraction frac(*(*iHit));
190 // frac.Fraction(iHitMap->second);
191 // emcShowerTds->Insert(frac);
192 // break;
193 // }
194 //} //RecEmcHitCol
195 } // CellIdMap
196
197 Double_t xPosition = ( *emcMcTds )->getPositionX();
198 Double_t yPosition = ( *emcMcTds )->getPositionY();
199 Double_t zPosition = ( *emcMcTds )->getPositionZ();
200 Double_t px = ( *emcMcTds )->getPx();
201 Double_t py = ( *emcMcTds )->getPy();
202 Double_t pz = ( *emcMcTds )->getPz();
203 Double_t depositEnergy = ( *emcMcTds )->getDepositEnergy();
204
205 TEmcMc* emcMcRoot = new TEmcMc();
206 // m_common.m_emcMcHitMap[(*emcMcTds)] = emcMcRoot;
207
208 emcMcRoot->setId( id );
209 emcMcRoot->setHitMap( HitMap );
210
211 emcMcRoot->setHitEmc( hitEmc );
212 emcMcRoot->setPDGCode( PDGCode );
213 emcMcRoot->setPDGCharge( PDGCharge );
214 emcMcRoot->setTime( time );
215 // emcMcRoot->setHitMap(hitMap);
216
217 emcMcRoot->setTrackIndex( trackIndex );
218 emcMcRoot->setPositionX( xPosition );
219 emcMcRoot->setPositionY( yPosition );
220 emcMcRoot->setPositionZ( zPosition );
221 emcMcRoot->setPx( px );
222 emcMcRoot->setPy( py );
223 emcMcRoot->setPz( pz );
224 emcMcRoot->setDepositEnergy( depositEnergy );
225
226 McEvt->addEmcMc( emcMcRoot );
227 }
228
229 return StatusCode::SUCCESS;
230}
Double_t time
ObjectVector< EmcMcHit > EmcMcHitCol
IDataProviderSvc * m_eds
pointer to eventdataservice
void setHitMap(std::map< Int_t, Double_t > hitMap)
void setDepositEnergy(Double_t depositEnergy)
void addEmcMc(TEmcMc *mcHit)
Emc.
Definition TMcEvent.cxx:91

◆ DataObjectToTObject() [2/3]

virtual StatusCode EmcMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
virtual

transformation to root

Implements RootEventBaseCnv.

◆ DataObjectToTObject() [3/3]

virtual StatusCode EmcMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
virtual

transformation to root

Implements RootEventBaseCnv.

◆ TObjectToDataObject() [1/3]

StatusCode EmcMcHitCnv::TObjectToDataObject ( DataObject *& obj)
virtual

transformation from root

Implements RootEventBaseCnv.

Definition at line 36 of file EmcMcHitCnv.cxx.

36 {
37 // creation of TDS object from root object
38
39 MsgStream log( msgSvc(), "EmcMcHitCnv" );
40 log << MSG::DEBUG << "EmcMcHitCnv::TObjectToDataObject" << endmsg;
41 StatusCode sc = StatusCode::SUCCESS;
42
43 // create the TDS location for the MdcMc Collection
44 EmcMcHitCol* emcMcTdsCol = new EmcMcHitCol;
45 refpObject = emcMcTdsCol;
46
47 // now convert
48 if ( !m_emcMcHitCol ) return sc;
49 TIter emcMcIter( m_emcMcHitCol );
50 TEmcMc* emcMcRoot = 0;
51 while ( ( emcMcRoot = (TEmcMc*)emcMcIter.Next() ) )
52 {
53 // unsigned int id = emcMcRoot ->getId();
54 Identifier id;
55 unsigned int id_root = emcMcRoot->getId();
56 id = id_root;
57 unsigned int trackIndex = emcMcRoot->getTrackIndex();
58
59 int hitEmc = emcMcRoot->getHitEmc();
60 int PDGCode = emcMcRoot->getPDGCode();
61 double PDGCharge = emcMcRoot->getPDGCharge();
62 double time = emcMcRoot->getTime();
63
64 double xPosition = emcMcRoot->getPositionX();
65 double yPosition = emcMcRoot->getPositionY();
66 double zPosition = emcMcRoot->getPositionZ();
67 double px = emcMcRoot->getPx();
68 double py = emcMcRoot->getPy();
69 double pz = emcMcRoot->getPz();
70 double depositEnergy = emcMcRoot->getDepositEnergy();
71
72 EmcMcHit* emcMcTds = new EmcMcHit();
73 m_common.m_rootEmcMcHitMap[emcMcRoot] = emcMcTds;
74
75 emcMcTds->setIdentifier( id );
76
77 map<Int_t, Double_t> hitMap = emcMcRoot->getHitMap();
78 map<Identifier, Double_t> TdshitMap;
79 map<Int_t, Double_t> HitMap = emcMcRoot->getHitMap();
80 map<Int_t, Double_t>::iterator iHitMap;
81 for ( iHitMap = HitMap.begin(); iHitMap != HitMap.end(); iHitMap++ )
82 {
83
84 Identifier id( iHitMap->first );
85 pair<Identifier, Double_t> TdsHit( id, iHitMap->second );
86 TdshitMap.insert( TdsHit );
87
88 // RecEmcHitCol::iterator iHit;
89 // for(iHit=emcRecHitCol->begin();
90 // iHit!=emcRecHitCol->end();
91 // iHit++) {
92
93 // RecEmcID idHit((*iHit)->getCellId());
94
95 // if(id==idHit) {
96 // RecEmcFraction frac(*(*iHit));
97 // frac.Fraction(iHitMap->second);
98 // emcShowerTds->Insert(frac);
99 // break;
100 // }
101 //} //RecEmcHitCol
102 } // CellIdMap
103 emcMcTds->setHitMap( TdshitMap );
104
105 emcMcTds->setHitEmc( hitEmc );
106 emcMcTds->setPDGCode( PDGCode );
107 emcMcTds->setPDGCharge( PDGCharge );
108 emcMcTds->setTime( time );
109
110 emcMcTds->setTrackIndex( trackIndex );
111 emcMcTds->setPositionX( xPosition );
112 emcMcTds->setPositionY( yPosition );
113 emcMcTds->setPositionZ( zPosition );
114 emcMcTds->setPx( px );
115 emcMcTds->setPy( py );
116 emcMcTds->setPz( pz );
117 emcMcTds->setDepositEnergy( depositEnergy );
118
119 emcMcTdsCol->push_back( emcMcTds );
120 }
121 // m_emcMcHitCol->Delete(); // wensp add 2005/12/30
122 delete m_emcMcHitCol;
123 m_emcMcHitCol = 0;
124 return StatusCode::SUCCESS;
125}
void setPositionX(double positionX)
void setDepositEnergy(double depositEnergy)
void setHitMap(std::map< Identifier, double > &hitMap)
void setTrackIndex(unsigned int trackIndex)
void setIdentifier(Identifier &id)
void setPositionY(double positionY)
void setPositionZ(double positionZ)
std::map< Int_t, Double_t > getHitMap() const

◆ TObjectToDataObject() [2/3]

virtual StatusCode EmcMcHitCnv::TObjectToDataObject ( DataObject *& obj)
virtual

transformation from root

Implements RootEventBaseCnv.

◆ TObjectToDataObject() [3/3]

virtual StatusCode EmcMcHitCnv::TObjectToDataObject ( DataObject *& obj)
virtual

transformation from root

Implements RootEventBaseCnv.

◆ CnvFactory< EmcMcHitCnv >

friend class CnvFactory< EmcMcHitCnv >
friend

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