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

#include <EmcMcHitCnv.h>

+ Inheritance diagram for EmcMcHitCnv:

Public Member Functions

virtual ~EmcMcHitCnv ()
 
virtual ~EmcMcHitCnv ()
 
- 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
 
 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
 
destinationoperator (const source &) const
 

Static Public Member Functions

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.
 

Protected Member Functions

 EmcMcHitCnv (ISvcLocator *svc)
 
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
 
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
 
 EmcMcHitCnv (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
 
virtual destinationconvert (const source &) const =0
 

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

Constructor & Destructor Documentation

◆ ~EmcMcHitCnv() [1/2]

virtual EmcMcHitCnv::~EmcMcHitCnv ( )
inlinevirtual

◆ EmcMcHitCnv() [1/2]

EmcMcHitCnv::EmcMcHitCnv ( ISvcLocator *  svc)
protected

Definition at line 28 of file EmcMcHitCnv.cxx.

30{
31 // Here we associate this converter with the /Event path on the TDS.
32 MsgStream log(msgSvc(), "EmcMcHitCnv");
33 // log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
34 m_rootBranchname ="m_emcMcHitCol";
35 //declareObject(EventModel::MC::EmcMcHitCol, objType(), m_rootTreename, m_rootBranchname);
36 m_adresses.push_back(&m_emcMcHitCol);
37 m_emcMcHitCol=0;
38}
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)

◆ ~EmcMcHitCnv() [2/2]

virtual EmcMcHitCnv::~EmcMcHitCnv ( )
inlinevirtual

◆ EmcMcHitCnv() [2/2]

EmcMcHitCnv::EmcMcHitCnv ( ISvcLocator *  svc)
protected

Member Function Documentation

◆ classID() [1/2]

static const CLID & EmcMcHitCnv::classID ( )
inlinestatic

Definition at line 24 of file Event/RootCnvSvc/RootCnvSvc-02-01-11/RootCnvSvc/Mc/EmcMcHitCnv.h.

25 {
26 return CLID_EmcMcHitCol;
27 }
const CLID & CLID_EmcMcHitCol
Definition: EventModel.cxx:221

◆ classID() [2/2]

static const CLID & EmcMcHitCnv::classID ( )
inlinestatic

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

25 {
26 return CLID_EmcMcHitCol;
27 }

◆ DataObjectToTObject() [1/2]

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

transformation to root

Implements RootEventBaseCnv.

Definition at line 132 of file EmcMcHitCnv.cxx.

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

◆ DataObjectToTObject() [2/2]

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

transformation to root

Implements RootEventBaseCnv.

◆ TObjectToDataObject() [1/2]

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

transformation from root

Implements RootEventBaseCnv.

Definition at line 40 of file EmcMcHitCnv.cxx.

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

◆ TObjectToDataObject() [2/2]

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

transformation from root

Implements RootEventBaseCnv.

Friends And Related Function Documentation

◆ CnvFactory< EmcMcHitCnv >


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